|
|
@@ -1,11 +1,16 @@
|
|
|
-#include "StdAfx.h"
|
|
|
+#include "stdafx.h"
|
|
|
#include "ScannerSetFSM.h"
|
|
|
#include "EventCode.h"
|
|
|
#include "SpIni.h"
|
|
|
-#include "CameraImpl.h"
|
|
|
+#include "toolkit.h"
|
|
|
+#include "iniutil.h"
|
|
|
+#include "path.h"
|
|
|
+#include "CommEntityUtil.hpp"
|
|
|
|
|
|
+#if defined(RVC_OS_WIN)
|
|
|
#include "SetupApi.h"
|
|
|
-#pragma comment(lib, "SetupAPI.lib")
|
|
|
+#include <process.h>
|
|
|
+#endif //RVC_OS_WIN
|
|
|
|
|
|
#define CHECKDEV_TIMER_ID 1
|
|
|
const int MILLISECOND_TO_CHECKDEV = 15 * 1000;
|
|
|
@@ -19,110 +24,9 @@ const int MILLISECOND_WAIT_TIMEOUT_DEFAULT = 10 * 1000;
|
|
|
const int MILLISECOND_WAIT_TIMEOUT_STARTPREVIEW = 20 * 1000;
|
|
|
const int MILLISECOND_WAIT_TIMEOUT_SCANIMAGE = 15 * 1000;
|
|
|
|
|
|
-using namespace HeartBeat;
|
|
|
-
|
|
|
-//#include "..\mod_assistantchannel\AssistantChannel_client_g.h"
|
|
|
-//#include "..\mod_Assistantchannel\chan_protocol.h"
|
|
|
-//using namespace AssistantChannel;
|
|
|
+#define MODULE_VERION_FULL "1.0.0.2"
|
|
|
|
|
|
-//namespace ChannelSideNamespace {
|
|
|
-//
|
|
|
-//class CChannelSideHelper {
|
|
|
-//
|
|
|
-//public:
|
|
|
-//
|
|
|
-// class ChannelClient : public ChannelService_ClientBase
|
|
|
-// {
|
|
|
-// public:
|
|
|
-// explicit ChannelClient(CEntityBase* pEntity)
|
|
|
-// : ChannelService_ClientBase(pEntity) {}
|
|
|
-// };
|
|
|
-//
|
|
|
-// explicit CChannelSideHelper(CEntityBase* entity)
|
|
|
-// :_entity(entity)
|
|
|
-// ,m_pOtherSideEntity(NULL)
|
|
|
-// ,m_bConnected(FALSE)
|
|
|
-// ,rc(Error_Succeed)
|
|
|
-// {
|
|
|
-// Connect();
|
|
|
-// }
|
|
|
-// BOOL Connect() {
|
|
|
-// if(!m_pOtherSideEntity) {
|
|
|
-// m_pOtherSideEntity = new ChannelClient(_entity);
|
|
|
-// LOG_ASSERT(m_bConnected == FALSE && "m_bConnected == FALSE");
|
|
|
-// }
|
|
|
-// if(!m_bConnected) {
|
|
|
-// rc = m_pOtherSideEntity->Connect();
|
|
|
-// if(rc == 0) {
|
|
|
-// m_bConnected = TRUE;
|
|
|
-// ChannelService_BeginRecv_Sub Sub;
|
|
|
-// Sub.type = ACM_TYPE_PHT;
|
|
|
-// rc = m_pOtherSideEntity->BeginRecv(Sub);
|
|
|
-// if (rc != 0) {
|
|
|
-// Dbg("m_pOtherSideEntity->BeginRecv(Sub) failed: %d", rc);
|
|
|
-// ReleaseConn();
|
|
|
-// }
|
|
|
-// } else {
|
|
|
-// Dbg("m_pOtherSideEntity->Connect() failed: %d", rc);
|
|
|
-// }
|
|
|
-// }
|
|
|
-// return m_bConnected;
|
|
|
-// }
|
|
|
-//
|
|
|
-// BOOL ReConnect() {
|
|
|
-// ReleaseConn();
|
|
|
-// return Connect();
|
|
|
-// }
|
|
|
-//
|
|
|
-// BOOL IsConnected() const {
|
|
|
-// return m_bConnected;
|
|
|
-// }
|
|
|
-//
|
|
|
-// BOOL Send(CBlob& data) {
|
|
|
-// if(!m_bConnected && !Connect()) {
|
|
|
-// return FALSE;
|
|
|
-// }
|
|
|
-// ChannelService_Send_Info Info;
|
|
|
-// Info.compress = false;
|
|
|
-// Info.encrypt = false;
|
|
|
-// Info.type = ACM_TYPE_PHT;
|
|
|
-// Info.id = 0;
|
|
|
-// Info.sub_type = ACM_PHT_ANS;
|
|
|
-// Info.data = data;
|
|
|
-// rc = m_pOtherSideEntity->Send(Info);
|
|
|
-// if(rc == 0) {
|
|
|
-// Dbg("m_pOtherSideEntity->Send(Info) succ.");
|
|
|
-// return TRUE;
|
|
|
-// } else {
|
|
|
-// Dbg("m_pOtherSideEntity->Send(Info) failed: %d", rc);
|
|
|
-// ReleaseConn();
|
|
|
-// return FALSE;
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-// ~CChannelSideHelper() {
|
|
|
-// ReleaseConn();
|
|
|
-// }
|
|
|
-//private:
|
|
|
-// void ReleaseConn() {
|
|
|
-// if(!m_pOtherSideEntity)
|
|
|
-// return;
|
|
|
-// if(m_bConnected) {
|
|
|
-// m_pOtherSideEntity->GetFunction()->CloseSession();
|
|
|
-// m_bConnected = FALSE;
|
|
|
-// }
|
|
|
-// m_pOtherSideEntity->SafeDelete();
|
|
|
-// m_pOtherSideEntity = NULL;
|
|
|
-// }
|
|
|
-//
|
|
|
-// CEntityBase* _entity;
|
|
|
-// ChannelClient* m_pOtherSideEntity;
|
|
|
-// BOOL m_bConnected;
|
|
|
-// ErrorCodeEnum rc;
|
|
|
-//};
|
|
|
-//
|
|
|
-//}
|
|
|
-/***/
|
|
|
+using namespace HeartBeat;
|
|
|
|
|
|
const char* EvtTypeToString(int nEvtType)
|
|
|
{
|
|
|
@@ -179,7 +83,6 @@ const char* EvtTypeToString(int nEvtType)
|
|
|
return "Unknown EventType";
|
|
|
break;
|
|
|
}
|
|
|
- return "Unknown EventType";
|
|
|
}
|
|
|
|
|
|
CScannerFSM::CScannerFSM(void)
|
|
|
@@ -190,6 +93,8 @@ CScannerFSM::CScannerFSM(void)
|
|
|
m_bStand2SMachine(false),
|
|
|
m_bDesk2SMachine(false),
|
|
|
m_bJBMachine(false),
|
|
|
+ m_bDesk1SMachine(false),
|
|
|
+ m_bUsePortableScanner(false),
|
|
|
m_pHSPSClient(NULL),
|
|
|
m_pPortableClient(NULL),
|
|
|
m_ecSelfTest(Error_Succeed),
|
|
|
@@ -198,20 +103,23 @@ CScannerFSM::CScannerFSM(void)
|
|
|
m_nSrcState(s0),
|
|
|
m_iEvt(-1)
|
|
|
{
|
|
|
- InitializeCriticalSection(&cs_devEvt);
|
|
|
ListEntry_InitHead(&ContextListHead);
|
|
|
- m_hrCoInited = CoInitializeEx(NULL, COINIT_MULTITHREADED);
|
|
|
+#if defined(RVC_OS_WIN)
|
|
|
+ m_hrCoInited = CoInitializeEx(NULL, COINIT_MULTITHREADED);
|
|
|
+#endif //RVC_OS_WIN
|
|
|
}
|
|
|
|
|
|
CScannerFSM::~CScannerFSM(void)
|
|
|
{
|
|
|
ReleaseSuitableEntity();
|
|
|
- DestoryCamereBuckets(m_cameralist);
|
|
|
- DeleteCriticalSection(&cs_devEvt);
|
|
|
|
|
|
- if(m_hrCoInited == S_OK) {
|
|
|
- CoUninitialize();
|
|
|
- }
|
|
|
+#if defined(RVC_OS_WIN)
|
|
|
+ DestoryCamereBuckets(m_cameralist);
|
|
|
+ if (m_hrCoInited == S_OK) {
|
|
|
+ CoUninitialize();
|
|
|
+ }
|
|
|
+#endif //RVC_OS_WIN
|
|
|
+
|
|
|
if(m_bJBMachine) {
|
|
|
DestoryMethodQueue();
|
|
|
}
|
|
|
@@ -221,8 +129,9 @@ ErrorCodeEnum CScannerFSM::OnInit()
|
|
|
{
|
|
|
LOG_FUNCTION();
|
|
|
ErrorCodeEnum erroCode = Error_Succeed;
|
|
|
- Dbg("Version: 1.0.0.2007, Complied at: %s %s --Gifur", __DATE__, __TIME__);
|
|
|
+ Dbg("Version: %s, Complied at: %s %s", MODULE_VERION_FULL, __DATE__, __TIME__);
|
|
|
CSmartPointer<IConfigInfo> spConfig;
|
|
|
+ SP::Module::Comm::TerminalMachineInfo machineInfo = SP::Module::Comm::GetTerminalMachineInfo(GetEntityBase());
|
|
|
CSystemStaticInfo sysInfo;
|
|
|
erroCode = GetEntityBase()->GetFunction()->GetSystemStaticInfo(sysInfo);
|
|
|
if (FAILURED(erroCode))
|
|
|
@@ -240,18 +149,22 @@ ErrorCodeEnum CScannerFSM::OnInit()
|
|
|
}
|
|
|
m_bStand2SMachine = !m_csMachineType.Compare("RVC.Stand2S", true);
|
|
|
m_bJBMachine = !m_csMachineType.Compare("RVC.IL", true);
|
|
|
-
|
|
|
- if(m_bPadMachine || m_bDesk2SMachine) {
|
|
|
- LoadConfigAboutCamera();
|
|
|
- GetCameraInfors(m_cameralist);
|
|
|
- HANDLE hEvtThread = (HANDLE)_beginthreadex(NULL, 0, EventRevThread, this, 0, NULL);
|
|
|
- if(hEvtThread == NULL || hEvtThread == INVALID_HANDLE_VALUE) {
|
|
|
- Dbg("Create EventRevThread failed");
|
|
|
- } else {
|
|
|
- Sleep(100);
|
|
|
- LOG_ASSERT(gEventRevWnd != NULL);
|
|
|
- }
|
|
|
- }
|
|
|
+ m_bDesk1SMachine = !m_csMachineType.Compare("RVC.Desk1S", true);
|
|
|
+#if defined(RVC_OS_WIN)
|
|
|
+ if (m_bPadMachine || m_bDesk2SMachine || m_bDesk1SMachine) {
|
|
|
+ m_bUsePortableScanner = true;
|
|
|
+ LoadConfigAboutCamera();
|
|
|
+ GetCameraInfors(m_cameralist);
|
|
|
+
|
|
|
+ HANDLE hEvtThread = (HANDLE)_beginthreadex(NULL, 0, EventRevThread, this, 0, NULL);
|
|
|
+ if (hEvtThread == NULL || hEvtThread == INVALID_HANDLE_VALUE) {
|
|
|
+ Dbg("Create EventRevThread failed");
|
|
|
+ } else {
|
|
|
+ Sleep(100);
|
|
|
+ LOG_ASSERT(gEventRevWnd != NULL);
|
|
|
+ }
|
|
|
+ }
|
|
|
+#endif //RVC_OS_WIN
|
|
|
if(m_bJBMachine) {
|
|
|
InitializeMehodQueue();
|
|
|
}
|
|
|
@@ -274,7 +187,8 @@ void CScannerFSM::s0_on_entry()
|
|
|
PostEventFIFO(new FSMEvent(USER_EVT_DEV_INVALID));
|
|
|
}
|
|
|
}
|
|
|
- else if(m_bPadMachine || m_bDesk2SMachine)
|
|
|
+
|
|
|
+ else if(m_bUsePortableScanner)
|
|
|
{
|
|
|
ErrorCodeEnum erroCode = CheckPortableConnectStatus();
|
|
|
if(FAILED(erroCode)) {
|
|
|
@@ -423,11 +337,12 @@ void CScannerFSM::s1_on_entry()
|
|
|
LOG_FUNCTION();
|
|
|
FSMEvent* evt = new FSMEvent(USER_EVT_ESTIMATE_FINISHED);
|
|
|
evt->param1 = evt->param2 = 0;
|
|
|
+ int flag = 0;
|
|
|
+#if defined(RVC_OS_WIN)
|
|
|
CAutoArray<ScannerDeviceInfo> cameralist;
|
|
|
bool bInnerUpdated = true;
|
|
|
int devCount = GetCurrentCameraList(cameralist, bInnerUpdated);
|
|
|
LOG_ASSERT(!bInnerUpdated || devCount == m_cameralist.size());
|
|
|
- int flag = 0;
|
|
|
if(devCount > 0) {
|
|
|
for(int i=0; i<devCount; ++i) {
|
|
|
//ʶ±ðµ½¸ßÅÄÒÇÉãÏñÍ·
|
|
|
@@ -449,6 +364,7 @@ void CScannerFSM::s1_on_entry()
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+#endif //RVC_OS_WIN
|
|
|
evt->param1 = flag;
|
|
|
PostEventFIFO(evt);
|
|
|
m_nFatalTimes = 0;
|
|
|
@@ -645,7 +561,7 @@ unsigned int CScannerFSM::s3_on_event(FSMEvent* e)
|
|
|
void CScannerFSM::s4_on_entry()
|
|
|
{
|
|
|
LOG_FUNCTION();
|
|
|
- if(m_bStand2SMachine || m_bPadMachine || m_bDesk2SMachine)
|
|
|
+ if(m_bStand2SMachine || m_bUsePortableScanner)
|
|
|
{
|
|
|
ScheduleTimer(CHECKDEV_TIMER_ID, MILLISECOND_TO_CHECKDEV);
|
|
|
}
|
|
|
@@ -657,7 +573,7 @@ void CScannerFSM::s4_on_entry()
|
|
|
|
|
|
void CScannerFSM::s4_on_exit()
|
|
|
{
|
|
|
- if(m_bStand2SMachine || m_bPadMachine || m_bDesk2SMachine)
|
|
|
+ if(m_bStand2SMachine || m_bUsePortableScanner)
|
|
|
{
|
|
|
CancelTimer(CHECKDEV_TIMER_ID);
|
|
|
}
|
|
|
@@ -680,7 +596,7 @@ unsigned int CScannerFSM::s4_on_event(FSMEvent* e)
|
|
|
if(e->param1 == CHECKDEV_TIMER_ID)
|
|
|
{
|
|
|
e->SetHandled();
|
|
|
- if(!m_bPadMachine && !m_bDesk2SMachine) {
|
|
|
+ if(!m_bUsePortableScanner) {
|
|
|
if(ISSUCCEEDED(CheckHSPSConnectStatus()))
|
|
|
{
|
|
|
PostEventFIFO(new FSMEvent(USER_EVT_DEV_RECOVER));
|
|
|
@@ -762,7 +678,7 @@ int CScannerFSM::StartPreview(SpReqAnsContext<ScannerService_StartPreview_Req,
|
|
|
Dbg("StartPreview context suc, retCode: ans(%d), ctx(%d).", ans.retCode, ctx->Ans.retCode);
|
|
|
}
|
|
|
}
|
|
|
- else if(m_bPadMachine || m_bDesk2SMachine) {
|
|
|
+ else if(m_bUsePortableScanner) {
|
|
|
PortableScannerService_StartPreview_Req req = {};
|
|
|
PortableScannerService_StartPreview_Ans ans = {};
|
|
|
|
|
|
@@ -824,7 +740,7 @@ int CScannerFSM::StopPreview(SpReqAnsContext<ScannerService_CancelPreview_Req,
|
|
|
}else {
|
|
|
Dbg("CancelPreview context suc.");
|
|
|
}
|
|
|
- }else if(m_bPadMachine || m_bDesk2SMachine) {
|
|
|
+ }else if(m_bUsePortableScanner) {
|
|
|
|
|
|
PortableScannerService_CancelPreview_Req req = {};
|
|
|
PortableScannerService_CancelPreview_Ans ans = {};
|
|
|
@@ -886,7 +802,7 @@ int CScannerFSM::ScanImage(SpReqAnsContext<ScannerService_ScanImage_Req,
|
|
|
ctx->Ans.filePath = ans.filePath;
|
|
|
ctx->Ans.imageData = ans.imageData;
|
|
|
}
|
|
|
- }else if(m_bPadMachine || m_bDesk2SMachine) {
|
|
|
+ }else if(m_bUsePortableScanner) {
|
|
|
PortableScannerService_ScanImage_Req req = {};
|
|
|
PortableScannerService_ScanImage_Ans ans = {};
|
|
|
|
|
|
@@ -918,7 +834,7 @@ int CScannerFSM::ScanImage(SpReqAnsContext<ScannerService_ScanImage_Req,
|
|
|
ctx->Ans.imageData = ans.imageData;
|
|
|
}
|
|
|
}
|
|
|
- else if(m_bPadMachine || m_bDesk2SMachine) {
|
|
|
+ else if(m_bUsePortableScanner) {
|
|
|
PortableScannerService_ScanImageEx_Req req = {};
|
|
|
PortableScannerService_ScanImageEx_Ans ans = {};
|
|
|
|
|
|
@@ -980,7 +896,7 @@ int CScannerFSM::SetProperty(SpReqAnsContext<ScannerService_SetProperty_Req,
|
|
|
ctx->Ans.retCode = ans.retCode;
|
|
|
Dbg("SetProperty context suc, retCode: ans(%d), ctx(%d).", ans.retCode, ctx->Ans.retCode);
|
|
|
}
|
|
|
- }else if(m_bPadMachine || m_bDesk2SMachine) {
|
|
|
+ }else if(m_bUsePortableScanner) {
|
|
|
|
|
|
PortableScannerService_SetProperty_Req req = {};
|
|
|
PortableScannerService_SetProperty_Ans ans = {};
|
|
|
@@ -1035,7 +951,7 @@ int CScannerFSM::ShowLTProperty(SpReqAnsContext<ScannerService_ShowProperty_Req,
|
|
|
HSPScannerService_ShowProperty_Ans ans = {};
|
|
|
erroCode = m_pHSPSClient->ShowProperty(req, ans, MILLISECOND_WAIT_TIMEOUT_DEFAULT);
|
|
|
|
|
|
- } else if(m_bPadMachine || m_bDesk2SMachine) {
|
|
|
+ } else if(m_bUsePortableScanner) {
|
|
|
PortableScannerService_ShowProperty_Req req = {};
|
|
|
PortableScannerService_ShowProperty_Ans ans = {};
|
|
|
erroCode = m_pPortableClient->ShowProperty(req, ans, MILLISECOND_WAIT_TIMEOUT_DEFAULT);
|
|
|
@@ -1094,7 +1010,7 @@ int CScannerFSM::SetWinPos(SpReqAnsContext<ScannerService_SetWindowPos_Req,
|
|
|
req.nWidth = ctx->Req.nWidth;
|
|
|
|
|
|
erroCode = m_pHSPSClient->SetWinPos(req, ans, MILLISECOND_WAIT_TIMEOUT_DEFAULT);
|
|
|
- } else if(m_bPadMachine || m_bDesk2SMachine) {
|
|
|
+ } else if(m_bUsePortableScanner) {
|
|
|
PortableScannerService_SetWinPos_Req req = {};
|
|
|
PortableScannerService_SetWinPos_Ans ans = {};
|
|
|
|
|
|
@@ -1157,7 +1073,7 @@ int CScannerFSM::GetDevStatus(SpReqAnsContext<ScannerService_GetDevStatus_Req,
|
|
|
ctx->Ans.bInvalid = ans.connected == 0 ? false : true;
|
|
|
ctx->Ans.bPreview = ans.previewing == 0 ? false : true;
|
|
|
}
|
|
|
- } else if(m_bPadMachine || m_bDesk2SMachine) {
|
|
|
+ } else if(m_bUsePortableScanner) {
|
|
|
PortableScannerService_GetDevStatus_Req req = {};
|
|
|
PortableScannerService_GetDevStatus_Ans ans = {};
|
|
|
|
|
|
@@ -1226,7 +1142,7 @@ int CScannerFSM::GetDevInfo(SpReqAnsContext<ScannerService_GetDevInfo_Req,
|
|
|
ctx->Ans.version = ans.version;
|
|
|
ctx->Ans.state = ans.state;
|
|
|
}
|
|
|
- }else if(m_bPadMachine || m_bDesk2SMachine) {
|
|
|
+ }else if(m_bUsePortableScanner) {
|
|
|
PortableScannerService_GetDevInfo_Req req = {};
|
|
|
PortableScannerService_GetDevInfo_Ans ans = {};
|
|
|
erroCode = m_pPortableClient->GetDevInfo(req, ans, MILLISECOND_WAIT_TIMEOUT_DEFAULT);
|
|
|
@@ -1272,24 +1188,26 @@ int CScannerFSM::GetOnlineDevices(SpReqAnsContext<ScannerService_GetOnlineCamera
|
|
|
ReleaseSuitableEntity();
|
|
|
return ret == Error_Succeed ? 0 : 1;
|
|
|
}
|
|
|
- CAutoArray<ScannerDeviceInfo> cameralist;
|
|
|
- if(FALSE) {
|
|
|
- UpdateCameraInfors(m_cameralist);
|
|
|
- }
|
|
|
- int nCount = m_cameralist.size();
|
|
|
- Dbg("Path3: Current camera count: %d", nCount);
|
|
|
- ctx->Ans.devCount = nCount;
|
|
|
- if(nCount > 0) {
|
|
|
- ctx->Ans.devFriendlyNames.Init(nCount);
|
|
|
- ctx->Ans.devType.Init(nCount);
|
|
|
- for(int i=0; i<nCount; ++i) {
|
|
|
- ctx->Ans.devFriendlyNames[i] = m_cameralist[i]->szDevName;
|
|
|
- ctx->Ans.devType[i] = GetRVCCameraType(m_cameralist[i]->szDevName);
|
|
|
- Dbg("[%d]%s(%d)", i, (LPCTSTR)ctx->Ans.devFriendlyNames[i], ctx->Ans.devType[i]);
|
|
|
- }
|
|
|
- }
|
|
|
- ctx->Answer(Error_Succeed);
|
|
|
- return nCount;
|
|
|
+
|
|
|
+#if defined(RVC_OS_WIN)
|
|
|
+ int nCount = m_cameralist.size();
|
|
|
+ Dbg("Path3: Current camera count: %d", nCount);
|
|
|
+ ctx->Ans.devCount = nCount;
|
|
|
+ if (nCount > 0) {
|
|
|
+ ctx->Ans.devFriendlyNames.Init(nCount);
|
|
|
+ ctx->Ans.devType.Init(nCount);
|
|
|
+ for (int i = 0; i < nCount; ++i) {
|
|
|
+ ctx->Ans.devFriendlyNames[i] = m_cameralist[i]->szDevName;
|
|
|
+ ctx->Ans.devType[i] = GetRVCCameraType(m_cameralist[i]->szDevName);
|
|
|
+ Dbg("[%d]%s(%d)", i, (LPCTSTR)ctx->Ans.devFriendlyNames[i], ctx->Ans.devType[i]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ctx->Answer(Error_Succeed);
|
|
|
+ return nCount;
|
|
|
+#else
|
|
|
+ ctx->Answer(Error_NotSupport);
|
|
|
+ return 0;
|
|
|
+#endif //RVC_OS_WIN
|
|
|
}
|
|
|
|
|
|
ErrorCodeEnum CScannerFSM::OnDevExit()
|
|
|
@@ -1313,7 +1231,7 @@ ErrorCodeEnum CScannerFSM::OnDevExit()
|
|
|
if(m_bStand2SMachine) {
|
|
|
HSPScannerService_Exit_Info info = {};
|
|
|
erroCode = m_pHSPSClient->Exit();
|
|
|
- }else if(m_bPadMachine || m_bDesk2SMachine) {
|
|
|
+ }else if(m_bUsePortableScanner) {
|
|
|
PortableScannerService_Exit_Info info = {};
|
|
|
erroCode = m_pPortableClient->Exit();
|
|
|
}
|
|
|
@@ -1497,61 +1415,32 @@ ErrorCodeEnum CScannerFSM::LoadConfigAboutCamera()
|
|
|
if(index != -1) {
|
|
|
strPath[index] = '\0';
|
|
|
} else {
|
|
|
- strPath[index] += '\\';
|
|
|
+ strPath[index] += SPLIT_SLASH;
|
|
|
}
|
|
|
- CSimpleStringA strMCRunCfg = strPath + "runinfo\\runcfg\\MediaController.ini";
|
|
|
+ CSimpleStringA strMCRunCfg = strPath + "runinfo" SPLIT_SLASH_STR "runcfg" SPLIT_SLASH_STR "MediaController.ini";
|
|
|
Dbg("%s", (LPCTSTR)strMCRunCfg);
|
|
|
if(nEnvID == -2) {
|
|
|
- DWORD dwSize = ::GetPrivateProfileStringA("Video", "FrontCamera", "$",
|
|
|
- lpValue, MAX_PATH, strMCRunCfg);
|
|
|
+ DWORD dwSize = inifile_read_str_s("Video", "FrontCamera", "$", lpValue, MAX_PATH, strMCRunCfg);
|
|
|
Dbg("Retrive env(front) camera: %s", lpValue);
|
|
|
if(strlen(lpValue) > 1) {
|
|
|
- m_fixedCamera[CAMTYPE_ENV-1].strDevName = GetPrefixCameraName(CSimpleStringA(lpValue));
|
|
|
+ CSimpleStringA strValue(lpValue);
|
|
|
+ m_fixedCamera[CAMTYPE_ENV-1].strDevName = GetPrefixCameraName(strValue);
|
|
|
m_fixedCamera[CAMTYPE_ENV-1].devType = CAMTYPE_ENV;
|
|
|
Dbg("Found front camera name: %s", strEnvCamera.GetData());
|
|
|
}
|
|
|
- //if(strlen(lpValue) > 1) {
|
|
|
- // char* splitMark = strchr(lpValue, ';');
|
|
|
- // if(splitMark != NULL) {
|
|
|
- // splitMark[0] = '\0';
|
|
|
- // if(strlen(lpValue) > 0) {
|
|
|
- // strEnvCamera = lpValue;
|
|
|
- // m_fixedCamera[CAMTYPE_ENV-1].strDevName = strEnvCamera;
|
|
|
- // m_fixedCamera[CAMTYPE_ENV-1].devType = CAMTYPE_ENV;
|
|
|
- // Dbg("Found front camera name: %s", strEnvCamera.GetData());
|
|
|
- // }
|
|
|
- // }
|
|
|
- //}
|
|
|
- //memset(lpValue, 0, sizeof(lpValue));
|
|
|
}
|
|
|
if(nOptID == -2) {
|
|
|
- DWORD dwSize = ::GetPrivateProfileStringA("Video", "RearCamera", "$",
|
|
|
- lpValue, MAX_PATH, strMCRunCfg);
|
|
|
+ DWORD dwSize = inifile_read_str_s("Video", "RearCamera", "$", lpValue, MAX_PATH, strMCRunCfg);
|
|
|
Dbg("Retrive opt(rear) camera from runtime config: %s", lpValue);
|
|
|
if(strlen(lpValue) > 1) {
|
|
|
- m_fixedCamera[CAMTYPE_OPT-1].strDevName = GetPrefixCameraName(CSimpleStringA(lpValue));
|
|
|
+ CSimpleStringA strValue(lpValue);
|
|
|
+ m_fixedCamera[CAMTYPE_OPT-1].strDevName = GetPrefixCameraName(strValue);
|
|
|
m_fixedCamera[CAMTYPE_OPT-1].devType = CAMTYPE_OPT;
|
|
|
Dbg("Found rear camera name: %s", strOptCamera.GetData());
|
|
|
}
|
|
|
- //if(strlen(lpValue) > 1) {
|
|
|
- // char* splitMark = strchr(lpValue, ';');
|
|
|
- // if(splitMark != NULL) {
|
|
|
- // splitMark[0] = '\0';
|
|
|
- // if(strlen(lpValue) > 0) {
|
|
|
- // strOptCamera = lpValue;
|
|
|
- // m_fixedCamera[CAMTYPE_OPT-1].strDevName = strOptCamera;
|
|
|
- // m_fixedCamera[CAMTYPE_OPT-1].devType = CAMTYPE_OPT;
|
|
|
- // Dbg("Found rear camera name: %s", strOptCamera.GetData());
|
|
|
- // }
|
|
|
- // }
|
|
|
- //}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- //if(nEnvID == -1 || nOptID == -1) {
|
|
|
- // Dbg("Did 35 know about that and popup it as an errot ?");
|
|
|
- // return Error_DevMedia;
|
|
|
- //}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -1586,26 +1475,30 @@ int CScannerFSM::GetCurrentCameraList(
|
|
|
bool bUpdatedRecord)
|
|
|
{
|
|
|
int nCount = 0;
|
|
|
- devInforLists.Clear();
|
|
|
- if(!bUpdatedRecord) {
|
|
|
- CAMERA_BUCKET buckets;
|
|
|
- nCount = GetCameraInfors(buckets);
|
|
|
- Dbg("Path1: Current camera count: %d", nCount);
|
|
|
- if(nCount > 0) {
|
|
|
- RefreshCameraBusyState(devInforLists, buckets, nCount);
|
|
|
- DestoryCamereBuckets(buckets);
|
|
|
- }
|
|
|
- }else {
|
|
|
- UpdateCameraInfors(m_cameralist);
|
|
|
- nCount = m_cameralist.size();
|
|
|
- Dbg("Path2: Current camera count: %d", nCount);
|
|
|
- if(nCount > 0) {
|
|
|
- RefreshCameraBusyState(devInforLists, m_cameralist, nCount);
|
|
|
- }
|
|
|
- }
|
|
|
+#if defined(RVC_OS_WIN)
|
|
|
+ devInforLists.Clear();
|
|
|
+ if (!bUpdatedRecord) {
|
|
|
+ CAMERA_BUCKET buckets;
|
|
|
+ nCount = GetCameraInfors(buckets);
|
|
|
+ Dbg("Path1: Current camera count: %d", nCount);
|
|
|
+ if (nCount > 0) {
|
|
|
+ RefreshCameraBusyState(devInforLists, buckets, nCount);
|
|
|
+ DestoryCamereBuckets(buckets);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ UpdateCameraInfors(m_cameralist);
|
|
|
+ nCount = m_cameralist.size();
|
|
|
+ Dbg("Path2: Current camera count: %d", nCount);
|
|
|
+ if (nCount > 0) {
|
|
|
+ RefreshCameraBusyState(devInforLists, m_cameralist, nCount);
|
|
|
+ }
|
|
|
+ }
|
|
|
+#endif //RVC_OS_WIN
|
|
|
return nCount;
|
|
|
}
|
|
|
|
|
|
+#if defined(RVC_OS_WIN)
|
|
|
+
|
|
|
void CScannerFSM::RefreshCameraBusyState(
|
|
|
CAutoArray<ScannerDeviceInfo>& devInforLists, const CAMERA_BUCKET& buckets, int bucketSize)
|
|
|
{
|
|
|
@@ -1627,6 +1520,7 @@ void CScannerFSM::RefreshCameraBusyState(
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+#endif //RVC_OS_WIN
|
|
|
|
|
|
static BOOL IsTheSameDevice(CSimpleStringA& szRunDev, CSimpleStringA& szConfigDev)
|
|
|
{
|
|
|
@@ -1657,7 +1551,8 @@ CapTypeEnum CScannerFSM::GetRVCCameraType(LPCTSTR lpcszDevName)
|
|
|
} else {
|
|
|
bool bGet = false;
|
|
|
for(int i=0; i<FIX_CAMERA_COUNTS; ++i) {
|
|
|
- if(IsTheSameDevice(CSimpleStringA(lpcszDevName), m_fixedCamera[i].strDevName)) {
|
|
|
+ CSimpleStringA strDevName(lpcszDevName);
|
|
|
+ if(IsTheSameDevice(strDevName, m_fixedCamera[i].strDevName)) {
|
|
|
type = m_fixedCamera[i].devType;
|
|
|
Dbg("Detect [%s] is %d", lpcszDevName, type);
|
|
|
bGet = true;
|
|
|
@@ -1679,10 +1574,11 @@ CapTypeEnum CScannerFSM::GetRVCCameraType(LPCTSTR lpcszDevName)
|
|
|
|
|
|
void CScannerFSM::OnDeviceInsert()
|
|
|
{
|
|
|
- if(!m_bPadMachine && !m_bDesk2SMachine) {
|
|
|
+ if(!m_bUsePortableScanner) {
|
|
|
return;
|
|
|
}
|
|
|
- EnterCriticalSection(&cs_devEvt);
|
|
|
+#if defined(RVC_OS_WIN)
|
|
|
+ std::lock_guard<std::mutex> guard(mMtx);
|
|
|
CAMERA_BUCKET newBuckets;
|
|
|
int newCount = GetCameraInfors(newBuckets);
|
|
|
Dbg("OnDeviceInsert: %d VS %d", newCount, m_cameralist.size());
|
|
|
@@ -1727,15 +1623,18 @@ void CScannerFSM::OnDeviceInsert()
|
|
|
}
|
|
|
UpdateCameraInfors(m_cameralist);
|
|
|
}
|
|
|
- LeaveCriticalSection(&cs_devEvt);
|
|
|
+#endif //RVC_OS_WIN
|
|
|
}
|
|
|
|
|
|
void CScannerFSM::OnDeviceRemoved()
|
|
|
{
|
|
|
- if(!m_bPadMachine && !m_bDesk2SMachine) {
|
|
|
+ if(!m_bUsePortableScanner) {
|
|
|
return;
|
|
|
}
|
|
|
- EnterCriticalSection(&cs_devEvt);
|
|
|
+
|
|
|
+#if defined(RVC_OS_WIN)
|
|
|
+
|
|
|
+ std::lock_guard<std::mutex> guard(mMtx);
|
|
|
CAMERA_BUCKET newBuckets;
|
|
|
int newCount = GetCameraInfors(newBuckets);
|
|
|
Dbg("OnDeviceRemoved: now %d VS before %d", newCount, m_cameralist.size());
|
|
|
@@ -1771,15 +1670,6 @@ void CScannerFSM::OnDeviceRemoved()
|
|
|
bReBind = true;
|
|
|
}
|
|
|
}
|
|
|
- // Cancel to Drop scanner anyway. -Josephus@20171030 11:09:28
|
|
|
- //Dbg("Find %s is removed and portable scanner entity stills hold it, send drop message",
|
|
|
- // (*citer)->szDevName);
|
|
|
- //auto rc = DropOffPortScannerDevice();
|
|
|
- //if(FAILURED(rc)) {
|
|
|
- // Dbg("Opps! DropOffPortScannerDevice failed RC=0x%X", rc);
|
|
|
- //}else {
|
|
|
- // bReBind = true;
|
|
|
- //}
|
|
|
break;
|
|
|
}else {
|
|
|
Dbg("removed one: %s", (*citer)->szDevName);
|
|
|
@@ -1790,12 +1680,14 @@ void CScannerFSM::OnDeviceRemoved()
|
|
|
}
|
|
|
UpdateCameraInfors(m_cameralist);
|
|
|
}
|
|
|
- LeaveCriticalSection(&cs_devEvt);
|
|
|
+
|
|
|
+#endif //RVC_OS_WIN
|
|
|
+
|
|
|
}
|
|
|
|
|
|
void CScannerFSM::PSEntityPostCameraError(LPCTSTR lpcszCameraName)
|
|
|
{
|
|
|
- if((!m_bPadMachine && !m_bDesk2SMachine) || lpcszCameraName == NULL) {
|
|
|
+ if((!m_bUsePortableScanner) || lpcszCameraName == NULL) {
|
|
|
return;
|
|
|
}
|
|
|
CSimpleStringA strCameraName = lpcszCameraName;
|
|
|
@@ -1840,52 +1732,12 @@ void CScannerFSM::PSEntityPostCameraError(LPCTSTR lpcszCameraName)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-//void CScannerFSM::UnitTest_AssistChannel_Send()
|
|
|
-//{
|
|
|
-// CChannelSideHelper conn(this->GetEntityBase());
|
|
|
-// CSimpleStringA csImageFile;
|
|
|
-// ErrorCodeEnum erroCode = m_pEntity->GetFunction()->GetPath("Dep", csImageFile);
|
|
|
-// csImageFile += "\\img1.jpg";
|
|
|
-// assert(conn.IsConnected() == TRUE);
|
|
|
-// FILE* fHandle = fopen(csImageFile, "rb");
|
|
|
-// CBlob cbData;
|
|
|
-// if(fHandle)
|
|
|
-// {
|
|
|
-// fseek(fHandle, 0, SEEK_END);
|
|
|
-// long fileSize = ftell(fHandle);
|
|
|
-// if(fileSize <= 0) {
|
|
|
-// LOG_TRACE("filesize(%s) error: %ld.", (LPCTSTR)csImageFile, fileSize);
|
|
|
-// fclose(fHandle);
|
|
|
-// }
|
|
|
-// else
|
|
|
-// {
|
|
|
-// cbData.Alloc(fileSize);
|
|
|
-// Dbg("FileSize: %ld, BufferLength: %u", fileSize, cbData.m_iLength);
|
|
|
-// fseek(fHandle, 0, SEEK_SET);
|
|
|
-// fread(cbData.m_pData, 1, fileSize, fHandle);
|
|
|
-// fclose(fHandle);
|
|
|
-//
|
|
|
-// for(;;) {
|
|
|
-// if(!conn.Send(cbData)) {
|
|
|
-// break;
|
|
|
-// }
|
|
|
-// Sleep(1000);
|
|
|
-// }
|
|
|
-//
|
|
|
-// }
|
|
|
-// }
|
|
|
-// else
|
|
|
-// {
|
|
|
-// LOG_TRACE("fopen(%s) failed.", (LPCTSTR)csImageFile);
|
|
|
-// }
|
|
|
-//}
|
|
|
-
|
|
|
ErrorCodeEnum CScannerFSM::IsPortScanHoldDevice(ScannerDeviceInfo* pInfo, int& curState)
|
|
|
{
|
|
|
if(pInfo == NULL) {
|
|
|
return Error_Param;
|
|
|
}
|
|
|
- if((m_bPadMachine || m_bDesk2SMachine) && ISSUCCEEDED(ConnectToPortableScanner())) {
|
|
|
+ if((m_bUsePortableScanner) && ISSUCCEEDED(ConnectToPortableScanner())) {
|
|
|
PortableScannerService_GetDevStatus_Req req = {};
|
|
|
PortableScannerService_GetDevStatus_Ans ans = {};
|
|
|
auto ec = m_pPortableClient->GetDevStatus(req, ans, MILLISECOND_WAIT_TIMEOUT_DEFAULT);
|
|
|
@@ -1923,7 +1775,7 @@ ErrorCodeEnum CScannerFSM::IsPortScanHoldDevice(bool& hasHolden,
|
|
|
CSimpleStringA& strDevName,
|
|
|
bool& bBusy)
|
|
|
{
|
|
|
- if((m_bPadMachine || m_bDesk2SMachine) && ISSUCCEEDED(ConnectToPortableScanner())) {
|
|
|
+ if((m_bUsePortableScanner) && ISSUCCEEDED(ConnectToPortableScanner())) {
|
|
|
PortableScannerService_GetDevStatus_Req req = {};
|
|
|
PortableScannerService_GetDevStatus_Ans ans = {};
|
|
|
auto ec = m_pPortableClient->GetDevStatus(req, ans, MILLISECOND_WAIT_TIMEOUT_DEFAULT);
|
|
|
@@ -1953,7 +1805,7 @@ ErrorCodeEnum CScannerFSM::IsPortScanHoldDevice(bool& hasHolden,
|
|
|
|
|
|
ErrorCodeEnum CScannerFSM::AttachCheck()
|
|
|
{
|
|
|
- if(!m_bPadMachine && !m_bDesk2SMachine) {
|
|
|
+ if(!m_bUsePortableScanner) {
|
|
|
return Error_Succeed;
|
|
|
}
|
|
|
ErrorCodeEnum ec = Error_Succeed;
|
|
|
@@ -1985,7 +1837,7 @@ ErrorCodeEnum CScannerFSM::AttachCheck()
|
|
|
|
|
|
ErrorCodeEnum CScannerFSM::_BindPSDevice(int nDevID, LPCTSTR lpcszDevName, bool bForce)
|
|
|
{
|
|
|
- if(!m_bPadMachine && !m_bDesk2SMachine) {
|
|
|
+ if(!m_bUsePortableScanner) {
|
|
|
return Error_InvalidState;
|
|
|
}
|
|
|
auto rc = ConnectToPortableScanner();
|
|
|
@@ -2081,7 +1933,7 @@ int CScannerFSM::GetAdvancedScannerDeviceEx(ScannerDeviceInfo* pDevInfo,
|
|
|
ErrorCodeEnum CScannerFSM::DropOffPortScannerDevice()
|
|
|
{
|
|
|
ErrorCodeEnum rc = Error_Unexpect;
|
|
|
- if((m_bPadMachine || m_bDesk2SMachine) && ISSUCCEEDED(ConnectToPortableScanner())) {
|
|
|
+ if((m_bUsePortableScanner) && ISSUCCEEDED(ConnectToPortableScanner())) {
|
|
|
rc = m_pPortableClient->DropOffDevice();
|
|
|
FreePortableScannerClient();
|
|
|
}
|
|
|
@@ -2135,7 +1987,7 @@ ErrorCodeEnum CScannerFSM::BindPSDevice(int nDevID, LPCTSTR lpcszDevName)
|
|
|
|
|
|
void CScannerFSM::SendBroadcastAbout()
|
|
|
{
|
|
|
- if(!m_bPadMachine && !m_bDesk2SMachine) {
|
|
|
+ if(!m_bUsePortableScanner) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
@@ -2270,6 +2122,8 @@ ErrorCodeEnum CScannerFSM::SendRequest2Heatbeat(
|
|
|
{
|
|
|
LOG_FUNCTION();
|
|
|
static PTC_ENTITY_INTERFACE_QUEUE ptInterfaceQueue = NULL;
|
|
|
+ static std::mutex mt4InterfaceQueue;
|
|
|
+
|
|
|
Dbg("dwMethodSigure: %d", dwMethodSig);
|
|
|
ErrorCodeEnum Error = Error_Succeed;
|
|
|
ptInterfaceQueue = NULL;
|
|
|
@@ -2283,8 +2137,9 @@ ErrorCodeEnum CScannerFSM::SendRequest2Heatbeat(
|
|
|
return Error_MethodNotFound;
|
|
|
}
|
|
|
|
|
|
- //TODO: LOCK
|
|
|
- InterlockedExchangeAdd(&ptInterfaceQueue->dwSequence, 1);
|
|
|
+ mt4InterfaceQueue.lock();
|
|
|
+ ptInterfaceQueue->dwSequence += 1;
|
|
|
+ mt4InterfaceQueue.unlock();
|
|
|
PTC_CONTEXT_CALL_ITEM ptContextItem = NULL;
|
|
|
if(ptCtx != NULL) {
|
|
|
ptContextItem = (PTC_CONTEXT_CALL_ITEM)TWHeapAlloc(sizeof(TC_CONTEXT_CALL_ITEM));
|
|
|
@@ -2798,34 +2653,42 @@ ErrorCodeEnum CScannerFSM::ReceiveRequest5Heartbeat(
|
|
|
return Error;
|
|
|
}
|
|
|
|
|
|
-GUID* StrToGUID(const WCHAR *guid_string)
|
|
|
+namespace
|
|
|
{
|
|
|
- char buffer[64];
|
|
|
- GUID* guid = (GUID*) buffer;
|
|
|
- WCHAR upperGuid[40+1]={0};
|
|
|
- for (int i =0 ; i < 40+1; i++)
|
|
|
- {
|
|
|
- upperGuid[i] = guid_string[i];
|
|
|
- if (upperGuid[i]>=L'a' && upperGuid[i]<=L'z')
|
|
|
- {
|
|
|
- upperGuid[i] += L'A' - L'a';
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
- swscanf_s(upperGuid, L"{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
|
|
|
- &guid->Data1,
|
|
|
- &guid->Data2,
|
|
|
- &guid->Data3,
|
|
|
- &guid->Data4[0],
|
|
|
- &guid->Data4[1],
|
|
|
- &guid->Data4[2],
|
|
|
- &guid->Data4[3],
|
|
|
- &guid->Data4[4],
|
|
|
- &guid->Data4[5],
|
|
|
- &guid->Data4[6],
|
|
|
- &guid->Data4[7]);
|
|
|
+#if defined(RVC_OS_WIN)
|
|
|
+
|
|
|
+GUID* StrToGUID(const WCHAR* guid_string)
|
|
|
+{
|
|
|
+ static char buffer[64];
|
|
|
+ memset(buffer, 0, sizeof(buffer));
|
|
|
+ GUID* guid = (GUID*)buffer;
|
|
|
+ WCHAR upperGuid[40 + 1] = { 0 };
|
|
|
+ for (int i = 0; i < 40 + 1; i++) {
|
|
|
+ upperGuid[i] = guid_string[i];
|
|
|
+ if (upperGuid[i] >= L'a' && upperGuid[i] <= L'z') {
|
|
|
+ upperGuid[i] += L'A' - L'a';
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ swscanf_s(upperGuid, L"{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
|
|
|
+ &guid->Data1,
|
|
|
+ &guid->Data2,
|
|
|
+ &guid->Data3,
|
|
|
+ &guid->Data4[0],
|
|
|
+ &guid->Data4[1],
|
|
|
+ &guid->Data4[2],
|
|
|
+ &guid->Data4[3],
|
|
|
+ &guid->Data4[4],
|
|
|
+ &guid->Data4[5],
|
|
|
+ &guid->Data4[6],
|
|
|
+ &guid->Data4[7]);
|
|
|
+
|
|
|
+ return guid; //TODO:
|
|
|
+}
|
|
|
+
|
|
|
+#endif //RVC_OS_WIN
|
|
|
|
|
|
- return guid;
|
|
|
}
|
|
|
|
|
|
bool CScannerFSM::FindEwsCameraName(CSimpleStringA& strRetrievedName,
|
|
|
@@ -2835,6 +2698,9 @@ bool CScannerFSM::FindEwsCameraName(CSimpleStringA& strRetrievedName,
|
|
|
return false;
|
|
|
}
|
|
|
bool bRet = false;
|
|
|
+
|
|
|
+#if defined(RVC_OS_WIN)
|
|
|
+
|
|
|
GUID deviceGuid = *StrToGUID(L"{6BDD1FC6-810F-11D0-BEC7-08002BE2092F}");
|
|
|
HDEVINFO hDev = SetupDiGetClassDevs(&deviceGuid, NULL, NULL, DIGCF_PRESENT);
|
|
|
if(INVALID_HANDLE_VALUE == hDev) {
|
|
|
@@ -2887,63 +2753,24 @@ bool CScannerFSM::FindEwsCameraName(CSimpleStringA& strRetrievedName,
|
|
|
if(hDev) {
|
|
|
SetupDiDestroyDeviceInfoList(hDev);
|
|
|
}
|
|
|
+
|
|
|
+#endif //RVC_OS_WIN
|
|
|
+
|
|
|
return bRet;
|
|
|
}
|
|
|
|
|
|
+//TODO(Gifur): draw out the same code with FindEwsCameraName
|
|
|
bool CScannerFSM::IsEwsCamera(LPCTSTR lpcszDevfriendlyName)
|
|
|
{
|
|
|
- bool bRet = false;
|
|
|
- GUID deviceGuid = *StrToGUID(L"{6BDD1FC6-810F-11D0-BEC7-08002BE2092F}");
|
|
|
- HDEVINFO hDev = SetupDiGetClassDevs(&deviceGuid, NULL, NULL, DIGCF_PRESENT);
|
|
|
- if(INVALID_HANDLE_VALUE == hDev) {
|
|
|
- return bRet;
|
|
|
- }
|
|
|
- SP_CLASSIMAGELIST_DATA _spImageData = {0};
|
|
|
- _spImageData.cbSize = sizeof(SP_CLASSIMAGELIST_DATA);
|
|
|
- SetupDiGetClassImageList(&_spImageData);
|
|
|
-
|
|
|
- SP_DEVINFO_DATA DevInfo;
|
|
|
- ZeroMemory(&DevInfo, sizeof(SP_DEVINFO_DATA));
|
|
|
- DevInfo.cbSize = sizeof(SP_DEVINFO_DATA);
|
|
|
- DWORD DeviceIndex = 0;
|
|
|
-
|
|
|
- while(SetupDiEnumDeviceInfo(hDev, DeviceIndex, &DevInfo)) {
|
|
|
- int wImageIdx = 0;
|
|
|
- if (SetupDiGetClassImageIndex(&_spImageData, &DevInfo.ClassGuid, &wImageIdx)) {
|
|
|
- char szName[MAX_PATH] = {0};
|
|
|
- bool bHere = false;
|
|
|
- if(SetupDiGetDeviceInstanceId(hDev, &DevInfo, szName, MAX_PATH - 1, NULL)) {
|
|
|
- Dbg("InstanceId: %s", szName);
|
|
|
- if (!_stricmp(szName, m_strEwsRecordName.GetData())) {
|
|
|
- bHere = true;
|
|
|
- }
|
|
|
- } else {
|
|
|
- if (SetupDiGetDeviceRegistryProperty(
|
|
|
- hDev,&DevInfo, SPDRP_DEVICEDESC, NULL, (PBYTE)szName, MAX_PATH - 1, 0)) {
|
|
|
- Dbg("RegistryProperty: %s", szName);
|
|
|
- if (!_stricmp(szName, m_strEwsRecordName.GetData())) {
|
|
|
- bHere = true;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- if(bHere){
|
|
|
- if (SetupDiGetDeviceRegistryProperty(
|
|
|
- hDev,&DevInfo, SPDRP_FRIENDLYNAME, NULL, (PBYTE)szName, MAX_PATH - 1, 0)) {
|
|
|
- Dbg("FriendName: %s", szName);
|
|
|
- if(!_stricmp(szName, lpcszDevfriendlyName)) {
|
|
|
- bRet = true;
|
|
|
- }
|
|
|
- }
|
|
|
- break;
|
|
|
- }
|
|
|
+ CSimpleStringA strRetrievedName(true);
|
|
|
+ CSimpleStringA strRootName(true);
|
|
|
+ bool bRet = FindEwsCameraName(strRetrievedName, m_strEwsRecordName);
|
|
|
+ if (bRet) {
|
|
|
+ if (strRetrievedName.Compare(lpcszDevfriendlyName, true) == 0) {
|
|
|
+ return true;
|
|
|
}
|
|
|
- DeviceIndex++;
|
|
|
}
|
|
|
- SetupDiDestroyClassImageList(&_spImageData);
|
|
|
- if(hDev) {
|
|
|
- SetupDiDestroyDeviceInfoList(hDev);
|
|
|
- }
|
|
|
- return bRet;
|
|
|
+ return false;
|
|
|
}
|
|
|
|
|
|
|