Jelajahi Sumber

SATDevices中新增或删除设备时,SATExecutor中也同步新增或删除设备;

scbc.sat2 5 tahun lalu
induk
melakukan
850b7ab878

+ 9 - 2
SATService/SATService/SATDevices.cpp

@@ -1,5 +1,6 @@
 #include "StdAfx.h"
 #include "SATDevices.h"
+#include "SATExecutor.h"
 
 bool CSATDevices::s_bEnableAndroid = true;
 ULONGLONG CSATDevices::s_ulEraseDuration = 30000;
@@ -205,6 +206,7 @@ void CSATDevices::DelDevices(std::string name)
 				str.append(name);
 				WinExec(str.c_str(), SW_HIDE);
 				s_vtDevices.erase(it);
+				CSATExecutor::GetInstance()->AddDevices(*it);
 			}
 			break;
 		}
@@ -221,8 +223,10 @@ void CSATDevices::AddReticleDevices(std::string ip)
 	stDevice.nUsageState = SATDEV::Idle;
 
 	AutoThreadSection ats(&s_ThreadSection);
-	if (!IsDeviceExist(stDevice))
+	if (!IsDeviceExist(stDevice)) {
 		s_vtDevices.push_back(stDevice);
+		CSATExecutor::GetInstance()->AddDevices(stDevice);
+	}
 }
 
 void CSATDevices::AddVirtualDevices(std::string name)
@@ -235,8 +239,10 @@ void CSATDevices::AddVirtualDevices(std::string name)
 	stDevice.nUsageState = SATDEV::Idle;
 
 	AutoThreadSection ats(&s_ThreadSection);
-	if (!IsDeviceExist(stDevice))
+	if (!IsDeviceExist(stDevice)) {
 		s_vtDevices.push_back(stDevice);
+		CSATExecutor::GetInstance()->AddDevices(stDevice);
+	}
 }
 
 bool CSATDevices::IsDeviceExist(SATDEV::STDevice &stDevice)
@@ -302,6 +308,7 @@ bool CSATDevices::IsNewDevices(SATDEV::STDevice &stDevice)
 	if ( bNewDevices ) {
 		AutoThreadSection ats(&s_ThreadSection);
 		s_vtDevices.push_back(stDevice);
+		CSATExecutor::GetInstance()->AddDevices(stDevice);
 	}
 
 	return bNewDevices;

+ 2 - 1
SATService/SATService/SATExecutor.h

@@ -68,6 +68,8 @@ protected:
 	SATHTTP::STCase* GetFreeCaseScript(std::vector<SATHTTP::STCase> &vtCases);
 	// 执行空闲新用例;
 	SATHTTP::STCase* ExecuteFreeCaseScript(SATHTTP::STTask* pTask);
+	
+public:
 	// 添加设备;
 	void AddDevices(const SATDEV::STDevice &stDevice);
 	// 删除设备;
@@ -77,7 +79,6 @@ protected:
 	// 设备是否存在;
 	bool IsDeviceExist(std::string strDevName);
 
-
 public:
 	// 登录;
 	bool Login(std::string user, std::string password, std::string actuator, bool bLogin = true);