Browse Source

Z991239-968 #comment feat: ScannerSet实体跨平台

gifur 5 years ago
parent
commit
fd7e479e8d

+ 1 - 0
DevAdapter/include/DeviceCrossHelper.h → Module/include/DeviceCrossHelper.h

@@ -3,6 +3,7 @@
 #define _RVC_DEVICE_CROSS_HELPER_H_
 
 #include "ListEntry.h"
+#include "SpHelper.h"
 
 #ifndef FIELD_OFFSET
 // begin_ntoshvp

+ 2 - 1
Module/include/EventCode.h

@@ -466,7 +466,8 @@ static const char* Device_Type_Table[] = {
 #define LOG_EVT_HSPS_LOST_CONNECT 0x21700004
 #define LOG_EVT_HSPS_READ_IMAGE_FILE_FAILED 0x21700005
 #define LOG_EVT_HSPS_READ_IMAGEEX_FILE_FAILED 0x21700006
-#define LOG_EVT_SCANNERSET_HSPSCNT_FAILED 0x21700101
+
+#define LOG_EVT_SCANNERSET_HSPSCNT_FAILED 0x21800101
 
 #define LOG_EVT_PORTABLESCANNER_NO_AVAILABLE 0x21600201
 #define LOG_WARN_CONNECT_PORTABLESCANNER_FAILED 0x21600202

+ 13 - 0
Module/mod_ScannerSet/CMakeLists.txt

@@ -4,16 +4,29 @@ file(GLOB ${MODULE_PREFIX}_SRCS RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}"
     "${CMAKE_CURRENT_SOURCE_DIR}/*.h" "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp"
     "${CMAKE_CURRENT_SOURCE_DIR}/*.hpp")
 
+if(NOT MSVC)
+list(REMOVE_ITEM ${MODULE_PREFIX}_SRCS 
+    EventRevWnd.cpp
+    EventRevWnd.h
+    CameraImpl.cpp
+    CameraImpl.h)
+endif(NOT MSVC)
+
 set(MOD_VERSION_STRING "0.0.1-dev1")
 add_module_libraries(${MODULE_PREFIX} ${MODULE_NAME} ${MOD_VERSION_STRING})
 
 set(${MODULE_PREFIX}_LIBS ${MODULE_BASE_LIBS})
+if(MSVC)
+    list(APPEND ${MODULE_PREFIX}_LIBS SetupAPI)
+endif(MSVC)
 target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})  
 
 target_include_directories(${MODULE_NAME} 
     PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
     PRIVATE ${MODULE_BASE_DIR}/mod_HSPScanner
     PRIVATE ${MODULE_BASE_DIR}/mod_MaintainWatcher
+    PRIVATE ${MODULE_BASE_DIR}/mod_PortableScanner
+    PRIVATE ${MODULE_BASE_DIR}/mod_heartbeat
 )
 
 deploy_module(${MODULE_PREFIX} ${MODULE_NAME})

+ 1 - 16
Module/mod_ScannerSet/CameraImpl.cpp

@@ -1,22 +1,7 @@
-#include "StdAfx.h"
+#include "stdafx.h"
 #include "CameraImpl.h"
 #include "Dshow.h" 
 
-//  -Josephus@2017117 14:52:48
-//#include <memutil.h>
-//#include <md5.h>
-
-//libvideoframework
-//#include "videoutil.h"
-//#include "videocap.h"
-//#include "videoclock.h"
-//#include "videorender.h"
-//#include "videoview.h"
-//#include "videocommon.h"
-//
-//#pragma comment(lib, "libvideohorflip.lib")
-//#pragma comment(lib, "libvideoframework.lib")
-
 
 static int Bin2Str(unsigned char *x, int xlen, char *str, int str_size)
 {

+ 3 - 3
Module/mod_ScannerSet/CameraImpl.h

@@ -31,9 +31,9 @@ typedef struct _CAMERA_INFOR_ITEM
 	void Copy(struct _CAMERA_INFOR_ITEM* prhs) {
 		if(prhs != NULL) {
 			uWaveInID = prhs->uWaveInID;
-			strcpy_s(szDevPath, prhs->szDevPath);
-			strcpy_s(szDevName, prhs->szDevName);
-			strcpy_s(szCLSID, prhs->szCLSID);
+			strcpy_s(szDevPath, MAX_PATH, prhs->szDevPath);
+			strcpy_s(szDevName, MAX_PATH, prhs->szDevName);
+			strcpy_s(szCLSID, MAX_PATH, prhs->szCLSID);
 		}
 	}
 	void Display() {

+ 2 - 0
Module/mod_ScannerSet/ChangeLog

@@ -0,0 +1,2 @@
+
+* 合并国密版本内容(2020年10月27日,廖桂发)

+ 1 - 1
Module/mod_ScannerSet/EventRevWnd.cpp

@@ -110,7 +110,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
 								Dbg("Stopping Capture (Device Lost). Select New Capture Device\0");
 								break;
 							}
-							pf->Release();
+							//pf->Release();
 						}
 					}
 				}

+ 1 - 1
Module/mod_ScannerSet/EventRevWnd.h

@@ -1,7 +1,7 @@
 #ifndef _TW_EVENT_RECEIVE_WINDOW_H__
 #define _TW_EVENT_RECEIVE_WINDOW_H__
 
-#pragma once;
+#pragma once
 
 #include "SpBase.h"
 #include <DShow.h>

+ 0 - 44
Module/mod_ScannerSet/ReadMe.txt

@@ -1,44 +0,0 @@
-========================================================================
-    动态链接库:mod_HSPScanner 项目概述
-========================================================================
-
-应用程序向导已为您创建了此 mod_HSPScanner DLL。
-
-本文件概要介绍组成 mod_HSPScanner 应用程序的每个文件的内容。
-
-
-mod_HSPScanner.vcxproj
-    这是使用应用程序向导生成的 VC++ 项目的主项目文件,
-    其中包含生成该文件的 Visual C++ 
-    的版本信息,以及有关使用应用程序向导选择的平台、配置和项目功能的信息。
-
-mod_HSPScanner.vcxproj.filters
-    这是使用“应用程序向导”生成的 VC++ 项目筛选器文件。 
-    它包含有关项目文件与筛选器之间的关联信息。 在 IDE 
-    中,通过这种关联,在特定节点下以分组形式显示具有相似扩展名的文件。
-    例如,“.cpp”文件与“源文件”筛选器关联。
-
-mod_HSPScanner.cpp
-    这是主 DLL 源文件。
-
-	此 DLL 在创建时不导出任何符号。 因此,在生成此 DLL 时
- 	生成时不会产生 .lib 文件。 如果希望此项目
- 	成为其他某个项目的项目依赖项,则需要
- 	添加代码以从 DLL 导出某些符号,
- 	以便产生一个导出库,或者,也可以在项目“属性页”对话框中的
- 	“链接器”文件夹中,将“常规”属性页上的
- 	“忽略输入库”属性设置为“是”。
-
-/////////////////////////////////////////////////////////////////////////////
-其他标准文件:
-
-StdAfx.h,StdAfx.cpp
-    这些文件用于生成名为 mod_HSPScanner.pch 的预编译头 (PCH) 文件和
-    名为 StdAfx.obj 的预编译类型文件。
-
-/////////////////////////////////////////////////////////////////////////////
-其他注释:
-
-应用程序向导使用“TODO:”注释来指示应添加或自定义的源代码部分。
-
-/////////////////////////////////////////////////////////////////////////////

+ 181 - 354
Module/mod_ScannerSet/ScannerSetFSM.cpp

@@ -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;
 }
 
 

+ 19 - 11
Module/mod_ScannerSet/ScannerSetFSM.h

@@ -3,6 +3,8 @@
 
 #pragma once
 
+#include <mutex>
+
 #include "SpFSM.h"
 #include "ScannerSet_server_g.h"
 #include "ScannerSet_msg_g.h"
@@ -10,13 +12,16 @@ using namespace ScannerSet;
 
 #define SS_MAX_METHOD_COUNT 11
 
-#include "..\mod_HSPScanner\HSPScanner_client_g.h"
-using namespace HSPScanner;
+#include "HSPScanner_client_g.h"
 #include "PortableScanner_client_g.h"
-using namespace PortableScanner;
 #include "HeartBeat_client_g.h"
 
+using namespace HSPScanner;
+using namespace PortableScanner;
+
+#if defined(RVC_OS_WIN)
 #include "CameraImpl.h"
+#endif //RVC_OS_WIN
 #include "DeviceCrossHelper.h"
 
 #define ISSUCCEEDED(hr) ((hr) == Error_Succeed)
@@ -406,6 +411,8 @@ private:
 	bool m_bStand2SMachine;
 	bool m_bDesk2SMachine;
 	bool m_bJBMachine;
+	bool m_bDesk1SMachine;
+	bool m_bUsePortableScanner;
 
 	CHSPSInnerClient* m_pHSPSClient;
 	CPortableScannerClient* m_pPortableClient;
@@ -421,8 +428,10 @@ private:
 
 	HRESULT m_hrCoInited;
 
-	CAMERA_BUCKET m_cameralist;
-	CRITICAL_SECTION cs_devEvt;
+#if defined(RVC_OS_WIN)
+    CAMERA_BUCKET m_cameralist;
+#endif //RVC_OS_WIN
+	std::mutex mMtx;
 
 	static const int FIX_CAMERA_COUNTS = 3;
 	ScannerDeviceInfo m_fixedCamera[FIX_CAMERA_COUNTS];
@@ -443,9 +452,6 @@ public:
 
 public:
 
-	//void UnitTest_AssistChannel_Send();
-	//bool UnitTest_StopIt;
-
 	ErrorCodeEnum CheckHSPSConnectStatus();
 	ErrorCodeEnum ConnectToHSPScanner();
 	void FreeHSPScannerClient()
@@ -522,7 +528,7 @@ private:
 
 	bool IsSuitableEntityAvailable() {
 		if((m_bStand2SMachine && ISSUCCEEDED(ConnectToHSPScanner()))
-			|| ( (m_bDesk2SMachine || m_bPadMachine) && ISSUCCEEDED(ConnectToPortableScanner()))
+			|| ( (m_bUsePortableScanner) && ISSUCCEEDED(ConnectToPortableScanner()))
 			|| (m_bJBMachine  && ISSUCCEEDED(ConnectToHeartbeat()))) {
 				return true;
 		}
@@ -531,7 +537,7 @@ private:
 	void ReleaseSuitableEntity() {
 		if(m_bStand2SMachine) {
 			FreeHSPScannerClient();
-		}else if(m_bDesk2SMachine || m_bPadMachine) {
+		}else if(m_bUsePortableScanner) {
 			FreePortableScannerClient();
 		} else if(m_bJBMachine) {
 			FreeHeartbeatClient();
@@ -548,7 +554,9 @@ private:
 	bool IsPortableScannerDetected(LPCTSTR strDeviceID, BOOL& bUpstairOne);
 	int GetCurrentCameraList(CAutoArray<ScannerDeviceInfo>& devInforLists, bool bUpdatedRecord = false);
 
-	void RefreshCameraBusyState(CAutoArray<ScannerDeviceInfo>& devInforLists, const CAMERA_BUCKET& buckets, int bucketSize);
+#if defined(RVC_OS_WIN)
+    void RefreshCameraBusyState(CAutoArray<ScannerDeviceInfo>& devInforLists, const CAMERA_BUCKET& buckets, int bucketSize);
+#endif //RVC_OS_WIN
 
 	ErrorCodeEnum _BindPSDevice(int nDevID, LPCTSTR lpcszDevName, bool bForce = false);
 

+ 0 - 103
Module/mod_ScannerSet/mod_ScannerSet.vcxproj

@@ -1,103 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-  <ItemGroup Label="ProjectConfigurations">
-    <ProjectConfiguration Include="Debug|Win32">
-      <Configuration>Debug</Configuration>
-      <Platform>Win32</Platform>
-    </ProjectConfiguration>
-    <ProjectConfiguration Include="Release|Win32">
-      <Configuration>Release</Configuration>
-      <Platform>Win32</Platform>
-    </ProjectConfiguration>
-  </ItemGroup>
-  <PropertyGroup Label="Globals">
-    <ProjectGuid>{1E7F0A40-3BA2-489F-8D7D-FAEE61D343E9}</ProjectGuid>
-    <Keyword>Win32Proj</Keyword>
-    <RootNamespace>mod_HSPScanner</RootNamespace>
-  </PropertyGroup>
-  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
-    <ConfigurationType>DynamicLibrary</ConfigurationType>
-    <UseDebugLibraries>true</UseDebugLibraries>
-    <CharacterSet>MultiByte</CharacterSet>
-    <PlatformToolset>Windows7.1SDK</PlatformToolset>
-  </PropertyGroup>
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
-    <ConfigurationType>DynamicLibrary</ConfigurationType>
-    <UseDebugLibraries>false</UseDebugLibraries>
-    <WholeProgramOptimization>true</WholeProgramOptimization>
-    <CharacterSet>Unicode</CharacterSet>
-  </PropertyGroup>
-  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
-  <ImportGroup Label="ExtensionSettings">
-  </ImportGroup>
-  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
-    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
-  </ImportGroup>
-  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
-    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
-  </ImportGroup>
-  <PropertyGroup Label="UserMacros" />
-  <Import Project="..\modmake.setting" />
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
-    <LinkIncremental>true</LinkIncremental>
-  </PropertyGroup>
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
-    <LinkIncremental>false</LinkIncremental>
-  </PropertyGroup>
-  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
-    <ClCompile>
-      <PrecompiledHeader>Create</PrecompiledHeader>
-      <WarningLevel>Level3</WarningLevel>
-      <Optimization>Disabled</Optimization>
-      <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;MOD_HSPSCANNER_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
-      <AdditionalIncludeDirectories>$(FrameworkHeadRoot)\Common;$(DevHeadPath);$(ModuleCommonHeadPath);..\mod_PortableScanner;..\mod_heartbeat;$(FrameworkHeadRoot)\libtoolkit;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
-    </ClCompile>
-    <Link>
-      <SubSystem>Windows</SubSystem>
-      <GenerateDebugInformation>true</GenerateDebugInformation>
-      <AdditionalDependencies>$(FrameworkLib)\SpBase.lib;$(FrameworkLib)\libtoolkit.lib;$(ThirdPartyLib)\avutil.lib;$(ThirdPartyLib)\swscale.lib;%(AdditionalDependencies)</AdditionalDependencies>
-    </Link>
-  </ItemDefinitionGroup>
-  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
-    <ClCompile>
-      <WarningLevel>Level3</WarningLevel>
-      <PrecompiledHeader>Use</PrecompiledHeader>
-      <Optimization>MaxSpeed</Optimization>
-      <FunctionLevelLinking>true</FunctionLevelLinking>
-      <IntrinsicFunctions>true</IntrinsicFunctions>
-      <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;MOD_HSPSCANNER_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
-    </ClCompile>
-    <Link>
-      <SubSystem>Windows</SubSystem>
-      <GenerateDebugInformation>true</GenerateDebugInformation>
-      <EnableCOMDATFolding>true</EnableCOMDATFolding>
-      <OptimizeReferences>true</OptimizeReferences>
-    </Link>
-  </ItemDefinitionGroup>
-  <ItemGroup>
-    <None Include="ReadMe.txt" />
-  </ItemGroup>
-  <ItemGroup>
-    <ClInclude Include="CameraImpl.h" />
-    <ClInclude Include="EventRevWnd.h" />
-    <ClInclude Include="mod_ScannerSet.h" />
-    <ClInclude Include="ScannerSetFSM.h" />
-    <ClInclude Include="ScannerSet_def_g.h" />
-    <ClInclude Include="ScannerSet_msg_g.h" />
-    <ClInclude Include="ScannerSet_server_g.h" />
-    <ClInclude Include="targetver.h" />
-  </ItemGroup>
-  <ItemGroup>
-    <ResourceCompile Include="..\..\Version.rc" />
-  </ItemGroup>
-  <ItemGroup>
-    <ClCompile Include="CameraImpl.cpp" />
-    <ClCompile Include="EventRevWnd.cpp" />
-    <ClCompile Include="mod_ScannerSet.cpp" />
-    <ClCompile Include="ScannerSetFSM.cpp" />
-  </ItemGroup>
-  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
-  <ImportGroup Label="ExtensionTargets">
-  </ImportGroup>
-</Project>

+ 0 - 65
Module/mod_ScannerSet/mod_ScannerSet.vcxproj.filters

@@ -1,65 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-  <ItemGroup>
-    <Filter Include="源文件">
-      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
-      <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
-    </Filter>
-    <Filter Include="头文件">
-      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
-      <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
-    </Filter>
-    <Filter Include="资源文件">
-      <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
-      <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
-    </Filter>
-  </ItemGroup>
-  <ItemGroup>
-    <None Include="ReadMe.txt" />
-  </ItemGroup>
-  <ItemGroup>
-    <ClInclude Include="targetver.h">
-      <Filter>头文件</Filter>
-    </ClInclude>
-    <ClInclude Include="mod_ScannerSet.h">
-      <Filter>头文件</Filter>
-    </ClInclude>
-    <ClInclude Include="ScannerSet_def_g.h">
-      <Filter>头文件</Filter>
-    </ClInclude>
-    <ClInclude Include="ScannerSet_server_g.h">
-      <Filter>头文件</Filter>
-    </ClInclude>
-    <ClInclude Include="ScannerSetFSM.h">
-      <Filter>头文件</Filter>
-    </ClInclude>
-    <ClInclude Include="CameraImpl.h">
-      <Filter>头文件</Filter>
-    </ClInclude>
-    <ClInclude Include="EventRevWnd.h">
-      <Filter>头文件</Filter>
-    </ClInclude>
-    <ClInclude Include="ScannerSet_msg_g.h">
-      <Filter>头文件</Filter>
-    </ClInclude>
-  </ItemGroup>
-  <ItemGroup>
-    <ResourceCompile Include="..\..\Version.rc">
-      <Filter>资源文件</Filter>
-    </ResourceCompile>
-  </ItemGroup>
-  <ItemGroup>
-    <ClCompile Include="mod_ScannerSet.cpp">
-      <Filter>源文件</Filter>
-    </ClCompile>
-    <ClCompile Include="ScannerSetFSM.cpp">
-      <Filter>源文件</Filter>
-    </ClCompile>
-    <ClCompile Include="CameraImpl.cpp">
-      <Filter>源文件</Filter>
-    </ClCompile>
-    <ClCompile Include="EventRevWnd.cpp">
-      <Filter>源文件</Filter>
-    </ClCompile>
-  </ItemGroup>
-</Project>