瀏覽代碼

Z991239-4378 #comment CardIssuer和CardReadAdapter的双版本代码功能同步

oilyang 2 年之前
父節點
當前提交
30c586207d

+ 103 - 5
DevAdapter/include/CardAssist.cpp

@@ -425,6 +425,21 @@ bool CCardProcess::DetectIfICCard(CardReadType eType, DeviceBaseClass *pCardX, i
 		cardType = ch;
 		Dbg("Detect contactless card type %d",ch);
 	}
+	else if (eType == CARD_MACHINE_ISSUER_RF)
+	{
+		pCardI = dynamic_cast<CardIssuerClass*>(pCardX);
+		char ch;
+		eErr = pCardI->ActiveContactlessICCard('A', 'B', 'M', ch);
+		if (eErr != Error_Succeed)
+		{
+			QueryLastErr(pCardI, errMsg);
+			errMsg = CSimpleStringA::Format("(CardIssuer)DetectIfICCard::ActiveContactlessICCard failed(%d):%s", SpStrError(eErr), errMsg.GetData());
+			LogWarn(Severity_Middle, Error_Unexpect, ContactlessCard_UserErrorCode_ActiveContactlessICCard_Failed, errMsg.GetData());
+			return false;
+		}
+		cardType = ch;
+		Dbg(CSimpleStringA::Format("(CardIssuer)Detect contactless card type %d", ch));
+	}
 	return true;
 }
 ErrorCodeEnum CCardProcess::BuildSupportedAppList(CardReadType eType,DeviceBaseClass *pCardX,vector<AIDData>& vAIDFromTerm)
@@ -451,7 +466,7 @@ ErrorCodeEnum CCardProcess::BuildSupportedAppList(CardReadType eType,DeviceBaseC
 		memcpy(pData, pse1, tmpPse1);
 		ConstructAPDU(cls, ins, p1, p2, tmpPse1, pData, &le);
 	}
-	else if (eType == CARD_MACHINE_RFIC || eType == CARD_MACHINE_SWIPER_RF)
+	else if (eType == CARD_MACHINE_RFIC || eType == CARD_MACHINE_SWIPER_RF || eType == CARD_MACHINE_ISSUER_RF)
 	{
 		tmpPse2 = strlen(pse2);
 		pData = new BYTE[tmpPse2+1];
@@ -485,6 +500,12 @@ ErrorCodeEnum CCardProcess::BuildSupportedAppList(CardReadType eType,DeviceBaseC
 		eErr = pCardI->ICCommand(cmdSend,cmdRecv);
 		errICCommand = CardIssuer_UserErrorCode_ICCommand_Failed;
 	}
+	else if (eType == CARD_MACHINE_ISSUER_RF)
+	{
+		pCardI = dynamic_cast<CardIssuerClass*>(pCardX);
+		eErr = pCardI->RFTypeABCommand(cmdSend, cmdRecv);
+		errICCommand = ContactlessCard_UserErrorCode_RFTypeABCommand_Failed;
+	}
 	else if (eType == CARD_MACHINE_SWIPER || eType == CARD_MACHINE_SWIPER_RF)
 	{
 		pCardS = dynamic_cast<CardSwiperClass*>(pCardX);
@@ -559,6 +580,11 @@ ErrorCodeEnum CCardProcess::BuildSupportedAppList(CardReadType eType,DeviceBaseC
 						eErr = pCardI->ICCommand(cmdSend,cmdRecv);
 						errICCommand = CardIssuer_UserErrorCode_ICCommand_Failed;
 					}
+					else if (eType == CARD_MACHINE_ISSUER_RF)
+					{
+						eErr = pCardI->RFTypeABCommand(cmdSend, cmdRecv);
+						errICCommand = ContactlessCard_UserErrorCode_RFTypeABCommand_Failed;
+					}
 					else if (eType == CARD_MACHINE_SWIPER || eType == CARD_MACHINE_SWIPER_RF)
 					{
 						eErr = pCardS->ICCommand(cmdSend,cmdRecv);
@@ -644,6 +670,9 @@ ErrorCodeEnum CCardProcess::BuildSupportedAppList(CardReadType eType,DeviceBaseC
 			case CARD_MACHINE_ISSUER:
 				errICCommand = CardIssuer_UserErrorCode_ICCommand_RecvData_Invalid;
 				break;
+			case CARD_MACHINE_ISSUER_RF:
+				errICCommand = ContactlessCard_UserErrorCode_ICCommand_RecvData_Invalid;
+				break;
 			case CARD_MACHINE_SWIPER:
 			case CARD_MACHINE_SWIPER_RF:
 				//errICCommand = CardSwiper_UserErrorCode_ICCommand_RecvData_Invalid;
@@ -699,8 +728,8 @@ ErrorCodeEnum CCardProcess::BuildAppListByAIDs(CardReadType eType,DeviceBaseClas
 	vector<AIDData>::iterator it;
 	CmdInfo cmdSend,cmdRecv;
 
-	ErrorCodeEnum eErr;
-	if (eType == CARD_MACHINE_ISSUER)
+	ErrorCodeEnum eErr = Error_Unexpect;
+	if (eType == CARD_MACHINE_ISSUER || eType == CARD_MACHINE_ISSUER_RF)
 	{
 		pCardI = dynamic_cast<CardIssuerClass*>(pCardX);
 	}
@@ -736,6 +765,10 @@ Step7:
 		{
 			eErr = pCardI->ICCommand(cmdSend,cmdRecv);
 		}
+		else if (eType == CARD_MACHINE_ISSUER_RF)
+		{
+			eErr = pCardI->RFTypeABCommand(cmdSend, cmdRecv);
+		}
 		else if (eType == CARD_MACHINE_SWIPER)
 		{
 			eErr = pCardS->ICCommand(cmdSend,cmdRecv);				
@@ -884,6 +917,12 @@ ErrorCodeEnum CCardProcess::AppSelected(CardReadType eType,DeviceBaseClass *pCar
 		eErr = pCardI->ICCommand(cmdSend,cmdRecv);
 		errICCommand = CardIssuer_UserErrorCode_ICCommand_Failed;
 	}
+	else if (eType == CARD_MACHINE_ISSUER_RF)
+	{
+		pCardI = dynamic_cast<CardIssuerClass*>(pCardX);
+		eErr = pCardI->RFTypeABCommand(cmdSend, cmdRecv);
+		errICCommand = ContactlessCard_UserErrorCode_RFTypeABCommand_Failed;
+	}
 	else if (eType == CARD_MACHINE_SWIPER || eType == CARD_MACHINE_SWIPER_RF)
 	{
 		pCardS = dynamic_cast<CardSwiperClass*>(pCardX);
@@ -940,6 +979,12 @@ ErrorCodeEnum CCardProcess::AppSelected(CardReadType eType,DeviceBaseClass *pCar
 				eErr = pCardI->ICCommand(cmdSend,cmdRecv);
 				errICCommand = CardIssuer_UserErrorCode_ICCommand_Failed;
 			}
+			else if (eType == CARD_MACHINE_ISSUER_RF)
+			{
+				pCardI = dynamic_cast<CardIssuerClass*>(pCardX);
+				eErr = pCardI->RFTypeABCommand(cmdSend, cmdRecv);
+				errICCommand = ContactlessCard_UserErrorCode_RFTypeABCommand_Failed;
+			}
 			else if (eType == CARD_MACHINE_SWIPER || eType == CARD_MACHINE_SWIPER_RF)
 			{
 				pCardS = dynamic_cast<CardSwiperClass*>(pCardX);
@@ -1003,6 +1048,9 @@ ErrorCodeEnum CCardProcess::AppSelected(CardReadType eType,DeviceBaseClass *pCar
 			case CARD_MACHINE_ISSUER:
 				errICCommand = CardIssuer_UserErrorCode_ICCommand_RecvData_Invalid;
 				break;
+			case CARD_MACHINE_ISSUER_RF:
+				errICCommand = ContactlessCard_UserErrorCode_ICCommand_RecvData_Invalid;
+				break;
 			case CARD_MACHINE_SWIPER:
 			case CARD_MACHINE_SWIPER_RF:
 				//errICCommand = CardSwiper_UserErrorCode_ICCommand_RecvData_Invalid;
@@ -1037,7 +1085,7 @@ ErrorCodeEnum CCardProcess::ReadData(CardReadType eType,DeviceBaseClass *pCardX,
 	m_AIP[1] = data[1];
 
 	ErrorCodeEnum eErr;
-	if (eType == CARD_MACHINE_ISSUER)
+	if (eType == CARD_MACHINE_ISSUER || eType == CARD_MACHINE_ISSUER_RF)
 	{
 		pCardI = dynamic_cast<CardIssuerClass*>(pCardX);
 	}
@@ -1070,6 +1118,10 @@ ErrorCodeEnum CCardProcess::ReadData(CardReadType eType,DeviceBaseClass *pCardX,
 			{
 				eErr = pCardI->ICCommand(cmdSend,cmdRecv);
 			}
+			else if (eType == CARD_MACHINE_ISSUER_RF)
+			{
+				eErr = pCardI->RFTypeABCommand(cmdSend, cmdRecv);
+			}
 			else if (eType == CARD_MACHINE_SWIPER)
 			{
 				eErr = pCardS->ICCommand(cmdSend,cmdRecv);
@@ -1173,6 +1225,11 @@ void CCardProcess::ProcessDDFRecord(CardReadType eType,DeviceBaseClass *pCardX,v
 		pCardI = dynamic_cast<CardIssuerClass*>(pCardX);
 		eErr = pCardI->ICCommand(cmdSend,cmdRecv);
 	}
+	else if (eType == CARD_MACHINE_ISSUER_RF)
+	{
+		pCardI = dynamic_cast<CardIssuerClass*>(pCardX);
+		eErr = pCardI->RFTypeABCommand(cmdSend, cmdRecv);
+	}
 	else if (eType == CARD_MACHINE_SWIPER || eType == CARD_MACHINE_SWIPER_RF)
 	{
 		pCardS = dynamic_cast<CardSwiperClass*>(pCardX);
@@ -1217,6 +1274,10 @@ void CCardProcess::ProcessDDFRecord(CardReadType eType,DeviceBaseClass *pCardX,v
 					{
 						eErr = pCardI->ICCommand(cmdSend,cmdRecv);
 					}
+					else if (eType == CARD_MACHINE_ISSUER_RF)
+					{
+						eErr = pCardI->RFTypeABCommand(cmdSend, cmdRecv);
+					}
 					else if (eType == CARD_MACHINE_SWIPER)
 					{
 						eErr = pCardS->ICCommand(cmdSend,cmdRecv);
@@ -1635,6 +1696,11 @@ int CCardProcess::TermActionAnalyze(CardReadType eType,DeviceBaseClass *pCardX,C
 		pCardI = dynamic_cast<CardIssuerClass*>(pCardX);
 		eErr = pCardI->ICCommand(cmdSend,cmdRecv);
 	}
+	else if (eType == CARD_MACHINE_ISSUER_RF)
+	{
+		pCardI = dynamic_cast<CardIssuerClass*>(pCardX);
+		eErr = pCardI->RFTypeABCommand(cmdSend, cmdRecv);
+	}
 	else if (eType == CARD_MACHINE_SWIPER || eType == CARD_MACHINE_SWIPER_RF)
 	{
 		pCardS = dynamic_cast<CardSwiperClass*>(pCardX);
@@ -1673,6 +1739,10 @@ int CCardProcess::TermActionAnalyze(CardReadType eType,DeviceBaseClass *pCardX,C
 			{
 				eErr = pCardI->ICCommand(cmdSend,cmdRecv);
 			}
+			else if (eType == CARD_MACHINE_ISSUER_RF)
+			{
+				eErr = pCardI->RFTypeABCommand(cmdSend, cmdRecv);
+			}
 			else if (eType == CARD_MACHINE_SWIPER)
 			{
 				eErr = pCardS->ICCommand(cmdSend,cmdRecv);
@@ -1957,6 +2027,11 @@ int CCardProcess::IssueBankAuth(CardReadType eType,DeviceBaseClass *pCardX)
 		pCardI = dynamic_cast<CardIssuerClass*>(pCardX);
 		eErr = pCardI->ICCommand(cmdSend,cmdRecv);
 	}
+	else if (eType == CARD_MACHINE_ISSUER_RF)
+	{
+		pCardI = dynamic_cast<CardIssuerClass*>(pCardX);
+		eErr = pCardI->RFTypeABCommand(cmdSend, cmdRecv);
+	}
 	else if (eType == CARD_MACHINE_SWIPER || eType == CARD_MACHINE_SWIPER_RF)
 	{
 		pCardS = dynamic_cast<CardSwiperClass*>(pCardX);
@@ -2029,7 +2104,7 @@ void CCardProcess::ExecuteIssuerScript(CardReadType eType,DeviceBaseClass *pCard
 	CardIssuerClass *pCardI;
 	CardSwiperClass *pCardS;
 	ErrorCodeEnum eErr;
-	if (eType == CARD_MACHINE_ISSUER)
+	if (eType == CARD_MACHINE_ISSUER || eType == CARD_MACHINE_ISSUER_RF)
 	{
 		pCardI = dynamic_cast<CardIssuerClass*>(pCardX);
 	}
@@ -2064,6 +2139,10 @@ void CCardProcess::ExecuteIssuerScript(CardReadType eType,DeviceBaseClass *pCard
 			{
 				eErr = pCardI->ICCommand(cmdSend,cmdRecv);
 			}
+			else if (eType == CARD_MACHINE_ISSUER_RF)
+			{
+				eErr = pCardI->RFTypeABCommand(cmdSend, cmdRecv);
+			}
 			else if (eType == CARD_MACHINE_SWIPER)
 			{
 				eErr = pCardS->ICCommand(cmdSend,cmdRecv);
@@ -2149,6 +2228,11 @@ int CCardProcess::TransEnd(CardReadType eType,DeviceBaseClass *pCardX,bool bCDA)
 		pCardI = dynamic_cast<CardIssuerClass*>(pCardX);
 		eErr = pCardI->ICCommand(cmdSend,cmdRecv);
 	}
+	else if (eType == CARD_MACHINE_ISSUER_RF)
+	{
+		pCardI = dynamic_cast<CardIssuerClass*>(pCardX);
+		eErr = pCardI->RFTypeABCommand(cmdSend, cmdRecv);
+	}
 	else if (eType == CARD_MACHINE_SWIPER || eType == CARD_MACHINE_SWIPER_RF)
 	{
 		pCardS = dynamic_cast<CardSwiperClass*>(pCardX);
@@ -2187,6 +2271,10 @@ int CCardProcess::TransEnd(CardReadType eType,DeviceBaseClass *pCardX,bool bCDA)
 			{
 				eErr = pCardI->ICCommand(cmdSend,cmdRecv);
 			}
+			else if (eType == CARD_MACHINE_ISSUER_RF)
+			{
+				eErr = pCardI->RFTypeABCommand(cmdSend, cmdRecv);
+			}
 			else if (eType == CARD_MACHINE_SWIPER)
 			{
 				eErr = pCardS->ICCommand(cmdSend,cmdRecv);
@@ -2279,6 +2367,11 @@ void CCardProcess::GetBaseInfoNotInRecord(CardReadType eType,DeviceBaseClass *pC
 		pCardI = dynamic_cast<CardIssuerClass*>(pCardX);
 		eErr = pCardI->ICCommand(cmdSend,cmdRecv);
 	}
+	else if (eType == CARD_MACHINE_ISSUER_RF)
+	{
+		pCardI = dynamic_cast<CardIssuerClass*>(pCardX);
+		eErr = pCardI->RFTypeABCommand(cmdSend, cmdRecv);
+	}
 	else if (eType == CARD_MACHINE_SWIPER || eType == CARD_MACHINE_SWIPER_RF)
 	{
 		pCardS = dynamic_cast<CardSwiperClass*>(pCardX);
@@ -2399,6 +2492,11 @@ int CCardProcess::GetICDataFromCard(CardReadType eType,DeviceBaseClass *pCardX,
 			pCardI = dynamic_cast<CardIssuerClass*>(pCardX);
 			errBuildAppList = CardIssuer_UserErrorCode_BuildSupportedAppList_Failed;
 		}
+		else if (eType == CARD_MACHINE_ISSUER_RF)
+		{
+			pCardI = dynamic_cast<CardIssuerClass*>(pCardX);
+			errBuildAppList = ContactlessCard_UserErrorCode_BuildSupportedAppList_Failed;
+		}
 		else if (eType == CARD_MACHINE_SWIPER || eType == CARD_MACHINE_SWIPER_RF)
 		{
 			pCardS = dynamic_cast<CardSwiperClass*>(pCardX);

+ 1 - 0
DevAdapter/include/CardAssist.h

@@ -18,6 +18,7 @@ enum CardReadType
 	CARD_MACHINE_SWIPER,
 	CARD_MACHINE_RFIC,
 	CARD_MACHINE_SWIPER_RF,
+	CARD_MACHINE_ISSUER_RF
 };
 enum TagVectorType
 {

+ 51 - 34
Module/mod_CardReadAdapter/CardReadAdapterFSM.cpp

@@ -57,11 +57,6 @@ void CCardReadAdapterFSM::s0_on_entry()
 		m_eMachineType = MachineType_RVC_DESK2S;
 	else if (_strnicmp((const char*)m_csMachineType, "RVC.Desk1S", strlen("RVC.Desk1S")) == 0)
 		m_eMachineType = MachineType_RVC_DESK1S;
-	else if (_strnicmp((const char*)m_csMachineType, "RVC.IL", strlen("RVC.IL")) == 0)
-	{
-		m_bRVCIL = true;
-		m_eMachineType = MachineType_RVC_IL;
-	}
 	FSMEvent *pEvt;
 
 	pEvt = new FSMEvent(USER_EVT_INIT);
@@ -125,6 +120,7 @@ void CCardReadAdapterFSM::s2_on_entry()
 	m_bIssuingExit = false;
 	m_bCancelAccept = false;
 	m_lastS2Event = m_lastS2EvtParam1 = 0;
+	m_busCtx.eCardProcStage = Card_ProcStage_Idle;
 }
 void CCardReadAdapterFSM::s2_on_exit()
 {
@@ -715,7 +711,7 @@ int CCardReadAdapterFSM::CardIssuerRead(SpReqAnsContext<CardReadAdapterService_R
 		char msg[128];
 		memset(msg, 0, 128);
 		sprintf(msg, "Maybe the thread pool is wrong.CardIssuerRead,bCancel:%d,cardpos:%d", m_bCancelAccept, m_busCtx.eCardFromWhich);
-		LogWarn(Severity_Low, Error_NotInit, CardReadAdapter_UserErrorCode_MayBe_ThreadPool_Wrong, msg);
+		LogWarn(Severity_Middle, Error_NotInit, CardReadAdapter_UserErrorCode_MayBe_ThreadPool_Wrong, msg);
 		return 3;
 	}
 	ErrorCodeEnum eErr = Error_Unexpect;
@@ -754,12 +750,14 @@ int CCardReadAdapterFSM::CardIssuerRead(SpReqAnsContext<CardReadAdapterService_R
 					CardIssuerService_Insert_Ans ans;
 					req.aid = ctx->Req.aid;
 					DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("to call cardissuer insert..");
+					m_busCtx.eCardProcStage = Card_ProcStage_WaitForCard;
 					eErr = m_pCardIssuer->Insert(req, ans, 59000, dwUsrErrCode);
 					if (eErr == Error_Succeed)
 					{
 						DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Card insert into CardIssuer.");
 						bHasCard = true;
 						m_busCtx.eCardFromWhich = Card_In_CardIssuer;
+						m_busCtx.eCardProcStage = Card_ProcStage_Read;
 						if (IsContactlessCardSessionOK())
 							m_pContactless->CancelInsert();
 					}
@@ -816,7 +814,7 @@ int CCardReadAdapterFSM::CardIssuerRead(SpReqAnsContext<CardReadAdapterService_R
 			}
 		}
 		else {
-			DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER)("CardIssuer QueryCardInfo failed return:", eErr);
+			DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER)("CardIssuer QueryCardInfo failed return:%d", eErr);
 			return 1;//oilyang@20190709
 		}
 		if (bHasCard && bNeedPreOnline)
@@ -902,6 +900,7 @@ int CCardReadAdapterFSM::ContactlessCardRead(SpReqAnsContext<CardReadAdapterServ
 			dwEnd = GetTickCountRVC();
 			DWORD dwTimeout = ReadCard_TIMEOUT - (dwEnd-dwStart);
 			m_busCtx.eCardFromWhich = Card_In_No_Where;
+			m_busCtx.eCardProcStage = Card_ProcStage_WaitForCard;
 			eErr = m_pContactless->Insert(req, ans, dwTimeout, dwUserCode);
 			if (eErr == Error_Succeed)
 			{
@@ -919,6 +918,7 @@ int CCardReadAdapterFSM::ContactlessCardRead(SpReqAnsContext<CardReadAdapterServ
 				ctx->Ans.t2ExpireDate = ans.t2ExpireDate;
 				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Card in ContactlessCard.");
 				m_busCtx.eCardFromWhich = Card_In_ContactlessCard;
+				m_busCtx.eCardProcStage = Card_ProcStage_Read;
 				//if (IsCardIssuerSessionOK()){
 				//	m_pCardIssuer->CancelInsert();
 				//}
@@ -1082,11 +1082,13 @@ int CCardReadAdapterFSM::CardSwiperRead(SpReqAnsContext<CardReadAdapterService_R
 			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)(CSimpleStringA::Format("CardSwiperRead, aid:%s,lightPos:%d",(const char*)req.aid,req.LightPos));
 
 			DWORD dwUserCode = 0;
+			m_busCtx.eCardProcStage = Card_ProcStage_WaitForCard;
 			eErr = m_pCardSwiper->Read(req, ans, 60000, dwUserCode);
 			eRetErr = eErr;
 			if (eErr == Error_Succeed)
 			{
 				m_busCtx.eCardFromWhich = Card_In_CardSwiper;
+				m_busCtx.eCardProcStage = Card_ProcStage_Read;
 				//oilyang@20180913 由于CardSwiper没有插卡过程,直接进行pboc流程,需要提前取消其他实体的输入
 				if (IsCardIssuerSessionOK())
 					m_pCardIssuer->CancelInsert();
@@ -1398,6 +1400,7 @@ int CCardReadAdapterFSM::EjectCard(SpReqAnsContext<CardReadAdapterService_Eject_
 		if (eErr == Error_Succeed)
 		{
 			m_busCtx.eCardFromWhich = Card_In_No_Where;
+			m_busCtx.eCardProcStage = Card_ProcStage_Eject;
 			DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("CardIssuer EjectCard suc.");
 		}
 		else {
@@ -1413,6 +1416,7 @@ int CCardReadAdapterFSM::EjectCard(SpReqAnsContext<CardReadAdapterService_Eject_
 		if (eErr == Error_Succeed)
 		{
 			m_busCtx.eCardFromWhich = Card_In_No_Where;
+			m_busCtx.eCardProcStage = Card_ProcStage_Eject;
 			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("ContactlessCard EjectCard suc.");
 		}
 		else {
@@ -1428,6 +1432,7 @@ int CCardReadAdapterFSM::EjectCard(SpReqAnsContext<CardReadAdapterService_Eject_
 		if (eErr == Error_Succeed)
 		{
 			m_busCtx.eCardFromWhich = Card_In_No_Where;
+			m_busCtx.eCardProcStage = Card_ProcStage_Eject;
 			DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("CardSwiper EjectCard suc.");
 		}
 		else {
@@ -1457,6 +1462,7 @@ int CCardReadAdapterFSM::CaptureCard(SpReqAnsContext<CardReadAdapterService_Capt
 		{
 			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("CardIssuer Capture card suc.");
 			m_busCtx.eCardFromWhich = Card_In_No_Where;
+			m_busCtx.eCardProcStage = Card_ProcStage_Capture;
 		}
 		else {
 			DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("CaptureCard, CardIssuer Capture failed return:%d", eErr);
@@ -1566,7 +1572,7 @@ void CCardReadAdapterFSM::CheckAndReconnectSession()
 	{
 		//the first time to connect or need to reconnect
 		//CardIssuer
-		if (!m_bRVCIL && (m_pCardIssuer == NULL || (m_pCardIssuer != NULL && m_pCardIssuer->QuerySessionClosed())))
+		if ((m_pCardIssuer == NULL || (m_pCardIssuer != NULL && m_pCardIssuer->QuerySessionClosed())))
 		{
 			if (m_pCardIssuer != NULL)
 			{
@@ -1676,7 +1682,7 @@ bool CCardReadAdapterFSM::IsTheEntity(int module,ModuleType eModule)
 	//oilyang@20180409 add req.module==99
 	else if (module == 99)
 	{
-		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("req.module is 99,machineType is:%s",(const char*)m_csMachineType);
+		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("req.module is 99,machineType is:%s",m_csMachineType.GetData());
 		//oilyang@20200730 according to meeting with Ratail/Test/Hangzhou
 		//Desk2S 2.1 can insert into CardIssuer
 		//oilyang@20200612 if "RVC.Desk2S" ,no need to call  CardIssuer(insert card)
@@ -1716,15 +1722,16 @@ int CCardReadAdapterFSM::SetSomeFlag(SpReqAnsContext<CardReadAdapterService_SetS
 			req.reserved1[i] = ctx->Req.reserved1[i];
 		}
 		ErrorCodeEnum eErr = m_pCardIssuer->SetSomeFlag(req, ans,10000);
-		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("CardIssuer SetSomeFlag ret:%d",eErr);
 		if (eErr == Error_Succeed)
 		{
 			ctx->Ans.reserved1.Copy(ans.reserved1);
 			ctx->Ans.reserved2.Copy(ans.reserved2);
 			ctx->Answer(Error_Succeed);
 		}
-		else
+		else{
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("CardIssuer SetSomeFlag failed return:%d",eErr);
 			ctx->Answer(Error_Unexpect);
+		}
 	}
 	else
 	{
@@ -1809,8 +1816,8 @@ int CCardReadAdapterFSM::GetDevInfo(SpReqAnsContext<CardReadAdapterService_GetDe
 		ctx->Ans.model[index] = csCIModel;
 		ctx->Ans.version[index] = csCIVersion;
 		ctx->Ans.state[index] = ciState;
-		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER)("CardIssuer,type:%s,model:%s,version:%s,state:%d", (const char*)csCIType, (const char*)csCIModel
-			, (const char*)csCIVersion, ciState);
+		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER)("CardIssuer, type:%s, model:%s, version:%s, state:%d", 
+				csCIType.GetData(), csCIModel.GetData(), csCIVersion.GetData(), ciState);
 		index++;
 	}
 	if (bCC)
@@ -1820,8 +1827,8 @@ int CCardReadAdapterFSM::GetDevInfo(SpReqAnsContext<CardReadAdapterService_GetDe
 		ctx->Ans.model[index] = csCCModel;
 		ctx->Ans.version[index] = csCCVersion;
 		ctx->Ans.state[index] = ccState;
-		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER)("ContactlessCard,type:%s,model:%s,version:%s,state:%d", (const char*)csCCType, (const char*)csCCModel
-			, (const char*)csCCVersion, ccState);
+		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER)("ContactlessCard, type:%s, model:%s, version:%s, state:%d", 
+			csCCType.GetData(), csCCModel.GetData(), csCCVersion.GetData(), ccState);
 		index++;
 	}
 	if (bCS)
@@ -1831,8 +1838,8 @@ int CCardReadAdapterFSM::GetDevInfo(SpReqAnsContext<CardReadAdapterService_GetDe
 		ctx->Ans.model[index] = csCSModel;
 		ctx->Ans.version[index] = csCSVersion;
 		ctx->Ans.state[index] = csState;
-		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER)("CardSwiper,type:%s,model:%s,version:%s,state:%d", (const char*)csCSType, (const char*)csCSModel
-			, (const char*)csCSVersion, csState);
+		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER)("CardSwiper, type:%s, model:%s, version:%s, state:%d", 
+			csCSType.GetData(), csCSModel.GetData(), csCSVersion.GetData(), csState);
 		index++;
 	}
 	ctx->Answer(Error_Succeed);
@@ -2274,16 +2281,18 @@ int CCardReadAdapterFSM::PreOnlineOnStore(SpReqAnsContext<CardReadAdapterService
 			LogWarn(Severity_Low, Error_Unexpect, CardReadAdapter_UserErrorCode_PreOnline_Result, outParam.GetData());
 			ctx->Answer(eErr);
 		}else if (eErr == Error_TimeOut) {
-			DbgWithLink(LOG_LEVEL_ERROR, LOG_TYPE_USER).setLogCode("QLR040220327").setResultCode("RTA2R01")("HBService_No_Return");
+			DbgWithLink(LOG_LEVEL_ERROR, LOG_TYPE_USER).setLogCode("QLR040220327").setResultCode("RTA2R01")("PreOnlineOnStore timeout(62s)");
 			DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)(CSimpleStringA::Format("PreOnlineOnStore, CardIssuer PreOnlineOnStore failed return:%d", eErr));
 			ctx->Answer(Error_TimeOut, CardReadAdapter_UserErrorCode_HBService_No_Return);
 		}
 		else if (eErr == Error_Duplication)
 			ctx->Answer(Error_DevNotAvailable, CardIssuer_UserErrorCode_DupCallPreOnline_WhileInWorking);
 		else if (eErr == Error_ReplyTimeOut)
-			ctx->Answer(Error_DevNotAvailable, CardIssuer_UserErrorCode_CardStore_Reply_TooLong);
+			ctx->Answer(Error_Unexpect, CardIssuer_UserErrorCode_CardStore_Reply_TooLong);
 		else if (eErr == Error_DevNotAvailable)
 			ctx->Answer(Error_DevNotAvailable, CardIssuer_UserErrorCode_CardActive_CardStore_OffLine);
+		else if (eErr == Error_Hardware)
+			ctx->Answer(Error_DevNotAvailable, CardIssuer_UserErrorCode_CardActive_CardIssuer_InFaultState);
 		else {
 			DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)(CSimpleStringA::Format("PreOnlineOnStore, CardIssuer PreOnlineOnStore failed return:%d", eErr));
 			ctx->Answer(eErr);
@@ -2292,7 +2301,7 @@ int CCardReadAdapterFSM::PreOnlineOnStore(SpReqAnsContext<CardReadAdapterService
 	else
 	{
 		LogWarn(Severity_High, Error_Unexpect, CardReadAdapter_UserErrorCode_PreOnline_CardIssuer_Not_Ok, "Entity CardIssuer is not ok.");
-		ctx->Answer(Error_Unexpect, CardReadAdapter_UserErrorCode_PreOnline_CardIssuer_Not_Ok);
+		ctx->Answer(Error_DevNotAvailable, CardReadAdapter_UserErrorCode_PreOnline_CardIssuer_Not_Ok);
 	}
 	return 0;
 }
@@ -2339,6 +2348,7 @@ int CCardReadAdapterFSM::QueryCardInfoOnStore(SpReqAnsContext<CardReadAdapterSer
 	LOG_FUNCTION();
 	if (IsCardIssuerSessionOK())
 	{
+		DWORD dwUserErrorCode = 0;
 		ErrorCodeEnum eErr = Error_Unexpect;
 		CardIssuerService_QueryCardInfoOnStore_Req req;
 		CardIssuerService_QueryCardInfoOnStore_Ans ans;
@@ -2347,7 +2357,7 @@ int CCardReadAdapterFSM::QueryCardInfoOnStore(SpReqAnsContext<CardReadAdapterSer
 		req.reserved3.Copy(ctx->Req.reserved3);
 		req.reserved4.Copy(ctx->Req.reserved4);
 
-		eErr = m_pCardIssuer->QueryCardInfoOnStore(req, ans, INT_MAX / 2 - 5000);
+		eErr = m_pCardIssuer->QueryCardInfoOnStore(req, ans, INT_MAX / 2 - 5000, dwUserErrorCode);
 		if (eErr == Error_Succeed)
 		{
 			ctx->Ans.cardPos = ans.cardPos;
@@ -2356,16 +2366,17 @@ int CCardReadAdapterFSM::QueryCardInfoOnStore(SpReqAnsContext<CardReadAdapterSer
 			ctx->Ans.reserved2.Copy(ans.reserved2);
 			ctx->Ans.reserved3.Copy(ans.reserved3);
 			ctx->Ans.reserved4.Copy(ans.reserved4);
-		}
-		else {
+			ctx->Answer(Error_Succeed);
+		}else{
 			DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("QueryCardInfoOnStore, CardIssuer QueryCardInfoOnStore failed return:%d", eErr);
+			ctx->Answer(eErr, dwUserErrorCode);
 		}
-		ctx->Answer(eErr);
+		
 	}
 	else
 	{
 		DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("Entity CardIssuer is not ok.");
-		ctx->Answer(Error_Unexpect);
+		ctx->Answer(Error_DevNotAvailable, CardReadAdapter_UserErrorCode_PreOnline_CardIssuer_Not_Ok);
 	}
 	return 0;
 }
@@ -2374,6 +2385,7 @@ int CCardReadAdapterFSM::GetAddCardInfo(SpReqAnsContext<CardReadAdapterService_G
 	LOG_FUNCTION();
 	if (IsCardIssuerSessionOK())
 	{
+		DWORD dwUserErrorCode = 0;
 		ErrorCodeEnum eErr = Error_Unexpect;
 		CardIssuerService_GetAddCardInfo_Req req;
 		CardIssuerService_GetAddCardInfo_Ans ans;
@@ -2382,7 +2394,7 @@ int CCardReadAdapterFSM::GetAddCardInfo(SpReqAnsContext<CardReadAdapterService_G
 		req.reserved2.Copy(ctx->Req.reserved2);
 		req.reserved3.Copy(ctx->Req.reserved3);
 		req.reserved4.Copy(ctx->Req.reserved4);
-		eErr = m_pCardIssuer->GetAddCardInfo(req, ans, 10000);
+		eErr = m_pCardIssuer->GetAddCardInfo(req, ans, 10000, dwUserErrorCode);
 		if (eErr == Error_Succeed)
 		{
 			ctx->Ans.account = ans.account;
@@ -2393,16 +2405,16 @@ int CCardReadAdapterFSM::GetAddCardInfo(SpReqAnsContext<CardReadAdapterService_G
 			ctx->Ans.reserved2.Copy(ans.reserved2);
 			ctx->Ans.reserved3.Copy(ans.reserved3);
 			ctx->Ans.reserved4.Copy(ans.reserved4);
+			ctx->Answer(Error_Succeed);
+		}else{
+			DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("GetAddCardInfo, CardIssuer GetAddCardInfo failed return:%d,%x", eErr, dwUserErrorCode);
+			ctx->Answer(eErr, dwUserErrorCode);
 		}
-		else {
-			DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("GetAddCardInfo, CardIssuer GetAddCardInfo failed return:%d", eErr);
-		}
-		ctx->Answer(eErr);
 	}
 	else
 	{
 		DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("Entity CardIssuer is not ok.");
-		ctx->Answer(Error_Unexpect);
+		ctx->Answer(Error_DevNotAvailable, CardReadAdapter_UserErrorCode_PreOnline_CardIssuer_Not_Ok);
 	}
 	return 0;
 }
@@ -2520,12 +2532,13 @@ int CCardReadAdapterFSM::LocalCallHeartBeat(int method, CBlob &bbSend,bool bTwoW
 	req.paramX = bbSend;
 	req.type = method;
 	eErr = pClient->CrossTermCall(req, ans, 20000);
-	DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("CrossTermCall to HeartBeat from %s to %s, result:%x", (const char*)req.fromTerminalNo, (const char*)req.toTerminalNo, eErr);
+	DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("CrossTermCall to HeartBeat from %s to %s, result:%x",
+			req.fromTerminalNo.GetData(), req.toTerminalNo.GetData(), eErr);
 	return 0;
 }
 bool CCardReadAdapterFSM::GetAttachedTerminal(CSimpleStringA &csTerm)
 {
-	return GetEntityBase()->GetFunction()->GetSysVar("AttachedTerminal", csTerm);
+	return (Error_Succeed == GetEntityBase()->GetFunction()->GetSysVar("AttachedTerminal", csTerm));
 }
 void CCardReadAdapterFSM::CancelReadForEntity(ModuleType eModule)
 {
@@ -2542,9 +2555,13 @@ void CCardReadAdapterFSM::CancelReadForEntity(ModuleType eModule)
 	if (IsTheEntity(eModule, Module_ContactlessCard) && IsContactlessCardSessionOK())
 	{
 		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Cancel read by CardSwiper of ContactlessCard.");
-		ContactlessCardService_CancelInsert_Info info;
 		m_pContactless->CancelInsert();
 	}
+	if (IsTheEntity(eModule, Module_CardSwiper) && IsCardSwiperSessionOK())
+	{
+		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Cancel read by ContactlessCard of CardSwiper.");
+		m_pCardSwiper->CancelInsert();
+	}
 }
 int CCardReadAdapterFSM::PrintCardIm(SpReqAnsContext<CardReadAdapterService_PrintCardImmediately_Req, CardReadAdapterService_PrintCardImmediately_Ans>::Pointer ctx)
 {

+ 2 - 3
Module/mod_CardReadAdapter/CardReadAdapterFSM.h

@@ -779,7 +779,7 @@ public:
 
 		END_FSM_RULE()
 
-		CCardReadAdapterFSM() : m_pCardIssuer(NULL), m_pContactless(NULL), m_pCardSwiper(NULL), m_bRVCIL(false){}
+		CCardReadAdapterFSM() : m_pCardIssuer(NULL), m_pContactless(NULL), m_pCardSwiper(NULL){}
 	~CCardReadAdapterFSM(){}
 	virtual ErrorCodeEnum OnInit();
 	virtual ErrorCodeEnum OnExit();
@@ -905,8 +905,7 @@ private:
 	HMODULE m_hVerdorDll;
 	//GUIConsoleService_ClientBase *m_pGUIConsoleClient;
 	bool m_devInit, m_bCancelAccept, m_bWaitingAccept, m_bWaitAccepteMore
-		, m_bCDA, m_bIssuingExit, m_bCardIssued, m_bCaptureCfgFlag, m_bHasHopper[3], m_bBTConncting
-		,m_bRVCIL;
+		, m_bCDA, m_bIssuingExit, m_bCardIssued, m_bCaptureCfgFlag, m_bHasHopper[3], m_bBTConncting;
 	ErrorCodeEnum m_testResult;
 	//m_CardInit,m_CardRemains,m_CardIssued,m_CardMixed,m_CardPercent
 	int m_CardCaptured, m_issueStatusFromFile, m_issueStatus, m_port, m_baudRate, m_currentHopper, m_scanSlot;

+ 1 - 0
Module/mod_CardReadAdapter/CardReadAdapter_client_g.h

@@ -32,6 +32,7 @@ public:
 	}
 	void OnClose(ErrorCodeEnum)
 	{
+		Dbg("session closed.");
 		bSessionClosed = true;
 	}
 	bool QuerySessionClosed()

+ 32 - 2
Module/mod_CardReadAdapter/mod_CardReadAdapter.cpp

@@ -12,6 +12,7 @@
 void CardReadAdapterServerSession::Handle_Read(SpReqAnsContext<CardReadAdapterService_Read_Req, CardReadAdapterService_Read_Ans>::Pointer ctx)
 {
 	LOG_FUNCTION();
+	DbgWithLink(LOG_LEVEL_INFO, ctx->link.checkEmpty() ? LOG_TYPE_SYSTEM : LOG_TYPE_USER).setAPI("Read")("Invoke Read");
 	DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER)("Module:%d,lightPos:%d,bus data size:%d",ctx->Req.module,ctx->Req.lightPos,ctx->Req.businessData.GetLength());
 	if (ctx->Req.reserved1.GetCount() > 0)
 		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER)("reserved1[0]:%d",ctx->Req.reserved1[0]);
@@ -21,33 +22,39 @@ void CardReadAdapterServerSession::Handle_Read(SpReqAnsContext<CardReadAdapterSe
 void CardReadAdapterServerSession::Handle_Capture(SpReqAnsContext<CardReadAdapterService_Capture_Req, CardReadAdapterService_Capture_Ans>::Pointer ctx)
 {
 	LOG_FUNCTION();
+	DbgWithLink(LOG_LEVEL_INFO, ctx->link.checkEmpty() ? LOG_TYPE_SYSTEM : LOG_TYPE_USER).setAPI("Capture")("Invoke Capture");
 	m_pEntity->Capture(ctx);
 }
 
 void CardReadAdapterServerSession::Handle_Eject(SpReqAnsContext<CardReadAdapterService_Eject_Req, CardReadAdapterService_Eject_Ans>::Pointer ctx)
 {
 	LOG_FUNCTION();
+	DbgWithLink(LOG_LEVEL_INFO, ctx->link.checkEmpty() ? LOG_TYPE_SYSTEM : LOG_TYPE_USER).setAPI("Eject")("Invoke Eject");
 	m_pEntity->Eject(ctx);
 }
 
 void CardReadAdapterServerSession::Handle_CancelRead(SpOnewayCallContext<CardReadAdapterService_CancelRead_Info>::Pointer ctx)
 {
 	LOG_FUNCTION();
+	DbgWithLink(LOG_LEVEL_INFO, ctx->link.checkEmpty() ? LOG_TYPE_SYSTEM : LOG_TYPE_USER).setAPI("CancelRead")("Invoke CancelRead");
 	m_pEntity->CancelRead(ctx);
 }
 void CardReadAdapterServerSession::Handle_ReadWaitMore(SpOnewayCallContext<CardReadAdapterService_ReadWaitMore_Info>::Pointer ctx)
 {
 	LOG_FUNCTION();
+	DbgWithLink(LOG_LEVEL_INFO, ctx->link.checkEmpty() ? LOG_TYPE_SYSTEM : LOG_TYPE_USER).setAPI("ReadWaitMore")("Invoke ReadWaitMore");
 	m_pEntity->ReadWaitMore(ctx);
 }
 void CardReadAdapterServerSession::Handle_Issue(SpReqAnsContext<CardReadAdapterService_Issue_Req, CardReadAdapterService_Issue_Ans>::Pointer ctx)
 {
 	LOG_FUNCTION();
+	DbgWithLink(LOG_LEVEL_INFO, ctx->link.checkEmpty() ? LOG_TYPE_SYSTEM : LOG_TYPE_USER).setAPI("Issue")("Invoke Issue");
 	m_pEntity->Issue(ctx);
 }
 void CardReadAdapterServerSession::Handle_PreOnline(SpReqAnsContext<CardReadAdapterService_PreOnline_Req, CardReadAdapterService_PreOnline_Ans>::Pointer ctx)
 {
 	LOG_FUNCTION();
+	DbgWithLink(LOG_LEVEL_INFO, ctx->link.checkEmpty() ? LOG_TYPE_SYSTEM : LOG_TYPE_USER).setAPI("PreOnline")("Invoke PreOnline");
 	if (ctx->Req.reserved2.GetCount() > 0 && !ctx->Req.reserved2[0].IsNullOrEmpty() && _strnicmp("kaku#", (const char*)ctx->Req.reserved2[0], 5) == 0)
 		m_pEntity->PreOnline(ctx);
 	else
@@ -59,6 +66,7 @@ void CardReadAdapterServerSession::Handle_PreOnline(SpReqAnsContext<CardReadAdap
 void CardReadAdapterServerSession::Handle_PostOnline(SpReqAnsContext<CardReadAdapterService_PostOnline_Req, CardReadAdapterService_PostOnline_Ans>::Pointer ctx)
 {
 	LOG_FUNCTION();
+	DbgWithLink(LOG_LEVEL_INFO, ctx->link.checkEmpty() ? LOG_TYPE_SYSTEM : LOG_TYPE_USER).setAPI("PostOnline")("Invoke PostOnline");
 	m_pEntity->PostOnline(ctx);
 }
 void CardReadAdapterServerSession::Handle_Exit(SpOnewayCallContext<CardReadAdapterService_Exit_Info>::Pointer ctx)
@@ -70,97 +78,116 @@ void CardReadAdapterServerSession::Handle_Exit(SpOnewayCallContext<CardReadAdapt
 void CardReadAdapterServerSession::Handle_QueryCardInfo(SpReqAnsContext<CardReadAdapterService_QueryCardInfo_Req, CardReadAdapterService_QueryCardInfo_Ans>::Pointer ctx)
 {
 	LOG_FUNCTION();
+	DbgWithLink(LOG_LEVEL_INFO, ctx->link.checkEmpty() ? LOG_TYPE_SYSTEM : LOG_TYPE_USER).setAPI("QueryCardInfo")("Invoke QueryCardInfo");
 	m_pEntity->QueryCardInfo(ctx);
 }
 void CardReadAdapterServerSession::Handle_WriteTrack(SpReqAnsContext<CardReadAdapterService_WriteTrack_Req, CardReadAdapterService_WriteTrack_Ans>::Pointer ctx)
 {
 	LOG_FUNCTION();
-	//DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("oiltest %d,%d,t1[%S],t2[%S],t3[%S],[%S]",ctx->Req.co,ctx->Req.mode,(const wchar_t *)ctx->Req.track1,(const wchar_t *)ctx->Req.track2,(const wchar_t *)ctx->Req.track3,(const wchar_t *)ctx->Req.reserved);
+	DbgWithLink(LOG_LEVEL_INFO, ctx->link.checkEmpty() ? LOG_TYPE_SYSTEM : LOG_TYPE_USER).setAPI("WriteTrack")("Invoke WriteTrack");
+	//Dbg("oiltest %d,%d,t1[%S],t2[%S],t3[%S],[%S]",ctx->Req.co,ctx->Req.mode,(const wchar_t *)ctx->Req.track1,(const wchar_t *)ctx->Req.track2,(const wchar_t *)ctx->Req.track3,(const wchar_t *)ctx->Req.reserved);
 	m_pEntity->WriteTrack(ctx);
 }
 void CardReadAdapterServerSession::Handle_SetSomeFlag(SpReqAnsContext<CardReadAdapterService_SetSomeFlag_Req, CardReadAdapterService_SetSomeFlag_Ans>::Pointer ctx)
 {
 	LOG_FUNCTION();
+	DbgWithLink(LOG_LEVEL_INFO, ctx->link.checkEmpty() ? LOG_TYPE_SYSTEM : LOG_TYPE_USER).setAPI("SetSomeFlag")("Invoke SetSomeFlag");
 	m_pEntity->SetSomeFlag(ctx);
 }
 
 void CardReadAdapterServerSession::Handle_GetMaterialCount(SpReqAnsContext<CardReadAdapterService_GetMaterialCount_Req, CardReadAdapterService_GetMaterialCount_Ans>::Pointer ctx)
 {
 	LOG_FUNCTION();
+	DbgWithLink(LOG_LEVEL_INFO, ctx->link.checkEmpty() ? LOG_TYPE_SYSTEM : LOG_TYPE_USER).setAPI("GetMaterialCount")("Invoke GetMaterialCount");
 	m_pEntity->GetMaterialCount(ctx);
 }
 void CardReadAdapterServerSession::Handle_SetMaterialCount(SpReqAnsContext<CardReadAdapterService_SetMaterialCount_Req, CardReadAdapterService_SetMaterialCount_Ans>::Pointer ctx)
 {
 	LOG_FUNCTION();
+	DbgWithLink(LOG_LEVEL_INFO, ctx->link.checkEmpty() ? LOG_TYPE_SYSTEM : LOG_TYPE_USER).setAPI("SetMaterialCount")("Invoke SetMaterialCount");
 	m_pEntity->SetMaterialCount(ctx);
 }
 void CardReadAdapterServerSession::Handle_GetSCIInfo(SpReqAnsContext<CardReadAdapterService_GetSCIInfo_Req, CardReadAdapterService_GetSCIInfo_Ans>::Pointer ctx)
 {
 	LOG_FUNCTION();
+	DbgWithLink(LOG_LEVEL_INFO, ctx->link.checkEmpty() ? LOG_TYPE_SYSTEM : LOG_TYPE_USER).setAPI("GetSCIInfo")("Invoke GetSCIInfo");
 	m_pEntity->GetSCIInfo(ctx);
 }
 void CardReadAdapterServerSession::Handle_OpenSafeLock(SpReqAnsContext<CardReadAdapterService_OpenSafeLock_Req, CardReadAdapterService_OpenSafeLock_Ans>::Pointer ctx)
 {
 	LOG_FUNCTION();
+	DbgWithLink(LOG_LEVEL_INFO, ctx->link.checkEmpty() ? LOG_TYPE_SYSTEM : LOG_TYPE_USER).setAPI("OpenSafeLock")("Invoke OpenSafeLock");
 	m_pEntity->OpenSafeLock(ctx);
 }
 void CardReadAdapterServerSession::Handle_MagTransferInit(SpReqAnsContext<CardReadAdapterService_MagTransferInit_Req, CardReadAdapterService_MagTransferInit_Ans>::Pointer ctx)
 {
 	LOG_FUNCTION();
+	DbgWithLink(LOG_LEVEL_INFO, ctx->link.checkEmpty() ? LOG_TYPE_SYSTEM : LOG_TYPE_USER).setAPI("MagTransferInit")("Invoke MagTransferInit");
 	m_pEntity->MagTransferInit(ctx);
 }
 void CardReadAdapterServerSession::Handle_QueryConnInfo(SpReqAnsContext<CardReadAdapterService_QueryConnInfo_Req, CardReadAdapterService_QueryConnInfo_Ans>::Pointer ctx)
 {
 	LOG_FUNCTION();
+	DbgWithLink(LOG_LEVEL_INFO, ctx->link.checkEmpty() ? LOG_TYPE_SYSTEM : LOG_TYPE_USER).setAPI("QueryConnInfo")("Invoke QueryConnInfo");
 	m_pEntity->QueryConnInfo(ctx);
 }
 void CardReadAdapterServerSession::Handle_GetDevInfo(SpReqAnsContext<CardReadAdapterService_GetDevInfo_Req, CardReadAdapterService_GetDevInfo_Ans>::Pointer ctx)
 {
 	LOG_FUNCTION();
+	DbgWithLink(LOG_LEVEL_INFO, ctx->link.checkEmpty() ? LOG_TYPE_SYSTEM : LOG_TYPE_USER).setAPI("GetDevInfo")("Invoke GetDevInfo");
 	m_pEntity->GetDevInfo(ctx);
 }
 void CardReadAdapterServerSession::Handle_SAMICCommand(SpReqAnsContext<CardReadAdapterService_SAMICCommand_Req, CardReadAdapterService_SAMICCommand_Ans>::Pointer ctx)
 {
+	DbgWithLink(LOG_LEVEL_INFO, ctx->link.checkEmpty() ? LOG_TYPE_SYSTEM : LOG_TYPE_USER).setAPI("SAMICCommand")("Invoke SAMICCommand");
 	m_pEntity->SAMICCommand(ctx);
 }
 void CardReadAdapterServerSession::Handle_QueryPrinterStatus(SpReqAnsContext<CardReadAdapterService_QueryPrinterStatus_Req, CardReadAdapterService_QueryPrinterStatus_Ans>::Pointer ctx)
 {
 	LOG_FUNCTION();
+	DbgWithLink(LOG_LEVEL_INFO, ctx->link.checkEmpty() ? LOG_TYPE_SYSTEM : LOG_TYPE_USER).setAPI("QueryPrinterStatus")("Invoke QueryPrinterStatus");
 	m_pEntity->QueryPrinterStatus(ctx);
 }
 void CardReadAdapterServerSession::Handle_Print(SpReqAnsContext<CardReadAdapterService_Print_Req, CardReadAdapterService_Print_Ans>::Pointer ctx)
 {
 	LOG_FUNCTION();
+	DbgWithLink(LOG_LEVEL_INFO, ctx->link.checkEmpty() ? LOG_TYPE_SYSTEM : LOG_TYPE_USER).setAPI("Print")("Invoke Print");
 	m_pEntity->Print(ctx);
 }
 void CardReadAdapterServerSession::Handle_QuerySCIList(SpReqAnsContext<CardReadAdapterService_QuerySCIList_Req, CardReadAdapterService_QuerySCIList_Ans>::Pointer ctx)
 {
 	LOG_FUNCTION();
+	DbgWithLink(LOG_LEVEL_INFO, ctx->link.checkEmpty() ? LOG_TYPE_SYSTEM : LOG_TYPE_USER).setAPI("QuerySCIList")("Invoke QuerySCIList");
 	m_pEntity->QuerySCIList(ctx);
 }
 void CardReadAdapterServerSession::Handle_BindSCI(SpReqAnsContext<CardReadAdapterService_BindSCI_Req, CardReadAdapterService_BindSCI_Ans>::Pointer ctx)
 {
 	LOG_FUNCTION();
+	DbgWithLink(LOG_LEVEL_INFO, ctx->link.checkEmpty() ? LOG_TYPE_SYSTEM : LOG_TYPE_USER).setAPI("BindSCI")("Invoke BindSCI");
 	m_pEntity->BindSCI(ctx);
 }
 void CardReadAdapterServerSession::Handle_PreOnlineOnStore(SpReqAnsContext<CardReadAdapterService_PreOnlineOnStore_Req, CardReadAdapterService_PreOnlineOnStore_Ans>::Pointer ctx)
 {
 	LOG_FUNCTION();
+	DbgWithLink(LOG_LEVEL_INFO, ctx->link.checkEmpty() ? LOG_TYPE_SYSTEM : LOG_TYPE_USER).setAPI("PreOnlineOnStore")("Invoke PreOnlineOnStore");
 	m_pEntity->PreOnlineOnStore(ctx);
 }
 void CardReadAdapterServerSession::Handle_NotifyPreonline(SpReqAnsContext<CardReadAdapterService_NotifyPreonline_Req, CardReadAdapterService_NotifyPreonline_Ans>::Pointer ctx)
 {
 	LOG_FUNCTION();
+	DbgWithLink(LOG_LEVEL_INFO, ctx->link.checkEmpty() ? LOG_TYPE_SYSTEM : LOG_TYPE_USER).setAPI("NotifyPreonline")("Invoke NotifyPreonline");
 	m_pEntity->NotifyPreonline(ctx);
 }
 void CardReadAdapterServerSession::Handle_QueryCardInfoOnStore(SpReqAnsContext<CardReadAdapterService_QueryCardInfoOnStore_Req, CardReadAdapterService_QueryCardInfoOnStore_Ans>::Pointer ctx)
 {
 	LOG_FUNCTION();
+	DbgWithLink(LOG_LEVEL_INFO, ctx->link.checkEmpty() ? LOG_TYPE_SYSTEM : LOG_TYPE_USER).setAPI("QueryCardInfoOnStore")("Invoke QueryCardInfoOnStore");
 	m_pEntity->QueryCardInfoOnStore(ctx);
 }
 void CardReadAdapterServerSession::Handle_GetAddCardInfo(SpReqAnsContext<CardReadAdapterService_GetAddCardInfo_Req, CardReadAdapterService_GetAddCardInfo_Ans>::Pointer ctx)
 {
 	LOG_FUNCTION();
+	DbgWithLink(LOG_LEVEL_INFO, ctx->link.checkEmpty() ? LOG_TYPE_SYSTEM : LOG_TYPE_USER).setAPI("GetAddCardInfo")("Invoke GetAddCardInfo");
 	m_pEntity->GetAddCardInfo(ctx);
 }
 void CardReadAdapterServerSession::Handle_Test1(SpReqAnsContext<CardReadAdapterService_Test1_Req, CardReadAdapterService_Test1_Ans>::Pointer ctx)
@@ -176,16 +203,19 @@ void CardReadAdapterServerSession::Handle_Test2(SpReqAnsContext<CardReadAdapterS
 void CardReadAdapterServerSession::Handle_CrossTermCall(SpReqAnsContext<CardReadAdapterService_CrossTermCall_Req, CardReadAdapterService_CrossTermCall_Ans>::Pointer ctx)
 {
 	LOG_FUNCTION();
+	DbgWithLink(LOG_LEVEL_INFO, ctx->link.checkEmpty() ? LOG_TYPE_SYSTEM : LOG_TYPE_USER).setAPI("CrossTermCall")("Invoke CrossTermCall");
 	m_pEntity->CrossTermCall(ctx);
 }
 void CardReadAdapterServerSession::Handle_CrossTermInvokeInfo(SpOnewayCallContext<CardReadAdapterService_CrossTermInvokeInfo_Info>::Pointer ctx)
 {
 	LOG_FUNCTION();
+	DbgWithLink(LOG_LEVEL_INFO, ctx->link.checkEmpty() ? LOG_TYPE_SYSTEM : LOG_TYPE_USER).setAPI("CrossTermInvokeInfo")("Invoke CrossTermInvokeInfo");
 	m_pEntity->CrossTermInvokeInfo(ctx);
 }
 void CardReadAdapterServerSession::Handle_PrintCardImmediately(SpReqAnsContext<CardReadAdapterService_PrintCardImmediately_Req, CardReadAdapterService_PrintCardImmediately_Ans>::Pointer ctx)
 {
 	LOG_FUNCTION();
+	DbgWithLink(LOG_LEVEL_INFO, ctx->link.checkEmpty() ? LOG_TYPE_SYSTEM : LOG_TYPE_USER).setAPI("PrintCardImmediately")("Invoke PrintCardImmediately");
 	m_pEntity->PrintCardImmediately(ctx);
 }
 void CardReadAdapterServerSession::Handle_QueryCIStatus(SpReqAnsContext<CardReadAdapterService_QueryCIStatus_Req, CardReadAdapterService_QueryCIStatus_Ans>::Pointer ctx)
@@ -199,7 +229,7 @@ void CCardReadAdapterEntity::OnBroadcastEvent(CUUID SubID, const char *pszEntity
 	if (dwMessageSignature != eMsgSig_FetchCard && dwMessageSignature != eMsgSig_SCIConnect && dwMessageSignature != eMsgSig_ConnectStatus)
 		return;
 
-	DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("msg:%s,%d,%d",pszEntityName,dwMessageId,dwMessageSignature);
+	DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("OnBroadcastEvent,msg:%s,%d,%d",pszEntityName,dwMessageId,dwMessageSignature);
 	if (_strnicmp(pszEntityName, "CardIssuer", strlen("CardIssuer")) == 0)
 	{
 		if (dwMessageSignature == eMsgSig_FetchCard)

File diff suppressed because it is too large
+ 316 - 265
Module/mod_cardissuer/CardIssuerFSM.cpp


File diff suppressed because it is too large
+ 289 - 274
Module/mod_cardissuer/CardIssuerFSM.h


+ 13 - 16
Module/mod_cardissuer/CardIssuer_UserErrorCode.h

@@ -41,19 +41,12 @@
 #define CardIssuer_UserErrorCode_Adapter_Version					(CardIssuer_UserErrorCode_Start + 34)//告警适配器版本号(长城卡库是将驱动版本号告警上来)
 #define CardIssuer_UserErrorCode_DevOpenTime						(CardIssuer_UserErrorCode_Start + 35) //统计DevOpen时长
 
-#define CardIssuer_UserErrorCode_DevOpenFailed_Insert				(CardIssuer_UserErrorCode_Start + 36) //设备打开失败(Insert调用)
-#define CardIssuer_UserErrorCode_DevOpenFailed_Read				(CardIssuer_UserErrorCode_Start + 37) //设备打开失败(Read调用)
-#define CardIssuer_UserErrorCode_DevOpenFailed_ReadEx				(CardIssuer_UserErrorCode_Start + 38) //设备打开失败(ReadEx调用)
-#define CardIssuer_UserErrorCode_DevOpenFailed_Capture				(CardIssuer_UserErrorCode_Start + 39) //设备打开失败(Capture调用)
-#define CardIssuer_UserErrorCode_DevOpenFailed_Eject				(CardIssuer_UserErrorCode_Start + 40) //设备打开失败(Eject调用)
-#define CardIssuer_UserErrorCode_DevOpenFailed_Issue				(CardIssuer_UserErrorCode_Start + 41) //设备打开失败(Issue调用)
-#define CardIssuer_UserErrorCode_DevOpenFailed_IssueEx				(CardIssuer_UserErrorCode_Start + 42) //设备打开失败(IssueEx调用)
-#define CardIssuer_UserErrorCode_DevOpenFailed_PreOnline				(CardIssuer_UserErrorCode_Start + 43) //设备打开失败(PreOnline调用)
-#define CardIssuer_UserErrorCode_DevOpenFailed_PostOnline				(CardIssuer_UserErrorCode_Start + 44) //设备打开失败(PostOnline调用)OpenSafeLock
-#define CardIssuer_UserErrorCode_DevOpenFailed_OpenSafeLock				(CardIssuer_UserErrorCode_Start + 45) //设备打开失败(OpenSafeLock调用)
-#define CardIssuer_UserErrorCode_DevOpenFailed_SAMICCommand				(CardIssuer_UserErrorCode_Start + 46) //设备打开失败(SAMICCommand调用)
-#define CardIssuer_UserErrorCode_DevOpenFailed_PrintCardImmediately				(CardIssuer_UserErrorCode_Start + 47) //设备打开失败(PrintCardImmediately调用)
-#define CardIssuer_UserErrorCode_DevOpenFailed_Print				(CardIssuer_UserErrorCode_Start + 48) //设备打开失败(Print调用)
+#define CardIssuer_UserErrorCode_CaptureCard_OnExit					(CardIssuer_UserErrorCode_Start + 36) //OnExit时吞卡,实体退出。实际上会吗?
+#define CardIssuer_UserErrorCode_CaptureCard_Reset					(CardIssuer_UserErrorCode_Start + 37) //Reset时吞卡
+#define CardIssuer_UserErrorCode_CaptureCard_IssueExit				(CardIssuer_UserErrorCode_Start + 38) //发卡时业务强退
+#define CardIssuer_UserErrorCode_CaptureCard_IdleExit				(CardIssuer_UserErrorCode_Start + 39) //Idle空闲状态处理Exit事件时吞卡
+#define CardIssuer_UserErrorCode_CaptureCard_FromBusiness			(CardIssuer_UserErrorCode_Start + 40) //业务主动发起调用CaptureCard
+
 
 #define CardIssuer_UserErrorCode_CardStore_SlotNum					(CardIssuer_UserErrorCode_Start + 49) //记录卡库容量
 #define CardIssuer_UserErrorCode_Invoke_Access_IniDev_Failed		(CardIssuer_UserErrorCode_Start + 50) //建立加密通道时,调用准入接口失败
@@ -153,15 +146,18 @@
 //预留一部分用于CardAssist.cpp中的报错告警
 //自CardIssuer_UserErrorCode_Start + 121 ~ CardIssuer_UserErrorCode_Start + 140
 #define CardIssuer_UserErrorCode_ICCommand_RecvData_Invalid			(CardIssuer_UserErrorCode_Start + 121)	//APDU接收到的数据无效
-
+#define CardIssuer_UserErrorCode_ActiveContactlessICCard_Failed		(CardIssuer_UserErrorCode_Start + 122)	//激活非接失败
 //
 #define CardIssuer_UserErrorCode_Open_Success						(CardIssuer_UserErrorCode_Start + 141)	//读卡器最终打开成功
 #define CardIssuer_UserErrorCode_Open_Failed						(CardIssuer_UserErrorCode_Start + 142)	//读卡器最终打开失败
 
-//盘库
+
 #define CardIssuer_UserErrorCode_QueryCardInfoOnStore_Inparam		(CardIssuer_UserErrorCode_Start + 143)	//盘库接口入参
+#define CardIssuer_UserErrorCode_CaptureCard_SignFailed				(CardIssuer_UserErrorCode_Start + 144)	//签发失败,业务发起吞卡
+#define CardIssuer_UserErrorCode_CaptureCard_IssueFromCardStore		(CardIssuer_UserErrorCode_Start + 145)	//卡库本地领卡吞卡
+#define CardIssuer_UserErrorCode_CaptureCard_AddCard_ReadFailed		(CardIssuer_UserErrorCode_Start + 146)	//卡库加卡,读卡失败吞卡
+#define CardIssuer_UserErrorCode_CaptureCard_Operate_ReadFailed		(CardIssuer_UserErrorCode_Start + 147)	//卡库盘库,读卡失败吞卡
 
-//加卡
 #define CardIssuer_UserErrorCode_GetAddCardInfo_CardCount			(CardIssuer_UserErrorCode_Start + 150)	//卡库中卡片数量
 
 //LogWarn real root config
@@ -182,4 +178,5 @@
 #define CardIssuer_UserErrorCode_CardActive_CardStore_Issuing		(CardIssuer_UserErrorCode_Start + 167)	//跨机时卡库正在本地领卡
 #define CardIssuer_UserErrorCode_CardActive_CardStore_CallByOther	(CardIssuer_UserErrorCode_Start + 168)	//跨机时卡库正在其他VTM调用
 #define CardIssuer_UserErrorCode_ReadAccount_Cost_Time				(CardIssuer_UserErrorCode_Start + 169)	//ReadAccount耗时
+#define CardIssuer_UserErrorCode_CardActive_CardIssuer_InFaultState	(CardIssuer_UserErrorCode_Start + 170)	//卡库收到跨机请求时卡机未成功打开
 #endif //_CARDISSUER_USER_ERRORCODE_H

+ 1 - 0
Module/mod_cardissuer/CardIssuer_client_g.h

@@ -32,6 +32,7 @@ public:
 	}
 	void OnClose(ErrorCodeEnum)
 	{
+		Dbg("session closed.");
 		bSessionClosed = true;
 	}
 	bool QuerySessionClosed()

+ 31 - 3
Module/mod_cardissuer/mod_cardissuer.cpp

@@ -13,49 +13,58 @@
 void CardIssuerServerSession::Handle_Insert(SpReqAnsContext<CardIssuerService_Insert_Req, CardIssuerService_Insert_Ans>::Pointer ctx)
 {
 	LOG_FUNCTION();
+	DbgWithLink(LOG_LEVEL_INFO, ctx->link.checkEmpty() ? LOG_TYPE_SYSTEM : LOG_TYPE_USER).setAPI("Insert")("Invoke Insert");
 	m_pEntity->Insert(ctx);
 }
 void CardIssuerServerSession::Handle_Read(SpReqAnsContext<CardIssuerService_Read_Req, CardIssuerService_Read_Ans>::Pointer ctx)
 {
 	LOG_FUNCTION();
+	DbgWithLink(LOG_LEVEL_INFO, ctx->link.checkEmpty() ? LOG_TYPE_SYSTEM : LOG_TYPE_USER).setAPI("Read")("Invoke Read");
 	m_pEntity->Read(ctx);
 }
 
 void CardIssuerServerSession::Handle_Capture(SpReqAnsContext<CardIssuerService_Capture_Req, CardIssuerService_Capture_Ans>::Pointer ctx)
 {
 	LOG_FUNCTION();
+	DbgWithLink(LOG_LEVEL_INFO, ctx->link.checkEmpty() ? LOG_TYPE_SYSTEM : LOG_TYPE_USER).setAPI("Capture")("Invoke Capture");
 	m_pEntity->Capture(ctx);
 }
 
 void CardIssuerServerSession::Handle_Eject(SpReqAnsContext<CardIssuerService_Eject_Req, CardIssuerService_Eject_Ans>::Pointer ctx)
 {
 	LOG_FUNCTION();
+	DbgWithLink(LOG_LEVEL_INFO, ctx->link.checkEmpty() ? LOG_TYPE_SYSTEM : LOG_TYPE_USER).setAPI("Eject")("Invoke Eject");
 	m_pEntity->Eject(ctx);
 }
 
 void CardIssuerServerSession::Handle_CancelInsert(SpOnewayCallContext<CardIssuerService_CancelInsert_Info>::Pointer ctx)
 {
 	LOG_FUNCTION();
+	DbgWithLink(LOG_LEVEL_INFO, ctx->link.checkEmpty() ? LOG_TYPE_SYSTEM : LOG_TYPE_USER).setAPI("CancelInsert")("Invoke CancelInsert");
 	m_pEntity->CancelInsert(ctx);
 }
 void CardIssuerServerSession::Handle_InsertWaitMore(SpOnewayCallContext<CardIssuerService_InsertWaitMore_Info>::Pointer ctx)
 {
 	LOG_FUNCTION();
+	DbgWithLink(LOG_LEVEL_INFO, ctx->link.checkEmpty() ? LOG_TYPE_SYSTEM : LOG_TYPE_USER).setAPI("InsertWaitMore")("Invoke InsertWaitMore");
 	m_pEntity->InsertWaitMore(ctx);
 }
 void CardIssuerServerSession::Handle_Issue(SpReqAnsContext<CardIssuerService_Issue_Req, CardIssuerService_Issue_Ans>::Pointer ctx)
 {
 	LOG_FUNCTION();
+	DbgWithLink(LOG_LEVEL_INFO, ctx->link.checkEmpty() ? LOG_TYPE_SYSTEM : LOG_TYPE_USER).setAPI("Issue")("Invoke Issue");
 	m_pEntity->Issue(ctx);
 }
 void CardIssuerServerSession::Handle_PreOnline(SpReqAnsContext<CardIssuerService_PreOnline_Req, CardIssuerService_PreOnline_Ans>::Pointer ctx)
 {
 	LOG_FUNCTION();
+	DbgWithLink(LOG_LEVEL_INFO, ctx->link.checkEmpty() ? LOG_TYPE_SYSTEM : LOG_TYPE_USER).setAPI("PreOnline")("Invoke PreOnline");
 	m_pEntity->PreOnline(ctx);
 }
 void CardIssuerServerSession::Handle_PostOnline(SpReqAnsContext<CardIssuerService_PostOnline_Req, CardIssuerService_PostOnline_Ans>::Pointer ctx)
 {
 	LOG_FUNCTION();
+	DbgWithLink(LOG_LEVEL_INFO, ctx->link.checkEmpty() ? LOG_TYPE_SYSTEM : LOG_TYPE_USER).setAPI("PostOnline")("Invoke PostOnline");
 	m_pEntity->PostOnline(ctx);
 }
 void CardIssuerServerSession::Handle_Exit(SpOnewayCallContext<CardIssuerService_Exit_Info>::Pointer ctx)
@@ -66,89 +75,103 @@ void CardIssuerServerSession::Handle_Exit(SpOnewayCallContext<CardIssuerService_
 void CardIssuerServerSession::Handle_GetMaterialCount(SpReqAnsContext<CardIssuerService_GetMaterialCount_Req, CardIssuerService_GetMaterialCount_Ans>::Pointer ctx)
 {
 	LOG_FUNCTION();
+	DbgWithLink(LOG_LEVEL_INFO, ctx->link.checkEmpty() ? LOG_TYPE_SYSTEM : LOG_TYPE_USER).setAPI("GetMaterialCount")("Invoke GetMaterialCount");
 	m_pEntity->GetMaterialCount(ctx);
 }
 
 void CardIssuerServerSession::Handle_SetMaterialCount(SpReqAnsContext<CardIssuerService_SetMaterialCount_Req, CardIssuerService_SetMaterialCount_Ans>::Pointer ctx)
 {
 	LOG_FUNCTION();
+	DbgWithLink(LOG_LEVEL_INFO, ctx->link.checkEmpty() ? LOG_TYPE_SYSTEM : LOG_TYPE_USER).setAPI("SetMaterialCount")("Invoke SetMaterialCount");
 	m_pEntity->SetMaterialCount(ctx);
 }
  void CardIssuerServerSession::Handle_SetIssueFlag(SpOnewayCallContext<CardIssuerService_SetIssueFlag_Info>::Pointer ctx)
 {
 	LOG_FUNCTION();
+	DbgWithLink(LOG_LEVEL_INFO, ctx->link.checkEmpty() ? LOG_TYPE_SYSTEM : LOG_TYPE_USER).setAPI("SetIssueFlag")("Invoke SetIssueFlag");
 	m_pEntity->SetIssueFlag(ctx);
 }
 void CardIssuerServerSession::Handle_ReadEx(SpReqAnsContext<CardIssuerService_ReadEx_Req, CardIssuerService_ReadEx_Ans>::Pointer ctx)
 {
 	LOG_FUNCTION();
+	DbgWithLink(LOG_LEVEL_INFO, ctx->link.checkEmpty() ? LOG_TYPE_SYSTEM : LOG_TYPE_USER).setAPI("ReadEx")("Invoke ReadEx");
 	ctx->Answer(Error_NotImpl);
 }
 void CardIssuerServerSession::Handle_QueryCardInfo(SpReqAnsContext<CardIssuerService_QueryCardInfo_Req, CardIssuerService_QueryCardInfo_Ans>::Pointer ctx)
 {
 	LOG_FUNCTION();
+	DbgWithLink(LOG_LEVEL_INFO, ctx->link.checkEmpty() ? LOG_TYPE_SYSTEM : LOG_TYPE_USER).setAPI("QueryCardInfo");
 	m_pEntity->QueryCardInfo(ctx);
 }
 void CardIssuerServerSession::Handle_WriteTrack(SpReqAnsContext<CardIssuerService_WriteTrack_Req, CardIssuerService_WriteTrack_Ans>::Pointer ctx)
 {
 	LOG_FUNCTION();
+	DbgWithLink(LOG_LEVEL_INFO, ctx->link.checkEmpty() ? LOG_TYPE_SYSTEM : LOG_TYPE_USER).setAPI("WriteTrack")("Invoke WriteTrack");
 	m_pEntity->WriteTrack(ctx);
 }
 void CardIssuerServerSession::Handle_GetMaterialCountEx(SpReqAnsContext<CardIssuerService_GetMaterialCountEx_Req, CardIssuerService_GetMaterialCountEx_Ans>::Pointer ctx)
 {
 	LOG_FUNCTION();
+	DbgWithLink(LOG_LEVEL_INFO, ctx->link.checkEmpty() ? LOG_TYPE_SYSTEM : LOG_TYPE_USER).setAPI("GetMaterialCountEx")("Invoke GetMaterialCountEx");
 	m_pEntity->GetMaterialCountEx(ctx);
 }
 void CardIssuerServerSession::Handle_SetMaterialCountEx(SpReqAnsContext<CardIssuerService_SetMaterialCountEx_Req, CardIssuerService_SetMaterialCountEx_Ans>::Pointer ctx)
 {
-	DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER)("Handle_SetMaterialCountEx");
 	LOG_FUNCTION();
+	DbgWithLink(LOG_LEVEL_INFO, ctx->link.checkEmpty() ? LOG_TYPE_SYSTEM : LOG_TYPE_USER).setAPI("SetMaterialCountEx")("Invoke SetMaterialCountEx");
 	m_pEntity->SetMaterialCountEx(ctx);
 }
 void CardIssuerServerSession::Handle_SetSomeFlag(SpReqAnsContext<CardIssuerService_SetSomeFlag_Req, CardIssuerService_SetSomeFlag_Ans>::Pointer ctx)
 {
 	LOG_FUNCTION();
+	DbgWithLink(LOG_LEVEL_INFO, ctx->link.checkEmpty() ? LOG_TYPE_SYSTEM : LOG_TYPE_USER).setAPI("SetSomeFlag");
 	m_pEntity->SetSomeFlag(ctx);
 }
 void CardIssuerServerSession::Handle_GetSCIInfo(SpReqAnsContext<CardIssuerService_GetSCIInfo_Req, CardIssuerService_GetSCIInfo_Ans>::Pointer ctx)
 {
 	LOG_FUNCTION();
+	DbgWithLink(LOG_LEVEL_INFO, ctx->link.checkEmpty() ? LOG_TYPE_SYSTEM : LOG_TYPE_USER).setAPI("GetSCIInfo")("Invoke GetSCIInfo");
 	m_pEntity->GetSCIInfo(ctx);
 }
 void CardIssuerServerSession::Handle_IssueEx(SpReqAnsContext<CardIssuerService_IssueEx_Req, CardIssuerService_IssueEx_Ans>::Pointer ctx)
 {
 	LOG_FUNCTION();
+	DbgWithLink(LOG_LEVEL_INFO, ctx->link.checkEmpty() ? LOG_TYPE_SYSTEM : LOG_TYPE_USER).setAPI("IssueEx")("Invoke IssueEx");
 	m_pEntity->IssueEx(ctx);
 }
 void CardIssuerServerSession::Handle_OpenSafeLock(SpReqAnsContext<CardIssuerService_OpenSafeLock_Req, CardIssuerService_OpenSafeLock_Ans>::Pointer ctx)
 {
 	LOG_FUNCTION();
-	m_pEntity->OpenSafeLock(ctx);
+	ctx->Answer(Error_NotImpl);
 }
 void CardIssuerServerSession::Handle_SAMICCommand(SpReqAnsContext<CardIssuerService_SAMICCommand_Req, CardIssuerService_SAMICCommand_Ans>::Pointer ctx)
 {
+	DbgWithLink(LOG_LEVEL_INFO, ctx->link.checkEmpty() ? LOG_TYPE_SYSTEM : LOG_TYPE_USER).setAPI("SAMICCommand")("Invoke SAMICCommand");
 	m_pEntity->SAMICCommand(ctx);
 }
 void CardIssuerServerSession::Handle_QueryPrinterStatus(SpReqAnsContext<CardIssuerService_QueryPrinterStatus_Req, CardIssuerService_QueryPrinterStatus_Ans>::Pointer ctx)
 {
+	DbgWithLink(LOG_LEVEL_INFO, ctx->link.checkEmpty() ? LOG_TYPE_SYSTEM : LOG_TYPE_USER).setAPI("QueryPrinterStatus")("Invoke QueryPrinterStatus");
 	m_pEntity->QueryPrinterStatus(ctx);
 }
 void CardIssuerServerSession::Handle_Print(SpReqAnsContext<CardIssuerService_Print_Req, CardIssuerService_Print_Ans>::Pointer ctx)
 {
 	LOG_FUNCTION();
+	DbgWithLink(LOG_LEVEL_INFO, ctx->link.checkEmpty() ? LOG_TYPE_SYSTEM : LOG_TYPE_USER).setAPI("Print")("Invoke Print");
 	m_pEntity->Print(ctx);
 }
 void CardIssuerServerSession::Handle_QuerySCIList(SpReqAnsContext<CardIssuerService_QuerySCIList_Req, CardIssuerService_QuerySCIList_Ans>::Pointer ctx)
 {
 	LOG_FUNCTION();
+	DbgWithLink(LOG_LEVEL_INFO, ctx->link.checkEmpty() ? LOG_TYPE_SYSTEM : LOG_TYPE_USER).setAPI("QuerySCIList")("Invoke QuerySCIList");
 	m_pEntity->QuerySCIList(ctx);
 }
 void CardIssuerServerSession::Handle_BindSCI(SpReqAnsContext<CardIssuerService_BindSCI_Req, CardIssuerService_BindSCI_Ans>::Pointer ctx)
 {
 	LOG_FUNCTION();
+	DbgWithLink(LOG_LEVEL_INFO, ctx->link.checkEmpty() ? LOG_TYPE_SYSTEM : LOG_TYPE_USER).setAPI("BindSCI")("req.type = %d, req.sciNo:%s", ctx->Req.type, ctx->Req.sciNo.GetData());
 	CSimpleStringA tmpSCINo("");
 	m_pEntity->GetSCINo(tmpSCINo);
-	DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER)("type:%d",ctx->Req.type);
 	if ((ctx->Req.type == 2 && tmpSCINo.Compare(ctx->Req.sciNo) == 0) || (ctx->Req.type == 4 && tmpSCINo.GetLength() < 2))
 		ctx->Answer(Error_Succeed);
 	else
@@ -160,26 +183,31 @@ void CardIssuerServerSession::Handle_BindSCI(SpReqAnsContext<CardIssuerService_B
 void CardIssuerServerSession::Handle_PreOnlineOnStore(SpReqAnsContext<CardIssuerService_PreOnlineOnStore_Req, CardIssuerService_PreOnlineOnStore_Ans>::Pointer ctx)
 {
 	LOG_FUNCTION();
+	DbgWithLink(LOG_LEVEL_INFO, ctx->link.checkEmpty() ? LOG_TYPE_SYSTEM : LOG_TYPE_USER).setAPI("PreOnlineOnStore")("Invoke PreOnlineOnStore");
 	m_pEntity->PreOnlineOnStore(ctx);
 }
 void CardIssuerServerSession::Handle_NotifyPreonline(SpReqAnsContext<CardIssuerService_NotifyPreonline_Req, CardIssuerService_NotifyPreonline_Ans>::Pointer ctx)
 {
 	LOG_FUNCTION();
+	DbgWithLink(LOG_LEVEL_INFO, ctx->link.checkEmpty() ? LOG_TYPE_SYSTEM : LOG_TYPE_USER).setAPI("NotifyPreonline")("Invoke NotifyPreonline");
 	m_pEntity->NotifyPreonline(ctx);
 }
 void CardIssuerServerSession::Handle_QueryCardInfoOnStore(SpReqAnsContext<CardIssuerService_QueryCardInfoOnStore_Req, CardIssuerService_QueryCardInfoOnStore_Ans>::Pointer ctx)
 {
 	LOG_FUNCTION();
+	DbgWithLink(LOG_LEVEL_INFO, ctx->link.checkEmpty() ? LOG_TYPE_SYSTEM : LOG_TYPE_USER).setAPI("QueryCardInfoOnStore")("Invoke QueryCardInfoOnStore");
 	m_pEntity->QueryCardInfoOnStore(ctx);
 }
 void CardIssuerServerSession::Handle_GetAddCardInfo(SpReqAnsContext<CardIssuerService_GetAddCardInfo_Req, CardIssuerService_GetAddCardInfo_Ans>::Pointer ctx)
 {
 	LOG_FUNCTION();
+	DbgWithLink(LOG_LEVEL_INFO, ctx->link.checkEmpty() ? LOG_TYPE_SYSTEM : LOG_TYPE_USER).setAPI("GetAddCardInfo")("Invoke GetAddCardInfo");
 	m_pEntity->GetAddCardInfo(ctx);
 }
 void CardIssuerServerSession::Handle_PrintCardImmediately(SpReqAnsContext<CardIssuerService_PrintCardImmediately_Req, CardIssuerService_PrintCardImmediately_Ans>::Pointer ctx)
 {
 	LOG_FUNCTION();
+	DbgWithLink(LOG_LEVEL_INFO, ctx->link.checkEmpty() ? LOG_TYPE_SYSTEM : LOG_TYPE_USER).setAPI("PrintCardImmediately")("Invoke PrintCardImmediately");
 	m_pEntity->PrintCardImmediately(ctx);
 }
 void CardIssuerServerSession::Handle_QueryCIStatus(SpReqAnsContext<CardIssuerService_QueryCIStatus_Req, CardIssuerService_QueryCIStatus_Ans>::Pointer ctx)

+ 19 - 55
Module/mod_cardissuer/mod_cardissuer.h

@@ -1,9 +1,9 @@
 #include "CardIssuer_server_g.h"
 #include "CardIssuer_def_g.h"
 #include "CardIssuerFSM.h"
+#include "DevEntityCommBase.hpp"
 using namespace CardIssuer;
 
-//#pragma comment(lib,"CardIssuer.lib")
 class CCardIssuerEntity;
 
 class CardIssuerServerSession : public CardIssuerService_ServerSessionBase
@@ -49,27 +49,23 @@ private:
 	CCardIssuerEntity* m_pEntity;
 };
 
-class CCardIssuerEntity : public CDevAdptEntityBase,public ISysVarListener
+class CCardIssuerEntity : public CDevAdptEntityBase, public ISysVarListener
 {
 public:
 	CCardIssuerEntity() :bInitialized(false)
 	{
-		//MessageBoxA(NULL, "", "", MB_OK);
 	}
 	virtual ~CCardIssuerEntity(){}
 	virtual const char *GetEntityName() const { return "CardIssuer"; }
 	virtual void OnPreStart(CAutoArray<CSimpleStringA> strArgs,CSmartPointer<ITransactionContext> pTransactionContext) 
 	{ 
 		LOG_FUNCTION();
-		//MessageBoxA(0,0,0,0);
 		ErrorCodeEnum eStart = m_fsm.Init(this);
 		if (eStart == Error_Succeed)
 		{
 		}
 		GetFunction()->RegistSysVarEvent("UIState", this);
 		pTransactionContext->SendAnswer(eStart);
-		//ErrorCodeEnum Error = __OnStart(Error_Succeed);
-		//pTransactionContext->SendAnswer(Error);
 	}
 
 	virtual void OnPreClose(EntityCloseCauseEnum eCloseCause,CSmartPointer<ITransactionContext> pTransactionContext) 
@@ -84,7 +80,7 @@ public:
 		pTransactionContext->SendAnswer(Error); 
 	}
 	virtual ErrorCodeEnum __OnStart(ErrorCodeEnum preOperationError)
-	{
+	{	
 		return Error_Succeed;
 	}
 	virtual ErrorCodeEnum __OnPause(ErrorCodeEnum preOperationError, CSmartPointer<ITransactionContext> pTransactionContext)
@@ -105,19 +101,17 @@ public:
 		m_bNewSessionInit = true;
 		return new CardIssuerServerSession(this);
 	}
-	
+
 	void Insert(SpReqAnsContext<CardIssuerService_Insert_Req, CardIssuerService_Insert_Ans>::Pointer ctx)
 	{
 		LOG_FUNCTION();
-		if (!m_fsm.GetDevInitFlag()) {
-			ctx->Answer(Error_DevNotAvailable);
-			LogWarn(Severity_Middle, Error_DevNotAvailable, CardIssuer_UserErrorCode_DevOpenFailed_Insert, "Insert but DevOpen failed.");
-		}
-		else
-		{
+		if(!m_fsm.GetDevInitFlag()){
+			ctx->Answer(Error_DevNotAvailable, CardIssuer_UserErrorCode_DevOpen_Failed);
+			LogWarn(Severity_Middle, Error_DevNotAvailable, CardIssuer_UserErrorCode_DevOpen_Failed, "Insert but DevOpen failed.");
+		}else{
 			m_bNewSessionInit = false;
 			m_fsm.SetExitFlag(false);
-			CardAcceptEvent* e = new CardAcceptEvent();
+			CardAcceptEvent *e = new CardAcceptEvent();
 			e->ctx = ctx;
 			m_fsm.PostEventFIFO(e);
 		}
@@ -169,7 +163,7 @@ public:
 	{
 		LOG_FUNCTION();
 		if (!m_fsm.GetDevInitFlag()) {
-			ctx->Answer(Error_DevNotAvailable);
+			ctx->Answer(Error_DevNotAvailable, CardIssuer_UserErrorCode_DevOpen_Failed);
 		}
 		else {
 			if (ctx->Req.reserved1.GetLength() > 0 && strnicmp("kaku#", (const char*)ctx->Req.reserved1, 5) == 0)
@@ -313,7 +307,7 @@ public:
 	{
 		LOG_FUNCTION();
 		if (!m_fsm.GetDevInitFlag()) {
-			ctx->Answer(Error_DevNotAvailable);
+			ctx->Answer(Error_DevNotAvailable, CardIssuer_UserErrorCode_DevOpen_Failed);
 		}
 		else {
 			m_bNewSessionInit = false;
@@ -324,9 +318,6 @@ public:
 	}
 	void OpenSafeLock(SpReqAnsContext<CardIssuerService_OpenSafeLock_Req, CardIssuerService_OpenSafeLock_Ans>::Pointer ctx)
 	{
-		OpenSafeLockEvent *pEvt = new OpenSafeLockEvent();
-		pEvt->ctx = ctx;
-		m_fsm.PostEventFIFO(pEvt);
 	}
 	void SAMICCommand(SpReqAnsContext<CardIssuerService_SAMICCommand_Req, CardIssuerService_SAMICCommand_Ans>::Pointer ctx)
 	{
@@ -372,7 +363,7 @@ public:
 	void QueryCardInfoOnStore(SpReqAnsContext<CardIssuerService_QueryCardInfoOnStore_Req, CardIssuerService_QueryCardInfoOnStore_Ans>::Pointer ctx)
 	{
 		if (!m_fsm.GetDevInitFlag()) {
-			ctx->Answer(Error_DevNotAvailable);
+			ctx->Answer(Error_DevNotAvailable, CardIssuer_UserErrorCode_DevOpen_Failed);
 		}
 		else
 		{
@@ -383,7 +374,13 @@ public:
 	}
 	void GetAddCardInfo(SpReqAnsContext<CardIssuerService_GetAddCardInfo_Req, CardIssuerService_GetAddCardInfo_Ans>::Pointer ctx)
 	{
-		m_fsm.GetAddCardInfo(ctx);
+		if (!m_fsm.GetDevInitFlag()) {
+			ctx->Answer(Error_DevNotAvailable, CardIssuer_UserErrorCode_DevOpen_Failed);
+		}
+		else
+		{
+			m_fsm.GetAddCardInfo(ctx);
+		}
 	}
 	void PrintCardImmediately(SpReqAnsContext<CardIssuerService_PrintCardImmediately_Req, CardIssuerService_PrintCardImmediately_Ans>::Pointer ctx)
 	{
@@ -411,40 +408,7 @@ public:
 	virtual bool IsMultiThread()const{return true;}
 protected:
 private:
-	CardIssuerClass* m_pCardIss;
 	CCardIssuerFSM m_fsm;
 	
 	bool bInitialized,m_bNewSessionInit;
-	//LONG m_lenAPDU;
-	//BYTE m_APDUsendBuf[512];
-
-private:
-//	void ConstructAPDU(BYTE cls,BYTE ins,BYTE p1,BYTE p2,BYTE lc,LPBYTE data,LPBYTE le)
-//{
-//	LOG_FUNCTION();
-//	m_lenAPDU = 0;
-//	m_APDUsendBuf[0] = cls;
-//	m_APDUsendBuf[1] = ins;
-//	m_APDUsendBuf[2] = p1;
-//	m_APDUsendBuf[3] = p2;
-//	m_lenAPDU = 4;
-//	if (lc != NULL && data != NULL)
-//	{
-//		m_APDUsendBuf[4] = lc;
-//		m_lenAPDU++;
-//		if (lc != 0)
-//		{
-//			memcpy(m_APDUsendBuf+m_lenAPDU,data,lc);
-//			m_lenAPDU += lc;
-//		}
-//	}
-//	if (le != NULL)
-//		m_APDUsendBuf[m_lenAPDU++] = (*le);
-//	if (!data)
-//	{
-//		delete[] data;
-//		data = NULL;
-//	}
-//	Dbg("cmd len[%d]",m_lenAPDU);
-//}
 };

Some files were not shown because too many files changed in this diff