|
@@ -3,10 +3,12 @@
|
|
#include "PythonExecutor.h"
|
|
#include "PythonExecutor.h"
|
|
#include "CharEncoding.h"
|
|
#include "CharEncoding.h"
|
|
#include "SynSerial.h"
|
|
#include "SynSerial.h"
|
|
|
|
+#include "IRControl.h"
|
|
|
|
|
|
CSATExecutor::CSATExecutor(void)
|
|
CSATExecutor::CSATExecutor(void)
|
|
{
|
|
{
|
|
m_bLogin = FALSE;
|
|
m_bLogin = FALSE;
|
|
|
|
+ m_bStopWathTV = FALSE;
|
|
m_hEventHearbeat = NULL;
|
|
m_hEventHearbeat = NULL;
|
|
m_hThreadHearbeat = NULL;
|
|
m_hThreadHearbeat = NULL;
|
|
m_hEventExcuteScript = NULL;
|
|
m_hEventExcuteScript = NULL;
|
|
@@ -15,6 +17,8 @@ CSATExecutor::CSATExecutor(void)
|
|
|
|
|
|
CSATExecutor::~CSATExecutor(void)
|
|
CSATExecutor::~CSATExecutor(void)
|
|
{
|
|
{
|
|
|
|
+ m_bStopWathTV = FALSE;
|
|
|
|
+ EndofWork();
|
|
}
|
|
}
|
|
|
|
|
|
bool CSATExecutor::IsTaskExist(SATHTTP::STTask &task)
|
|
bool CSATExecutor::IsTaskExist(SATHTTP::STTask &task)
|
|
@@ -1224,6 +1228,11 @@ DWORD CSATExecutor::ExecuteScriptThread(LPVOID lpVoid)
|
|
|
|
|
|
DWORD CSATExecutor::WathTVPortThread(PVOID lpVoid)
|
|
DWORD CSATExecutor::WathTVPortThread(PVOID lpVoid)
|
|
{
|
|
{
|
|
|
|
+ CSATExecutor *that = (CSATExecutor*)lpVoid;
|
|
|
|
+ if ( !that )
|
|
|
|
+ return 0;
|
|
|
|
+
|
|
|
|
+
|
|
CSynSerial tv;
|
|
CSynSerial tv;
|
|
std::string buffer;
|
|
std::string buffer;
|
|
TCHAR szLastPort[10] = {0};
|
|
TCHAR szLastPort[10] = {0};
|
|
@@ -1231,41 +1240,36 @@ DWORD CSATExecutor::WathTVPortThread(PVOID lpVoid)
|
|
std::vector<std::string> vtNotifyReboot;
|
|
std::vector<std::string> vtNotifyReboot;
|
|
std::vector<std::string> vtNotifyShutdown;
|
|
std::vector<std::string> vtNotifyShutdown;
|
|
DWORD dwTickCount = GetTickCount();
|
|
DWORD dwTickCount = GetTickCount();
|
|
-/*
|
|
|
|
- while(!g_bStopThread)
|
|
|
|
- {
|
|
|
|
- // 读取配置文件;
|
|
|
|
|
|
+
|
|
|
|
+ while( !that->m_bStopWathTV ) {
|
|
|
|
+ // 实时读取配置文件;
|
|
GLOBAL::GetIniInfo();
|
|
GLOBAL::GetIniInfo();
|
|
- if ( !GLOBAL::g_stSATConfig.bWatchTVPort )
|
|
|
|
- {
|
|
|
|
|
|
+ if ( !GLOBAL::g_stSATConfig.bWatchTVPort ) {
|
|
Sleep(5000);
|
|
Sleep(5000);
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
|
|
|
|
- if ( GetTickCount() - dwTickCount > 5000 )
|
|
|
|
- {// 5秒更新一次;
|
|
|
|
- dwTickCount = GetTickCount();
|
|
|
|
|
|
+ if ( GetTickCount() - dwTickCount > 5000 ) { // 5秒更新一次;
|
|
vtNotifyReboot.clear();
|
|
vtNotifyReboot.clear();
|
|
vtNotifyShutdown.clear();
|
|
vtNotifyShutdown.clear();
|
|
|
|
+ dwTickCount = GetTickCount();
|
|
GLOBAL::Split(GLOBAL::g_stSATConfig.szTVReboot, _T(";"), vtNotifyReboot);
|
|
GLOBAL::Split(GLOBAL::g_stSATConfig.szTVReboot, _T(";"), vtNotifyReboot);
|
|
GLOBAL::Split(GLOBAL::g_stSATConfig.szTVShutdown, _T(";"), vtNotifyShutdown);
|
|
GLOBAL::Split(GLOBAL::g_stSATConfig.szTVShutdown, _T(";"), vtNotifyShutdown);
|
|
}
|
|
}
|
|
|
|
|
|
// 串口是否变更;
|
|
// 串口是否变更;
|
|
- if ( _tcsicmp(szLastPort, GLOBAL::g_stSATConfig.szTVPort) )
|
|
|
|
- {
|
|
|
|
|
|
+ if ( _tcsicmp(szLastPort, GLOBAL::g_stSATConfig.szTVPort) ) {
|
|
_tcscpy_s(szLastPort, GLOBAL::g_stSATConfig.szTVPort);
|
|
_tcscpy_s(szLastPort, GLOBAL::g_stSATConfig.szTVPort);
|
|
// 重启打开串口;
|
|
// 重启打开串口;
|
|
tv.CloseSerialPort();
|
|
tv.CloseSerialPort();
|
|
}
|
|
}
|
|
|
|
|
|
- if ( !tv.IsOpen() )
|
|
|
|
- {
|
|
|
|
|
|
+ // 如果串口打开失败重新打开;
|
|
|
|
+ if ( !tv.IsOpen() ) {
|
|
tv.OpenSerialPort(szLastPort, 115200, 8, 0, 1, 0, 1000);
|
|
tv.OpenSerialPort(szLastPort, 115200, 8, 0, 1, 0, 1000);
|
|
}
|
|
}
|
|
|
|
|
|
- if ( tv.IsOpen() )
|
|
|
|
- {
|
|
|
|
|
|
+ if ( tv.IsOpen() ) {
|
|
BYTE szBuffer[1024] = {0};
|
|
BYTE szBuffer[1024] = {0};
|
|
DWORD dwBuffer = tv.ReadComm(szBuffer, 1024, 1000);
|
|
DWORD dwBuffer = tv.ReadComm(szBuffer, 1024, 1000);
|
|
if ( dwBuffer != 0 )
|
|
if ( dwBuffer != 0 )
|
|
@@ -1277,20 +1281,17 @@ DWORD CSATExecutor::WathTVPortThread(PVOID lpVoid)
|
|
// 遍历是否有符合的子串;
|
|
// 遍历是否有符合的子串;
|
|
for ( std::vector<std::string>::iterator it = vtNotifyReboot.begin(); it != vtNotifyReboot.end(); it++ )
|
|
for ( std::vector<std::string>::iterator it = vtNotifyReboot.begin(); it != vtNotifyReboot.end(); it++ )
|
|
{
|
|
{
|
|
- if ( _tcsstr(buffer.c_str(), it->c_str()) )
|
|
|
|
- {
|
|
|
|
|
|
+ if ( _tcsstr(buffer.c_str(), it->c_str()) ) {
|
|
nType = 1;
|
|
nType = 1;
|
|
bAbnormal = true;
|
|
bAbnormal = true;
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- if ( !bAbnormal )
|
|
|
|
- {
|
|
|
|
|
|
+ if ( !bAbnormal ) {
|
|
for ( std::vector<std::string>::iterator it = vtNotifyShutdown.begin(); it != vtNotifyShutdown.end(); it++ )
|
|
for ( std::vector<std::string>::iterator it = vtNotifyShutdown.begin(); it != vtNotifyShutdown.end(); it++ )
|
|
{
|
|
{
|
|
- if ( _tcsstr(buffer.c_str(), it->c_str()) )
|
|
|
|
- {
|
|
|
|
|
|
+ if ( _tcsstr(buffer.c_str(), it->c_str()) ) {
|
|
nType = -1;
|
|
nType = -1;
|
|
bAbnormal = true;
|
|
bAbnormal = true;
|
|
break;
|
|
break;
|
|
@@ -1299,38 +1300,36 @@ DWORD CSATExecutor::WathTVPortThread(PVOID lpVoid)
|
|
}
|
|
}
|
|
|
|
|
|
// 1分钟前,是否有收到脚本通知;
|
|
// 1分钟前,是否有收到脚本通知;
|
|
- if ( Global::g_notify.notify )
|
|
|
|
- {
|
|
|
|
- __int64 nd = gmt - Global::g_notify.datetime;
|
|
|
|
|
|
+ if ( GLOBAL::g_PyNotify.notify ) {
|
|
|
|
+ __int64 nd = gmt - GLOBAL::g_PyNotify.datetime;
|
|
#ifdef _DEBUG
|
|
#ifdef _DEBUG
|
|
- TRACE3("判断时间%ld-通知时间%ld=相差时间%ld\n\n", gmt, Global::g_notify.datetime, nd);
|
|
|
|
|
|
+ TRACE3("判断时间%ld-通知时间%ld=相差时间%ld\n\n", gmt, GLOBAL::g_PyNotify.datetime, nd);
|
|
#endif
|
|
#endif
|
|
if ( nd < 60)
|
|
if ( nd < 60)
|
|
{
|
|
{
|
|
// 监测的类型与通知类型是否一致;
|
|
// 监测的类型与通知类型是否一致;
|
|
- if ( (nType == 1 && Global::g_notify.report_type == _T("reboot")) ||
|
|
|
|
- (nType == -1 && Global::g_notify.report_type == _T("shutdown")) )
|
|
|
|
|
|
+ if ( (nType == 1 && GLOBAL::g_PyNotify.report_type == _T("reboot")) ||
|
|
|
|
+ (nType == -1 && GLOBAL::g_PyNotify.report_type == _T("shutdown")) )
|
|
{
|
|
{
|
|
bAbnormal = false;
|
|
bAbnormal = false;
|
|
// 重置;
|
|
// 重置;
|
|
- Global::g_notify.notify = false;
|
|
|
|
- Global::g_notify.datetime = 0;
|
|
|
|
- Global::g_notify.report_type.clear();
|
|
|
|
|
|
+ GLOBAL::g_PyNotify.notify = false;
|
|
|
|
+ GLOBAL::g_PyNotify.datetime = 0;
|
|
|
|
+ GLOBAL::g_PyNotify.report_type.clear();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- if (bAbnormal)
|
|
|
|
- {
|
|
|
|
|
|
+ if (bAbnormal) {
|
|
if ( nType == -1 )
|
|
if ( nType == -1 )
|
|
{
|
|
{
|
|
// 遥控:重启电视机;
|
|
// 遥控:重启电视机;
|
|
- if ( Global::g_SendPowerKey )
|
|
|
|
- Global::g_SendPowerKey();
|
|
|
|
|
|
+ if ( Connect("127.0.0.1", 40000) )
|
|
|
|
+ sendSignal("POWER", 1, 1000);
|
|
}
|
|
}
|
|
|
|
|
|
// 压入容器中;
|
|
// 压入容器中;
|
|
- Global::TLog tlog;
|
|
|
|
|
|
+ GLOBAL::PyNotice tlog;
|
|
if ( nType == -1 )
|
|
if ( nType == -1 )
|
|
tlog.report_type = "Abnormal shutdown";
|
|
tlog.report_type = "Abnormal shutdown";
|
|
else if ( nType == 1 )
|
|
else if ( nType == 1 )
|
|
@@ -1342,18 +1341,17 @@ DWORD CSATExecutor::WathTVPortThread(PVOID lpVoid)
|
|
TCHAR szDataTime[64] = {0};
|
|
TCHAR szDataTime[64] = {0};
|
|
_stprintf_s(szDataTime,_T("Time of exception:%04d-%02d-%02d %02d:%02d:%02d"), gmtm.tm_year + 1900, gmtm.tm_mon+1, gmtm.tm_mday, gmtm.tm_hour, gmtm.tm_min, gmtm.tm_sec);
|
|
_stprintf_s(szDataTime,_T("Time of exception:%04d-%02d-%02d %02d:%02d:%02d"), gmtm.tm_year + 1900, gmtm.tm_mon+1, gmtm.tm_mday, gmtm.tm_hour, gmtm.tm_min, gmtm.tm_sec);
|
|
tlog.report_data = szDataTime;
|
|
tlog.report_data = szDataTime;
|
|
- Global::g_vtAbnormal.push_back(tlog);
|
|
|
|
|
|
|
|
// 最后,重置;
|
|
// 最后,重置;
|
|
- Global::g_notify.notify = false;
|
|
|
|
- Global::g_notify.datetime = 0;
|
|
|
|
- Global::g_notify.report_type.clear();
|
|
|
|
|
|
+ GLOBAL::g_PyNotify.notify = false;
|
|
|
|
+ GLOBAL::g_PyNotify.datetime = 0;
|
|
|
|
+ GLOBAL::g_PyNotify.report_type.clear();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
Sleep(200);
|
|
Sleep(200);
|
|
}
|
|
}
|
|
-*/
|
|
|
|
|
|
+
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|