|
@@ -130,8 +130,8 @@ unsigned int CCardReadAdapterFSM::s2_on_event(FSMEvent* pEvt)
|
|
|
// --no matter what MachineType is,just call it
|
|
|
pEvt->SetHandled();
|
|
|
CardReadEvent* cre = dynamic_cast<CardReadEvent*>(pEvt);
|
|
|
- bool bCardIssuer, bCardSwiper, bContactlessCard;
|
|
|
- bCardIssuer = bCardSwiper = bContactlessCard = false;
|
|
|
+ bool bCardIssuer, bContactlessCard;
|
|
|
+ bCardIssuer = bContactlessCard = false;
|
|
|
if (m_eMachineType == SP::Module::Comm::RVC_Stand2S || m_eMachineType == SP::Module::Comm::RVC_Stand1SPlus)
|
|
|
{
|
|
|
ContactlessCardReadTask* cTask = new ContactlessCardReadTask(this);
|
|
@@ -154,8 +154,8 @@ unsigned int CCardReadAdapterFSM::s2_on_event(FSMEvent* pEvt)
|
|
|
GetEntityBase()->GetFunction()->PostThreadPoolTask(iTask);
|
|
|
DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER)("ReadTask to CardIssuer");
|
|
|
}
|
|
|
- if (bCardIssuer || bCardSwiper || bContactlessCard)
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER)("ReadTask, bCardIssuer,bCardSwiper,bContactlessCard:%d,%d,%d", bCardIssuer, bCardSwiper, bContactlessCard);
|
|
|
+ if (bCardIssuer || bContactlessCard)
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER)("ReadTask, bCardIssuer,bContactlessCard:%d,%d", bCardIssuer, bContactlessCard);
|
|
|
else
|
|
|
{
|
|
|
DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER)("ReadTask: can't find the right entity.");
|
|
@@ -480,7 +480,7 @@ unsigned int CCardReadAdapterFSM::s3_on_event(FSMEvent* pEvt)
|
|
|
ret = 0;
|
|
|
break;
|
|
|
}
|
|
|
- else if (pEvt->param1 == 9)//CardSwiper Timeout,need to cancel ContactlessCard insert
|
|
|
+ else if (pEvt->param1 == 9)//ContactlessCard Timeout,need to cancel ContactlessCard insert
|
|
|
{
|
|
|
DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("ContactlessCard Timeout,need to cancel CardIssuer insert");
|
|
|
if (IsContactlessCardSessionOK())
|
|
@@ -669,7 +669,7 @@ int CCardReadAdapterFSM::DoWork(int type)
|
|
|
int CCardReadAdapterFSM::CardIssuerRead(SpReqAnsContext<CardReadAdapterService_Read_Req, CardReadAdapterService_Read_Ans>::Pointer ctx)
|
|
|
{
|
|
|
LOG_FUNCTION();
|
|
|
- if (m_bCancelAccept || (m_busCtx.eCardFromWhich == Card_In_ContactlessCard || m_busCtx.eCardFromWhich == Card_In_CardSwiper))
|
|
|
+ if (m_bCancelAccept || (m_busCtx.eCardFromWhich == Card_In_ContactlessCard))
|
|
|
{
|
|
|
char msg[128];
|
|
|
memset(msg, 0, 128);
|
|
@@ -992,7 +992,7 @@ int CCardReadAdapterFSM::CardIssuerRead(SpReqAnsContext<CardReadAdapterService_R
|
|
|
int CCardReadAdapterFSM::ContactlessCardRead(SpReqAnsContext<CardReadAdapterService_Read_Req, CardReadAdapterService_Read_Ans>::Pointer ctx)
|
|
|
{
|
|
|
LOG_FUNCTION();
|
|
|
- if (m_bCancelAccept || (m_busCtx.eCardFromWhich == Card_In_CardIssuer || m_busCtx.eCardFromWhich == Card_In_CardSwiper))
|
|
|
+ if (m_bCancelAccept || (m_busCtx.eCardFromWhich == Card_In_CardIssuer))
|
|
|
{
|
|
|
char msg[128];
|
|
|
memset(msg, 0, 128);
|
|
@@ -1212,158 +1212,7 @@ int CCardReadAdapterFSM::IssueCard(SpReqAnsContext<CardReadAdapterService_Issue_
|
|
|
return 1;
|
|
|
}
|
|
|
}
|
|
|
-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;
|
|
|
-
|
|
|
- //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;
|
|
|
- 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()
|
|
|
{
|
|
|
ErrorCodeEnum eErr = Error_Unexpect;
|
|
@@ -1795,7 +1644,7 @@ int CCardReadAdapterFSM::QueryCardInfo(SpReqAnsContext<CardReadAdapterService_Qu
|
|
|
void CCardReadAdapterFSM::CheckAndReconnectSession()
|
|
|
{
|
|
|
ErrorCodeEnum eErr = Error_Unexpect;
|
|
|
- int cardIssuerCount = 0, contactlessCardCount = 0, cardSwiperCount = 0;
|
|
|
+ int cardIssuerCount = 0, contactlessCardCount = 0;
|
|
|
while (1)
|
|
|
{
|
|
|
//the first time to connect or need to reconnect
|
|
@@ -1908,12 +1757,7 @@ bool CCardReadAdapterFSM::IsContactlessCardSessionOK()
|
|
|
return true;
|
|
|
return false;
|
|
|
}
|
|
|
-bool CCardReadAdapterFSM::IsCardSwiperSessionOK()
|
|
|
-{
|
|
|
- //if (m_pCardSwiper != NULL && !m_pCardSwiper->QuerySessionClosed())
|
|
|
- // return true;
|
|
|
- return false;
|
|
|
-}
|
|
|
+
|
|
|
bool CCardReadAdapterFSM::IsTheEntity(int module,ModuleType eModule)
|
|
|
{
|
|
|
if (module == 0)
|
|
@@ -2371,19 +2215,14 @@ int CCardReadAdapterFSM::OpenSafeLock(SpReqAnsContext<CardReadAdapterService_Ope
|
|
|
}
|
|
|
int CCardReadAdapterFSM::MagTransferInit(SpReqAnsContext<CardReadAdapterService_MagTransferInit_Req, CardReadAdapterService_MagTransferInit_Ans>::Pointer ctx)
|
|
|
{
|
|
|
- LOG_FUNCTION();
|
|
|
-
|
|
|
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)
|
|
|
{
|
|
|
-
|
|
|
DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("Entity CardSwiper is not ok.");
|
|
|
ctx->Answer(Error_Unexpect);
|
|
|
-
|
|
|
return 0;
|
|
|
}
|
|
|
void CCardReadAdapterFSM::DoExit()
|