|
|
@@ -152,23 +152,6 @@ unsigned int CCardReadAdapterFSM::s2_on_event(FSMEvent* pEvt)
|
|
|
DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER)("ReadTask to ContactlessCard");
|
|
|
}
|
|
|
}
|
|
|
- //oilyang@20200730 according to meeting with Ratail/Test/Hangzhou
|
|
|
- //Desk2S 2.1 have no CardSwiper,so no need call it
|
|
|
- if (!(m_eMachineType == SP::Module::Comm::RVC_Stand2S
|
|
|
- || m_eMachineType == SP::Module::Comm::RVC_CardStore
|
|
|
- || m_eMachineType == SP::Module::Comm::RVC_CardPrinter
|
|
|
- || m_eMachineType == SP::Module::Comm::RVC_Stand1SPlus
|
|
|
- || (m_eMachineType == SP::Module::Comm::RVC_Desk2S && m_majorVerion == 2 && m_minorVerion == 1)))
|
|
|
- {
|
|
|
- CardSwiperReadTask* sTask = new CardSwiperReadTask(this);
|
|
|
- sTask->ctx = cre->ctx;
|
|
|
- if (IsTheEntity(cre->ctx->Req.module, Module_CardSwiper) && IsCardSwiperSessionOK())
|
|
|
- {
|
|
|
- bCardSwiper = true;
|
|
|
- GetEntityBase()->GetFunction()->PostThreadPoolTask(sTask);
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER)("ReadTask to CardSwiper");
|
|
|
- }
|
|
|
- }
|
|
|
//oilyang@20200426 暂时未发现这行代码的用处,可能简版?后来废弃。暂时保留,后续考虑去掉
|
|
|
if ((cre->ctx->Req.reserved1.GetCount() == 0 || cre->ctx->Req.reserved1[0] != 1))//except for cross call
|
|
|
{
|
|
|
@@ -495,8 +478,6 @@ unsigned int CCardReadAdapterFSM::s3_on_event(FSMEvent* pEvt)
|
|
|
DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("ContactlessCard Timeout,need to cancel CardIssuer insert");
|
|
|
if (IsCardIssuerSessionOK())
|
|
|
(*m_pCardIssuer)(EntityResource::getLink().upgradeLink())->CancelInsert();
|
|
|
- if (IsCardSwiperSessionOK())
|
|
|
- (*m_pCardSwiper)(EntityResource::getLink().upgradeLink())->CancelInsert();
|
|
|
crfe->ctx->Answer(Error_TimeOut);
|
|
|
ret = 0;
|
|
|
break;
|
|
|
@@ -515,24 +496,12 @@ unsigned int CCardReadAdapterFSM::s3_on_event(FSMEvent* pEvt)
|
|
|
DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("as card in ContactlessCard,to cancel others");
|
|
|
if (IsCardIssuerSessionOK())
|
|
|
(*m_pCardIssuer)(EntityResource::getLink().upgradeLink())->CancelInsert();
|
|
|
- if (IsCardSwiperSessionOK())
|
|
|
- (*m_pCardSwiper)(EntityResource::getLink().upgradeLink())->CancelInsert();
|
|
|
}
|
|
|
else if (m_busCtx.eCardFromWhich == Card_In_CardIssuer)
|
|
|
{
|
|
|
DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("as card in CardIssuer,to cancel others");
|
|
|
if (IsContactlessCardSessionOK())
|
|
|
(*m_pContactless)(EntityResource::getLink().upgradeLink())->CancelInsert();
|
|
|
- if (IsCardSwiperSessionOK())
|
|
|
- (*m_pCardSwiper)(EntityResource::getLink().upgradeLink())->CancelInsert();
|
|
|
- }
|
|
|
- else if (m_busCtx.eCardFromWhich == Card_In_CardSwiper)
|
|
|
- {
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("as card in CardSwiper,to cancel others");
|
|
|
- if (IsCardIssuerSessionOK())
|
|
|
- (*m_pCardIssuer)(EntityResource::getLink().upgradeLink())->CancelInsert();
|
|
|
- if (IsContactlessCardSessionOK())
|
|
|
- (*m_pContactless)(EntityResource::getLink().upgradeLink())->CancelInsert();
|
|
|
}
|
|
|
return ret;
|
|
|
}
|
|
|
@@ -1043,153 +1012,155 @@ int CCardReadAdapterFSM::IssueCard(SpReqAnsContext<CardReadAdapterService_Issue_
|
|
|
}
|
|
|
int CCardReadAdapterFSM::CardSwiperRead(SpReqAnsContext<CardReadAdapterService_Read_Req, CardReadAdapterService_Read_Ans>::Pointer ctx,int &eRetErr)
|
|
|
{
|
|
|
- if (m_bCancelAccept || (m_busCtx.eCardFromWhich == Card_In_CardIssuer || m_busCtx.eCardFromWhich == Card_In_ContactlessCard))
|
|
|
- {
|
|
|
- char msg[128];
|
|
|
- memset(msg, 0, 128);
|
|
|
- sprintf(msg, "Maybe the thread pool is wrong.CardSwiperRead,bCancel:%d,cardpos:%d", m_bCancelAccept, m_busCtx.eCardFromWhich);
|
|
|
- LogWarn(Severity_Middle, Error_NotInit, CardReadAdapter_UserErrorCode_MayBe_ThreadPool_Wrong, msg);
|
|
|
- return 3;
|
|
|
- }
|
|
|
- ErrorCodeEnum eErr = Error_Unexpect;
|
|
|
+ //if (m_bCancelAccept || (m_busCtx.eCardFromWhich == Card_In_CardIssuer || m_busCtx.eCardFromWhich == Card_In_ContactlessCard))
|
|
|
+ //{
|
|
|
+ // char msg[128];
|
|
|
+ // memset(msg, 0, 128);
|
|
|
+ // sprintf(msg, "Maybe the thread pool is wrong.CardSwiperRead,bCancel:%d,cardpos:%d", m_bCancelAccept, m_busCtx.eCardFromWhich);
|
|
|
+ // LogWarn(Severity_Middle, Error_NotInit, CardReadAdapter_UserErrorCode_MayBe_ThreadPool_Wrong, msg);
|
|
|
+ // return 3;
|
|
|
+ //}
|
|
|
+ //ErrorCodeEnum eErr = Error_Unexpect;
|
|
|
|
|
|
- DWORD elapsed = 0;
|
|
|
- DWORD dwStart = GetTickCountRVC();
|
|
|
- DWORD dwEnd = GetTickCountRVC();
|
|
|
- while (elapsed + ReadCard_Min_Time < ReadCard_TIMEOUT)//要给Read和PreOnline两阶段 至少预留12s左右
|
|
|
- {
|
|
|
- if (IsTheEntity(ctx->Req.module, Module_CardSwiper) && IsCardSwiperSessionOK())
|
|
|
- {
|
|
|
- CardSwiperService_Read_Req req;
|
|
|
- CardSwiperService_Read_Ans ans;
|
|
|
- req.aid = ctx->Req.aid;
|
|
|
- req.LightPos = 0;
|
|
|
- if (ctx->Req.lightPos == 0)
|
|
|
- req.LightPos = 7;
|
|
|
- if ((ctx->Req.lightPos&LightPos_CardSwiper_Mag) == LightPos_CardSwiper_Mag)
|
|
|
- req.LightPos += 1;
|
|
|
- if ((ctx->Req.lightPos&LightPos_CardSwiper_IC) == LightPos_CardSwiper_IC)
|
|
|
- req.LightPos += 2;
|
|
|
- if ((ctx->Req.lightPos&LightPos_CardSwiper_RFIC) == LightPos_CardSwiper_RFIC)
|
|
|
- req.LightPos += 4;
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)(CSimpleStringA::Format("CardSwiperRead, aid:%s,lightPos:%d",(const char*)req.aid,req.LightPos));
|
|
|
+ //DWORD elapsed = 0;
|
|
|
+ //DWORD dwStart = GetTickCountRVC();
|
|
|
+ //DWORD dwEnd = GetTickCountRVC();
|
|
|
+ //while (elapsed + ReadCard_Min_Time < ReadCard_TIMEOUT)//要给Read和PreOnline两阶段 至少预留12s左右
|
|
|
+ //{
|
|
|
+ // if (IsTheEntity(ctx->Req.module, Module_CardSwiper) && IsCardSwiperSessionOK())
|
|
|
+ // {
|
|
|
+ // CardSwiperService_Read_Req req;
|
|
|
+ // CardSwiperService_Read_Ans ans;
|
|
|
+ // req.aid = ctx->Req.aid;
|
|
|
+ // req.LightPos = 0;
|
|
|
+ // if (ctx->Req.lightPos == 0)
|
|
|
+ // req.LightPos = 7;
|
|
|
+ // if ((ctx->Req.lightPos&LightPos_CardSwiper_Mag) == LightPos_CardSwiper_Mag)
|
|
|
+ // req.LightPos += 1;
|
|
|
+ // if ((ctx->Req.lightPos&LightPos_CardSwiper_IC) == LightPos_CardSwiper_IC)
|
|
|
+ // req.LightPos += 2;
|
|
|
+ // if ((ctx->Req.lightPos&LightPos_CardSwiper_RFIC) == LightPos_CardSwiper_RFIC)
|
|
|
+ // req.LightPos += 4;
|
|
|
+ // 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)(EntityResource::getLink().upgradeLink())->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)(EntityResource::getLink().upgradeLink())->CancelInsert();
|
|
|
- if (IsContactlessCardSessionOK())
|
|
|
- (*m_pContactless)(EntityResource::getLink().upgradeLink())->CancelInsert();
|
|
|
- ctx->Ans.track1 = ans.track1;
|
|
|
- ctx->Ans.track2 = ans.track2;
|
|
|
- ctx->Ans.track3 = ans.track3;
|
|
|
- if (ans.ICType == 5)//oilyang@20170204 如果插错卡,反馈为未检测到(有效)卡
|
|
|
- ctx->Ans.ICType = 0;
|
|
|
- else if (ans.ICType == 6)//身份证
|
|
|
- ctx->Ans.ICType = 5;
|
|
|
- else
|
|
|
- ctx->Ans.ICType = ans.ICType;
|
|
|
- ctx->Ans.ICCardNo = ans.ICData;
|
|
|
- ctx->Ans.status = ans.status;
|
|
|
- if (ans.CardPos == 2 || ans.CardPos == 5)
|
|
|
- ctx->Ans.cardPos = CardPos_CardSwiper_IC_Insert;
|
|
|
- else if (ans.CardPos == 4 || ans.CardPos == 6)
|
|
|
- ctx->Ans.cardPos = CardPos_CardSwiper_RFIC;
|
|
|
- else
|
|
|
- ctx->Ans.cardPos = ans.CardPos;
|
|
|
- ctx->Ans.t2Account = ans.t2Account;
|
|
|
- ctx->Ans.t2Region = ans.t2Region;
|
|
|
- ctx->Ans.t2CardSerial = ans.t2CardSerial;
|
|
|
- ctx->Ans.t2CVC = ans.t2CVC;
|
|
|
- ctx->Ans.t2ExpireDate = ans.t2ExpireDate;
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)(CSimpleStringA::Format("ICType:%d,%d, accountNo:%s****%s", ctx->Ans.ICType, ans.ICType,
|
|
|
- (const char*)ctx->Ans.t2Account.SubString(0, 4), (const char*)ctx->Ans.t2Account.SubString(ctx->Ans.t2Account.GetLength() - 4, 4)));
|
|
|
- if (ans.ICType == 3 || ans.ICType == 4)
|
|
|
- {
|
|
|
- CardSwiperService_PreOnline_Req req;
|
|
|
- CardSwiperService_PreOnline_Ans ans;
|
|
|
- req.businessData = ctx->Req.businessData;
|
|
|
- BroadcastReadICing(0);
|
|
|
- dwEnd = GetTickCountRVC();
|
|
|
- DWORD elapse1 = ReadCard_TIMEOUT - (dwEnd-dwStart);
|
|
|
- if(elapse1 < 10000)//PreOnline较慢,预留一定时间
|
|
|
- {
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("There is no more time to invoke PreOnline");
|
|
|
- ctx->Ans.result = "";
|
|
|
- return 9;
|
|
|
- }
|
|
|
- dwUserCode = 0;
|
|
|
- eErr = (*m_pCardSwiper)(EntityResource::getLink().upgradeLink())->PreOnline(req, ans, elapse1, dwUserCode);
|
|
|
- if (eErr == Error_Succeed)
|
|
|
- {
|
|
|
- ctx->Ans.result = ans.result;
|
|
|
- }
|
|
|
- else if(eErr == Error_Interact){
|
|
|
- if(m_eMachineType == SP::Module::Comm::RVC_Desk2S){
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("CardSwiper(RVC_Desk2S) return Error_Interact, no need loop.");
|
|
|
- ctx->Ans.result = "";
|
|
|
- ctx->Answer(Error_Unexpect, dwUserCode);
|
|
|
- return 0;
|
|
|
- }
|
|
|
- else
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("CardSwiper return Error_Interact, need loop.");
|
|
|
- dwEnd = GetTickCountRVC();
|
|
|
- elapsed = dwEnd - dwStart;
|
|
|
- Sleep(200);
|
|
|
- continue;
|
|
|
- }else{
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)(CSimpleStringA::Format("CardSwiper PreOnline failed return:%d", eErr));
|
|
|
- ctx->Ans.result = "";
|
|
|
- }
|
|
|
- }
|
|
|
- }else if(eErr == Error_Param){
|
|
|
- eErr = Error_Unexpect;
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("TrackData maybe some wrong");
|
|
|
- }else if(eErr == Error_Interact){
|
|
|
- if(m_eMachineType == SP::Module::Comm::RVC_Desk2S){
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("CardSwiper(RVC_Desk2S) return Error_Interact, no need loop.");
|
|
|
- return 9;//Maybe vendor's QueryCardStatus timeout
|
|
|
- }else{
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("CardSwiper ReadCard:ActiveContactlessICCard or ICCommand failed, need loop");
|
|
|
- dwEnd = GetTickCountRVC();
|
|
|
- elapsed = dwEnd - dwStart;
|
|
|
- Sleep(200);
|
|
|
- continue;
|
|
|
- }
|
|
|
- }else{
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)(CSimpleStringA::Format("CardSwiper Read failed return:%d", eErr));
|
|
|
- }
|
|
|
- if (eErr == Error_TimeOut)
|
|
|
- {
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("CardSwiper timeout.");
|
|
|
- return 9;
|
|
|
- }
|
|
|
- else if (eErr == Error_InvalidState)
|
|
|
- {
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("CardSwiper in error state.");
|
|
|
- return 1;
|
|
|
- }
|
|
|
- else{
|
|
|
- ctx->Answer(eErr, dwUserCode);
|
|
|
- return 0;
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)(CSimpleStringA::Format("can't find the corresponding Entity.req.Module:%d", ctx->Req.module));
|
|
|
- return 1;
|
|
|
- }
|
|
|
- break;
|
|
|
- }
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("no more time to loop again");
|
|
|
- return 9;
|
|
|
+ // DWORD dwUserCode = 0;
|
|
|
+ // m_busCtx.eCardProcStage = Card_ProcStage_WaitForCard;
|
|
|
+ // eErr = (*m_pCardSwiper)(EntityResource::getLink().upgradeLink())->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)(EntityResource::getLink().upgradeLink())->CancelInsert();
|
|
|
+ // if (IsContactlessCardSessionOK())
|
|
|
+ // (*m_pContactless)(EntityResource::getLink().upgradeLink())->CancelInsert();
|
|
|
+ // ctx->Ans.track1 = ans.track1;
|
|
|
+ // ctx->Ans.track2 = ans.track2;
|
|
|
+ // ctx->Ans.track3 = ans.track3;
|
|
|
+ // if (ans.ICType == 5)//oilyang@20170204 如果插错卡,反馈为未检测到(有效)卡
|
|
|
+ // ctx->Ans.ICType = 0;
|
|
|
+ // else if (ans.ICType == 6)//身份证
|
|
|
+ // ctx->Ans.ICType = 5;
|
|
|
+ // else
|
|
|
+ // ctx->Ans.ICType = ans.ICType;
|
|
|
+ // ctx->Ans.ICCardNo = ans.ICData;
|
|
|
+ // ctx->Ans.status = ans.status;
|
|
|
+ // if (ans.CardPos == 2 || ans.CardPos == 5)
|
|
|
+ // ctx->Ans.cardPos = CardPos_CardSwiper_IC_Insert;
|
|
|
+ // else if (ans.CardPos == 4 || ans.CardPos == 6)
|
|
|
+ // ctx->Ans.cardPos = CardPos_CardSwiper_RFIC;
|
|
|
+ // else
|
|
|
+ // ctx->Ans.cardPos = ans.CardPos;
|
|
|
+ // ctx->Ans.t2Account = ans.t2Account;
|
|
|
+ // ctx->Ans.t2Region = ans.t2Region;
|
|
|
+ // ctx->Ans.t2CardSerial = ans.t2CardSerial;
|
|
|
+ // ctx->Ans.t2CVC = ans.t2CVC;
|
|
|
+ // ctx->Ans.t2ExpireDate = ans.t2ExpireDate;
|
|
|
+ // DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)(CSimpleStringA::Format("ICType:%d,%d, accountNo:%s****%s", ctx->Ans.ICType, ans.ICType,
|
|
|
+ // (const char*)ctx->Ans.t2Account.SubString(0, 4), (const char*)ctx->Ans.t2Account.SubString(ctx->Ans.t2Account.GetLength() - 4, 4)));
|
|
|
+ // if (ans.ICType == 3 || ans.ICType == 4)
|
|
|
+ // {
|
|
|
+ // CardSwiperService_PreOnline_Req req;
|
|
|
+ // CardSwiperService_PreOnline_Ans ans;
|
|
|
+ // req.businessData = ctx->Req.businessData;
|
|
|
+ // BroadcastReadICing(0);
|
|
|
+ // dwEnd = GetTickCountRVC();
|
|
|
+ // DWORD elapse1 = ReadCard_TIMEOUT - (dwEnd-dwStart);
|
|
|
+ // if(elapse1 < 10000)//PreOnline较慢,预留一定时间
|
|
|
+ // {
|
|
|
+ // DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("There is no more time to invoke PreOnline");
|
|
|
+ // ctx->Ans.result = "";
|
|
|
+ // return 9;
|
|
|
+ // }
|
|
|
+ // dwUserCode = 0;
|
|
|
+ // eErr = (*m_pCardSwiper)(EntityResource::getLink().upgradeLink())->PreOnline(req, ans, elapse1, dwUserCode);
|
|
|
+ // if (eErr == Error_Succeed)
|
|
|
+ // {
|
|
|
+ // ctx->Ans.result = ans.result;
|
|
|
+ // }
|
|
|
+ // else if(eErr == Error_Interact){
|
|
|
+ // if(m_eMachineType == SP::Module::Comm::RVC_Desk2S){
|
|
|
+ // DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("CardSwiper(RVC_Desk2S) return Error_Interact, no need loop.");
|
|
|
+ // ctx->Ans.result = "";
|
|
|
+ // ctx->Answer(Error_Unexpect, dwUserCode);
|
|
|
+ // return 0;
|
|
|
+ // }
|
|
|
+ // else
|
|
|
+ // DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("CardSwiper return Error_Interact, need loop.");
|
|
|
+ // dwEnd = GetTickCountRVC();
|
|
|
+ // elapsed = dwEnd - dwStart;
|
|
|
+ // Sleep(200);
|
|
|
+ // continue;
|
|
|
+ // }else{
|
|
|
+ // DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)(CSimpleStringA::Format("CardSwiper PreOnline failed return:%d", eErr));
|
|
|
+ // ctx->Ans.result = "";
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }else if(eErr == Error_Param){
|
|
|
+ // eErr = Error_Unexpect;
|
|
|
+ // DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("TrackData maybe some wrong");
|
|
|
+ // }else if(eErr == Error_Interact){
|
|
|
+ // if(m_eMachineType == SP::Module::Comm::RVC_Desk2S){
|
|
|
+ // DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("CardSwiper(RVC_Desk2S) return Error_Interact, no need loop.");
|
|
|
+ // return 9;//Maybe vendor's QueryCardStatus timeout
|
|
|
+ // }else{
|
|
|
+ // DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("CardSwiper ReadCard:ActiveContactlessICCard or ICCommand failed, need loop");
|
|
|
+ // dwEnd = GetTickCountRVC();
|
|
|
+ // elapsed = dwEnd - dwStart;
|
|
|
+ // Sleep(200);
|
|
|
+ // continue;
|
|
|
+ // }
|
|
|
+ // }else{
|
|
|
+ // DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)(CSimpleStringA::Format("CardSwiper Read failed return:%d", eErr));
|
|
|
+ // }
|
|
|
+ // if (eErr == Error_TimeOut)
|
|
|
+ // {
|
|
|
+ // DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("CardSwiper timeout.");
|
|
|
+ // return 9;
|
|
|
+ // }
|
|
|
+ // else if (eErr == Error_InvalidState)
|
|
|
+ // {
|
|
|
+ // DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("CardSwiper in error state.");
|
|
|
+ // return 1;
|
|
|
+ // }
|
|
|
+ // else{
|
|
|
+ // ctx->Answer(eErr, dwUserCode);
|
|
|
+ // return 0;
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // else
|
|
|
+ // {
|
|
|
+ // DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)(CSimpleStringA::Format("can't find the corresponding Entity.req.Module:%d", ctx->Req.module));
|
|
|
+ // return 1;
|
|
|
+ // }
|
|
|
+ // break;
|
|
|
+ //}
|
|
|
+ //DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("no more time to loop again");
|
|
|
+ //return 9;
|
|
|
+ DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)(CSimpleStringA::Format("can't find the corresponding Entity.req.Module:%d", ctx->Req.module));
|
|
|
+ return 1;
|
|
|
}
|
|
|
void CCardReadAdapterFSM::CancelRead()
|
|
|
{
|
|
|
@@ -1205,11 +1176,7 @@ void CCardReadAdapterFSM::CancelRead()
|
|
|
DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER)("ContactlessCard read canceled by front user.");
|
|
|
(*m_pContactless)(EntityResource::getLink().upgradeLink())->CancelInsert();
|
|
|
}
|
|
|
- if (IsCardSwiperSessionOK())
|
|
|
- {
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER)("CardSwiper read canceled by front user.");
|
|
|
- eErr = (*m_pCardSwiper)(EntityResource::getLink().upgradeLink())->CancelInsert();
|
|
|
- }
|
|
|
+
|
|
|
}
|
|
|
void CCardReadAdapterFSM::ReadWaitMore()
|
|
|
{
|
|
|
@@ -1223,10 +1190,6 @@ void CCardReadAdapterFSM::ReadWaitMore()
|
|
|
{
|
|
|
(*m_pContactless)(EntityResource::getLink().upgradeLink())->InsertWaitMore();
|
|
|
}
|
|
|
- if (IsCardSwiperSessionOK())
|
|
|
- {
|
|
|
- (*m_pCardSwiper)(EntityResource::getLink().upgradeLink())->InsertWaitMore();
|
|
|
- }
|
|
|
|
|
|
}
|
|
|
int CCardReadAdapterFSM::WriteTrack(SpReqAnsContext<CardReadAdapterService_WriteTrack_Req, CardReadAdapterService_WriteTrack_Ans>::Pointer ctx)
|
|
|
@@ -1307,23 +1270,6 @@ int CCardReadAdapterFSM::PreOnline(SpReqAnsContext<CardReadAdapterService_PreOnl
|
|
|
}
|
|
|
ctx->Answer(eErr, dwUsrErrCode, csRetStr);
|
|
|
}
|
|
|
- else if (IsTheEntity(ctx->Req.module, Module_CardSwiper) && IsCardSwiperSessionOK())
|
|
|
- {
|
|
|
- CardSwiperService_PreOnline_Req req;
|
|
|
- CardSwiperService_PreOnline_Ans ans;
|
|
|
- req.businessData = ctx->Req.businessData;
|
|
|
- //req.reserved1 = ctx->Req.reserved1;
|
|
|
- //req.reserved2 = ctx->Req.reserved2;
|
|
|
- eErr = (*m_pCardSwiper)(EntityResource::getLink().upgradeLink())->PreOnline(req, ans, 50000, dwUsrErrCode, csRetStr);
|
|
|
- if (eErr == Error_Succeed)
|
|
|
- {
|
|
|
- ctx->Ans.result = ans.result;
|
|
|
- }
|
|
|
- else {
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER)("PreOnline, CardSwiper PreOnline failed return:%d", eErr);
|
|
|
- }
|
|
|
- ctx->Answer(eErr, dwUsrErrCode, csRetStr);
|
|
|
- }
|
|
|
return 0;
|
|
|
}
|
|
|
int CCardReadAdapterFSM::PostOnline(SpReqAnsContext<CardReadAdapterService_PostOnline_Req, CardReadAdapterService_PostOnline_Ans>::Pointer ctx)
|
|
|
@@ -1363,21 +1309,6 @@ int CCardReadAdapterFSM::PostOnline(SpReqAnsContext<CardReadAdapterService_PostO
|
|
|
}
|
|
|
ctx->Answer(eErr, dwUsrErrCode, csRetStr);
|
|
|
}
|
|
|
- else if (IsTheEntity(ctx->Req.module, Module_CardSwiper) && IsCardSwiperSessionOK())
|
|
|
- {
|
|
|
- CardSwiperService_PostOnline_Req req;
|
|
|
- CardSwiperService_PostOnline_Ans ans;
|
|
|
- req.data = ctx->Req.data;
|
|
|
- eErr = (*m_pCardSwiper)(EntityResource::getLink().upgradeLink())->PostOnline(req, ans, 50000, dwUsrErrCode, csRetStr);
|
|
|
- if (eErr == Error_Succeed)
|
|
|
- {
|
|
|
- ctx->Ans.result = ans.result;
|
|
|
- }
|
|
|
- else {
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER)("PostOnline, CardSwiper PostOnline failed return:%d", eErr);
|
|
|
- }
|
|
|
- ctx->Answer(eErr, dwUsrErrCode, csRetStr);
|
|
|
- }
|
|
|
return 0;
|
|
|
}
|
|
|
int CCardReadAdapterFSM::EjectCard(SpReqAnsContext<CardReadAdapterService_Eject_Req, CardReadAdapterService_Eject_Ans>::Pointer ctx)
|
|
|
@@ -1420,22 +1351,6 @@ int CCardReadAdapterFSM::EjectCard(SpReqAnsContext<CardReadAdapterService_Eject_
|
|
|
}
|
|
|
ctx->Answer(eErr, dwUsrErrCode, csRetStr);
|
|
|
}
|
|
|
- else if (IsTheEntity(ctx->Req.module, Module_CardSwiper) && IsCardSwiperSessionOK())
|
|
|
- {
|
|
|
- CardSwiperService_Eject_Req req;
|
|
|
- CardSwiperService_Eject_Ans ans;
|
|
|
- eErr = (*m_pCardSwiper)(EntityResource::getLink().upgradeLink())->Eject(req, ans, 50000, dwUsrErrCode, csRetStr);
|
|
|
- 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 {
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("EjectCard, CardSwiper EjectCard failed return:%d", eErr);
|
|
|
- }
|
|
|
- ctx->Answer(eErr, dwUsrErrCode, csRetStr);
|
|
|
- }
|
|
|
else
|
|
|
{
|
|
|
DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("EjectCard, nothing to do.");
|
|
|
@@ -1526,36 +1441,6 @@ int CCardReadAdapterFSM::QueryCardInfo(SpReqAnsContext<CardReadAdapterService_Qu
|
|
|
ctx->Ans.ContactlessCardPos = -1;
|
|
|
}
|
|
|
}
|
|
|
- if (IsTheEntity(ctx->Req.module, Module_CardSwiper) && IsCardSwiperSessionOK())
|
|
|
- {
|
|
|
- CardSwiperService_QueryCardInfo_Req req;
|
|
|
- CardSwiperService_QueryCardInfo_Ans ans;
|
|
|
- eErr = (*m_pCardSwiper)(EntityResource::getLink().upgradeLink())->QueryCardInfo(req, ans, 10000, dwUsrErrCode);
|
|
|
- if (eErr == Error_Succeed)
|
|
|
- {
|
|
|
- switch (ans.position)
|
|
|
- {
|
|
|
- case 2:
|
|
|
- ctx->Ans.CardSwiperPos = 1;
|
|
|
- break;
|
|
|
- case 3:
|
|
|
- ctx->Ans.CardSwiperPos = 2;
|
|
|
- break;
|
|
|
- case 4:
|
|
|
- ctx->Ans.CardSwiperPos = 3;
|
|
|
- break;
|
|
|
- case 6:
|
|
|
- ctx->Ans.CardSwiperPos = 4;
|
|
|
- break;
|
|
|
- default:
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- else {
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("QueryCardInfo, CardSwiper QueryCardInfo failed return:%d", eErr);
|
|
|
- ctx->Ans.CardSwiperPos = 0;//oilyang@20220906 查询失败直接给不知道,不再给-1
|
|
|
- }
|
|
|
- }
|
|
|
ctx->Answer(Error_Succeed);
|
|
|
DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER)("<QueryCardInfo>, CardFromWhich:%d, position(CI,CC,CS) %d,%d,%d",
|
|
|
m_busCtx.eCardFromWhich, ctx->Ans.CardIssuerPos, ctx->Ans.ContactlessCardPos, ctx->Ans.CardSwiperPos);
|
|
|
@@ -1623,37 +1508,6 @@ void CCardReadAdapterFSM::CheckAndReconnectSession()
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- //CardSwiper
|
|
|
- if ((m_eMachineType != SP::Module::Comm::RVC_Stand2S
|
|
|
- && m_eMachineType != SP::Module::Comm::RVC_CardStore
|
|
|
- && m_eMachineType != SP::Module::Comm::RVC_CardPrinter
|
|
|
- && m_eMachineType != SP::Module::Comm::RVC_Stand1SPlus)
|
|
|
- &&(m_pCardSwiper == NULL || (m_pCardSwiper != NULL && m_pCardSwiper->QuerySessionClosed())))
|
|
|
- {
|
|
|
- if (m_pCardSwiper != NULL)
|
|
|
- {
|
|
|
- m_pCardSwiper->GetFunction()->CloseSession();
|
|
|
- m_pCardSwiper = NULL;
|
|
|
- }
|
|
|
- m_pCardSwiper = new CardSwiperService_ClientBase(GetEntityBase());
|
|
|
- if (m_pCardSwiper != NULL)
|
|
|
- {
|
|
|
- eErr = m_pCardSwiper->Connect();
|
|
|
- if (eErr != Error_Succeed)
|
|
|
- {
|
|
|
- if (cardSwiperCount%120 == 0)//about 10 minutes can't connect to entity
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("connect to entity CardSwiper failed.%d", eErr);
|
|
|
- cardSwiperCount++;
|
|
|
- m_pCardSwiper->SafeDelete();
|
|
|
- m_pCardSwiper = NULL;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- cardSwiperCount = 0;
|
|
|
- DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("Connect to entity CardSwiper suc.");
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
Sleep(5000);
|
|
|
}
|
|
|
}
|
|
|
@@ -1671,8 +1525,8 @@ bool CCardReadAdapterFSM::IsContactlessCardSessionOK()
|
|
|
}
|
|
|
bool CCardReadAdapterFSM::IsCardSwiperSessionOK()
|
|
|
{
|
|
|
- if (m_pCardSwiper != NULL && !m_pCardSwiper->QuerySessionClosed())
|
|
|
- return true;
|
|
|
+ //if (m_pCardSwiper != NULL && !m_pCardSwiper->QuerySessionClosed())
|
|
|
+ // return true;
|
|
|
return false;
|
|
|
}
|
|
|
bool CCardReadAdapterFSM::IsTheEntity(int module,ModuleType eModule)
|
|
|
@@ -1784,23 +1638,6 @@ int CCardReadAdapterFSM::GetDevInfo(SpReqAnsContext<CardReadAdapterService_GetDe
|
|
|
DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("GetDevInfo, ContactlessCard GetDevInfo failed return:%d", eErr);
|
|
|
}
|
|
|
}
|
|
|
- if (IsTheEntity(ctx->Req.module, Module_CardSwiper) && IsCardSwiperSessionOK())
|
|
|
- {
|
|
|
- CardSwiperService_GetDevInfo_Req req;
|
|
|
- CardSwiperService_GetDevInfo_Ans ans;
|
|
|
- eErr = (*m_pCardSwiper)(EntityResource::getLink().upgradeLink())->GetDevInfo(req, ans, 10000);
|
|
|
- if (eErr == Error_Succeed)
|
|
|
- {
|
|
|
- bCS = true;
|
|
|
- count++;
|
|
|
- csCSType = ans.type;
|
|
|
- csCSModel = ans.model;
|
|
|
- csCSVersion = ans.version;
|
|
|
- csState = ans.state;
|
|
|
- }else{
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)(CSimpleStringA::Format("GetDevInfo, CardSwiper GetDevInfo failed return:%d", eErr));
|
|
|
- }
|
|
|
- }
|
|
|
ctx->Ans.ModuleNum = count;
|
|
|
ctx->Ans.ModuleSN.Init(count);
|
|
|
ctx->Ans.type.Init(count);
|
|
|
@@ -1831,17 +1668,6 @@ int CCardReadAdapterFSM::GetDevInfo(SpReqAnsContext<CardReadAdapterService_GetDe
|
|
|
csCCType.GetData(), csCCModel.GetData(), csCCVersion.GetData(), ccState);
|
|
|
index++;
|
|
|
}
|
|
|
- if (bCS)
|
|
|
- {
|
|
|
- ctx->Ans.ModuleSN[index] = Module_CardSwiper;
|
|
|
- ctx->Ans.type[index] = csCSType;
|
|
|
- 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",
|
|
|
- csCSType.GetData(), csCSModel.GetData(), csCSVersion.GetData(), csState);
|
|
|
- index++;
|
|
|
- }
|
|
|
ctx->Answer(Error_Succeed);
|
|
|
return 0;
|
|
|
}
|
|
|
@@ -1988,54 +1814,18 @@ int CCardReadAdapterFSM::OpenSafeLock(SpReqAnsContext<CardReadAdapterService_Ope
|
|
|
int CCardReadAdapterFSM::MagTransferInit(SpReqAnsContext<CardReadAdapterService_MagTransferInit_Req, CardReadAdapterService_MagTransferInit_Ans>::Pointer ctx)
|
|
|
{
|
|
|
LOG_FUNCTION();
|
|
|
- if (IsCardSwiperSessionOK())
|
|
|
- {
|
|
|
- ErrorCodeEnum eErr = Error_Unexpect;
|
|
|
- CardSwiperService_MagTransferInit_Req req;
|
|
|
- CardSwiperService_MagTransferInit_Ans ans;
|
|
|
- req.data = ctx->Req.data;
|
|
|
- eErr = (*m_pCardSwiper)(EntityResource::getLink().upgradeLink())->MagTransferInit(req, ans, 15000);
|
|
|
- if (eErr == Error_Succeed)
|
|
|
- {
|
|
|
- ctx->Ans.ex = ans.ex;
|
|
|
- ctx->Ans.result = ans.result;
|
|
|
- }
|
|
|
- else {
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("MagTransferInit, CardSwiper MagTransferInit failed return:%d", eErr);
|
|
|
- }
|
|
|
- ctx->Answer(eErr);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("Entity CardSwiper is not ok.");
|
|
|
- ctx->Answer(Error_Unexpect);
|
|
|
- }
|
|
|
+
|
|
|
+ DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("Entity CardSwiper is not ok.");
|
|
|
+ ctx->Answer(Error_Unexpect);
|
|
|
+
|
|
|
return 0;
|
|
|
}
|
|
|
int CCardReadAdapterFSM::QueryConnInfo(SpReqAnsContext<CardReadAdapterService_QueryConnInfo_Req, CardReadAdapterService_QueryConnInfo_Ans>::Pointer ctx)
|
|
|
{
|
|
|
- if (IsCardSwiperSessionOK())
|
|
|
- {
|
|
|
- ErrorCodeEnum eErr = Error_Unexpect;
|
|
|
- CardSwiperService_QueryConnInfo_Req req;
|
|
|
- CardSwiperService_QueryConnInfo_Ans ans;
|
|
|
- eErr = (*m_pCardSwiper)(EntityResource::getLink().upgradeLink())->QueryConnInfo(req, ans, 15000);
|
|
|
- if (eErr == Error_Succeed)
|
|
|
- {
|
|
|
- ctx->Ans.connect = ans.connect;
|
|
|
- ctx->Ans.reserved1 = ans.reserved1;
|
|
|
- ctx->Ans.reserved2 = ans.reserved2;
|
|
|
- }
|
|
|
- else {
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("QueryConnInfo, CardSwiper QueryConnInfo failed return:%d", eErr);
|
|
|
- }
|
|
|
- ctx->Answer(eErr);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("Entity CardSwiper is not ok.");
|
|
|
- ctx->Answer(Error_Unexpect);
|
|
|
- }
|
|
|
+
|
|
|
+ DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("Entity CardSwiper is not ok.");
|
|
|
+ ctx->Answer(Error_Unexpect);
|
|
|
+
|
|
|
return 0;
|
|
|
}
|
|
|
void CCardReadAdapterFSM::DoExit()
|
|
|
@@ -2049,10 +1839,6 @@ void CCardReadAdapterFSM::DoExit()
|
|
|
{
|
|
|
eErr = (*m_pContactless)(EntityResource::getLink().upgradeLink())->Exit();
|
|
|
}
|
|
|
- if (IsCardSwiperSessionOK())
|
|
|
- {
|
|
|
- eErr = (*m_pCardSwiper)(EntityResource::getLink().upgradeLink())->Exit();
|
|
|
- }
|
|
|
}
|
|
|
void CCardReadAdapterFSM::BroadcastReadICing(int status)
|
|
|
{
|
|
|
@@ -2566,11 +2352,6 @@ void CCardReadAdapterFSM::CancelReadForEntity(ModuleType eModule)
|
|
|
DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Cancel read by CardSwiper of ContactlessCard.");
|
|
|
(*m_pContactless)(EntityResource::getLink().upgradeLink())->CancelInsert();
|
|
|
}
|
|
|
- if (IsTheEntity(eModule, Module_CardSwiper) && IsCardSwiperSessionOK())
|
|
|
- {
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Cancel read by ContactlessCard of CardSwiper.");
|
|
|
- (*m_pCardSwiper)(EntityResource::getLink().upgradeLink())->CancelInsert();
|
|
|
- }
|
|
|
}
|
|
|
int CCardReadAdapterFSM::PrintCardIm(SpReqAnsContext<CardReadAdapterService_PrintCardImmediately_Req, CardReadAdapterService_PrintCardImmediately_Ans>::Pointer ctx)
|
|
|
{
|