mod_CardReadAdapter.h 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393
  1. #include "CardReadAdapter_server_g.h"
  2. #include "CardReadAdapter_def_g.h"
  3. #include "CardReadAdapterFSM.h"
  4. using namespace CardReadAdapter;
  5. class CCardReadAdapterEntity;
  6. class CardReadAdapterServerSession : public CardReadAdapterService_ServerSessionBase
  7. {
  8. public:
  9. CardReadAdapterServerSession(CCardReadAdapterEntity* pEntity):m_pEntity(pEntity){}
  10. virtual ~CardReadAdapterServerSession(){}
  11. virtual void Handle_Read(SpReqAnsContext<CardReadAdapterService_Read_Req, CardReadAdapterService_Read_Ans>::Pointer ctx);
  12. virtual void Handle_CancelRead(SpOnewayCallContext<CardReadAdapterService_CancelRead_Info>::Pointer ctx);
  13. virtual void Handle_ReadWaitMore(SpOnewayCallContext<CardReadAdapterService_ReadWaitMore_Info>::Pointer ctx);
  14. virtual void Handle_Capture(SpReqAnsContext<CardReadAdapterService_Capture_Req, CardReadAdapterService_Capture_Ans>::Pointer ctx);
  15. virtual void Handle_Eject(SpReqAnsContext<CardReadAdapterService_Eject_Req, CardReadAdapterService_Eject_Ans>::Pointer ctx);
  16. virtual void Handle_PreOnline(SpReqAnsContext<CardReadAdapterService_PreOnline_Req, CardReadAdapterService_PreOnline_Ans>::Pointer ctx);
  17. virtual void Handle_PostOnline(SpReqAnsContext<CardReadAdapterService_PostOnline_Req, CardReadAdapterService_PostOnline_Ans>::Pointer ctx);
  18. virtual void Handle_Exit(SpOnewayCallContext<CardReadAdapterService_Exit_Info>::Pointer ctx);
  19. virtual void Handle_QueryCardInfo(SpReqAnsContext<CardReadAdapterService_QueryCardInfo_Req, CardReadAdapterService_QueryCardInfo_Ans>::Pointer ctx);
  20. virtual void Handle_WriteTrack(SpReqAnsContext<CardReadAdapterService_WriteTrack_Req, CardReadAdapterService_WriteTrack_Ans>::Pointer ctx);
  21. virtual void Handle_SetSomeFlag(SpReqAnsContext<CardReadAdapterService_SetSomeFlag_Req, CardReadAdapterService_SetSomeFlag_Ans>::Pointer ctx);
  22. virtual void Handle_Issue(SpReqAnsContext<CardReadAdapterService_Issue_Req, CardReadAdapterService_Issue_Ans>::Pointer ctx);
  23. virtual void Handle_GetDevInfo(SpReqAnsContext<CardReadAdapterService_GetDevInfo_Req, CardReadAdapterService_GetDevInfo_Ans>::Pointer ctx);
  24. virtual void Handle_GetMaterialCount(SpReqAnsContext<CardReadAdapterService_GetMaterialCount_Req, CardReadAdapterService_GetMaterialCount_Ans>::Pointer ctx);
  25. virtual void Handle_SetMaterialCount(SpReqAnsContext<CardReadAdapterService_SetMaterialCount_Req, CardReadAdapterService_SetMaterialCount_Ans>::Pointer ctx);
  26. virtual void Handle_GetSCIInfo(SpReqAnsContext<CardReadAdapterService_GetSCIInfo_Req, CardReadAdapterService_GetSCIInfo_Ans>::Pointer ctx);
  27. virtual void Handle_OpenSafeLock(SpReqAnsContext<CardReadAdapterService_OpenSafeLock_Req, CardReadAdapterService_OpenSafeLock_Ans>::Pointer ctx);
  28. virtual void Handle_MagTransferInit(SpReqAnsContext<CardReadAdapterService_MagTransferInit_Req, CardReadAdapterService_MagTransferInit_Ans>::Pointer ctx);
  29. virtual void Handle_QueryConnInfo(SpReqAnsContext<CardReadAdapterService_QueryConnInfo_Req, CardReadAdapterService_QueryConnInfo_Ans>::Pointer ctx);
  30. virtual void Handle_SAMICCommand(SpReqAnsContext<CardReadAdapterService_SAMICCommand_Req, CardReadAdapterService_SAMICCommand_Ans>::Pointer ctx);
  31. virtual void Handle_QueryPrinterStatus(SpReqAnsContext<CardReadAdapterService_QueryPrinterStatus_Req, CardReadAdapterService_QueryPrinterStatus_Ans>::Pointer ctx);
  32. virtual void Handle_Print(SpReqAnsContext<CardReadAdapterService_Print_Req, CardReadAdapterService_Print_Ans>::Pointer ctx);
  33. virtual void Handle_QuerySCIList(SpReqAnsContext<CardReadAdapterService_QuerySCIList_Req, CardReadAdapterService_QuerySCIList_Ans>::Pointer ctx);
  34. virtual void Handle_BindSCI(SpReqAnsContext<CardReadAdapterService_BindSCI_Req, CardReadAdapterService_BindSCI_Ans>::Pointer ctx);
  35. virtual void Handle_PreOnlineOnStore(SpReqAnsContext<CardReadAdapterService_PreOnlineOnStore_Req, CardReadAdapterService_PreOnlineOnStore_Ans>::Pointer ctx);
  36. virtual void Handle_NotifyPreonline(SpReqAnsContext<CardReadAdapterService_NotifyPreonline_Req, CardReadAdapterService_NotifyPreonline_Ans>::Pointer ctx);
  37. virtual void Handle_QueryCardInfoOnStore(SpReqAnsContext<CardReadAdapterService_QueryCardInfoOnStore_Req, CardReadAdapterService_QueryCardInfoOnStore_Ans>::Pointer ctx);
  38. virtual void Handle_GetAddCardInfo(SpReqAnsContext<CardReadAdapterService_GetAddCardInfo_Req, CardReadAdapterService_GetAddCardInfo_Ans>::Pointer ctx);
  39. virtual void Handle_Test1(SpReqAnsContext<CardReadAdapterService_Test1_Req, CardReadAdapterService_Test1_Ans>::Pointer ctx);
  40. virtual void Handle_Test2(SpReqAnsContext<CardReadAdapterService_Test2_Req, CardReadAdapterService_Test2_Ans>::Pointer ctx);
  41. virtual void Handle_CrossTermCall(SpReqAnsContext<CardReadAdapterService_CrossTermCall_Req, CardReadAdapterService_CrossTermCall_Ans>::Pointer ctx);
  42. virtual void Handle_CrossTermInvokeInfo(SpOnewayCallContext<CardReadAdapterService_CrossTermInvokeInfo_Info>::Pointer ctx);
  43. virtual void Handle_PrintCardImmediately(SpReqAnsContext<CardReadAdapterService_PrintCardImmediately_Req, CardReadAdapterService_PrintCardImmediately_Ans>::Pointer ctx);
  44. virtual void Handle_QueryCIStatus(SpReqAnsContext<CardReadAdapterService_QueryCIStatus_Req, CardReadAdapterService_QueryCIStatus_Ans>::Pointer ctx);
  45. private:
  46. CCardReadAdapterEntity* m_pEntity;
  47. };
  48. class CCardReadAdapterEntity : public CEntityBase,public IBroadcastListener
  49. {
  50. public:
  51. CCardReadAdapterEntity() :bInitialized(false),m_msgMaxInterval(5000)//, m_bCIMsg(false), m_bCCMsg(false), m_bCSMsg(false)
  52. {
  53. //MessageBoxA(NULL, "", "", MB_OK);
  54. }
  55. virtual ~CCardReadAdapterEntity(){}
  56. virtual const char *GetEntityName() const { return "CardReadAdapter"; }
  57. virtual void OnPreStart(CAutoArray<CSimpleStringA> strArgs,CSmartPointer<ITransactionContext> pTransactionContext)
  58. {
  59. LOG_FUNCTION();
  60. //MessageBoxA(0,0,0,0);
  61. ErrorCodeEnum eStart = m_fsm.Init(this);
  62. if (eStart == Error_Succeed)
  63. {
  64. DoStart();
  65. GetFunction()->SubscribeBroadcast("CardIssuerStand", "", this, m_uuidCIMsg);
  66. GetFunction()->SubscribeBroadcast("CardIssuerStore", "", this, m_uuidCISMsg);
  67. GetFunction()->SubscribeBroadcast("ContactlessCard", "", this, m_uuidCCMsg);
  68. }
  69. pTransactionContext->SendAnswer(eStart);
  70. }
  71. virtual void OnPreClose(EntityCloseCauseEnum eCloseCause,CSmartPointer<ITransactionContext> pTransactionContext)
  72. {
  73. ErrorCodeEnum Error = __OnStart(Error_Succeed);
  74. pTransactionContext->SendAnswer(Error);
  75. }
  76. virtual void OnPrePause(CSmartPointer<ITransactionContext> pTransactionContext)
  77. {
  78. ErrorCodeEnum Error = __OnPause(Error_Succeed);
  79. pTransactionContext->SendAnswer(Error);
  80. }
  81. virtual ErrorCodeEnum __OnStart(ErrorCodeEnum preOperationError)
  82. {
  83. return Error_Succeed;
  84. }
  85. virtual ErrorCodeEnum __OnPause(ErrorCodeEnum preOperationError)
  86. {
  87. return Error_Succeed;
  88. }
  89. virtual ErrorCodeEnum __OnClose(ErrorCodeEnum preOperationError)
  90. {
  91. return Error_Succeed;
  92. }
  93. virtual void OnSelfTest(EntityTestEnum eTestType,CSmartPointer<ITransactionContext> pTransactionContext)
  94. {
  95. m_fsm.SelfTest(eTestType,pTransactionContext);
  96. }
  97. virtual CServerSessionBase* OnNewSession(const char*,const char*)
  98. {
  99. DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("A new connecting request arrived.");
  100. m_bNewSessionInit = true;
  101. return new CardReadAdapterServerSession(this);
  102. }
  103. bool Init()
  104. {
  105. }
  106. void Read(SpReqAnsContext<CardReadAdapterService_Read_Req, CardReadAdapterService_Read_Ans>::Pointer ctx)
  107. {
  108. LOG_FUNCTION();
  109. //oilyang@20210125 add:query current FSM state ,then post event
  110. int xFSM, xS2Evt, xS2EvtParam1;
  111. xFSM = xS2Evt = xS2EvtParam1 = 0;
  112. m_fsm.QueryCurrFSMAndLastS2EventInfo(xFSM, xS2Evt, xS2EvtParam1);
  113. CSimpleStringA msg = CSimpleStringA::Format("While FSM is in state:%d lastS2evt:%d,param1:%d,a new Read req arrived."
  114. , xFSM, xS2Evt, xS2EvtParam1);
  115. //3:Working 4:Failed
  116. if (xFSM == 3)
  117. {
  118. ctx->Answer(Error_InvalidState, CardReadAdapter_UserErrorCode_Read_Wrong_In_Working);
  119. LogWarn(Severity_Middle, Error_InvalidState, CardReadAdapter_UserErrorCode_Read_Wrong_In_Working, (LPCTSTR)msg);
  120. }
  121. else if (xFSM == 4)
  122. {
  123. ctx->Answer(Error_InvalidState, CardReadAdapter_UserErrorCode_Read_Wrong_In_Failed);
  124. LogWarn(Severity_Middle, Error_InvalidState, CardReadAdapter_UserErrorCode_Read_Wrong_In_Failed, (LPCTSTR)msg);
  125. }
  126. else
  127. {
  128. CardReadEvent* e = new CardReadEvent();
  129. e->ctx = ctx;
  130. m_fsm.PostEventFIFO(e);
  131. }
  132. }
  133. void Capture(SpReqAnsContext<CardReadAdapterService_Capture_Req, CardReadAdapterService_Capture_Ans>::Pointer ctx)
  134. {
  135. LOG_FUNCTION();
  136. CardCaptureEvent* e = new CardCaptureEvent();
  137. e->ctx = ctx;
  138. m_fsm.PostEventFIFO(e);
  139. }
  140. void Eject(SpReqAnsContext<CardReadAdapterService_Eject_Req, CardReadAdapterService_Eject_Ans>::Pointer ctx)
  141. {
  142. LOG_FUNCTION();
  143. CardEjectEvent* e = new CardEjectEvent();
  144. e->ctx = ctx;
  145. m_fsm.PostEventFIFO(e);
  146. }
  147. void CancelRead(SpOnewayCallContext<CardReadAdapterService_CancelRead_Info>::Pointer ctx)
  148. {
  149. LOG_FUNCTION();
  150. CancelReadEvent* e = new CancelReadEvent();
  151. m_fsm.PostEventFIFO(e);
  152. }
  153. void ReadWaitMore(SpOnewayCallContext<CardReadAdapterService_ReadWaitMore_Info>::Pointer ctx)
  154. {
  155. LOG_FUNCTION();
  156. ReadWaitMoreEvent* e = new ReadWaitMoreEvent();
  157. m_fsm.PostEventFIFO(e);
  158. }
  159. void Issue(SpReqAnsContext<CardReadAdapterService_Issue_Req, CardReadAdapterService_Issue_Ans>::Pointer ctx)
  160. {
  161. m_bNewSessionInit = false;
  162. CardIssueEvent *pEvt = new CardIssueEvent();
  163. pEvt->ctx = ctx;
  164. m_fsm.PostEventFIFO(pEvt);
  165. }
  166. void PreOnline(SpReqAnsContext<CardReadAdapterService_PreOnline_Req, CardReadAdapterService_PreOnline_Ans>::Pointer ctx)
  167. {
  168. LOG_FUNCTION();
  169. if (m_fsm.GetCurrState()->id == 3)
  170. {
  171. ctx->Answer(Error_DevNotAvailable, CardReadAdapter_UserErrorCode_CardIssuer_Is_Working);
  172. LogWarn(Severity_Middle, Error_DevNotAvailable, CardReadAdapter_UserErrorCode_CardIssuer_Is_Working, "CardReadAdapter is working,duplicated call.");
  173. }
  174. else
  175. {
  176. PreOnlineEvent* e = new PreOnlineEvent();
  177. e->ctx = ctx;
  178. m_fsm.PostEventFIFO(e);
  179. }
  180. }
  181. void PostOnline(SpReqAnsContext<CardReadAdapterService_PostOnline_Req, CardReadAdapterService_PostOnline_Ans>::Pointer ctx)
  182. {
  183. LOG_FUNCTION();
  184. PostOnlineEvent* e = new PostOnlineEvent();
  185. e->ctx = ctx;
  186. m_fsm.PostEventFIFO(e);
  187. }
  188. void Exit(SpOnewayCallContext<CardReadAdapterService_Exit_Info>::Pointer ctx)
  189. {
  190. LOG_FUNCTION();
  191. m_bNewSessionInit = false;
  192. FSMEvent* evt = new FSMEvent(USER_EVT_EXIT);
  193. m_fsm.PostEventFIFO(evt);
  194. }
  195. void QueryCardInfo(SpReqAnsContext<CardReadAdapterService_QueryCardInfo_Req, CardReadAdapterService_QueryCardInfo_Ans>::Pointer ctx)
  196. {
  197. int xFSM, xS2Evt, xS2EvtParam1;
  198. xFSM = xS2Evt = xS2EvtParam1 = 0;
  199. m_fsm.QueryCurrFSMAndLastS2EventInfo(xFSM, xS2Evt, xS2EvtParam1);
  200. CSimpleStringA msg = CSimpleStringA::Format("While FSM is in state:%d lastS2evt:%d,param1:%d,a new QueryCardInfo req arrived."
  201. , xFSM, xS2Evt, xS2EvtParam1);
  202. //3:Working 4:Failed
  203. if (xFSM == 3)
  204. {
  205. ctx->Answer(Error_InvalidState, CardReadAdapter_UserErrorCode_QueryCardInfo_Wrong_In_Working);
  206. LogWarn(Severity_Middle, Error_InvalidState, CardReadAdapter_UserErrorCode_QueryCardInfo_Wrong_In_Working, (LPCTSTR)msg);
  207. }
  208. else if (xFSM == 4)
  209. {
  210. ctx->Answer(Error_InvalidState, CardReadAdapter_UserErrorCode_QueryCardInfo_Wrong_In_Failed);
  211. LogWarn(Severity_Middle, Error_InvalidState, CardReadAdapter_UserErrorCode_QueryCardInfo_Wrong_In_Failed, (LPCTSTR)msg);
  212. }
  213. else
  214. {
  215. QueryCardInfoEvent* pEvt = new QueryCardInfoEvent();
  216. pEvt->ctx = ctx;
  217. m_fsm.PostEventFIFO(pEvt);
  218. }
  219. }
  220. void WriteTrack(SpReqAnsContext<CardReadAdapterService_WriteTrack_Req, CardReadAdapterService_WriteTrack_Ans>::Pointer ctx)
  221. {
  222. CardWriteEvent *pEvt = new CardWriteEvent();
  223. pEvt->ctx = ctx;
  224. m_fsm.PostEventFIFO(pEvt);
  225. }
  226. void SetSomeFlag(SpReqAnsContext<CardReadAdapterService_SetSomeFlag_Req, CardReadAdapterService_SetSomeFlag_Ans>::Pointer ctx)
  227. {
  228. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER)("set issue flag to %d.", ctx->Req.IssueBusiness);
  229. if (ctx->Req.reserved1.GetCount() > 0)
  230. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER)("hoppernum:%d", ctx->Req.reserved1[0]);
  231. SetSomeFlagEvent *pEvt = new SetSomeFlagEvent();
  232. pEvt->ctx = ctx;
  233. m_fsm.PostEventFIFO(pEvt);
  234. }
  235. void GetMaterialCount(SpReqAnsContext<CardReadAdapterService_GetMaterialCount_Req, CardReadAdapterService_GetMaterialCount_Ans>::Pointer ctx)
  236. {
  237. GetMaterialEvent *pEvt = new GetMaterialEvent();
  238. pEvt->ctx = ctx;
  239. m_fsm.PostEventFIFO(pEvt);
  240. }
  241. void SetMaterialCount(SpReqAnsContext<CardReadAdapterService_SetMaterialCount_Req, CardReadAdapterService_SetMaterialCount_Ans>::Pointer ctx)
  242. {
  243. SetMaterialEvent *pEvt = new SetMaterialEvent();
  244. pEvt->ctx = ctx;
  245. m_fsm.PostEventFIFO(pEvt);
  246. }
  247. void GetSCIInfo(SpReqAnsContext<CardReadAdapterService_GetSCIInfo_Req, CardReadAdapterService_GetSCIInfo_Ans>::Pointer ctx)
  248. {
  249. GetSCIInfoEvent *pEvt = new GetSCIInfoEvent();
  250. pEvt->ctx = ctx;
  251. m_fsm.PostEventFIFO(pEvt);
  252. }
  253. void OpenSafeLock(SpReqAnsContext<CardReadAdapterService_OpenSafeLock_Req, CardReadAdapterService_OpenSafeLock_Ans>::Pointer ctx)
  254. {
  255. OpenSafeLockEvent *pEvt = new OpenSafeLockEvent();
  256. pEvt->ctx = ctx;
  257. m_fsm.PostEventFIFO(pEvt);
  258. }
  259. void MagTransferInit(SpReqAnsContext<CardReadAdapterService_MagTransferInit_Req, CardReadAdapterService_MagTransferInit_Ans>::Pointer ctx)
  260. {
  261. MagTransferInitEvent *pEvt = new MagTransferInitEvent();
  262. pEvt->ctx = ctx;
  263. m_fsm.PostEventFIFO(pEvt);
  264. }
  265. void QueryConnInfo(SpReqAnsContext<CardReadAdapterService_QueryConnInfo_Req, CardReadAdapterService_QueryConnInfo_Ans>::Pointer ctx)
  266. {
  267. QueryConnInfoEvent *pEvt = new QueryConnInfoEvent();
  268. pEvt->ctx = ctx;
  269. m_fsm.PostEventFIFO(pEvt);
  270. }
  271. void SAMICCommand(SpReqAnsContext<CardReadAdapterService_SAMICCommand_Req, CardReadAdapterService_SAMICCommand_Ans>::Pointer ctx)
  272. {
  273. SAMICCommandEvent *pEvt = new SAMICCommandEvent();
  274. pEvt->ctx = ctx;
  275. m_fsm.PostEventFIFO(pEvt);
  276. }
  277. void QueryPrinterStatus(SpReqAnsContext<CardReadAdapterService_QueryPrinterStatus_Req, CardReadAdapterService_QueryPrinterStatus_Ans>::Pointer ctx)
  278. {
  279. QueryPrinterStatusEvent *pEvt = new QueryPrinterStatusEvent();
  280. pEvt->ctx = ctx;
  281. m_fsm.PostEventFIFO(pEvt);
  282. }
  283. void Print(SpReqAnsContext<CardReadAdapterService_Print_Req, CardReadAdapterService_Print_Ans>::Pointer ctx)
  284. {
  285. PrintEvent *pEvt = new PrintEvent();
  286. pEvt->ctx = ctx;
  287. m_fsm.PostEventFIFO(pEvt);
  288. }
  289. void QuerySCIList(SpReqAnsContext<CardReadAdapterService_QuerySCIList_Req, CardReadAdapterService_QuerySCIList_Ans>::Pointer ctx)
  290. {
  291. QuerySCIListEvent *pEvt = new QuerySCIListEvent();
  292. pEvt->ctx = ctx;
  293. m_fsm.PostEventFIFO(pEvt);
  294. }
  295. void BindSCI(SpReqAnsContext<CardReadAdapterService_BindSCI_Req, CardReadAdapterService_BindSCI_Ans>::Pointer ctx)
  296. {
  297. BindSCIEvent *pEvt = new BindSCIEvent();
  298. pEvt->ctx = ctx;
  299. m_fsm.PostEventFIFO(pEvt);
  300. }
  301. void PreOnlineOnStore(SpReqAnsContext<CardReadAdapterService_PreOnlineOnStore_Req, CardReadAdapterService_PreOnlineOnStore_Ans>::Pointer ctx)
  302. {
  303. PreOnlineOnStoreEvent *pEvt = new PreOnlineOnStoreEvent();
  304. pEvt->ctx = ctx;
  305. m_fsm.PostEventFIFO(pEvt);
  306. }
  307. void NotifyPreonline(SpReqAnsContext<CardReadAdapterService_NotifyPreonline_Req, CardReadAdapterService_NotifyPreonline_Ans>::Pointer ctx)
  308. {
  309. NotifyPreonlineEvent *pEvt = new NotifyPreonlineEvent();
  310. pEvt->ctx = ctx;
  311. m_fsm.PostEventFIFO(pEvt);
  312. }
  313. void QueryCardInfoOnStore(SpReqAnsContext<CardReadAdapterService_QueryCardInfoOnStore_Req, CardReadAdapterService_QueryCardInfoOnStore_Ans>::Pointer ctx)
  314. {
  315. QueryCardInfoOnStoreEvent *pEvt = new QueryCardInfoOnStoreEvent();
  316. pEvt->ctx = ctx;
  317. m_fsm.PostEventFIFO(pEvt);
  318. }
  319. void GetAddCardInfo(SpReqAnsContext<CardReadAdapterService_GetAddCardInfo_Req, CardReadAdapterService_GetAddCardInfo_Ans>::Pointer ctx)
  320. {
  321. GetAddCardInfoEvent *pEvt = new GetAddCardInfoEvent();
  322. pEvt->ctx = ctx;
  323. m_fsm.PostEventFIFO(pEvt);
  324. }
  325. void CrossTermCall(SpReqAnsContext<CardReadAdapterService_CrossTermCall_Req, CardReadAdapterService_CrossTermCall_Ans>::Pointer ctx)
  326. {
  327. CrossTermCallEvent *pEvt = new CrossTermCallEvent();
  328. pEvt->ctx = ctx;
  329. m_fsm.PostEventFIFO(pEvt);
  330. }
  331. void CrossTermInvokeInfo(SpOnewayCallContext<CardReadAdapterService_CrossTermInvokeInfo_Info>::Pointer ctx)
  332. {
  333. m_fsm.CrossTermInvokeInfo(ctx);
  334. }
  335. void PrintCardImmediately(SpReqAnsContext<CardReadAdapterService_PrintCardImmediately_Req, CardReadAdapterService_PrintCardImmediately_Ans>::Pointer ctx)
  336. {
  337. PrintCardImEvent* pEvt = new PrintCardImEvent();
  338. pEvt->ctx = ctx;
  339. m_fsm.PostEventFIFO(pEvt);
  340. }
  341. void QueryCIStatus(SpReqAnsContext<CardReadAdapterService_QueryCIStatus_Req, CardReadAdapterService_QueryCIStatus_Ans>::Pointer ctx)
  342. {
  343. QueryCIStatusEvent* pEvt = new QueryCIStatusEvent();
  344. pEvt->ctx = ctx;
  345. m_fsm.PostEventFIFO(pEvt);
  346. }
  347. void GetDevInfo(SpReqAnsContext<CardReadAdapterService_GetDevInfo_Req, CardReadAdapterService_GetDevInfo_Ans>::Pointer ctx)
  348. {
  349. GetDevInfoEvent *pEvt = new GetDevInfoEvent();
  350. pEvt->ctx = ctx;
  351. m_fsm.PostEventFIFO(pEvt);
  352. }
  353. virtual bool IsService()const{return true;}
  354. virtual bool IsMultiThread()const{return true;}
  355. virtual void OnBroadcastEvent(CUUID SubID, const char *pszEntityName, DWORD dwMessageId, DWORD dwMessageSignature, CAutoBuffer Buffer);
  356. void DoBroadMsg(int msgType, int status);
  357. void DoStart();
  358. protected:
  359. private:
  360. CCardReadAdapterFSM m_fsm;
  361. CUUID m_uuidCIMsg, m_uuidCISMsg, m_uuidCSMsg, m_uuidCCMsg;
  362. bool bInitialized, m_bNewSessionInit;// , m_bCIMsg, m_bCCMsg, m_bCSMsg;
  363. int m_msgMaxInterval;
  364. private:
  365. };
  366. struct DoBroadMsgTask : public ITaskSp
  367. {
  368. CCardReadAdapterEntity* pEntity;
  369. int m_msgType;
  370. int m_status;
  371. DoBroadMsgTask(CCardReadAdapterEntity* f, int msgType, int status) : pEntity(f),m_msgType(msgType),m_status(status) {}
  372. void Process()
  373. {
  374. pEntity->DoBroadMsg(m_msgType, m_status);
  375. }
  376. };