mod_CardReadAdapter.h 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417
  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_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. GetFunction()->SubscribeBroadcast("CardIssuer", "", this, m_uuidCIMsg);
  65. GetFunction()->SubscribeBroadcast("ContactlessCard", "", this, m_uuidCCMsg);
  66. GetFunction()->SubscribeBroadcast("CardSwiper", "", this, m_uuidCSMsg);
  67. }
  68. pTransactionContext->SendAnswer(eStart);
  69. }
  70. virtual void OnPreClose(EntityCloseCauseEnum eCloseCause,CSmartPointer<ITransactionContext> pTransactionContext)
  71. {
  72. ErrorCodeEnum Error = __OnStart(Error_Succeed);
  73. pTransactionContext->SendAnswer(Error);
  74. }
  75. virtual void OnPrePause(CSmartPointer<ITransactionContext> pTransactionContext)
  76. {
  77. ErrorCodeEnum Error = __OnPause(Error_Succeed);
  78. pTransactionContext->SendAnswer(Error);
  79. }
  80. virtual ErrorCodeEnum __OnStart(ErrorCodeEnum preOperationError)
  81. {
  82. return Error_Succeed;
  83. }
  84. virtual ErrorCodeEnum __OnPause(ErrorCodeEnum preOperationError)
  85. {
  86. return Error_Succeed;
  87. }
  88. virtual ErrorCodeEnum __OnClose(ErrorCodeEnum preOperationError)
  89. {
  90. return Error_Succeed;
  91. }
  92. virtual void OnSelfTest(EntityTestEnum eTestType,CSmartPointer<ITransactionContext> pTransactionContext)
  93. {
  94. m_fsm.SelfTest(eTestType,pTransactionContext);
  95. }
  96. virtual CServerSessionBase* OnNewSession(const char*,const char*)
  97. {
  98. DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("A new connecting request arrived.");
  99. m_bNewSessionInit = true;
  100. return new CardReadAdapterServerSession(this);
  101. }
  102. bool Init()
  103. {
  104. }
  105. void Read(SpReqAnsContext<CardReadAdapterService_Read_Req, CardReadAdapterService_Read_Ans>::Pointer ctx)
  106. {
  107. LOG_FUNCTION();
  108. if (m_fsm.IsRVCIL())
  109. {
  110. CBlob bbSend;
  111. SpObject2Blob(ctx->Req, bbSend);
  112. //m_fsm.SetReadCtx(ctx);
  113. m_fsm.SaveCtx(CardReadAdapterService_Method_Read, ctx);
  114. ctx.AddRef();
  115. m_fsm.LocalCallHeartBeat(CardReadAdapterService_Method_Read, bbSend);
  116. }
  117. else
  118. {
  119. //oilyang@20210125 add:query current FSM state ,then post event
  120. int xFSM, xS2Evt, xS2EvtParam1;
  121. xFSM = xS2Evt = xS2EvtParam1 = 0;
  122. m_fsm.QueryCurrFSMAndLastS2EventInfo(xFSM,xS2Evt,xS2EvtParam1);
  123. CSimpleStringA msg = CSimpleStringA::Format("While FSM is in state:%d lastS2evt:%d,param1:%d,a new Read req arrived."
  124. , xFSM, xS2Evt, xS2EvtParam1);
  125. //3:Working 4:Failed
  126. if (xFSM == 3)
  127. {
  128. ctx->Answer(Error_InvalidState, CardReadAdapter_UserErrorCode_Read_Wrong_In_Working);
  129. LogWarn(Severity_Middle, Error_InvalidState, CardReadAdapter_UserErrorCode_Read_Wrong_In_Working, (LPCTSTR)msg);
  130. }
  131. else if (xFSM == 4)
  132. {
  133. ctx->Answer(Error_InvalidState, CardReadAdapter_UserErrorCode_Read_Wrong_In_Failed);
  134. LogWarn(Severity_Middle, Error_InvalidState, CardReadAdapter_UserErrorCode_Read_Wrong_In_Failed, (LPCTSTR)msg);
  135. }
  136. else
  137. {
  138. CardReadEvent* e = new CardReadEvent();
  139. e->ctx = ctx;
  140. m_fsm.PostEventFIFO(e);
  141. }
  142. }
  143. }
  144. void Capture(SpReqAnsContext<CardReadAdapterService_Capture_Req, CardReadAdapterService_Capture_Ans>::Pointer ctx)
  145. {
  146. LOG_FUNCTION();
  147. CardCaptureEvent* e = new CardCaptureEvent();
  148. e->ctx = ctx;
  149. m_fsm.PostEventFIFO(e);
  150. }
  151. void Eject(SpReqAnsContext<CardReadAdapterService_Eject_Req, CardReadAdapterService_Eject_Ans>::Pointer ctx)
  152. {
  153. LOG_FUNCTION();
  154. CardEjectEvent* e = new CardEjectEvent();
  155. e->ctx = ctx;
  156. m_fsm.PostEventFIFO(e);
  157. }
  158. void CancelRead(SpOnewayCallContext<CardReadAdapterService_CancelRead_Info>::Pointer ctx)
  159. {
  160. LOG_FUNCTION();
  161. if (m_fsm.IsRVCIL())
  162. {
  163. CBlob bbSend;
  164. //ErrorCodeEnum eErr = SpObject2Blob(ctx->Info, bbSend);
  165. m_fsm.LocalCallHeartBeat(CardReadAdapterService_Method_CancelRead, bbSend,true);
  166. }
  167. else
  168. {
  169. CancelReadEvent *e = new CancelReadEvent();
  170. m_fsm.PostEventFIFO(e);
  171. }
  172. }
  173. void ReadWaitMore(SpOnewayCallContext<CardReadAdapterService_ReadWaitMore_Info>::Pointer ctx)
  174. {
  175. LOG_FUNCTION();
  176. if (m_fsm.IsRVCIL())
  177. {
  178. CBlob bbSend;
  179. //ErrorCodeEnum eErr = SpObject2Blob(ctx->Info, bbSend);
  180. m_fsm.LocalCallHeartBeat(CardReadAdapterService_Method_ReadWaitMore, bbSend);
  181. }
  182. else
  183. {
  184. ReadWaitMoreEvent *e = new ReadWaitMoreEvent();
  185. m_fsm.PostEventFIFO(e);
  186. }
  187. }
  188. void Issue(SpReqAnsContext<CardReadAdapterService_Issue_Req, CardReadAdapterService_Issue_Ans>::Pointer ctx)
  189. {
  190. m_bNewSessionInit = false;
  191. CardIssueEvent *pEvt = new CardIssueEvent();
  192. pEvt->ctx = ctx;
  193. m_fsm.PostEventFIFO(pEvt);
  194. }
  195. void PreOnline(SpReqAnsContext<CardReadAdapterService_PreOnline_Req, CardReadAdapterService_PreOnline_Ans>::Pointer ctx)
  196. {
  197. LOG_FUNCTION();
  198. if (m_fsm.GetCurrState()->id == 3)
  199. {
  200. ctx->Answer(Error_DevNotAvailable, CardReadAdapter_UserErrorCode_CardIssuer_Is_Working);
  201. LogWarn(Severity_Middle, Error_DevNotAvailable, CardReadAdapter_UserErrorCode_CardIssuer_Is_Working, "CardIssuer is working,duplicated call.");
  202. }
  203. else
  204. {
  205. PreOnlineEvent* e = new PreOnlineEvent();
  206. e->ctx = ctx;
  207. m_fsm.PostEventFIFO(e);
  208. }
  209. }
  210. void PostOnline(SpReqAnsContext<CardReadAdapterService_PostOnline_Req, CardReadAdapterService_PostOnline_Ans>::Pointer ctx)
  211. {
  212. LOG_FUNCTION();
  213. PostOnlineEvent* e = new PostOnlineEvent();
  214. e->ctx = ctx;
  215. m_fsm.PostEventFIFO(e);
  216. }
  217. void Exit(SpOnewayCallContext<CardReadAdapterService_Exit_Info>::Pointer ctx)
  218. {
  219. LOG_FUNCTION();
  220. m_bNewSessionInit = false;
  221. if (m_fsm.IsRVCIL())
  222. {
  223. CBlob bbSend;
  224. //ErrorCodeEnum eErr = SpObject2Blob(ctx->Info, bbSend);
  225. m_fsm.LocalCallHeartBeat(CardReadAdapterService_Method_Exit, bbSend);
  226. }
  227. else
  228. {
  229. FSMEvent *evt = new FSMEvent(USER_EVT_EXIT);
  230. m_fsm.PostEventFIFO(evt);
  231. }
  232. }
  233. void QueryCardInfo(SpReqAnsContext<CardReadAdapterService_QueryCardInfo_Req, CardReadAdapterService_QueryCardInfo_Ans>::Pointer ctx)
  234. {
  235. int xFSM, xS2Evt, xS2EvtParam1;
  236. xFSM = xS2Evt = xS2EvtParam1 = 0;
  237. m_fsm.QueryCurrFSMAndLastS2EventInfo(xFSM, xS2Evt, xS2EvtParam1);
  238. CSimpleStringA msg = CSimpleStringA::Format("While FSM is in state:%d lastS2evt:%d,param1:%d,a new QueryCardInfo req arrived."
  239. , xFSM, xS2Evt, xS2EvtParam1);
  240. //3:Working 4:Failed
  241. if (xFSM == 3)
  242. {
  243. ctx->Answer(Error_InvalidState, CardReadAdapter_UserErrorCode_QueryCardInfo_Wrong_In_Working);
  244. LogWarn(Severity_Middle, Error_InvalidState, CardReadAdapter_UserErrorCode_QueryCardInfo_Wrong_In_Working, (LPCTSTR)msg);
  245. }
  246. else if (xFSM == 4)
  247. {
  248. ctx->Answer(Error_InvalidState, CardReadAdapter_UserErrorCode_QueryCardInfo_Wrong_In_Failed);
  249. LogWarn(Severity_Middle, Error_InvalidState, CardReadAdapter_UserErrorCode_QueryCardInfo_Wrong_In_Failed, (LPCTSTR)msg);
  250. }
  251. else
  252. {
  253. QueryCardInfoEvent* pEvt = new QueryCardInfoEvent();
  254. pEvt->ctx = ctx;
  255. m_fsm.PostEventFIFO(pEvt);
  256. }
  257. }
  258. void WriteTrack(SpReqAnsContext<CardReadAdapterService_WriteTrack_Req, CardReadAdapterService_WriteTrack_Ans>::Pointer ctx)
  259. {
  260. CardWriteEvent *pEvt = new CardWriteEvent();
  261. pEvt->ctx = ctx;
  262. m_fsm.PostEventFIFO(pEvt);
  263. }
  264. void SetSomeFlag(SpReqAnsContext<CardReadAdapterService_SetSomeFlag_Req, CardReadAdapterService_SetSomeFlag_Ans>::Pointer ctx)
  265. {
  266. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER)("set issue flag to %d.", ctx->Req.IssueBusiness);
  267. if (ctx->Req.reserved1.GetCount() > 0)
  268. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER)("hoppernum:%d", ctx->Req.reserved1[0]);
  269. SetSomeFlagEvent *pEvt = new SetSomeFlagEvent();
  270. pEvt->ctx = ctx;
  271. m_fsm.PostEventFIFO(pEvt);
  272. }
  273. void GetMaterialCount(SpReqAnsContext<CardReadAdapterService_GetMaterialCount_Req, CardReadAdapterService_GetMaterialCount_Ans>::Pointer ctx)
  274. {
  275. GetMaterialEvent *pEvt = new GetMaterialEvent();
  276. pEvt->ctx = ctx;
  277. m_fsm.PostEventFIFO(pEvt);
  278. }
  279. void SetMaterialCount(SpReqAnsContext<CardReadAdapterService_SetMaterialCount_Req, CardReadAdapterService_SetMaterialCount_Ans>::Pointer ctx)
  280. {
  281. SetMaterialEvent *pEvt = new SetMaterialEvent();
  282. pEvt->ctx = ctx;
  283. m_fsm.PostEventFIFO(pEvt);
  284. }
  285. void GetSCIInfo(SpReqAnsContext<CardReadAdapterService_GetSCIInfo_Req, CardReadAdapterService_GetSCIInfo_Ans>::Pointer ctx)
  286. {
  287. GetSCIInfoEvent *pEvt = new GetSCIInfoEvent();
  288. pEvt->ctx = ctx;
  289. m_fsm.PostEventFIFO(pEvt);
  290. }
  291. void OpenSafeLock(SpReqAnsContext<CardReadAdapterService_OpenSafeLock_Req, CardReadAdapterService_OpenSafeLock_Ans>::Pointer ctx)
  292. {
  293. OpenSafeLockEvent *pEvt = new OpenSafeLockEvent();
  294. pEvt->ctx = ctx;
  295. m_fsm.PostEventFIFO(pEvt);
  296. }
  297. void MagTransferInit(SpReqAnsContext<CardReadAdapterService_MagTransferInit_Req, CardReadAdapterService_MagTransferInit_Ans>::Pointer ctx)
  298. {
  299. MagTransferInitEvent *pEvt = new MagTransferInitEvent();
  300. pEvt->ctx = ctx;
  301. m_fsm.PostEventFIFO(pEvt);
  302. }
  303. void QueryConnInfo(SpReqAnsContext<CardReadAdapterService_QueryConnInfo_Req, CardReadAdapterService_QueryConnInfo_Ans>::Pointer ctx)
  304. {
  305. QueryConnInfoEvent *pEvt = new QueryConnInfoEvent();
  306. pEvt->ctx = ctx;
  307. m_fsm.PostEventFIFO(pEvt);
  308. }
  309. void SAMICCommand(SpReqAnsContext<CardReadAdapterService_SAMICCommand_Req, CardReadAdapterService_SAMICCommand_Ans>::Pointer ctx)
  310. {
  311. SAMICCommandEvent *pEvt = new SAMICCommandEvent();
  312. pEvt->ctx = ctx;
  313. m_fsm.PostEventFIFO(pEvt);
  314. }
  315. void QueryPrinterStatus(SpReqAnsContext<CardReadAdapterService_QueryPrinterStatus_Req, CardReadAdapterService_QueryPrinterStatus_Ans>::Pointer ctx)
  316. {
  317. QueryPrinterStatusEvent *pEvt = new QueryPrinterStatusEvent();
  318. pEvt->ctx = ctx;
  319. m_fsm.PostEventFIFO(pEvt);
  320. }
  321. void Print(SpReqAnsContext<CardReadAdapterService_Print_Req, CardReadAdapterService_Print_Ans>::Pointer ctx)
  322. {
  323. PrintEvent *pEvt = new PrintEvent();
  324. pEvt->ctx = ctx;
  325. m_fsm.PostEventFIFO(pEvt);
  326. }
  327. void QuerySCIList(SpReqAnsContext<CardReadAdapterService_QuerySCIList_Req, CardReadAdapterService_QuerySCIList_Ans>::Pointer ctx)
  328. {
  329. QuerySCIListEvent *pEvt = new QuerySCIListEvent();
  330. pEvt->ctx = ctx;
  331. m_fsm.PostEventFIFO(pEvt);
  332. }
  333. void BindSCI(SpReqAnsContext<CardReadAdapterService_BindSCI_Req, CardReadAdapterService_BindSCI_Ans>::Pointer ctx)
  334. {
  335. BindSCIEvent *pEvt = new BindSCIEvent();
  336. pEvt->ctx = ctx;
  337. m_fsm.PostEventFIFO(pEvt);
  338. }
  339. void PreOnlineOnStore(SpReqAnsContext<CardReadAdapterService_PreOnlineOnStore_Req, CardReadAdapterService_PreOnlineOnStore_Ans>::Pointer ctx)
  340. {
  341. PreOnlineOnStoreEvent *pEvt = new PreOnlineOnStoreEvent();
  342. pEvt->ctx = ctx;
  343. m_fsm.PostEventFIFO(pEvt);
  344. }
  345. void NotifyPreonline(SpReqAnsContext<CardReadAdapterService_NotifyPreonline_Req, CardReadAdapterService_NotifyPreonline_Ans>::Pointer ctx)
  346. {
  347. NotifyPreonlineEvent *pEvt = new NotifyPreonlineEvent();
  348. pEvt->ctx = ctx;
  349. m_fsm.PostEventFIFO(pEvt);
  350. }
  351. void QueryCardInfoOnStore(SpReqAnsContext<CardReadAdapterService_QueryCardInfoOnStore_Req, CardReadAdapterService_QueryCardInfoOnStore_Ans>::Pointer ctx)
  352. {
  353. QueryCardInfoOnStoreEvent *pEvt = new QueryCardInfoOnStoreEvent();
  354. pEvt->ctx = ctx;
  355. m_fsm.PostEventFIFO(pEvt);
  356. }
  357. void GetAddCardInfo(SpReqAnsContext<CardReadAdapterService_GetAddCardInfo_Req, CardReadAdapterService_GetAddCardInfo_Ans>::Pointer ctx)
  358. {
  359. GetAddCardInfoEvent *pEvt = new GetAddCardInfoEvent();
  360. pEvt->ctx = ctx;
  361. m_fsm.PostEventFIFO(pEvt);
  362. }
  363. void CrossTermCall(SpReqAnsContext<CardReadAdapterService_CrossTermCall_Req, CardReadAdapterService_CrossTermCall_Ans>::Pointer ctx)
  364. {
  365. CrossTermCallEvent *pEvt = new CrossTermCallEvent();
  366. pEvt->ctx = ctx;
  367. m_fsm.PostEventFIFO(pEvt);
  368. }
  369. void CrossTermInvokeInfo(SpOnewayCallContext<CardReadAdapterService_CrossTermInvokeInfo_Info>::Pointer ctx)
  370. {
  371. m_fsm.CrossTermInvokeInfo(ctx);
  372. }
  373. void PrintCardImmediately(SpReqAnsContext<CardReadAdapterService_PrintCardImmediately_Req, CardReadAdapterService_PrintCardImmediately_Ans>::Pointer ctx)
  374. {
  375. PrintCardImEvent* pEvt = new PrintCardImEvent();
  376. pEvt->ctx = ctx;
  377. m_fsm.PostEventFIFO(pEvt);
  378. }
  379. void QueryCIStatus(SpReqAnsContext<CardReadAdapterService_QueryCIStatus_Req, CardReadAdapterService_QueryCIStatus_Ans>::Pointer ctx)
  380. {
  381. QueryCIStatusEvent* pEvt = new QueryCIStatusEvent();
  382. pEvt->ctx = ctx;
  383. m_fsm.PostEventFIFO(pEvt);
  384. }
  385. void GetDevInfo(SpReqAnsContext<CardReadAdapterService_GetDevInfo_Req, CardReadAdapterService_GetDevInfo_Ans>::Pointer ctx)
  386. {
  387. GetDevInfoEvent *pEvt = new GetDevInfoEvent();
  388. pEvt->ctx = ctx;
  389. m_fsm.PostEventFIFO(pEvt);
  390. }
  391. virtual bool IsService()const{return true;}
  392. virtual bool IsMultiThread()const{return true;}
  393. virtual void OnBroadcastEvent(CUUID SubID, const char *pszEntityName, DWORD dwMessageId, DWORD dwMessageSignature, CAutoBuffer Buffer);
  394. protected:
  395. private:
  396. CCardReadAdapterFSM m_fsm;
  397. CUUID m_uuidCIMsg, m_uuidCSMsg, m_uuidCCMsg;
  398. bool bInitialized, m_bNewSessionInit;// , m_bCIMsg, m_bCCMsg, m_bCSMsg;
  399. private:
  400. };