فهرست منبع

新增删除设备功能;

scbc.sat2 5 سال پیش
والد
کامیت
bfdb1833e0
1فایلهای تغییر یافته به همراه17 افزوده شده و 10 حذف شده
  1. 17 10
      SATService/SATService/SATDevices.cpp

+ 17 - 10
SATService/SATService/SATDevices.cpp

@@ -139,16 +139,18 @@ DWORD CSATDevices::WorkThread(LPVOID lpVoid)
 
 		// 刷新当前设备列表;
 		std::vector<SATDEV::STDevice> vtDevices;
-#ifdef _DEBUG
-		printf("GetCurrentDevices\n");
-#endif
 		// 获取当前设备列表;
 		GetCurrentDevices(vtDevices);
-
 		AutoThreadSection ats(&s_ThreadSection);
+#ifdef _DEBUG
+		TRACE(_T("\t=================start==================\n"));
+#endif
 		// 遍历设备列表是否有下线设备;
 		std::vector<SATDEV::STDevice>::iterator it = s_vtDevices.begin();
 		for ( ;it != s_vtDevices.end(); ) {
+#ifdef _DEBUG
+		TRACE3(_T("\t当前设备类型:%d, 设备名称:%s, 设备状态:%d\n"), it->nType, it->strName.c_str(), it->nStatus);
+#endif
 			if ( it->nType == SATDEV::Virtual ) {
 				it++;
 				continue;
@@ -227,6 +229,9 @@ DWORD CSATDevices::WorkThread(LPVOID lpVoid)
 
 		// 保存全部设备状态;
 		SaveAllDevicesStatus2Config();
+#ifdef _DEBUG
+		TRACE(_T("\t=================end==================\n"));
+#endif
 	} while (WaitForSingleObject(that->m_hEvent, 2500) == WAIT_TIMEOUT);
 
 	printf("end thread\n");
@@ -246,8 +251,11 @@ void CSATDevices::DelDevices(std::string name)
 				str = "adb disconnect ";
 				str.append(name);
 				WinExec(str.c_str(), SW_HIDE);
+				CSATExecutor::GetInstance()->DelDevices(*it);
 				s_vtDevices.erase(it);
-				CSATExecutor::GetInstance()->AddDevices(*it);
+#ifdef _DEBUG
+				TRACE(_T("\t删除设备:%s\n"), name.c_str());
+#endif
 			}
 			break;
 		}
@@ -262,7 +270,9 @@ void CSATDevices::AddReticleDevices(std::string ip)
 	stDevice.ulOfflineTime = 0;
 	stDevice.nStatus = SATDEV::Online;
 	stDevice.nUsageState = SATDEV::Idle;
-
+#ifdef _DEBUG
+	TRACE1(_T("\t添加新设备:%s\n"), ip.c_str());
+#endif
 	AutoThreadSection ats(&s_ThreadSection);
 	if (!IsDeviceExist(stDevice)) {
 		s_vtDevices.push_back(stDevice);
@@ -341,9 +351,6 @@ bool CSATDevices::IsDevicesOffline(SATDEV::STDevice &stDevice, std::vector<SATDE
 		}
 	}	
 
-	// 将设备状态保存到配置文件中;
-	//SaveDeviceStatus2Config(stDevice);
-
 	return bOffline;
 }
 
@@ -359,7 +366,7 @@ bool CSATDevices::IsNewDevices(SATDEV::STDevice &stDevice)
 	}
 
 	// 如果是新设备(一般是usb连接)
-	if ( bNewDevices ) {
+	if ( bNewDevices && stDevice.nType != SATDEV::Reticle ) {
 		AutoThreadSection ats(&s_ThreadSection);
 		s_vtDevices.push_back(stDevice);
 		CSATExecutor::GetInstance()->AddDevices(stDevice);