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

Z991239-5596 #comment feat: 优化密码键盘getdevinfo接口

oilyang 1 жил өмнө
parent
commit
bbea6a305e

+ 15 - 25
Module/mod_pinpad/PinPadFSM.cpp

@@ -1265,13 +1265,10 @@ ErrorCodeEnum CPinPadFSM::GetCheckCode(SpReqAnsContext<PinPadService_GetCheckCod
 	ctx->Answer(Error_Succeed);
 	return Error_Succeed;
 }
-bool CPinPadFSM::GetDevInfo(DevCategoryInfo &devInfo)
+ErrorCodeEnum CPinPadFSM::GetDevInfo(DevCategoryInfo &devInfo)
 {
 	if (!m_bOpened)
-	{
-		devInfo.eState = m_eDevState;
-		return false;
-	}
+		return Error_DevNotAvailable;
 	DevCategoryInfo info;
 	ZeroMemory(info.szModel, MAX_DEV_MODEL_LEN);
 	ZeroMemory(info.szType, MAX_DEV_TYPE_LEN);
@@ -1279,6 +1276,7 @@ bool CPinPadFSM::GetDevInfo(DevCategoryInfo &devInfo)
 	m_ullBeginTime = SP::Module::Comm::RVCGetTickCount();
 	ErrorCodeEnum eErrDev = m_hDevHelper->GetDevCategory(info);
 	m_ullEndTime = SP::Module::Comm::RVCGetTickCount();
+
 	if (eErrDev == Error_Succeed)
 	{
 		m_szModel = info.szModel;
@@ -1286,6 +1284,16 @@ bool CPinPadFSM::GetDevInfo(DevCategoryInfo &devInfo)
 		m_szVendor = info.szVendor;
 		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("DevAdapter::GetDevCategory").setCostTime(m_ullEndTime - m_ullBeginTime)
 			("model,%d,%s;type,%d,%s;vendor,%d,%s", strlen(devInfo.szModel), m_szModel.GetData(), strlen(devInfo.szType), m_szType.GetData(), strlen(devInfo.szVendor), m_szVendor.GetData());
+		ZeroMemory(devInfo.szModel, MAX_DEV_MODEL_LEN);//CM=V2.0#PM=V1.0#MID=75500001#PID=12345678#FWID=V1234567#Vendor=nantian
+		ZeroMemory(devInfo.szType, MAX_DEV_TYPE_LEN);
+		ZeroMemory(devInfo.szVendor, MAX_DEV_VENDOR_LEN);
+		CSimpleStringA tmpModel("");
+		if (m_szModel.GetLength() > 1)
+			strncpy(devInfo.szModel, m_szModel.GetData(), m_szModel.GetLength());
+		if (m_szType.GetLength() > 1)
+			strncpy(devInfo.szType, m_szType.GetData(), m_szType.GetLength());
+		if (m_szVendor.GetLength() > 1)
+			strncpy(devInfo.szVendor, m_szVendor.GetData(), m_szVendor.GetLength());
 	}
 	else
 	{
@@ -1295,26 +1303,8 @@ bool CPinPadFSM::GetDevInfo(DevCategoryInfo &devInfo)
 		m_szVendor = "";
 		m_eDevState = DEVICE_STATUS_NOT_READY;
 	}
-	ZeroMemory(devInfo.szModel,MAX_DEV_MODEL_LEN);//CM=V2.0#PM=V1.0#MID=75500001#PID=12345678#FWID=V1234567#Vendor=nantian
-	ZeroMemory(devInfo.szType,MAX_DEV_TYPE_LEN);
-	ZeroMemory(devInfo.szVendor,MAX_DEV_VENDOR_LEN);
-	CSimpleStringA tmpModel("");
-	if (m_szModel.GetLength() > 1)
-	{
-		CSimpleStringA tmpAddStr("");
-		tmpAddStr = tmpAddStr + "Vendor=" + m_szVendor;
-		if (m_szModel[m_szModel.GetLength() - 1] == '#')
-			tmpModel = m_szModel + tmpAddStr;
-		else
-			tmpModel = m_szModel + "#" + tmpAddStr;
-		strncpy(devInfo.szModel, (const char*)tmpModel, tmpModel.GetLength());
-	}
-	if (m_szType.GetLength() > 1)
-		strncpy(devInfo.szType, (const char*)m_szType, m_szType.GetLength());
-	if (m_szVendor.GetLength() > 1)
-		strncpy(devInfo.szVendor, (const char*)m_szVendor, m_szVendor.GetLength());
-	devInfo.eState = m_eDevState;
-	return true;
+
+	return eErrDev;
 }
 void CPinPadFSM::SetInWhatPage(int iPageType)
 {

+ 1 - 1
Module/mod_pinpad/PinPadFSM.h

@@ -254,7 +254,7 @@ public:
 	int GetInputJS(SpReqAnsContext<PinPadService_GetInputJS_Req, PinPadService_GetInputJS_Ans>::Pointer ctxJS);
 	ErrorCodeEnum GetEncryptTextJS(SpReqAnsContext<PinPadService_GetInputJS_Req, PinPadService_GetInputJS_Ans>::Pointer ctxJS);
 
-	bool GetDevInfo(DevCategoryInfo &devInfo);
+	ErrorCodeEnum GetDevInfo(DevCategoryInfo &devInfo);
 	int LoadKeySM(SpReqAnsContext<PinPadService_LoadKeysSM_Req, PinPadService_LoadKeysSM_Ans>::Pointer ctx);
 	int EncryptSM(SpReqAnsContext<PinPadService_EncryptDataSM_Req, PinPadService_EncryptDataSM_Ans>::Pointer ctx);
 	ErrorCodeEnum GetCheckCode(SpReqAnsContext<PinPadService_GetCheckCode_Req, PinPadService_GetCheckCode_Ans>::Pointer ctx);

+ 10 - 3
Module/mod_pinpad/mod_PinPad.h

@@ -176,12 +176,19 @@ public:
 		{
 			DevCategoryInfo devInfo;
 			memset(&devInfo, 0, sizeof(devInfo));
-			if (m_fsm.GetDevInfo(devInfo))
+			ErrorCodeEnum eGetDevInfo = m_fsm.GetDevInfo(devInfo);
+			if (eGetDevInfo == Error_Succeed)
 			{
-				ctx->Ans.model = devInfo.szModel;
+				//oiltmp@20240823 纪林的与业务组的初始化优化完成之后,是不是不要再拼接了?
+				CSimpleStringA tmpAddStr("");
+				tmpAddStr = tmpAddStr + "Vendor=" + devInfo.szVendor;
+				if (devInfo.szModel[strlen(devInfo.szModel) - 1] == '#')
+					ctx->Ans.model = CSimpleStringA(devInfo.szModel) + tmpAddStr;
+				else
+					ctx->Ans.model = CSimpleStringA(devInfo.szModel) + "#" + tmpAddStr;
 				ctx->Ans.type = devInfo.szType;
 			}
-			ctx->Ans.state = devInfo.eState;
+			ctx->Ans.state = eGetDevInfo;
 			ctx->Answer(Error_Succeed);
 		}
 		else