ソースを参照

增加护理状态,并且在重启时先端口tcp

vothin 2 年 前
コミット
bbe44a035c

+ 2 - 3
jni/logic/DeviceUpdateLogic.cc

@@ -91,9 +91,8 @@ void updateDevice(){
 		UpgradeMonitor::getInstance()->checkUpgradeFile("/mnt/extsd");
 		LOGD("img版本-> %s", "");
 
-		// 更新设备的版本
-//		StoragePreferences::putString(WDKL_VERSION, info.version);
-//		StoragePreferences::putInt(JHWS_VERSION_NUMBER, info.versionNo);
+		//TCP启动
+		TcpClient::instance()->closeTcp();
 
 		system("touch /tmp/zkautoupgrade");
 		UPGRADEMONITOR->checkUpgradeFile("/tmp");

+ 20 - 3
jni/logic/mainLogic.cc

@@ -67,6 +67,7 @@ static bool serverInfo = true;	// 判断是否需要从服务器获取服务器
 static bool isHelpTimerRegistered = false;
 
 
+
 #define HELP_TIMER_HANDLE 3
 #define NURSING_TIME_HANDLE 6	// 护理的定时器id
 #define OXYGEN_TIME_HANDLE 7	// 吸氧倒计时
@@ -258,6 +259,7 @@ public:
 			StoragePreferences::putString(STORE_NURSE_TITLE, partSetting.nurseTitle);
 			StoragePreferences::putBool(STORE_NURSE_VISIBLE, partSetting.nurseValid==1);
 
+			StoragePreferences::putString(STORE_NURSING_COLOR_RGB, partSetting.nursingColorRgb);
 			StoragePreferences::putBool(STORE_AUDO_ANSWER, partSetting.autoAccept==1);
 
 			setRightTitle(root);
@@ -310,7 +312,7 @@ public:
 	// 判断是否处于增援状态,处于增援状态,就要显示蓝色
 	static void reinforceDispaly() {
 		if (reinforce) {
-			SetPainterInfo(0xFF2F9DF1,"增援已发出");
+			SetPainterInfo(0xFF2F9DF1, "增援已发出");
 			setHelpButton("/button/button_help3.png" ,false);
 		}
 	}
@@ -415,6 +417,7 @@ void cancelAutoBtnHelpTimer(){
 
 //标识方法
 void SetPainterInfo(uint32_t bgColor, const std::string& msg){
+
 	mPainterInfoPtr->setBackgroundColor(bgColor);
 	mTextInfoPtr->setText(msg);
 	if (bgColor == 0xFFFFFFFF){
@@ -469,6 +472,15 @@ static void onUI_init(){
 	}
 
 	udp_thread.getDeviceInfo();
+
+	if (StoragePreferences::getBool(STORE_NURSING_TYPE, false)) {	// 如果处于护理状态
+		mFunctionWinPtr->showWnd();
+		mFunctionTextViewPtr->setText(LANGUAGEMANAGER->getValue("InNursing"));
+		mFunctionButtonPtr->setText(LANGUAGEMANAGER->getValue("NursingEnd"));
+		mFunctionBackPtr->setVisible(false);
+	} else {
+		mFunctionWinPtr->hideWnd();
+	}
 }
 
 /**
@@ -523,7 +535,7 @@ static bool onUI_Timer(int id){
 
 	case HELP_TIMER_HANDLE:	// 不能在线程里面关掉线程
 		{
-			SetPainterInfo(0xFFFFFFFF,"");
+			SetPainterInfo(0xFFFFFFFF, "");
 			setReinforce(false);
 			setHelpButton("/button/button_help2.png", true);
 			return false;
@@ -722,7 +734,7 @@ static bool onButtonClick_HelpButton(ZKButton *pButton) {
 	TcpClient::instance()->sendMsgWithCb(req.c_str(), callback);
 
 	setHelpButton("/button/button_help3.png" ,false);
-	SetPainterInfo(0xFF2F9DF1,"增援已发出");
+	SetPainterInfo(0xFF2F9DF1, "增援已发出");
 	setReinforce(true);		// 设置增援状态为true
 	//1分钟后无响应还原颜色
 	if (!isHelpTimerRegistered){
@@ -802,6 +814,9 @@ static bool onButtonClick_NursingButton(ZKButton *pButton) {
 		return 0;
 	};
 	TcpClient::instance()->sendMsgWithCb(req.c_str(), callback);
+
+	// 把护理状态缓存起来
+	StoragePreferences::putBool(STORE_NURSING_TYPE, true);
     return false;
 }
 
@@ -820,6 +835,8 @@ static bool onButtonClick_FunctionButton(ZKButton *pButton) {
 	sendProtocolTo(UART_TTYS2, (byte*)(sendMsg), strlen(sendMsg));
 
 	if (nursingTcpModel.json.size() != 0) {	// 对比一下,json里面不为空的时候
+		StoragePreferences::putBool(STORE_NURSING_TYPE, false);
+
 		// 发送tcp, tcp_type = SIDE, tcp_action = NURSING_END
 		TcpModel tcpModel;
 		tcpModel.tid = base::format("t%d", TimeHelper::getCurrentTime());

+ 59 - 17
jni/logic/startLogic.cc

@@ -183,6 +183,8 @@ void handleMsg(byte* inBytes){
 			EASYUICONTEXT->openActivity("DeviceUpdateActivity", intent);
 		}
 		else if (tcpModel.action == DeviceAction::RESTART) {	// 重启设备
+			//TCP启动
+			TcpClient::instance()->closeTcp();
 			sync();
 			reboot(RB_AUTOBOOT);
 		}
@@ -300,7 +302,6 @@ void handleMsg(byte* inBytes){
 				EASYUICONTEXT->goBack();
 			}
 
-
 			std::string color = StoragePreferences::getString(STORE_NURSING_COLOR_RGB, "010");
 			std::string heartStr;
 			if (color != "" && color.size() == 3) {
@@ -311,7 +312,6 @@ void handleMsg(byte* inBytes){
 			const char* sendMsg = heartStr.c_str();
 			sendProtocolTo(UART_TTYS2, (byte*)(sendMsg), strlen(sendMsg));
 
-
 			// 删除这个定时器
 			mActivityPtr->unregisterUserTimer(NURSING_TIME_HANDLE);
 			LOGD("收到服务器返回的消息,关闭Nursing的定时器");
@@ -331,18 +331,46 @@ void handleMsg(byte* inBytes){
 			sendProtocolTo(UART_TTYS2, (byte*)(sendMsg), strlen(sendMsg));
 		}
 		else if (tcpModel.action == SideAction::ACCEPT) {
-			// 收到ACCEPT,需要灭灯
-			// 还原成无灯光的状态
-			std::string heartStr = "DOORLED,000F";
-			const char* sendMsg = heartStr.c_str();
-			sendProtocolTo(UART_TTYS2, (byte*)(sendMsg), strlen(sendMsg));
+			// 如果还在护理状态,则变回护理灯
+			if (StoragePreferences::getBool(STORE_NURSING_TYPE, false)) {
+				std::string color = StoragePreferences::getString(STORE_NURSING_COLOR_RGB, "010");
+				std::string heartStr;
+				if (color != "" && color.size() == 3) {
+					heartStr = "DOORLED," + color + "F";
+				} else {
+					heartStr = "DOORLED,010F";
+				}
+				const char* sendMsg = heartStr.c_str();
+				sendProtocolTo(UART_TTYS2, (byte*)(sendMsg), strlen(sendMsg));
+			}
+			else {
+				// 收到ACCEPT,需要灭灯
+				// 还原成无灯光的状态
+				std::string heartStr = "DOORLED,000F";
+				const char* sendMsg = heartStr.c_str();
+				sendProtocolTo(UART_TTYS2, (byte*)(sendMsg), strlen(sendMsg));
+			}
 		}
 		else if (tcpModel.action == SideAction::CANCEL) {
-			// 收到CANCEL,需要灭灯
-			// 还原成无灯光的状态
-			std::string heartStr = "DOORLED,000F";
-			const char* sendMsg = heartStr.c_str();
-			sendProtocolTo(UART_TTYS2, (byte*)(sendMsg), strlen(sendMsg));
+			// 如果还在护理状态,则变回护理灯
+			if (StoragePreferences::getBool(STORE_NURSING_TYPE, false)) {
+				std::string color = StoragePreferences::getString(STORE_NURSING_COLOR_RGB, "010");
+				std::string heartStr;
+				if (color != "" && color.size() == 3) {
+					heartStr = "DOORLED," + color + "F";
+				} else {
+					heartStr = "DOORLED,010F";
+				}
+				const char* sendMsg = heartStr.c_str();
+				sendProtocolTo(UART_TTYS2, (byte*)(sendMsg), strlen(sendMsg));
+			}
+			else {
+				// 收到CANCEL,需要灭灯
+				// 还原成无灯光的状态
+				std::string heartStr = "DOORLED,000F";
+				const char* sendMsg = heartStr.c_str();
+				sendProtocolTo(UART_TTYS2, (byte*)(sendMsg), strlen(sendMsg));
+			}
 		}
 		else if (tcpModel.action == SideAction::SOS_CALL) {
 			// 收到SOS_CALL,需要亮红灯
@@ -358,11 +386,25 @@ void handleMsg(byte* inBytes){
 			mActivityPtr->registerUserTimer(SOS_LAMP_TIME_HANDLE, 120000);		// 2分钟后才能触发
 		}
 		else if (tcpModel.action == SideAction::SOS_CANCEL) {
-			// 收到SOS_CANCEL,需要灭灯
-			// 还原成无灯光的状态
-			std::string heartStr = "DOORLED,000F";
-			const char* sendMsg = heartStr.c_str();
-			sendProtocolTo(UART_TTYS2, (byte*)(sendMsg), strlen(sendMsg));
+			// 如果还在护理状态,则变回护理灯
+			if (StoragePreferences::getBool(STORE_NURSING_TYPE, false)) {
+				std::string color = StoragePreferences::getString(STORE_NURSING_COLOR_RGB, "010");
+				std::string heartStr;
+				if (color != "" && color.size() == 3) {
+					heartStr = "DOORLED," + color + "F";
+				} else {
+					heartStr = "DOORLED,010F";
+				}
+				const char* sendMsg = heartStr.c_str();
+				sendProtocolTo(UART_TTYS2, (byte*)(sendMsg), strlen(sendMsg));
+			}
+			else {
+				// 收到SOS_CANCEL,需要灭灯
+				// 还原成无灯光的状态
+				std::string heartStr = "DOORLED,000F";
+				const char* sendMsg = heartStr.c_str();
+				sendProtocolTo(UART_TTYS2, (byte*)(sendMsg), strlen(sendMsg));
+			}
 		}
 	}
 	else if (tcpModel.type == TcpType::CALLBACK) {

+ 6 - 0
jni/logic/ui3Logic.cc

@@ -382,6 +382,9 @@ static bool onButtonClick_BtnServerIPConfirm(ZKButton *pButton) {
     StoragePreferences::putString(STORE_GATEWAY, mEditTextServerIPPtr->getText().c_str());
 
     //mWindowServerIPPtr->hideWnd();
+
+	//TCP启动
+	TcpClient::instance()->closeTcp();
     //重启
     sync();
     reboot(RB_AUTOBOOT);
@@ -389,6 +392,9 @@ static bool onButtonClick_BtnServerIPConfirm(ZKButton *pButton) {
 }
 static bool onButtonClick_BtnRestart(ZKButton *pButton) {
     LOGD(" ButtonClick BtnRestart !!!\n");
+
+	//TCP启动
+	TcpClient::instance()->closeTcp();
     //重启
 	sync();
 	reboot(RB_AUTOBOOT);

+ 5 - 0
jni/net/tcp_client.cpp

@@ -142,6 +142,11 @@ void TcpClient::startTcp(){
 	my_thread.run("tcp thread");
 }
 
+void TcpClient::closeTcp() {
+	my_thread.requestExitAndWait();
+//		my_thread.requestExit();
+}
+
 bool TcpClient::busy() {
 	return instance()->busy_;
 }

+ 1 - 0
jni/net/tcp_client.h

@@ -21,6 +21,7 @@ public:
   static TcpClient* instance();
 
   void startTcp();
+  void closeTcp();
   void sendMsg(const char* msg);
   void sendMsgWithCb(const char* msg, TcpCallback callback);
 

+ 4 - 3
jni/service/BusinessConfig.h

@@ -45,13 +45,14 @@
 #define STORE_NURSE_TITLE "nurse_title"
 #define STORE_NURSE_VISIBLE "nurse_visible"
 
-#define STORE_NURSING_COLOR_RGB "nursingColorRgb"
+#define STORE_NURSING_COLOR_RGB "nursing_color_rgb"
+#define STORE_NURSING_TYPE "nursing_type"	// 护理的状态,如果是true,那就在护理中,如果是false,那就不在护理中
 
 #define STORE_AUDO_ANSWER "auto_answer"
 #define SIGNAL_TYPE "TCP" //TCP,SIP
 
-static std::string version = "v1.0.15";
-static int versionNo = 15;
+static std::string version = "v1.0.16";
+static int versionNo = 16;
 static std::string serverIP = "172.28.100.100";
 static std::string tcpIP = "172.28.100.100";
 static int serverHttpPort = 8006;

BIN
libs/armeabi/libzkgui.so


BIN
obj/activity/DeviceUpdateActivity.o


BIN
obj/activity/callActivity.o


BIN
obj/activity/mainActivity.o


BIN
obj/activity/startActivity.o


BIN
obj/activity/statusbar.o


BIN
obj/activity/ui3Activity.o


BIN
obj/activity/warnActivity.o


BIN
obj/core/update_assistant.o


BIN
obj/net/tcp_client.o


BIN
obj/service/BusinessConfig.o


BIN
obj/service/time.o