浏览代码

修复监听正常关机、重启功能;

Jeff 5 年之前
父节点
当前提交
1a47213555
共有 3 个文件被更改,包括 10 次插入11 次删除
  1. 2 5
      SATService/SATService/SATExecutor.cpp
  2. 2 2
      SATService/SATService/SATProtocol.h
  3. 6 4
      SATService/SATService/SATTCPServer.cpp

+ 2 - 5
SATService/SATService/SATExecutor.cpp

@@ -1232,7 +1232,6 @@ DWORD CSATExecutor::WathTVPortThread(PVOID lpVoid)
 	if ( !that )
 		return 0;
 
-	
 	CSynSerial tv;
 	std::string buffer;
 	TCHAR szLastPort[10] = {0};
@@ -1272,8 +1271,7 @@ DWORD CSATExecutor::WathTVPortThread(PVOID lpVoid)
 		if ( tv.IsOpen() ) {
 			BYTE szBuffer[1024] = {0};
 			DWORD dwBuffer = tv.ReadComm(szBuffer, 1024, 1000);
-			if ( dwBuffer != 0 )
-			{
+			if ( dwBuffer != 0 ) {
 				int nType = 0; // 0表示无异常类型,-1表示关机异常,1表示重启异常;
 				bool bAbnormal = false;
 				buffer = (char*)szBuffer;
@@ -1321,8 +1319,7 @@ DWORD CSATExecutor::WathTVPortThread(PVOID lpVoid)
 				}
 
 				if (bAbnormal) {
-					if ( nType == -1 )
-					{
+					if ( nType == -1 ) {
 						// 遥控:重启电视机;
 						if ( Connect("127.0.0.1", 40000) )
 							sendSignal("POWER", 1, 1000);

+ 2 - 2
SATService/SATService/SATProtocol.h

@@ -106,8 +106,8 @@ namespace SATPROTO{
 
 	typedef struct __PY_NOTICE__ {
 		__int64		nTimeStamp;					// 时间戳;
-		int			nNoticeType;					// 通知类型;
-		//char		szNotice[MAX_NOTICE];			// 通知内容;
+		int			nNoticeType;				// 通知类型;
+		//char		szNotice[MAX_NOTICE];		// 通知内容;
 	}PyNotice, *pPyNotice;
 
 #pragma pack(pop)

+ 6 - 4
SATService/SATService/SATTCPServer.cpp

@@ -991,11 +991,13 @@ void CSATTCPServer::_TaskProcess(PER_IO_CONTEXT* pIoContext, SATPROTO::Package*
 			case SATPROTO::CMD_PY_NOTICE:
 				{
 					SATPROTO::PyNotice *notice = (SATPROTO::PyNotice*)pak->buf;
-					if ( notice->nNoticeType == 0 ) { // 表示异常关机;
-
+					GLOBAL::g_PyNotify.notify = true;
+					GLOBAL::g_PyNotify.datetime = notice->nTimeStamp;
+					if ( notice->nNoticeType == 0 ) { // 表示正常关机;
+						GLOBAL::g_PyNotify.report_type = "shutdown";
 					}
-					else if ( notice->nNoticeType == 1 ) { // 表示异常重启;
-
+					else if ( notice->nNoticeType == 1 ) { // 表示常重启;
+						GLOBAL::g_PyNotify.report_type = "reboot";
 					}
 
 					// 封装返回数据;