|
@@ -8,6 +8,8 @@
|
|
|
#include "SpBase.h"
|
|
|
#include "mod_CardReadAdapter.h"
|
|
|
|
|
|
+const int iCardIssuerFetchCard = 1;
|
|
|
+const int iContactlessFetchCard = 2;
|
|
|
|
|
|
void CardReadAdapterServerSession::Handle_Read(SpReqAnsContext<CardReadAdapterService_Read_Req, CardReadAdapterService_Read_Ans>::Pointer ctx)
|
|
|
{
|
|
@@ -263,24 +265,15 @@ void CCardReadAdapterEntity::OnBroadcastEvent(CUUID SubID, const char *pszEntity
|
|
|
if (dwMessageSignature != eMsgSig_FetchCard && dwMessageSignature != eMsgSig_SCIConnect)
|
|
|
return;
|
|
|
|
|
|
- DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("OnBroadcastEvent,msg:%s,%d,%d",pszEntityName,dwMessageId,dwMessageSignature);
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("OnBroadcastEvent,msg:%s,%d,%d",pszEntityName,dwMessageId,dwMessageSignature);
|
|
|
if (_strnicmp(pszEntityName, "CardIssuer", strlen("CardIssuer")) == 0)
|
|
|
{
|
|
|
if (dwMessageSignature == eMsgSig_FetchCard)
|
|
|
{
|
|
|
CardIssuer::FetchCard fc;
|
|
|
SpBuffer2Object(Buffer, fc);
|
|
|
- CardIsserFetchCard evt;
|
|
|
- evt.status = fc.status;
|
|
|
- SpSendBroadcast(GetFunction(), SP_MSG_OF(CardIsserFetchCard), SP_MSG_SIG_OF(CardIsserFetchCard), evt);
|
|
|
- }
|
|
|
- else if (dwMessageSignature == eMsgSig_SCIConnect)
|
|
|
- {
|
|
|
- CardIssuer::SCIConnect scic;
|
|
|
- SpBuffer2Object(Buffer, scic);
|
|
|
- CardIssuerSCIConnect evt;
|
|
|
- evt.status = scic.status;
|
|
|
- SpSendBroadcast(GetFunction(), SP_MSG_OF(CardIssuerSCIConnect), SP_MSG_SIG_OF(CardIssuerSCIConnect), evt);
|
|
|
+ DoBroadMsgTask* task = new DoBroadMsgTask(this, iCardIssuerFetchCard,fc.status);
|
|
|
+ GetFunction()->PostThreadPoolTask(task);
|
|
|
}
|
|
|
}
|
|
|
else if (_strnicmp(pszEntityName, "ContactlessCard", strlen("ContactlessCard")) == 0)
|
|
@@ -299,17 +292,61 @@ void CCardReadAdapterEntity::OnBroadcastEvent(CUUID SubID, const char *pszEntity
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- ContactlessCardFetchCard evt;
|
|
|
- evt.status = fc.status;
|
|
|
- SpSendBroadcast(GetFunction(), SP_MSG_OF(ContactlessCardFetchCard), SP_MSG_SIG_OF(ContactlessCardFetchCard), evt);
|
|
|
+ DoBroadMsgTask* task = new DoBroadMsgTask(this, iContactlessFetchCard, fc.status);
|
|
|
+ GetFunction()->PostThreadPoolTask(task);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
+void CCardReadAdapterEntity::DoBroadMsg(int msgType,int status)
|
|
|
+{
|
|
|
+ ULLINT ullStart = SP::Module::Comm::RVCGetTickCount();
|
|
|
+ ULLINT ullEnd;
|
|
|
+ do
|
|
|
+ {
|
|
|
+ //in not "Working" (S3) state , means have done work
|
|
|
+ if (_stricmp(m_fsm.GetCurrStateName(), "Working") != 0)
|
|
|
+ break;
|
|
|
+ else
|
|
|
+ {
|
|
|
+ Sleep(200);
|
|
|
+ ullEnd = SP::Module::Comm::RVCGetTickCount();
|
|
|
+ }
|
|
|
+ } while (ullEnd - ullStart < m_msgMaxInterval);//need to set in center setting or not?
|
|
|
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("DoBroadcastMsg cost:%d(ms)", ullEnd - ullStart);
|
|
|
|
|
|
-
|
|
|
+ if (msgType == iCardIssuerFetchCard)
|
|
|
+ {
|
|
|
+ CardIsserFetchCard evt;
|
|
|
+ evt.status = status;
|
|
|
+ SpSendBroadcast(GetFunction(), SP_MSG_OF(CardIsserFetchCard), SP_MSG_SIG_OF(CardIsserFetchCard), evt);
|
|
|
+ }
|
|
|
+ else if (msgType == iContactlessFetchCard)
|
|
|
+ {
|
|
|
+ ContactlessCardFetchCard evt;
|
|
|
+ evt.status = status;
|
|
|
+ SpSendBroadcast(GetFunction(), SP_MSG_OF(ContactlessCardFetchCard), SP_MSG_SIG_OF(ContactlessCardFetchCard), evt);
|
|
|
+ }
|
|
|
+}
|
|
|
+void CCardReadAdapterEntity::DoStart()
|
|
|
+{
|
|
|
+ CSmartPointer<IConfigInfo> spCerConfig;
|
|
|
+ ErrorCodeEnum eErr = GetFunction()->OpenConfig(Config_CenterSetting, spCerConfig);
|
|
|
+ if (eErr != Error_Succeed) {
|
|
|
+ DbgWithLink(LOG_LEVEL_ERROR, LOG_TYPE_SYSTEM)("open CenterSetting file failed!");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ do
|
|
|
+ {
|
|
|
+ int value(0);
|
|
|
+ spCerConfig->ReadConfigValueInt(GetEntityName(), "MsgMaxInterval", value);
|
|
|
+ if (value > 1000 && value < 10000) {
|
|
|
+ m_msgMaxInterval = value;
|
|
|
+ }
|
|
|
+ } while (false);
|
|
|
+}
|
|
|
SP_BEGIN_ENTITY_MAP()
|
|
|
SP_ENTITY(CCardReadAdapterEntity)
|
|
|
SP_END_ENTITY_MAP()
|