Эх сурвалжийг харах

Z991239-1096 #comment 添加辅助头文件 other:添加辅助头文件

杨诗友80174847 4 жил өмнө
parent
commit
a086b8efe8

+ 130 - 0
Module/include/DeviceBaseHelper.h

@@ -0,0 +1,130 @@
+#ifndef __DEVICEBASE_HELPER_H
+#define __DEVICEBASE_HELPER_H
+#pragma once
+
+#include "DeviceBaseClass.h"
+
+
+enum DeviceType
+{
+	PinPadClassType
+};
+
+class DeviceBaseHelper
+{
+public:
+	static DeviceBaseClass* QueryDevComponent(const char *lpszRVCRunPath, DeviceType eDevType)
+	{
+		char root_path[MAX_PATH];
+		sprintf(root_path, "%s\\hardwarecfg\\root.ini", lpszRVCRunPath);
+	}
+
+	static ErrorCodeEnum GetAndSplitDevErrInfo(
+		DeviceBaseClass* inst, 
+		CSimpleStringA& csErrMsg, 
+		WORD& wdDevErrCode,
+		LPCTSTR lpszFuncNameForDisplay = ""
+	)
+	{
+		csErrMsg = "";
+		wdDevErrCode = 0;
+
+		BOOL bDisplayFunName = TRUE;
+		if( lpszFuncNameForDisplay == NULL || strlen(lpszFuncNameForDisplay) == 0 )
+			bDisplayFunName = FALSE;
+
+		if(inst == NULL)
+		{
+			Dbg("inst occurs nullptr !!!");
+			return Error_Param;
+		}
+
+		DevErrorInfo devErrInfo;
+		ZeroMemory(&devErrInfo, sizeof(DevErrorInfo));
+		ErrorCodeEnum erroCode = inst->GetLastErr(devErrInfo);
+		if(erroCode == Error_Succeed)
+		{
+			if(strlen(devErrInfo.szErrMsg) > 0)
+			{
+				csErrMsg = devErrInfo.szErrMsg;
+			}
+
+			if(devErrInfo.dwErrMsgLen > MAX_DEV_ERROR_MSG_LEN)
+			{
+				//oiltmp@20200520 comment the following line
+				//wdDevErrCode = (WORD)((devErrInfo.dwErrMsgLen >> 16) & 0x0000FFFF);
+			}
+			if(bDisplayFunName)
+			{
+				Dbg("Invoke <%s> failed, Dev_GLE: DevErrCode[%d], ErrMsg[%s]", 
+					lpszFuncNameForDisplay, wdDevErrCode, (LPCTSTR)csErrMsg);
+			}
+			else
+			{
+				Dbg("Dev_GLE: DevErrCode[%d], ErrMsg[%s]", wdDevErrCode, (LPCTSTR)csErrMsg);
+			}
+		}
+		else
+		{
+			if(bDisplayFunName)
+			{
+				Dbg("Invoke <%s> failed, and unfortunately Dev_GLE failed returned EC: %d(0x%X)", 
+					lpszFuncNameForDisplay, erroCode, erroCode);
+				csErrMsg = CSimpleStringA::Format("Invoke <%s> failed", lpszFuncNameForDisplay);
+			}
+			else
+			{
+				Dbg("Dev_GLE failed returned EC: %d(0x%X)", 
+					erroCode, erroCode);
+			}
+		}
+		return erroCode;
+	}
+
+	static ErrorCodeEnum LogDevErrInfo(DeviceBaseClass* inst, LPCTSTR lpszFuncName = "")
+	{
+		CSimpleStringA csMsg;
+		WORD wdErrorCode = 0;
+		return GetAndSplitDevErrInfo(inst, csMsg, wdErrorCode, lpszFuncName);
+	}
+
+	static BOOL GetDevErrorCode(DeviceBaseClass* inst, WORD& wdErrorCode)
+	{
+		CSimpleStringA csMsg;
+		ErrorCodeEnum eRet = GetAndSplitDevErrInfo(inst, csMsg, wdErrorCode);
+		return ((eRet == Error_Succeed) ? (TRUE) : (FALSE));
+	}
+
+	static VendorNameType GetCurVendorType(LPCTSTR vendorName) 
+	{
+		if(vendorName == NULL || strlen(vendorName) == 0) {
+			return Vendor_Invalide;
+		}
+		int idx = -1;
+		for(int i=0; i<sizeof(VendorNameStr)/sizeof(VendorNameStr[0]); ++i)
+		{
+			if(strnicmp(vendorName, VendorNameStr[i], strlen(VendorNameStr[i])) == 0) {
+				idx = i;
+				break;
+			}
+		}
+		if(idx == -1) {
+			/*历史遗留原因,怡化厂商有两个适配器名字*/
+			if(strnicmp(vendorName, "yihua", strlen("yihua")) == 0) {
+				idx = Vendor_YiHua;
+			} else {
+				idx	 = Vendor_Invalide;
+			}
+		}
+		return (VendorNameType)idx;
+	}
+};
+
+struct HardwareEntityCode {
+
+	DWORD dwEntityId;
+	DWORD dwVendorId;
+	DWORD dwVendorErroCode;
+	DWORD dwReserved;
+};
+#endif // __DEVICEBASE_HELPER_H

+ 494 - 0
Module/include/GetDevInfoHelper.h

@@ -0,0 +1,494 @@
+#pragma once
+#include "SpHelper.h"
+#include "SpFSM.h"
+#include "SimpleString.h"
+#include "Blob.h"
+#include "SpBase.h"
+#include <regex>
+/*------20200221------*/
+//modify by LZM
+ErrorCodeEnum VendorLogControlerEx(CEntityBase *pEntity,CSimpleStringA moduleName)
+{
+#ifdef RVC_WIN_OS
+	//get Device Information.
+	CSystemStaticInfo DevInfo;
+	pEntity->GetFunction()->GetSystemStaticInfo(DevInfo);
+	Dbg("Terminal NUM=%s",DevInfo.strTerminalID);
+	//read root.ini and get vendor,version,batch.
+	CSmartPointer<IConfigInfo> rootConfig;
+	ErrorCodeEnum eErrDev = pEntity->GetFunction()->OpenConfig(Config_Root,rootConfig);
+	if (eErrDev != Error_Succeed) {
+		Dbg("open Config_Root file failed!");
+		return eErrDev;
+	}
+	CSimpleStringA strVendor,strVersion,strBatch;
+	CSimpleStringA strTmp = CSimpleStringA::Format("Device.%s",moduleName.GetData());
+	Dbg("strTmp=%s",strTmp);
+	eErrDev = rootConfig->ReadConfigValue(strTmp,"Vendor",strVendor);
+	if(eErrDev != Error_Succeed || strVendor.IsNullOrEmpty()){
+		Dbg("read vendor failed!");
+		return eErrDev;
+	}
+	eErrDev = rootConfig->ReadConfigValue(strTmp,"Version",strVersion);
+	if(eErrDev != Error_Succeed || strVersion.IsNullOrEmpty()){
+		Dbg("read version failed!");
+		return eErrDev;
+	}
+	eErrDev = rootConfig->ReadConfigValue(strTmp,"Batch",strBatch);
+	if(eErrDev != Error_Succeed || strBatch.IsNullOrEmpty()){
+		Dbg("read batch failed!");
+		return eErrDev;
+	}
+	Dbg("strVendor=%s",strVendor);
+	Dbg("strVersion=%s",strVersion);
+	Dbg("strBatch=%s",strBatch);
+	//read CenterSetting get VendorRecodeLevel,VendorRecodeType,WhiteNameSheet.
+	CSmartPointer<IConfigInfo> centerConfig;
+	eErrDev = pEntity->GetFunction()->OpenConfig(Config_CenterSetting,centerConfig);
+	if (eErrDev != Error_Succeed) {
+		Dbg("open Config_CenterSetting file failed!");
+		return eErrDev;
+	}
+
+	CSimpleStringA strVendorRecodeLevel,strVendorRecodeType,strVendorDllName,strVendorLogPath;
+	eErrDev = centerConfig->ReadConfigValue(moduleName,strVendor.GetData(),strVendorRecodeLevel);
+	if(eErrDev!=Error_Succeed || strVendorRecodeLevel.IsNullOrEmpty())
+	{
+		eErrDev = centerConfig->ReadConfigValue(moduleName,"All",strVendorRecodeLevel);
+		if(eErrDev!=Error_Succeed || strVendorRecodeLevel.IsNullOrEmpty())
+		{
+			//default level:OFF.
+			strVendorRecodeLevel = "OFF";
+		}
+	}
+	//WhiteNameSheet is avaliable.
+	if (strVendorRecodeLevel.Compare("OFF") != 0)
+	{
+		//get WhiteNameSheet
+		CSimpleStringA strWhiteNameSheet;
+		eErrDev = centerConfig->ReadConfigValue(moduleName,"AllowTerminals",strWhiteNameSheet);
+		if (!strWhiteNameSheet.IsNullOrEmpty())
+		{
+			bool bWhiteNameSheet = false;
+			CAutoArray<CSimpleStringA> arrayWhiteNameSheet = strWhiteNameSheet.Split(',');
+			for (int i=0;i<arrayWhiteNameSheet.GetCount();i++)
+			{
+				std::regex pattern(arrayWhiteNameSheet[i]);
+				if(std::regex_match(DevInfo.strTerminalID.GetData(),pattern))
+				{
+					bWhiteNameSheet = true;
+					break;
+				}
+			}
+			//if this terminal is not at WhiteNameSheet,set level with "OFF".
+			if(!bWhiteNameSheet) strVendorRecodeLevel = "OFF";
+		}
+	}
+
+	eErrDev = centerConfig->ReadConfigValue(moduleName,"Type",strVendorRecodeType);
+	if(eErrDev!=Error_Succeed || strVendorRecodeType.IsNullOrEmpty())
+	{
+		//default type:FILE.
+		strVendorRecodeType = "FILE";
+	}
+	strVendorDllName = moduleName + "." + strVendor+"."+strVersion+"."+strBatch+".dll";
+
+
+	TCHAR szPath[MAX_PATH] = {0};
+	GetModuleFileNameA(NULL, szPath, MAX_PATH);
+	CSimpleStringA strDir =  szPath;
+	strVendorLogPath = strDir.SubString(0,1);
+	strVendorLogPath += ":/rvc/dbg";
+
+	Dbg("VENDOR_RECODE_LEVEL=%s",strVendorRecodeLevel);
+	Dbg("VENDOR_RECODE_TYPE=%s",strVendorRecodeType);
+	Dbg("VENDOR_DLL_NAME=%s",strVendorDllName);
+	Dbg("VENDOR_LOG_PATH=%s",strVendorLogPath);
+	if(!SetEnvironmentVariableA("VENDOR_RECODE_LEVEL",strVendorRecodeLevel.GetData())){
+		Dbg("Set VENDOR_RECODE_LEVEL Variable Failed.");
+	}
+	if(!SetEnvironmentVariableA("VENDOR_RECODE_TYPE",strVendorRecodeType.GetData())){
+		Dbg("Set VENDOR_RECODE_TYPE Variable Failed.");
+	}
+	if(!SetEnvironmentVariableA("VENDOR_DLL_NAME",strVendorDllName.GetData())){
+		Dbg("Set VENDOR_DLL_NAME Variable Failed.");
+	}
+	if(!SetEnvironmentVariableA("VENDOR_LOG_PATH",strVendorLogPath.GetData())){
+		Dbg("Set VENDOR_LOG_PATH Variable Failed.");
+	}
+#else
+#endif
+	return Error_Succeed;
+}
+ErrorCodeEnum VendorLogControler(FSMBase *pFSM,CSimpleStringA moduleName)
+{
+	return VendorLogControlerEx(pFSM->GetEntityBase(),moduleName);
+}
+/*--------------------*/
+
+//#define DeviceService_Method_GetDevInfo 65535
+//#define DeviceService_MethodSignature_GetDevInfo 296205965
+//
+//struct DeviceService_GetDevInfo_Req
+//{
+//	void Serialize(SpBuffer &Buf)
+//	{
+//	}
+//};
+//
+//struct DeviceService_GetDevInfo_Ans
+//{
+//	CSimpleStringA type;
+//	CSimpleStringA model;
+//	CSimpleStringA vendor;
+//	int state;
+//	WORD wMajor;		//release major version
+//	WORD wMinor;		//release minor version
+//	WORD wRevision;		//bug repair version with the major and minor version remains the same
+//	WORD wBuild;		//compile version
+//
+//	void Serialize(SpBuffer &Buf)
+//	{
+//		Buf & type & model & vendor & state & wMajor & wMinor & wRevision & wBuild;
+//	}
+//};
+//
+//class DeviceService_ClientBase : public CClientSessionBase {
+//public:
+//	DeviceService_ClientBase(CEntityBase *pEntity) : m_pEntityBase(pEntity), m_bSysManaged(false) {}
+//
+//protected:
+//	virtual ~DeviceService_ClientBase() {}
+//
+//public:
+//
+//	ErrorCodeEnum Connect(CSmartPointer<IAsynWaitSp> &spAsyncWait, const CSimpleStringA &strRemoteEntity)
+//	{
+//		CSmartPointer<IEntityFunction> pFunc = m_pEntityBase->GetFunction();
+//
+//		CSimpleStringA strServiceName = strRemoteEntity + "Service";
+//		ErrorCodeEnum Error = pFunc->ConnectRemoteEntity(this, (const char*)strRemoteEntity, (const char*)strServiceName, spAsyncWait);
+//		if (Error == Error_Succeed) {
+//			m_bSysManaged = true;
+//		}
+//		return Error;
+//	}
+//
+//	ErrorCodeEnum Connect(const CSimpleStringA &strRemoteEntity)
+//	{
+//		CSmartPointer<IAsynWaitSp> spAsyncWait;
+//		ErrorCodeEnum Error = Connect(spAsyncWait, strRemoteEntity);
+//		if (Error == Error_Succeed) {
+//			Error = spAsyncWait->WaitAnswer();
+//		}
+//		return Error;
+//	}
+//
+//	ErrorCodeEnum GetDevInfo(DeviceService_GetDevInfo_Req &Req, CSmartPointer<IAsynWaitSp> &spAsyncWait, DWORD dwTimeout)
+//	{
+//		CSmartPointer<IClientSessionFunction> pFunc = GetFunction();
+//		CAutoBuffer Buf = SpObject2Buffer(Req);
+//		return pFunc->AsyncRequest(DeviceService_Method_GetDevInfo, DeviceService_MethodSignature_GetDevInfo, Buf, spAsyncWait, dwTimeout);
+//	}
+//
+//	ErrorCodeEnum GetDevInfo(DeviceService_GetDevInfo_Req &Req, DeviceService_GetDevInfo_Ans &Ans, DWORD dwTimeout)
+//	{
+//		CSmartPointer<IAsynWaitSp> spAsyncWait;
+//		ErrorCodeEnum Error = GetDevInfo(Req, spAsyncWait, dwTimeout);
+//		if (Error == Error_Succeed) {
+//			bool bEnd = false;
+//			Error = SpWaitAnswerObject(spAsyncWait, Ans, bEnd);
+//			LOG_ASSERT(Error || bEnd);
+//		}
+//		return Error;
+//	}
+//
+//	bool SafeDelete()
+//	{
+//		if (!m_bSysManaged) {
+//			delete this;
+//		}
+//		return m_bSysManaged;
+//	}
+//
+//protected:
+//	bool m_bSysManaged;
+//	CEntityBase *m_pEntityBase;
+//};
+//
+//ErrorCodeEnum SpGetDeviceInfo(CEntityBase *pEntity, const CSimpleStringA &devDevEntityName, 
+//	CSimpleStringA &strType,	CSimpleStringA &strModel, CSimpleStringA &strVendor, int &nState, CBlob &blobVersion)
+//{
+//	DeviceService_ClientBase *pClient = new DeviceService_ClientBase(pEntity);
+//	ErrorCodeEnum rc = pClient->Connect(devDevEntityName);
+//	if (rc == Error_Succeed)
+//	{
+//		DeviceService_GetDevInfo_Req req;
+//		DeviceService_GetDevInfo_Ans ans;
+//		rc = pClient->GetDevInfo(req, ans, 5000);
+//		if (rc == Error_Succeed)
+//		{
+//			strType = ans.type;
+//			strModel = ans.model;
+//			strVendor = ans.vendor;
+//			nState = ans.state;
+//			blobVersion.Alloc(8);
+//			((BYTE*)blobVersion.m_pData)[0] = (ans.wMajor >> 8) & 0xFF;
+//			((BYTE*)blobVersion.m_pData)[1] = ans.wMajor & 0xFF;
+//			((BYTE*)blobVersion.m_pData)[2] = (ans.wMinor >> 8) & 0xFF;
+//			((BYTE*)blobVersion.m_pData)[3] = ans.wMinor & 0xFF;
+//			((BYTE*)blobVersion.m_pData)[4] = (ans.wRevision >> 8) & 0xFF;
+//			((BYTE*)blobVersion.m_pData)[5] = ans.wRevision & 0xFF;
+//			((BYTE*)blobVersion.m_pData)[6] = (ans.wBuild >> 8) & 0xFF;
+//			((BYTE*)blobVersion.m_pData)[7] = ans.wBuild & 0xFF;
+//		}
+//		pClient->GetFunction()->CloseSession();
+//	}
+//	pClient->SafeDelete();
+//	return rc;
+//}
+
+ErrorCodeEnum SpGetAllDevices(CEntityBase *pEntity, CAutoArray<CSimpleStringA> &devs)
+{
+	CSmartPointer<IConfigInfo> pConfig;
+	ErrorCodeEnum rc = pEntity->GetFunction()->OpenConfig(Config_Root, pConfig);
+	if (rc  == Error_Succeed)
+	{
+		int nCount(0);
+		rc = pConfig->ReadConfigValueInt("Device", "Number", nCount);
+		if (rc == Error_Succeed && nCount>0)
+		{
+			devs.Init(nCount);
+
+			for(int i=0; i<nCount; i++)
+			{
+				CSimpleStringA str = CSimpleStringA::Format("%d", i+1);
+				rc = pConfig->ReadConfigValue("Device", (const char*)str, devs[i]);
+			}
+		}
+	}
+
+	return rc;
+}
+
+
+ErrorCodeEnum SpGetDeviceInfo(CEntityBase *pCallerEntity, const CSimpleStringA &devDeviceName, 
+	CSimpleStringA &strModel, CSimpleStringA &strVendor, CSimpleStringA &strVersion)
+{
+	CSmartPointer<IConfigInfo> pConfig;
+	ErrorCodeEnum rc = pCallerEntity->GetFunction()->OpenConfig(Config_Root, pConfig);
+	if (rc  == Error_Succeed)
+	{
+		CSimpleStringA strSection = CSimpleStringA("Device.") + devDeviceName;				
+
+		pConfig->ReadConfigValue(strSection, "Vendor", strVendor);		
+		pConfig->ReadConfigValue(strSection, "Version", strVersion);
+		
+		strModel = devDeviceName;
+		if (!strVendor.IsNullOrEmpty())
+		{
+			strModel += ".";
+			strModel += strVendor;
+		}
+
+		if (!strVersion.IsNullOrEmpty())
+		{
+			strModel += ".";
+			strModel += strVersion;
+		}		
+	}
+
+	return rc;
+}
+
+ErrorCodeEnum SpGetDevAdaptorPath(CEntityBase *pCallerEntity, 
+								  const CSimpleStringA &devDeviceName, 
+								  CSimpleStringA &strDevAdaptorPath)
+{
+	CSmartPointer<IConfigInfo> pConfig;
+	ErrorCodeEnum rc = pCallerEntity->GetFunction()->OpenConfig(Config_Root, pConfig);
+	if (rc  == Error_Succeed)
+	{
+		CSimpleStringA strSection = CSimpleStringA("Device.") + devDeviceName;
+		
+		strDevAdaptorPath = devDeviceName;
+
+		CSimpleStringA str;
+		pConfig->ReadConfigValue(strSection, "Vendor", str);
+		if (!str.IsNullOrEmpty())
+		{
+			strDevAdaptorPath += ".";
+			strDevAdaptorPath += str;
+		}
+
+		str.Clear();
+		pConfig->ReadConfigValue(strSection, "Version", str);
+		if (!str.IsNullOrEmpty())
+		{
+			strDevAdaptorPath += ".";
+			strDevAdaptorPath += str;
+		}
+
+		str.Clear();
+		pConfig->ReadConfigValue(strSection, "Batch", str);
+		if (!str.IsNullOrEmpty())
+		{
+			strDevAdaptorPath += ".";
+			strDevAdaptorPath += str;
+		}
+
+		CSimpleStringA strDepPath;
+		pCallerEntity->GetFunction()->GetPath("Dep", strDepPath);
+#ifdef RVC_OS_WIN
+		strDevAdaptorPath = CSimpleStringA::Format("%s\\%s.dll",
+			(const char*)strDepPath,
+			(const char*)strDevAdaptorPath);
+#else
+		strDevAdaptorPath = CSimpleStringA::Format("%s/%s.so",
+			(const char*)strDepPath,
+			(const char*)strDevAdaptorPath);
+#endif
+	}
+
+	return rc;
+}
+
+// add by ly
+ErrorCodeEnum SpGetDevAdaptorPathByIndex(int nIndex, 
+	CEntityBase *pCallerEntity, 
+	const CSimpleStringA &devDeviceName, 
+	CSimpleStringA &strDevAdaptorPath)
+{
+	CSmartPointer<IConfigInfo> pConfig;
+	ErrorCodeEnum rc = pCallerEntity->GetFunction()->OpenConfig(Config_Root, pConfig);
+	if (rc  == Error_Succeed)
+	{
+		char tmp[64] = {0};
+		CSimpleStringA strSection = CSimpleStringA("Device.") + devDeviceName;
+
+		strDevAdaptorPath = devDeviceName;
+
+		CSimpleStringA str;
+		sprintf(tmp, "Vendor_%d", nIndex);
+		pConfig->ReadConfigValue(strSection, tmp, str);
+		if (!str.IsNullOrEmpty())
+		{
+			strDevAdaptorPath += ".";
+			strDevAdaptorPath += str;
+		}
+
+		str.Clear();
+		sprintf(tmp, "Version_%d", nIndex);
+		pConfig->ReadConfigValue(strSection, tmp, str);
+		if (!str.IsNullOrEmpty())
+		{
+			strDevAdaptorPath += ".";
+			strDevAdaptorPath += str;
+		}
+
+		str.Clear();
+		sprintf(tmp, "Batch_%d", nIndex);
+		pConfig->ReadConfigValue(strSection, tmp, str);
+		if (!str.IsNullOrEmpty())
+		{
+			strDevAdaptorPath += ".";
+			strDevAdaptorPath += str;
+		}
+
+		CSimpleStringA strDepPath;
+		pCallerEntity->GetFunction()->GetPath("Dep", strDepPath);
+
+		strDevAdaptorPath = CSimpleStringA::Format("%s\\%s.dll", 
+			(const char*)strDepPath, 
+			(const char*)strDevAdaptorPath);
+	}
+
+	return rc;
+}
+
+// BranchDevice [Josephus in 16:32:09 2016/6/22]
+ErrorCodeEnum SpGetBrDevAdaptorPath(CEntityBase *pCallerEntity, 
+	const CSimpleStringA &devDeviceName, 
+	CSimpleStringA &strDevAdaptorPath)
+{
+	CSmartPointer<IConfigInfo> pConfig;
+	ErrorCodeEnum rc = pCallerEntity->GetFunction()->OpenConfig(Config_Root, pConfig);
+	if (rc  == Error_Succeed)
+	{
+		CSimpleStringA strSection = CSimpleStringA("BranchDevice.") + devDeviceName;
+
+		strDevAdaptorPath = devDeviceName;
+
+		CSimpleStringA str;
+		pConfig->ReadConfigValue(strSection, "Branch", str);
+		if (!str.IsNullOrEmpty())
+		{
+			strDevAdaptorPath += ".";
+			strDevAdaptorPath += str;
+		}
+
+		str.Clear();
+		pConfig->ReadConfigValue(strSection, "Version", str);
+		if (!str.IsNullOrEmpty())
+		{
+			strDevAdaptorPath += ".";
+			strDevAdaptorPath += str;
+		}
+
+		str.Clear();
+		pConfig->ReadConfigValue(strSection, "Batch", str);
+		if (!str.IsNullOrEmpty())
+		{
+			strDevAdaptorPath += ".";
+			strDevAdaptorPath += str;
+		}
+
+		CSimpleStringA strDepPath;
+		pCallerEntity->GetFunction()->GetPath("Dep", strDepPath);
+
+		//strDevAdaptorPath = CSimpleStringA::Format("%s\\%s.dll", 
+		//	(const char*)strDepPath, 
+		//	(const char*)strDevAdaptorPath);
+		strDevAdaptorPath = CSimpleStringA::Format("%s.dll", (const char*)strDevAdaptorPath);
+	}
+
+	return rc;
+}
+
+ErrorCodeEnum IsNeedOpenUsb(CEntityBase *pCallerEntity, bool& bNeedOpenUsb)
+{
+	ErrorCodeEnum errCode = Error_Unexpect;
+	CSystemStaticInfo sysDevInfo;
+	errCode = pCallerEntity->GetFunction()->GetSystemStaticInfo(sysDevInfo);
+
+	if(errCode != Error_Succeed){
+		Dbg("get device info failed while judge open usb or not");
+	}else{
+		CSimpleStringA strMachineType;
+		strMachineType = sysDevInfo.strMachineType;
+		WORD majorVersion = sysDevInfo.MachineVersion.GetMajor();
+		WORD minorVersion = sysDevInfo.MachineVersion.GetMinor();
+		CSimpleStringA machineVersion = CSimpleStringA::Format("%d.%d", majorVersion, minorVersion);
+		Dbg("MachineType:%s, machineVersion:%s", strMachineType.GetData(), machineVersion.GetData());
+		
+		if(!strMachineType.Compare("RVC.PAD", true)
+			|| (!strMachineType.Compare("RVC.Desk2S", true) && !machineVersion.Compare("1.0")))
+		{
+			bNeedOpenUsb = false;
+		}
+		else if(!strMachineType.Compare("RVC.Stand2S", true) || !strMachineType.Compare("RVC.CardStore", true)
+			|| (!strMachineType.Compare("RVC.Desk2S", true) && !machineVersion.Compare("2.0"))
+			|| (!strMachineType.Compare("RVC.Desk2S", true) && !machineVersion.Compare("2.1"))
+			|| (!strMachineType.Compare("RVC.Desk1S", true) && !machineVersion.Compare("1.0")))
+		{
+			bNeedOpenUsb = true;
+		}
+		else
+		{
+			//TODO:: if add new machine type
+			bNeedOpenUsb = true;
+		}
+	}
+	return errCode;
+}
+