ソースを参照

1、添加本机IP地址和MAC地址日志打印输出,便于排查SAT上执行器IP地址异常的问题;
2、延长进程结束后,管道输出日志的时间;
3、修正设备使用状态设置的BUG(原因:使用了设备状态)
4、TCP通信中,设备信息查询添加字段:设备使用状态;
5、调换部分函数执行顺序;

scbc.sat2 5 年 前
コミット
353e285338

+ 4 - 0
SATService/SATService/Global.cpp

@@ -1272,6 +1272,8 @@ namespace GLOBAL
 			delete pIpAdapterInfo;
 		}
 
+		WriteTextLog("【当前主机IP地址:%s】", g_strIPAddress.c_str());
+
 		return g_strIPAddress;
 	}
 
@@ -1369,6 +1371,8 @@ namespace GLOBAL
 			g_strMacs.append(it->szMacAddress);
 			break;
 		}
+
+		WriteTextLog("【当前主机MAC地址:%s】", g_strMacs.c_str());
 #endif
 
 		return nTotal;

+ 4 - 2
SATService/SATService/PythonExecutor.cpp

@@ -202,7 +202,8 @@ int CPythonExecutor::RunScriptProcess()
 	// 等待进程完成退出.
 	WaitForSingleObject(m_pi.hProcess, INFINITE);
 
-	Sleep(5000);
+	// 必须等待,等待管道输出结果;
+	Sleep(6000);
 	GLOBAL::WriteTextLog("脚本进程结束(%ld)",  m_pi.dwProcessId);
 	// 同时需要关闭输出的管道,否则ReadFile会阻塞;
 	CloseHandle(m_hStdOutWrite);
@@ -344,7 +345,8 @@ int CPythonExecutor::ServiceRunScriptProcess()
 	// 等待进程完成退出.
 	WaitForSingleObject(m_pi.hProcess, INFINITE);
 	
-	Sleep(5000);
+	// 必须等待,等待管道输出结果;
+	Sleep(6000);
 	GLOBAL::WriteTextLog("脚本进程结束(%ld)",  m_pi.dwProcessId);
 	// 关闭进程句柄. 
 	CloseHandle(m_pi.hProcess);

+ 1 - 0
SATService/SATService/SATDevices.cpp

@@ -397,6 +397,7 @@ int CSATDevices::AttachDeviceName2Buffer(SATPROTO::Device (&pbuff)[SATPROTO::MAX
 		for ( ;it != s_vtDevices.end(); it++ ) {
 			pbuff[count].nType = it->nType;
 			pbuff[count].nStatus = it->nStatus;
+			pbuff[count].nUsageState = it->nUsageState;
 			memcpy_s(pbuff[count++].szName, MAX_PATH, it->strName.c_str(), it->strName.size());
 			// ³¬¹ýMAX_DEVSÍ˳ö;
 			if ( count == SATPROTO::MAX_DEVS )

+ 2 - 2
SATService/SATService/SATExecutor.cpp

@@ -175,9 +175,9 @@ void CSATExecutor::AddDevices(const SATDEV::STDevice &stDevice)
 
 	SATHTTP::STDevice http_dev;
 	// 设备使用状态;
-	if ( stDevice.nStatus == SATDEV::Idle )
+	if ( stDevice.nUsageState == SATDEV::Idle )
 		http_dev.strStatus = "0";
-	else if ( stDevice.nStatus == SATDEV::InUse )
+	else if ( stDevice.nUsageState == SATDEV::InUse )
 		http_dev.strStatus = "2";	// 注意避坑:0表示连接,即设备空闲;1表示设备断开;2表示设备繁忙
 	// 设备序列号;
 	http_dev.strDeviceSerial = stDevice.strName;

+ 2 - 1
SATService/SATService/SATProtocol.h

@@ -68,7 +68,8 @@ namespace SATPROTO{
 	typedef struct __DEVICE__ {
 		int 			nType;				// 0=虚拟, 1=usb, 2=网线;
 		char		 	szName[MAX_PATH];	// 设备名称(IP:端口号);
-		int				nStatus;			// 设备状态:0表示空闲,1表示繁忙;
+		int				nStatus;			// 设备状态:0=在线,1=离线(offline), 2=掉线(drop line);
+		int				nUsageState;		// 设备使用状态:0表示空闲,1表示繁忙;
 	}Device, *pDevice;
 
 	// 查询设备返回;

+ 1 - 1
SATService/SATService/SATService.cpp

@@ -63,8 +63,8 @@ int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
 	else
 	{
 		// TODO: 在此处为应用程序的行为编写代码。
-		GLOBAL::Python27Dir();
 		GLOBAL::GetIniInfo();
+		GLOBAL::Python27Dir();		
 		GLOBAL::GetMacAddress();
 		GLOBAL::GetLocalAddress();
 		GLOBAL::WriteTextLog("SATService goto start, tcp port = %ld", GLOBAL::g_stSATConfig.dwTCPSvrPort);