Bladeren bron

增加电源控制

vothin 1 jaar geleden
bovenliggende
commit
235c1303f1

+ 2 - 0
i18n/zh_CN.tr

@@ -84,6 +84,8 @@
     <string name="PostitionedMsg">已定位当前位置:</string>
     <string name="RoomPatrolMsg">已巡房:</string>
 	<string name="PromptQuit">提示语已结束</string>
+    <string name="RebootDevice">重启本机</string>
+    <string name="RebootPower">重启线路电源</string>
     <!-- 医护界面 -->
     <string name="MedicalLoginMsg">请输入正确的密码,进入医护功能</string>
     <string name="InputMedicalPassword">输入密码进入医护</string>

+ 17 - 0
jni/activity/functionActivity.cpp

@@ -4,6 +4,11 @@
 #include "functionActivity.h"
 
 /*TAG:GlobalVariable全局变量*/
+static ZKButton* mRebootDeviceButtonPtr;
+static ZKButton* mRebootPowerButtonPtr;
+static ZKTextView* mRebootDeviceTextViewPtr;
+static ZKTextView* mRebootPowerTextViewPtr;
+static ZKWindow* mRebootWindowPtr;
 static ZKButton* mServerCancelButtonPtr;
 static ZKButton* mServerConfirmButtonPtr;
 static ZKTextView* mServerPromptTextViewPtr;
@@ -76,6 +81,8 @@ typedef struct {
 
 /*TAG:ButtonCallbackTab按键映射表*/
 static S_ButtonCallback sButtonCallbackTab[] = {
+    ID_FUNCTION_RebootDeviceButton, onButtonClick_RebootDeviceButton,
+    ID_FUNCTION_RebootPowerButton, onButtonClick_RebootPowerButton,
     ID_FUNCTION_ServerCancelButton, onButtonClick_ServerCancelButton,
     ID_FUNCTION_ServerConfirmButton, onButtonClick_ServerConfirmButton,
     ID_FUNCTION_PwdBackButton, onButtonClick_PwdBackButton,
@@ -162,6 +169,11 @@ functionActivity::~functionActivity() {
     unregisterProtocolDataUpdateListener(onProtocolDataUpdate);
     onUI_quit();
     mActivityPtr = NULL;
+    mRebootDeviceButtonPtr = NULL;
+    mRebootPowerButtonPtr = NULL;
+    mRebootDeviceTextViewPtr = NULL;
+    mRebootPowerTextViewPtr = NULL;
+    mRebootWindowPtr = NULL;
     mServerCancelButtonPtr = NULL;
     mServerConfirmButtonPtr = NULL;
     mServerPromptTextViewPtr = NULL;
@@ -206,6 +218,11 @@ const char* functionActivity::getAppName() const{
 //TAG:onCreate
 void functionActivity::onCreate() {
 	Activity::onCreate();
+    mRebootDeviceButtonPtr = (ZKButton*)findControlByID(ID_FUNCTION_RebootDeviceButton);
+    mRebootPowerButtonPtr = (ZKButton*)findControlByID(ID_FUNCTION_RebootPowerButton);
+    mRebootDeviceTextViewPtr = (ZKTextView*)findControlByID(ID_FUNCTION_RebootDeviceTextView);
+    mRebootPowerTextViewPtr = (ZKTextView*)findControlByID(ID_FUNCTION_RebootPowerTextView);
+    mRebootWindowPtr = (ZKWindow*)findControlByID(ID_FUNCTION_RebootWindow);
     mServerCancelButtonPtr = (ZKButton*)findControlByID(ID_FUNCTION_ServerCancelButton);
     mServerConfirmButtonPtr = (ZKButton*)findControlByID(ID_FUNCTION_ServerConfirmButton);
     mServerPromptTextViewPtr = (ZKTextView*)findControlByID(ID_FUNCTION_ServerPromptTextView);

+ 5 - 0
jni/activity/functionActivity.h

@@ -27,6 +27,11 @@
 #include "window/ZKSlideWindow.h"
 
 /*TAG:Macro宏ID*/
+#define ID_FUNCTION_RebootDeviceButton    20012
+#define ID_FUNCTION_RebootPowerButton    20011
+#define ID_FUNCTION_RebootDeviceTextView    50011
+#define ID_FUNCTION_RebootPowerTextView    50012
+#define ID_FUNCTION_RebootWindow    110007
 #define ID_FUNCTION_ServerCancelButton    20010
 #define ID_FUNCTION_ServerConfirmButton    20009
 #define ID_FUNCTION_ServerPromptTextView    50009

+ 1 - 0
jni/logic/callLogic.cc

@@ -446,6 +446,7 @@ static bool onUI_Timer(int id){
 	case CALLING_TIME: {
 		//TCP call
 		TcpModel tcpModel;
+		tcpModel.tid = base::format("t%d", TimeHelper::getCurrentTime());
 		tcpModel.type = TcpType::VOICE;
 		tcpModel.action = VoiceAction::CANCEL;
 		tcpModel.from_id = StoragePreferences::getInt(STORE_DEVICE_ID,0);

+ 8 - 5
jni/logic/deviceInfoLogic.cc

@@ -379,12 +379,15 @@ static bool onButtonClick_VersionButton(ZKButton *pButton) {
 
 static bool onButtonClick_RestartButton(ZKButton *pButton) {
     LOGD(" ButtonClick RestartButton !!!\n");
+    Intent* intent = new Intent();
+	intent->putExtra(functionWindows, "reboot");
+	EASYUICONTEXT->openActivity("functionActivity", intent);
 
-	const char* req = "-1";
-	TcpClient::instance()->sendMsg(req);
-    //重启
-	sync();
-	reboot(RB_AUTOBOOT);
+//	const char* req = "-1";
+//	TcpClient::instance()->sendMsg(req);
+//    //重启
+//	sync();
+//	reboot(RB_AUTOBOOT);
     return false;
 }
 static bool onButtonClick_sys_back(ZKButton *pButton) {

+ 40 - 1
jni/logic/functionLogic.cc

@@ -237,7 +237,8 @@ static void onUI_intent(const Intent *intentPtr) {
 		}
 		else if (_functionWindows == "serverChange" ||
 				_functionWindows == "setting" ||
-				_functionWindows == "init") {
+				_functionWindows == "init" ||
+				_functionWindows == "reboot") {
 			pwdWindowInfo();
 		}
     }
@@ -502,6 +503,20 @@ static bool onButtonClick_PwdConfirmButton(ZKButton *pButton) {
 			mPwdPromptTextViewPtr->setTextColor(0xFFFF0000);
 		}
 	}
+	else if (_functionWindows == "reboot") {
+
+		// 密码为888
+		string cpwd = "888";
+		if (pwd == cpwd){
+			// 关闭密码输入界面
+			mPwdWindowPtr->hideWnd();
+			// 打开初始化界面
+			mRebootWindowPtr->showWnd();
+		} else {
+			mPwdPromptTextViewPtr->setTextTr("PasswordWrong");
+			mPwdPromptTextViewPtr->setTextColor(0xFFFF0000);
+		}
+	}
     return false;
 }
 
@@ -551,3 +566,27 @@ static bool onButtonClick_ServerCancelButton(ZKButton *pButton) {
 	EASYUICONTEXT->closeActivity("functionActivity");
     return false;
 }
+static bool onButtonClick_RebootDeviceButton(ZKButton *pButton) {
+    LOGD(" ButtonClick RebootDeviceButton !!!\n");
+	const char* req = "-1";
+	TcpClient::instance()->sendMsg(req);
+	//重启
+	sync();
+	reboot(RB_AUTOBOOT);
+    return false;
+}
+
+static bool onButtonClick_RebootPowerButton(ZKButton *pButton) {
+    LOGD(" ButtonClick RebootPowerButton !!!\n");
+	TcpModel tcpModel;
+	tcpModel.type = TcpType::DEVICE;
+	tcpModel.action = DeviceAction::POWER_RESET;
+	tcpModel.from_id = StoragePreferences::getInt(STORE_DEVICE_ID,0);
+	tcpModel.to_id = NULL;
+
+	std::string req = getTcpModelString(tcpModel);
+	LOGD("TCP DEVICE : %s",req.c_str());
+
+    TcpClient::instance()->sendMsg(req.c_str());
+    return false;
+}

+ 1 - 0
jni/net/tcp_client.cpp

@@ -95,6 +95,7 @@ public:
 		if (conn) {
 			byte buf[2048] = {0};
 			TcpModel tcpModel;
+			tcpModel.tid = base::format("t%d", TimeHelper::getCurrentTime());
 			tcpModel.type = TcpType::DEVICE;
 			tcpModel.action = DeviceAction::CONNECT;
 //			tcpModel.data = ETHERNETMANAGER->getMacAddr();

+ 7 - 2
jni/net/tcp_model.cpp

@@ -15,9 +15,10 @@ std::string getTcpModelString(TcpModel model){
 	Json::Value root;
 	if (model.tid != ""){
 		root["tid"] = model.tid;
-	} else {
-		root["tid"] = base::format("t%d",TimeHelper::getCurrentTime());
 	}
+//	else {
+//		root["tid"] = base::format("t%d",TimeHelper::getCurrentTime());
+//	}
 	root["type"] = model.type;
 	root["action"] = model.action;
 	if (model.from_id>0){
@@ -61,9 +62,13 @@ TcpModel getTcpModel(byte* inBytes){
 			tcpModel.to_id = root["toId"].asInt();
 		}
 		if (root.isMember("data")){
+			LOGD("tcp model str2 = %s", str);
 			if (root["data"].isInt()){
 				std::string s = std::to_string(root["data"].asInt());
 				tcpModel.data = s.c_str();
+			} else if (root["data"].isString()){
+				std::string s = root["data"].asString();
+				tcpModel.data = s.c_str();
 			} else {
 				tcpModel.json = root["data"];
 			}

+ 1 - 0
jni/net/tcp_model.h

@@ -75,6 +75,7 @@ public:
 	inline static std::string DEVICE_REFRESH = "DEVICE_REFRESH";
 	inline static std::string SYSTEM_SETTING = "SYSTEM_SETTING";
 	inline static std::string SERVER_CHANGE = "SERVER_CHANGE";
+	inline static std::string POWER_RESET = "POWER_RESET";
 };
 
 class DataAction {

+ 2 - 2
jni/service/BusinessConfig.h

@@ -64,8 +64,8 @@
 
 #define STORE_MAC_ADDR "mac_addr"
 
-static std::string versionCode = "v1.0.36";
-static int versionNo = 36;
+static std::string versionCode = "v1.0.37";
+static int versionNo = 37;
 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/callActivity.o


BIN
obj/activity/deviceInfoActivity.o


BIN
obj/activity/functionActivity.o


BIN
obj/activity/mainActivity.o


BIN
obj/activity/medicalCareActivity.o


BIN
obj/activity/moreActivity.o


BIN
obj/activity/navibar.o


BIN
obj/activity/promptActivity.o


BIN
obj/activity/settingActivity.o


BIN
obj/activity/sipTestActivity.o


BIN
obj/activity/startActivity.o


BIN
obj/activity/statusbar.o


BIN
obj/activity/updateActivity.o


BIN
obj/core/update_assistant.o


BIN
obj/net/tcp_client.o


BIN
obj/net/tcp_model.o


BIN
obj/server/http_server.o


BIN
obj/service/BusinessConfig.o


BIN
obj/service/time.o


BIN
obj/uart/UartContext.o


BIN
ui/function.ftu


BIN
ui/statusbar.ftu