Parcourir la source

Z991239-527 #comment fix: 1.添加扩展柜机型;2.去除GetDevInfoHelper的无用代码;3.修改厂商适配器dll的配置获取

gifur il y a 5 ans
Parent
commit
f4d4ce465a

+ 20 - 124
Common/GetDevInfoHelper.h

@@ -1,5 +1,9 @@
+#ifndef _RVC_COMMON_GETDEVINFOHELPER_H__
+#define _RVC_COMMON_GETDEVINFOHELPER_H__
+
 #pragma once
-#include "spHelper.h"
+
+#include "SpHelper.h"
 #include "SpFSM.h"
 #include "SimpleString.h"
 #include "Blob.h"
@@ -7,8 +11,11 @@
 #include <regex>
 /*------20200221------*/
 //modify by LZM
+
 ErrorCodeEnum VendorLogControlerEx(CEntityBase *pEntity,CSimpleStringA moduleName)
 {
+#ifdef _WIN32
+
 	//get Device Information.
 	CSystemStaticInfo DevInfo;
 	pEntity->GetFunction()->GetSystemStaticInfo(DevInfo);
@@ -116,6 +123,13 @@ ErrorCodeEnum VendorLogControlerEx(CEntityBase *pEntity,CSimpleStringA moduleNam
 		Dbg("Set VENDOR_LOG_PATH Variable Failed.");
 	}
 	return Error_Succeed;
+
+#else
+
+	return Error_NotSupport;
+
+#endif //_WIN32
+
 }
 ErrorCodeEnum VendorLogControler(FSMBase *pFSM,CSimpleStringA moduleName)
 {
@@ -123,128 +137,8 @@ ErrorCodeEnum VendorLogControler(FSMBase *pFSM,CSimpleStringA 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;
-//}
 
+/** For AccessAuth and Initializer and UpgradeMgr*/
 ErrorCodeEnum SpGetAllDevices(CEntityBase *pEntity, CAutoArray<CSimpleStringA> &devs)
 {
 	CSmartPointer<IConfigInfo> pConfig;
@@ -268,7 +162,7 @@ ErrorCodeEnum SpGetAllDevices(CEntityBase *pEntity, CAutoArray<CSimpleStringA> &
 	return rc;
 }
 
-
+/** For AccessAuth and UpgradeMgr*/
 ErrorCodeEnum SpGetDeviceInfo(CEntityBase *pCallerEntity, const CSimpleStringA &devDeviceName, 
 	CSimpleStringA &strModel, CSimpleStringA &strVendor, CSimpleStringA &strVersion)
 {
@@ -445,4 +339,6 @@ ErrorCodeEnum SpGetBrDevAdaptorPath(CEntityBase *pCallerEntity,
 	}
 
 	return rc;
-}
+}
+
+#endif

+ 1 - 1
Common/SpBase.h

@@ -1023,7 +1023,7 @@ protected:
 public:
 
 	/** get this entity name */
-	virtual const char *GetEntityName()const=0;
+	virtual const char *GetEntityName() const = 0;
 
 	/** get this entity version*/
 	virtual const char* GetEntityVersion() const { return "0.0.0"; }

+ 10 - 1
Common/SpComm.hpp

@@ -63,7 +63,8 @@ namespace SP
 			RVC_PAD,                /** PAD*/
 			RVC_Desk2S,           /** 低柜双屏*/
 			RVC_IL,                    /** 简版*/
-			RVC_Desk1S           /** 低柜一体机*/
+			RVC_Desk1S,          /** 低柜一体机*/
+			RPM_Stand1S         /** 扩展柜*/
 		};
 
 #define MACHINE_ENUM_TYPE(MACRO)	\
@@ -84,6 +85,10 @@ namespace SP
 			if (lpcszTypeName == NULL || strlen(lpcszTypeName) == 0)
 				return RVC_UNKNOWN;
 			MACHINE_ENUM_TYPE(ENUM_MAP_CONVERT)
+
+			if (stricmp(lpcszTypeName, "RPM.Stand1S") == 0)
+				return RPM_Stand1S;
+
 			return RVC_UNKNOWN;
 		}
 
@@ -96,6 +101,10 @@ namespace SP
 			default:
 				break;
 			}
+
+			if (what == RPM_Stand1S)
+				return "RPM.Stand1S";
+
 			return "Unkown";
 		}
 	};

+ 0 - 10
DevAdapter/include/DeviceBaseHelper.h

@@ -64,19 +64,9 @@ static const char* VendorNameStr[] = {
 	"hx"
 };
 
-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, 

+ 1 - 1
DevAdapter/include/DeviceCrossHelper.h

@@ -59,7 +59,7 @@ template<class TReq, class TAns>
 struct SpReqAnsContextNoAnswer : public SpReqAnsContext<TReq, TAns> 
 {
 	SpReqAnsContextNoAnswer(CSmartPointer<ITransactionContext> &pTransactionContext)
-		: SpReqAnsContext(pTransactionContext) {/*empty for sonar. */}
+		: SpReqAnsContext<TReq, TAns>(pTransactionContext) {/*empty for sonar. */}
 	ErrorCodeEnum Answer(ErrorCodeEnum Error = Error_Succeed)
 	{
 		Dbg("here has been override? no way bcz it's parent has no virtual statement.");

+ 1 - 1
Module/include/ModuleMix.h

@@ -43,7 +43,7 @@ enum UserDefEntityState
 	USER_SURVEILLANCE_EWSERROR,
 	USER_ENTITY_STATE_END
 };
-char *UserDefEntityMsg[USER_ENTITY_STATE_END][1] =
+const char *UserDefEntityMsg[USER_ENTITY_STATE_END][1] =
 {
 	"",
 	"·¢¿¨»ú--¿ÕÏÐ",

+ 170 - 49
module/include/mod_DevAdptEntityBase.hpp

@@ -3,8 +3,14 @@
 
 #pragma once
 
+#include "SpBase.h"
 #include "SpHelper.h"
 #include "DeviceBaseClass.h"
+#include "SimpleString.h"
+#include "path.h"
+#include <regex>
+#include <winpr/file.h>
+#include <winpr/environment.h>
 
 #define SAFE_FREE_LIBRARY(hModule)	\
 	do {							\
@@ -15,11 +21,11 @@
 	}while(0)
 
 #if DEVICE_BASE_INTERFACE_FILE_VERSION == 2
-using DevAdaptObjCreateFunc = ErrorCodeEnum(*)(DWORD dwDevClassID, DeviceBaseClass * &pOutDevAptObj);
-using DevAdaptObjReleaseFunc = ErrorCodeEnum(*)(DWORD dwDevClassID, DeviceBaseClass * &pInDevAptObj);
+	using DevAdaptObjCreateFunc = ErrorCodeEnum(*)(DWORD dwDevClassID, DeviceBaseClass * &pOutDevAptObj);
+	using DevAdaptObjReleaseFunc = ErrorCodeEnum(*)(DWORD dwDevClassID, DeviceBaseClass * &pInDevAptObj);
 #else
-using DevAdaptObjCreateFunc = ErrorCodeEnum(*)(DeviceBaseClass * &pOutDevAptObj);
-using DevAdaptObjReleaseFunc = ErrorCodeEnum(*)(DeviceBaseClass * &pInDevAptObj);
+	using DevAdaptObjCreateFunc = ErrorCodeEnum(*)(DeviceBaseClass * &pOutDevAptObj);
+	using DevAdaptObjReleaseFunc = ErrorCodeEnum(*)(DeviceBaseClass * &pInDevAptObj);
 #endif
 
 
@@ -101,10 +107,10 @@ struct DevAdptLibHelper
 	{
 		if (m_AdptObjPtr != nullptr) {
 			m_AdptObjPtr->DevClose();
-		}
-		if (m_AdptObjPtr != nullptr && nullptr != pFuncReleaseAdapt) {
-			pFuncReleaseAdapt(0, m_AdptObjPtr);
-			m_AdptObjPtr = nullptr;
+			if (nullptr != pFuncReleaseAdapt) {
+				pFuncReleaseAdapt(0, m_AdptObjPtr);
+				m_AdptObjPtr = nullptr;
+			}
 		}
 		SAFE_FREE_LIBRARY(hModule);
 	}
@@ -118,6 +124,10 @@ struct DevAdptLibHelper
 	{
 
 	}
+	~DevAdptLibHelper()
+	{
+		TearDown();
+	}
 
 private:
 
@@ -128,74 +138,116 @@ private:
 	TSubAdpt* m_AdptObjPtr;
 };
 
+struct VendorLibInfo
+{
+	CSimpleStringA strDevice;
+	CSimpleStringA strVendor;
+	CSimpleStringA strVersion;
+	CSimpleStringA strBatch;
+
+	VendorLibInfo() :strDevice(true), strVendor(true), strVersion(true), strBatch(true) {}
+
+	bool IsValid() const {
+		return (!strDevice.IsNullOrEmpty()
+			&& !strVendor.IsNullOrEmpty()
+			&& !strVersion.IsNullOrEmpty()
+			&& !strBatch.IsNullOrEmpty());
+	}
+
+	int GetVersion()
+	{
+		int result = 0;
+		if (!strVersion.IsNullOrEmpty()) {
+			result = atoi(strVersion.GetData());
+		}
+		return result;
+	}
+
+	int GetBatch()
+	{
+		int result = 0;
+		if (!strBatch.IsNullOrEmpty()) {
+			result = atoi(strBatch.GetData());
+		}
+		return result;
+	}
+
+	CSimpleStringA toLibNameString()
+	{
+		CSimpleStringA strFullLibName(true);
+		if (!strDevice.IsNullOrEmpty()) {
+			strFullLibName = strDevice;
+			if (strVendor.IsNullOrEmpty()) {
+				strFullLibName += ".";
+				strFullLibName += strVendor;
+			}
+			if (strVersion.IsNullOrEmpty()) {
+				strFullLibName += ".";
+				strFullLibName += strVersion;
+			}
+			if (strBatch.IsNullOrEmpty()) {
+				strFullLibName += ".";
+				strFullLibName += strBatch;
+			}
+
+#ifdef _WIN32
+			strFullLibName += ".dll";
+#else
+			CSimpleStringA strPrefix("lib");
+			strPrefix += strFullLibName;
+			strPrefix += ".so";
+			strFullLibName = strPrefix;
+#endif //_WIN32
+		}
+
+		return strFullLibName;
+	}
+};
+
 
 class CDevAdptEntityBase : public CEntityBase
 {
 
 public:
 
-	CDevAdptEntityBase() :m_strLibName(true) {}
+	CDevAdptEntityBase(){}
 
 	CSimpleStringA GetVendorLibName()
 	{
-		if (m_strLibName.IsNullOrEmpty()) {
-			ExtractVendorLibName(m_strLibName);
+		if (m_libInfo.IsValid()) {
+			ExtractVendorLibName();
 		}
-		return m_strLibName;
+		return m_libInfo.toLibNameString();
 	}
 
 	ErrorCodeEnum ExtractVendorLibFullPath(CSimpleStringA& csLibFullPath);
-
+	ErrorCodeEnum InitializeVendorLogSwitch();
 private:
 
-	ErrorCodeEnum ExtractVendorLibName(CSimpleStringA& csLibName);
+	ErrorCodeEnum ExtractVendorLibName();
 
-private:
-
-	CSimpleStringA m_strLibName;
+protected:
+	VendorLibInfo m_libInfo;
 };
 
-ErrorCodeEnum CDevAdptEntityBase::ExtractVendorLibName(CSimpleStringA& csLibName)
+inline ErrorCodeEnum CDevAdptEntityBase::ExtractVendorLibName()
 {
 	CSmartPointer<IConfigInfo> spRootConfig;
 	ErrorCodeEnum erroCode = GetFunction()->OpenConfig(Config_Root, spRootConfig);
-
 	if (IS_SUCCEED(erroCode)) {
 		CSimpleStringA strSection = CSimpleStringA("Device.") + GetEntityName();
-		csLibName = GetEntityBase()->GetEntityName();
-		CSimpleStringA str;
-		spRootConfig->ReadConfigValue(strSection, "Vendor", str);
-		if (!str.IsNullOrEmpty()) {
-			csLibName += ".";
-			csLibName += str;
-		} else {
-			erroCode = Error_NotConfig;
-		}
-
-		str.Clear();
-		spRootConfig->ReadConfigValue(strSection, "Version", str);
-		if (!str.IsNullOrEmpty()) {
-			csLibName += ".";
-			csLibName += str;
-		}
+		m_libInfo.strDevice = GetEntityName();
+		spRootConfig->ReadConfigValue(strSection, "Vendor", m_libInfo.strVendor);
+		spRootConfig->ReadConfigValue(strSection, "Version", m_libInfo.strVersion);
+		spRootConfig->ReadConfigValue(strSection, "Batch", m_libInfo.strBatch);
 
-		str.Clear();
-		spRootConfig->ReadConfigValue(strSection, "Batch", str);
-		if (!str.IsNullOrEmpty()) {
-			csLibName += ".";
-			csLibName += str;
-		}
-
-		str = csLibName + ".dll";
-		csLibName = str;
-	}
-	else {
-		//TODO: SetCustLastErrorCode();
+		if (!m_libInfo.IsValid())
+			erroCode = Error_NotConfig;
 	}
 	return erroCode;
 }
 
-ErrorCodeEnum CDevAdptEntityBase::ExtractVendorLibFullPath(CSimpleStringA& csLibFullPath)
+inline ErrorCodeEnum CDevAdptEntityBase::ExtractVendorLibFullPath(CSimpleStringA& csLibFullPath)
 {
 	CSimpleStringA strLibName = GetVendorLibName();
 	if (strLibName.IsNullOrEmpty()) {
@@ -204,9 +256,78 @@ ErrorCodeEnum CDevAdptEntityBase::ExtractVendorLibFullPath(CSimpleStringA& csLib
 	
 	CSimpleStringA strDepPath;
 	GetFunction()->GetPath("Dep", strDepPath);
-	csLibFullPath = CSimpleStringA::Format("%s\\%s", (LPCTSTR)strDepPath, (LPCTSTR)strLibName);
+	csLibFullPath = CSimpleStringA::Format("%s" SPLIT_SLASH_STR "%s", (LPCTSTR)strDepPath, (LPCTSTR)strLibName);
 
 	return Error_Succeed;
 }
 
+inline ErrorCodeEnum CDevAdptEntityBase::InitializeVendorLogSwitch()
+{
+	CSystemStaticInfo sysInfo;
+	GetFunction()->GetSystemStaticInfo(sysInfo);
+	if (!m_libInfo.IsValid())
+		ExtractVendorLibName();
+
+	struct VendorLogConfig {
+		CSimpleStringA strLevel;
+		CSimpleStringA strType;
+		CSimpleStringA strDllName;
+		CSimpleStringA strLogPath;
+
+		void Settle() {
+			SetEnvironmentVariableA("VENDOR_RECODE_LEVEL", strLevel);
+			SetEnvironmentVariableA("VENDOR_RECODE_TYPE", strType);
+			SetEnvironmentVariableA("VENDOR_DLL_NAME", strDllName);
+			SetEnvironmentVariableA("VENDOR_LOG_PATH", strLogPath);
+		}
+
+	} stLogConfig = { "OFF" "FILE", m_libInfo.toLibNameString(), ""};
+
+	CSmartPointer<IConfigInfo> centerConfig;
+	GetFunction()->OpenConfig(Config_CenterSetting, centerConfig);
+
+	CSimpleStringA str;
+	centerConfig->ReadConfigValue(GetEntityName(), m_libInfo.strVendor, str);
+	if (str.IsNullOrEmpty()) {
+		centerConfig->ReadConfigValue(GetEntityName(), "All", str);
+	}
+	if (!str.IsNullOrEmpty())
+		stLogConfig.strLevel = str;
+
+	if (stLogConfig.strLevel.Compare("OFF", true) != 0) {
+		CSimpleStringA strWhiteNameSheet;
+		centerConfig->ReadConfigValue(GetEntityName(), "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(sysInfo.strTerminalID.GetData(), pattern)) {
+					bWhiteNameSheet = true;
+					break;
+				}
+			}
+			//if this terminal is not at WhiteNameSheet,set level with "OFF".
+			if (!bWhiteNameSheet)
+				stLogConfig.strLevel = "OFF";
+		}
+	}
+
+	if (stLogConfig.strLevel.Compare("OFF", true) != 0) {
+		str.Clear();
+		centerConfig->ReadConfigValue(GetEntityName(), "Type", str);
+		if (!str.IsNullOrEmpty())
+			stLogConfig.strType = str;
+
+		TCHAR szPath[MAX_PATH] = { 0 };
+		GetModuleFileNameA(NULL, szPath, MAX_PATH);
+		CSimpleStringA strDir = szPath;
+		str = strDir.SubString(0, 1);
+		str += ":/rvc/dbg";
+		stLogConfig.strLogPath = str;
+
+		stLogConfig.Settle();
+	}
+}
+
 #endif /*_RVC_DEVICE_ADAPTER_ENTITY_BASE_H__*/