|
@@ -160,6 +160,7 @@ DWORD CSATDevices::WorkThread(LPVOID lpVoid)
|
|
|
if ( GetTickCount64() - it->ulOfflineTime > GLOBAL::g_stSATConfig.dwAdbTimeout ) {
|
|
|
// 移除设备(需要线程加锁);
|
|
|
it = s_vtDevices.erase(it);
|
|
|
+ GLOBAL::WriteTextLog("移除设备->设备类型:%d, 设备名称:%s, 状态:%d", it->nType, it->strName.c_str(), it->nStatus);
|
|
|
} else {
|
|
|
if ( it->nType == SATDEV::Reticle ) {
|
|
|
if ( it->nStatus == SATDEV::Offline ) {
|
|
@@ -167,12 +168,14 @@ DWORD CSATDevices::WorkThread(LPVOID lpVoid)
|
|
|
std::string str = "adb reconnect offline";
|
|
|
WinExec(str.c_str(), SW_HIDE);
|
|
|
// 重连后,break此次循环;
|
|
|
+ GLOBAL::WriteTextLog("offline重连->设备类型:%d, 设备名称:%s, 状态:%d, 命名:%s", it->nType, it->strName.c_str(), it->nStatus, str.c_str());
|
|
|
break;
|
|
|
}
|
|
|
else if ( it->nStatus == SATDEV::Dropline ) {
|
|
|
std::string str = "adb connect ";
|
|
|
str.append(it->strName);
|
|
|
WinExec(str.c_str(), SW_HIDE);
|
|
|
+ GLOBAL::WriteTextLog("dropline重连->设备类型:%d, 设备名称:%s, 状态:%d, 命名:%s", it->nType, it->strName.c_str(), it->nStatus, str.c_str());
|
|
|
}
|
|
|
} else if ( it->nType == SATDEV::Usb ) {
|
|
|
#if 0
|
|
@@ -180,11 +183,13 @@ DWORD CSATDevices::WorkThread(LPVOID lpVoid)
|
|
|
std::string str = "adb reconnect offline";
|
|
|
WinExec(str.c_str(), SW_HIDE);
|
|
|
#else
|
|
|
+ std::string str = "adb kill-server";
|
|
|
// 如果是usb的话,可能要kill-server,再全部重连接;
|
|
|
- WinExec("adb kill-server", SW_HIDE);
|
|
|
+ WinExec(str.c_str(), SW_HIDE);
|
|
|
// 重连所有;
|
|
|
ReConnectAllDevices();
|
|
|
// 重连后,break此次循环;
|
|
|
+ GLOBAL::WriteTextLog("usb重连->设备类型:%d, 设备名称:%s, 状态:%d, 命名:%s", it->nType, it->strName.c_str(), it->nStatus, str.c_str());
|
|
|
#endif
|
|
|
break;
|
|
|
}
|
|
@@ -270,11 +275,14 @@ bool CSATDevices::IsDeviceExist(SATDEV::STDevice &stDevice)
|
|
|
|
|
|
bool CSATDevices::IsDevicesOffline(SATDEV::STDevice &stDevice, std::vector<SATDEV::STDevice> &vtDevices )
|
|
|
{
|
|
|
+ bool bFound = false;
|
|
|
bool bOffline = true;
|
|
|
// 在当前设备列表查询;
|
|
|
std::vector<SATDEV::STDevice>::iterator it = vtDevices.begin();
|
|
|
for(; it != vtDevices.end(); it++ ) {
|
|
|
if ( _tcscmp(it->strName.c_str(), stDevice.strName.c_str()) == 0 ) {
|
|
|
+ // 找到设备;
|
|
|
+ bFound = true;
|
|
|
// 同步状态;
|
|
|
stDevice.nStatus = it->nStatus;
|
|
|
// 设备是否offline或dropline;
|
|
@@ -291,11 +299,18 @@ bool CSATDevices::IsDevicesOffline(SATDEV::STDevice &stDevice, std::vector<SATDE
|
|
|
stDevice.nStatus = SATDEV::Dropline;
|
|
|
stDevice.ulOfflineTime = GetTickCount64();
|
|
|
}
|
|
|
+
|
|
|
+ // 如果没找到设备,彻底离线;
|
|
|
+ if ( !bFound )
|
|
|
+ stDevice.nStatus = SATDEV::Dropline;
|
|
|
+
|
|
|
+ GLOBAL::WriteTextLog("离线->设备类型:%d, 设备名称:%s, 状态:%d", stDevice.nType, stDevice.strName.c_str(), stDevice.nStatus);
|
|
|
} else {
|
|
|
// 若重新连接,重置离线时间;
|
|
|
if ( stDevice.ulOfflineTime ) {
|
|
|
stDevice.nStatus = SATDEV::Online;
|
|
|
stDevice.ulOfflineTime = 0;
|
|
|
+ GLOBAL::WriteTextLog("重连成功->设备类型:%d, 设备名称:%s, 状态:%d", stDevice.nType, stDevice.strName.c_str(), stDevice.nStatus);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -341,7 +356,7 @@ void CSATDevices::GetCurrentDevices(std::vector<SATDEV::STDevice> &vtDevices)
|
|
|
if ( it->find(":5555") != std::string::npos )
|
|
|
stDevice.nType = SATDEV::Reticle;
|
|
|
else if ( it->find(":5555") == std::string::npos )
|
|
|
- stDevice.nType = SATDEV::Reticle;
|
|
|
+ stDevice.nType = SATDEV::Usb;
|
|
|
stDevice.ulOfflineTime = 0;
|
|
|
// 设备状态;
|
|
|
if ( (npos = it->find(" device")) != std::string::npos )
|