CardReadAdapterFSM.h 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362
  1. #ifndef __CARDREAD_ADAPTER_FSM_H
  2. #define __CARDREAD_ADAPTER_FSM_H
  3. #pragma once
  4. #include "SpFSM.h"
  5. #include "CardReadAdapter_server_g.h"
  6. #include "CommEntityUtil.hpp"
  7. #include "CardIssuerClass.h"
  8. //#include "CardAssist.h"
  9. #include "CardIssuer_UserErrorCode.h"
  10. #include "CardIssuerStore_UserErrorCode.h"
  11. //#include "ICDataElement.h"
  12. using namespace CardReadAdapter;
  13. #include "CardIssuerStand_client_g.h"
  14. #include "CardIssuerStore_client_g.h"
  15. #include "ContactlessCard_client_g.h"
  16. #include "CardIssuerStand_msg_g.h"
  17. #include "CardIssuerStore_msg_g.h"
  18. #include "ContactlessCard_msg_g.h"
  19. #include "CardReadAdapter_msg_g.h"
  20. #include "HeartBeat_client_g.h"
  21. #include "CardReadAdapter_UserErrorCode.h"
  22. #include <map>
  23. using namespace std;
  24. using namespace HeartBeat;
  25. using namespace CardIssuerStand;
  26. using namespace CardIssuerStore;
  27. using namespace ContactlessCard;
  28. enum EvtType
  29. {
  30. USER_EVT_TEST = EVT_USER + 1,
  31. USER_EVT_QUIT,
  32. USER_EVT_INIT,
  33. USER_EVT_INIT_FINISHED,
  34. // USER_EVT_CARD_ACCEPT,
  35. // USER_EVT_CARD_ACCEPT_FINISHED,
  36. USER_EVT_READ,
  37. USER_EVT_READ_FINISHED,
  38. USER_EVT_READ_CANCEL,
  39. USER_EVT_READ_WAIT_MORE,
  40. USER_EVT_PREONLINE,
  41. USER_EVT_POSTONLINE,
  42. USER_EVT_PREONLINE_FINISHED,
  43. USER_EVT_POSTONLINE_FINISHED,
  44. USER_EVT_EJECT,
  45. USER_EVT_EJECT_FINISHED,
  46. USER_EVT_ISSUE,
  47. USER_EVT_ISSUE_FINISHED,
  48. USER_EVT_CAPTURE,
  49. USER_EVT_WAITFINISHED,
  50. USER_EVT_CAPTUREFINISHED,
  51. USER_EVT_WAITFETCHINGTIMEOUT,
  52. USER_EVT_RESET,
  53. USER_EVT_RESETFINISHED,
  54. USER_EVT_EXIT,
  55. USER_EVT_WRITE,
  56. USER_EVT_WRITE_FINISHED,
  57. USER_EVT_SET_SOME_FLAG,
  58. USER_EVT_SET_SOME_FLAG_FINISHED,
  59. USER_EVT_GET_DEV_INFO,
  60. USER_EVT_GET_DEV_INFO_FINISHED,
  61. USER_EVT_QUERY_CARD_INFO,
  62. USER_EVT_QUERY_CARD_INFO_FINISHED,
  63. USER_EVT_GET_MATERIAL,
  64. USER_EVT_GET_MATERIAL_FINISHED,
  65. USER_EVT_SET_MATERIAL,
  66. USER_EVT_SET_MATERIAL_FINISHED,
  67. USER_EVT_GET_SCI_INFO,
  68. USER_EVT_GET_SCI_INFO_FINISHED,
  69. USER_EVT_OPEN_SAFELOCK,
  70. USER_EVT_OPEN_SAFELOCK_FINISHED,
  71. USER_EVT_MAGTRANS_INIT,
  72. USER_EVT_MAGTRANS_INIT_FINISHED,
  73. USER_EVT_QUERY_CONN_INFO,
  74. USER_EVT_QUERY_CONN_INFO_FINISHED,
  75. USER_EVT_SAM_IC_COMMAND,
  76. USER_EVT_SAM_IC_COMMAND_FINISHED,
  77. USER_EVT_PREONLINE_ON_STORE,
  78. USER_EVT_PREONLINE_ON_STORE_FINISHED,
  79. USER_EVT_GET_ADD_CARD_INFO,
  80. USER_EVT_GET_ADD_CARD_INFO_FINISHED,
  81. USER_EVT_NOTIFY_PREONLINE,
  82. USER_EVT_NOTIFY_PREONLINE_FINISHED,
  83. USER_EVT_QUERY_CARD_INFO_ON_STORE,
  84. USER_EVT_QUERY_CARD_INFO_ON_STORE_FINISHED,
  85. USER_EVT_QUERY_PRINTER_STATUS,
  86. USER_EVT_QUERY_PRINTER_STATUS_FINISHED,
  87. USER_EVT_PRINT,
  88. USER_EVT_PRINT_FINISHED,
  89. USER_EVT_QUERY_SCILIST,
  90. USER_EVT_QUERY_SCILIST_FINISHED,
  91. USER_EVT_BIND_SCI,
  92. USER_EVT_BIND_SCI_FINISHED,
  93. USER_EVT_CROSS_TERM_CALL,
  94. USER_EVT_CROSS_TERM_CALL_FINISHED,
  95. USER_EVT_TEST1,
  96. USER_EVT_TEST1_FINISHED,
  97. USER_EVT_TEST2,
  98. USER_EVT_TEST2_FINISHED,
  99. USER_EVT_PRINT_CARD_IM,
  100. USER_EVT_PRINT_CARD_IM_FINISHED,
  101. USER_EVT_QUERY_CI_STATUS,
  102. USER_EVT_QUERY_CI_STATUS_FINISHED,
  103. };
  104. enum CardFromWhichEntity//卡片信息从哪个实体返回
  105. {
  106. Card_In_No_Where,
  107. Card_In_CardIssuer,
  108. Card_In_ContactlessCard
  109. };
  110. enum CardProcStage//stage of card process
  111. {
  112. Card_ProcStage_Idle,
  113. Card_ProcStage_WaitForCard,
  114. Card_ProcStage_Read,
  115. Card_ProcStage_Eject,
  116. Card_ProcStage_Capture,
  117. };
  118. struct BusinessContext
  119. {
  120. CardFromWhichEntity eCardFromWhich;
  121. CardProcStage eCardProcStage;
  122. };
  123. enum ModuleType//从哪个实体读卡
  124. {
  125. Module_Any = 0,
  126. Module_CardIssuer = 1,
  127. Module_ContactlessCard = 2,
  128. Module_CardSwiper = 4,
  129. };
  130. enum CardPosType
  131. {
  132. CardPos_No_Card = 0,//0:检查超时,未发现设备有卡。
  133. CardPos_CardSwiper_Mag_Swipe,//1:CardSwiper刷卡
  134. CardPos_CardSwiper_IC_Insert,//2:CardSwiper插IC卡槽
  135. CardPos_CardSwiper_RFIC,//3 : CardSwiper非接卡
  136. CardPos_CardIssuer_Stand2S,//4:卡片在大机卡机里面
  137. CardPos_ContactlessCard,//5:卡片在大机非接上面
  138. CardPos_CardIssuer_Split//6:卡片在便携发卡机里面
  139. };
  140. enum LightPos
  141. {
  142. LightPos_ALL = 0,
  143. LightPos_CardIssuer = 1,
  144. LightPos_ContactlessCard = 2,
  145. LightPos_CardSwiper_Mag = 4,
  146. LightPos_CardSwiper_IC = 8,
  147. LightPos_CardSwiper_RFIC = 16,
  148. LightPos_CardIssuer_Only_Mag = 32,
  149. };
  150. class CCardReadAdapterEntity;
  151. class CCardReadAdapterFSM;
  152. const int ONE_K = 1024;
  153. class CardIssueEvent : public FSMEvent
  154. {
  155. public:
  156. CardIssueEvent() : FSMEvent(USER_EVT_ISSUE){}
  157. ~CardIssueEvent(){}
  158. SpReqAnsContext<CardReadAdapterService_Issue_Req, CardReadAdapterService_Issue_Ans>::Pointer ctx;
  159. virtual void OnUnhandled()
  160. {
  161. if (ctx != NULL)
  162. {
  163. DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("card issue unhandled");
  164. ctx->Answer(Error_InvalidState);
  165. }
  166. }
  167. };
  168. class CancelReadEvent : public FSMEvent
  169. {
  170. public:
  171. CancelReadEvent() : FSMEvent(USER_EVT_READ_CANCEL){}
  172. ~CancelReadEvent(){}
  173. virtual void OnUnhandled()
  174. {
  175. DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("card cancel accept unhandled");
  176. }
  177. };
  178. class ReadWaitMoreEvent : public FSMEvent
  179. {
  180. public:
  181. ReadWaitMoreEvent() : FSMEvent(USER_EVT_READ_WAIT_MORE){}
  182. ~ReadWaitMoreEvent(){}
  183. virtual void OnUnhandled()
  184. {
  185. DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("ReadWaitMore unhandled");
  186. }
  187. };
  188. class CardReadEvent : public FSMEvent
  189. {
  190. public:
  191. CardReadEvent() : FSMEvent(USER_EVT_READ){}
  192. ~CardReadEvent(){}
  193. SpReqAnsContext<CardReadAdapterService_Read_Req, CardReadAdapterService_Read_Ans>::Pointer ctx;
  194. virtual void OnUnhandled()
  195. {
  196. if (ctx != NULL)
  197. {
  198. DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("card read unhandled");
  199. ctx->Answer(Error_InvalidState);
  200. }
  201. }
  202. protected:
  203. private:
  204. };
  205. class CardReadFinishedEvent : public FSMEvent
  206. {
  207. public:
  208. CardReadFinishedEvent() : FSMEvent(USER_EVT_READ_FINISHED){}
  209. ~CardReadFinishedEvent(){}
  210. SpReqAnsContext<CardReadAdapterService_Read_Req, CardReadAdapterService_Read_Ans>::Pointer ctx;
  211. virtual void OnUnhandled()
  212. {
  213. if (ctx != NULL)
  214. {
  215. DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("card read unhandled(new)");
  216. }
  217. }
  218. protected:
  219. private:
  220. };
  221. class ResetDeviceEvent : public FSMEvent
  222. {
  223. public:
  224. ResetDeviceEvent() : FSMEvent(USER_EVT_RESET){}
  225. ~ResetDeviceEvent(){}
  226. protected:
  227. private:
  228. };
  229. class ResetFinishedEvent : public FSMEvent
  230. {
  231. public:
  232. ResetFinishedEvent() : FSMEvent(USER_EVT_RESETFINISHED){}
  233. ~ResetFinishedEvent(){}
  234. protected:
  235. private:
  236. };
  237. class PreOnlineEvent : public FSMEvent
  238. {
  239. public:
  240. PreOnlineEvent() : FSMEvent(USER_EVT_PREONLINE){}
  241. ~PreOnlineEvent(){}
  242. SpReqAnsContext<CardReadAdapterService_PreOnline_Req, CardReadAdapterService_PreOnline_Ans>::Pointer ctx;
  243. virtual void OnUnhandled()
  244. {
  245. if (ctx != NULL)
  246. ctx->Answer(Error_InvalidState);
  247. }
  248. protected:
  249. private:
  250. };
  251. class PostOnlineEvent : public FSMEvent
  252. {
  253. public:
  254. PostOnlineEvent() : FSMEvent(USER_EVT_POSTONLINE){}
  255. ~PostOnlineEvent(){}
  256. SpReqAnsContext<CardReadAdapterService_PostOnline_Req, CardReadAdapterService_PostOnline_Ans>::Pointer ctx;
  257. virtual void OnUnhandled()
  258. {
  259. if (ctx != NULL)
  260. ctx->Answer(Error_InvalidState);
  261. }
  262. protected:
  263. private:
  264. };
  265. class CardCaptureEvent : public FSMEvent
  266. {
  267. public:
  268. CardCaptureEvent() : FSMEvent(USER_EVT_CAPTURE){}
  269. ~CardCaptureEvent(){}
  270. SpReqAnsContext<CardReadAdapterService_Capture_Req, CardReadAdapterService_Capture_Ans>::Pointer ctx;
  271. virtual void OnUnhandled()
  272. {
  273. if (ctx != NULL)
  274. ctx->Answer(Error_InvalidState);
  275. }
  276. protected:
  277. private:
  278. };
  279. class CardEjectEvent : public FSMEvent
  280. {
  281. public:
  282. CardEjectEvent() : FSMEvent(USER_EVT_EJECT){}
  283. ~CardEjectEvent(){}
  284. SpReqAnsContext<CardReadAdapterService_Eject_Req, CardReadAdapterService_Eject_Ans>::Pointer ctx;
  285. virtual void OnUnhandled()
  286. {
  287. if (ctx != NULL)
  288. ctx->Answer(Error_InvalidState);
  289. }
  290. protected:
  291. private:
  292. };
  293. class CardWriteEvent : public FSMEvent
  294. {
  295. public:
  296. CardWriteEvent() : FSMEvent(USER_EVT_WRITE){}
  297. ~CardWriteEvent(){}
  298. SpReqAnsContext<CardReadAdapterService_WriteTrack_Req, CardReadAdapterService_WriteTrack_Ans>::Pointer ctx;
  299. virtual void OnUnhandled()
  300. {
  301. if (ctx != NULL)
  302. {
  303. DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("card read unhandled");
  304. ctx->Answer(Error_InvalidState);
  305. }
  306. }
  307. protected:
  308. private:
  309. };
  310. class CardWriteFinishedEvent : public FSMEvent
  311. {
  312. public:
  313. CardWriteFinishedEvent() : FSMEvent(USER_EVT_WRITE_FINISHED){}
  314. ~CardWriteFinishedEvent(){}
  315. SpReqAnsContext<CardReadAdapterService_WriteTrack_Req, CardReadAdapterService_WriteTrack_Ans>::Pointer ctx;
  316. virtual void OnUnhandled()
  317. {
  318. if (ctx != NULL)
  319. {
  320. DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("card read unhandled(new)");
  321. }
  322. }
  323. };
  324. class SetSomeFlagEvent : public FSMEvent
  325. {
  326. public:
  327. SetSomeFlagEvent() : FSMEvent(USER_EVT_SET_SOME_FLAG){}
  328. ~SetSomeFlagEvent(){}
  329. SpReqAnsContext<CardReadAdapterService_SetSomeFlag_Req, CardReadAdapterService_SetSomeFlag_Ans>::Pointer ctx;
  330. virtual void OnUnhandled()
  331. {
  332. if (ctx != NULL)
  333. {
  334. DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("SetSomeFlag unhandled");
  335. ctx->Answer(Error_InvalidState);
  336. }
  337. }
  338. };
  339. class QueryCardInfoEvent : public FSMEvent
  340. {
  341. public:
  342. QueryCardInfoEvent() : FSMEvent(USER_EVT_QUERY_CARD_INFO){}
  343. ~QueryCardInfoEvent(){}
  344. SpReqAnsContext<CardReadAdapterService_QueryCardInfo_Req, CardReadAdapterService_QueryCardInfo_Ans>::Pointer ctx;
  345. virtual void OnUnhandled()
  346. {
  347. if (ctx != NULL)
  348. {
  349. DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("QueryCardInfo unhandled");
  350. ctx->Answer(Error_InvalidState);
  351. }
  352. }
  353. };
  354. class GetMaterialEvent : public FSMEvent
  355. {
  356. public:
  357. GetMaterialEvent() : FSMEvent(USER_EVT_GET_MATERIAL){}
  358. ~GetMaterialEvent(){}
  359. SpReqAnsContext<CardReadAdapterService_GetMaterialCount_Req, CardReadAdapterService_GetMaterialCount_Ans>::Pointer ctx;
  360. virtual void OnUnhandled()
  361. {
  362. if (ctx != NULL)
  363. ctx->Answer(Error_InvalidState);
  364. }
  365. protected:
  366. private:
  367. };
  368. class SetMaterialEvent : public FSMEvent
  369. {
  370. public:
  371. SetMaterialEvent() : FSMEvent(USER_EVT_SET_MATERIAL){}
  372. ~SetMaterialEvent(){}
  373. SpReqAnsContext<CardReadAdapterService_SetMaterialCount_Req, CardReadAdapterService_SetMaterialCount_Ans>::Pointer ctx;
  374. virtual void OnUnhandled()
  375. {
  376. if (ctx != NULL)
  377. ctx->Answer(Error_InvalidState);
  378. }
  379. protected:
  380. private:
  381. };
  382. class GetSCIInfoEvent : public FSMEvent
  383. {
  384. public:
  385. GetSCIInfoEvent() : FSMEvent(USER_EVT_GET_SCI_INFO){}
  386. ~GetSCIInfoEvent(){}
  387. SpReqAnsContext<CardReadAdapterService_GetSCIInfo_Req, CardReadAdapterService_GetSCIInfo_Ans>::Pointer ctx;
  388. virtual void OnUnhandled()
  389. {
  390. if (ctx != NULL)
  391. ctx->Answer(Error_InvalidState);
  392. }
  393. protected:
  394. private:
  395. };
  396. class OpenSafeLockEvent : public FSMEvent
  397. {
  398. public:
  399. OpenSafeLockEvent() : FSMEvent(USER_EVT_OPEN_SAFELOCK){}
  400. ~OpenSafeLockEvent(){}
  401. SpReqAnsContext<CardReadAdapterService_OpenSafeLock_Req, CardReadAdapterService_OpenSafeLock_Ans>::Pointer ctx;
  402. virtual void OnUnhandled()
  403. {
  404. if (ctx != NULL)
  405. ctx->Answer(Error_InvalidState);
  406. }
  407. protected:
  408. private:
  409. };
  410. class MagTransferInitEvent : public FSMEvent
  411. {
  412. public:
  413. MagTransferInitEvent() : FSMEvent(USER_EVT_MAGTRANS_INIT){}
  414. ~MagTransferInitEvent(){}
  415. SpReqAnsContext<CardReadAdapterService_MagTransferInit_Req, CardReadAdapterService_MagTransferInit_Ans>::Pointer ctx;
  416. virtual void OnUnhandled()
  417. {
  418. if (ctx != NULL)
  419. ctx->Answer(Error_InvalidState);
  420. }
  421. protected:
  422. private:
  423. };
  424. class QueryConnInfoEvent : public FSMEvent
  425. {
  426. public:
  427. QueryConnInfoEvent() : FSMEvent(USER_EVT_QUERY_CONN_INFO){}
  428. ~QueryConnInfoEvent(){}
  429. SpReqAnsContext<CardReadAdapterService_QueryConnInfo_Req, CardReadAdapterService_QueryConnInfo_Ans>::Pointer ctx;
  430. virtual void OnUnhandled()
  431. {
  432. if (ctx != NULL)
  433. ctx->Answer(Error_InvalidState);
  434. }
  435. protected:
  436. private:
  437. };
  438. class SAMICCommandEvent : public FSMEvent
  439. {
  440. public:
  441. SAMICCommandEvent() : FSMEvent(USER_EVT_SAM_IC_COMMAND){}
  442. ~SAMICCommandEvent(){}
  443. SpReqAnsContext<CardReadAdapterService_SAMICCommand_Req, CardReadAdapterService_SAMICCommand_Ans>::Pointer ctx;
  444. virtual void OnUnhandled()
  445. {
  446. if (ctx != NULL)
  447. ctx->Answer(Error_InvalidState);
  448. }
  449. };
  450. class QueryPrinterStatusEvent : public FSMEvent
  451. {
  452. public:
  453. QueryPrinterStatusEvent() : FSMEvent(USER_EVT_QUERY_PRINTER_STATUS){}
  454. ~QueryPrinterStatusEvent(){}
  455. SpReqAnsContext<CardReadAdapterService_QueryPrinterStatus_Req, CardReadAdapterService_QueryPrinterStatus_Ans>::Pointer ctx;
  456. virtual void OnUnhandled()
  457. {
  458. if (ctx != NULL)
  459. ctx->Answer(Error_InvalidState);
  460. }
  461. };
  462. class PrintEvent : public FSMEvent
  463. {
  464. public:
  465. PrintEvent() : FSMEvent(USER_EVT_PRINT){}
  466. ~PrintEvent(){}
  467. SpReqAnsContext<CardReadAdapterService_Print_Req, CardReadAdapterService_Print_Ans>::Pointer ctx;
  468. virtual void OnUnhandled()
  469. {
  470. if (ctx != NULL)
  471. ctx->Answer(Error_InvalidState);
  472. }
  473. };
  474. class QuerySCIListEvent : public FSMEvent
  475. {
  476. public:
  477. QuerySCIListEvent() : FSMEvent(USER_EVT_QUERY_SCILIST){}
  478. ~QuerySCIListEvent(){}
  479. SpReqAnsContext<CardReadAdapterService_QuerySCIList_Req, CardReadAdapterService_QuerySCIList_Ans>::Pointer ctx;
  480. virtual void OnUnhandled()
  481. {
  482. if (ctx != NULL)
  483. ctx->Answer(Error_InvalidState);
  484. }
  485. };
  486. class BindSCIEvent : public FSMEvent
  487. {
  488. public:
  489. BindSCIEvent() : FSMEvent(USER_EVT_BIND_SCI){}
  490. ~BindSCIEvent(){}
  491. SpReqAnsContext<CardReadAdapterService_BindSCI_Req, CardReadAdapterService_BindSCI_Ans>::Pointer ctx;
  492. virtual void OnUnhandled()
  493. {
  494. if (ctx != NULL)
  495. ctx->Answer(Error_InvalidState);
  496. }
  497. };
  498. class PreOnlineOnStoreEvent : public FSMEvent
  499. {
  500. public:
  501. PreOnlineOnStoreEvent() : FSMEvent(USER_EVT_PREONLINE_ON_STORE){}
  502. ~PreOnlineOnStoreEvent(){}
  503. SpReqAnsContext<CardReadAdapterService_PreOnlineOnStore_Req, CardReadAdapterService_PreOnlineOnStore_Ans>::Pointer ctx;
  504. virtual void OnUnhandled()
  505. {
  506. if (ctx != NULL)
  507. ctx->Answer(Error_InvalidState);
  508. }
  509. };
  510. class PreOnlineOnStoreFinishedEvent : public FSMEvent
  511. {
  512. public:
  513. PreOnlineOnStoreFinishedEvent() : FSMEvent(USER_EVT_PREONLINE_ON_STORE_FINISHED){}
  514. ~PreOnlineOnStoreFinishedEvent(){}
  515. SpReqAnsContext<CardReadAdapterService_PreOnlineOnStore_Req, CardReadAdapterService_PreOnlineOnStore_Ans>::Pointer ctx;
  516. virtual void OnUnhandled()
  517. {
  518. if (ctx != NULL)
  519. ctx->Answer(Error_InvalidState);
  520. }
  521. };
  522. class NotifyPreonlineEvent : public FSMEvent
  523. {
  524. public:
  525. NotifyPreonlineEvent() : FSMEvent(USER_EVT_NOTIFY_PREONLINE){}
  526. ~NotifyPreonlineEvent(){}
  527. SpReqAnsContext<CardReadAdapterService_NotifyPreonline_Req, CardReadAdapterService_NotifyPreonline_Ans>::Pointer ctx;
  528. virtual void OnUnhandled()
  529. {
  530. if (ctx != NULL)
  531. ctx->Answer(Error_InvalidState);
  532. }
  533. };
  534. class NotifyPreonlineFinishedEvent : public FSMEvent
  535. {
  536. public:
  537. NotifyPreonlineFinishedEvent() : FSMEvent(USER_EVT_NOTIFY_PREONLINE_FINISHED){}
  538. ~NotifyPreonlineFinishedEvent(){}
  539. SpReqAnsContext<CardReadAdapterService_NotifyPreonline_Req, CardReadAdapterService_NotifyPreonline_Ans>::Pointer ctx;
  540. virtual void OnUnhandled()
  541. {
  542. if (ctx != NULL)
  543. ctx->Answer(Error_InvalidState);
  544. }
  545. };
  546. class QueryCardInfoOnStoreEvent : public FSMEvent
  547. {
  548. public:
  549. QueryCardInfoOnStoreEvent() : FSMEvent(USER_EVT_QUERY_CARD_INFO_ON_STORE){}
  550. ~QueryCardInfoOnStoreEvent(){}
  551. SpReqAnsContext<CardReadAdapterService_QueryCardInfoOnStore_Req, CardReadAdapterService_QueryCardInfoOnStore_Ans>::Pointer ctx;
  552. virtual void OnUnhandled()
  553. {
  554. if (ctx != NULL)
  555. ctx->Answer(Error_InvalidState);
  556. }
  557. };
  558. class QueryCardInfoOnStoreFinishedEvent : public FSMEvent
  559. {
  560. public:
  561. QueryCardInfoOnStoreFinishedEvent() : FSMEvent(USER_EVT_QUERY_CARD_INFO_ON_STORE_FINISHED){}
  562. ~QueryCardInfoOnStoreFinishedEvent(){}
  563. SpReqAnsContext<CardReadAdapterService_QueryCardInfoOnStore_Req, CardReadAdapterService_QueryCardInfoOnStore_Ans>::Pointer ctx;
  564. virtual void OnUnhandled()
  565. {
  566. if (ctx != NULL)
  567. ctx->Answer(Error_InvalidState);
  568. }
  569. };
  570. class GetAddCardInfoEvent : public FSMEvent
  571. {
  572. public:
  573. GetAddCardInfoEvent() : FSMEvent(USER_EVT_GET_ADD_CARD_INFO){}
  574. ~GetAddCardInfoEvent(){}
  575. SpReqAnsContext<CardReadAdapterService_GetAddCardInfo_Req, CardReadAdapterService_GetAddCardInfo_Ans>::Pointer ctx;
  576. virtual void OnUnhandled()
  577. {
  578. if (ctx != NULL)
  579. ctx->Answer(Error_InvalidState);
  580. }
  581. };
  582. class GetAddCardInfoFinishedEvent : public FSMEvent
  583. {
  584. public:
  585. GetAddCardInfoFinishedEvent() : FSMEvent(USER_EVT_GET_ADD_CARD_INFO_FINISHED){}
  586. ~GetAddCardInfoFinishedEvent(){}
  587. SpReqAnsContext<CardReadAdapterService_GetAddCardInfo_Req, CardReadAdapterService_GetAddCardInfo_Ans>::Pointer ctx;
  588. virtual void OnUnhandled()
  589. {
  590. if (ctx != NULL)
  591. ctx->Answer(Error_InvalidState);
  592. }
  593. };
  594. class CrossTermCallEvent : public FSMEvent
  595. {
  596. public:
  597. CrossTermCallEvent() : FSMEvent(USER_EVT_CROSS_TERM_CALL){}
  598. ~CrossTermCallEvent(){}
  599. SpReqAnsContext<CardReadAdapterService_CrossTermCall_Req, CardReadAdapterService_CrossTermCall_Ans>::Pointer ctx;
  600. virtual void OnUnhandled()
  601. {
  602. if (ctx != NULL)
  603. ctx->Answer(Error_InvalidState);
  604. }
  605. };
  606. class PrintCardImEvent : public FSMEvent
  607. {
  608. public:
  609. PrintCardImEvent() : FSMEvent(USER_EVT_PRINT_CARD_IM) {}
  610. ~PrintCardImEvent() {}
  611. SpReqAnsContext<CardReadAdapterService_PrintCardImmediately_Req, CardReadAdapterService_PrintCardImmediately_Ans>::Pointer ctx;
  612. virtual void OnUnhandled()
  613. {
  614. if (ctx != NULL)
  615. ctx->Answer(Error_InvalidState);
  616. }
  617. };
  618. class PrintCardImFinishedEvent : public FSMEvent
  619. {
  620. public:
  621. PrintCardImFinishedEvent() : FSMEvent(USER_EVT_PRINT_CARD_IM_FINISHED) {}
  622. ~PrintCardImFinishedEvent() {}
  623. SpReqAnsContext<CardReadAdapterService_PrintCardImmediately_Req, CardReadAdapterService_PrintCardImmediately_Ans>::Pointer ctx;
  624. virtual void OnUnhandled()
  625. {
  626. if (ctx != NULL)
  627. ctx->Answer(Error_InvalidState);
  628. }
  629. };
  630. class QueryCIStatusEvent : public FSMEvent
  631. {
  632. public:
  633. QueryCIStatusEvent() : FSMEvent(USER_EVT_QUERY_CI_STATUS) {}
  634. ~QueryCIStatusEvent() {}
  635. SpReqAnsContext<CardReadAdapterService_QueryCIStatus_Req, CardReadAdapterService_QueryCIStatus_Ans>::Pointer ctx;
  636. virtual void OnUnhandled()
  637. {
  638. if (ctx != NULL)
  639. ctx->Answer(Error_InvalidState);
  640. }
  641. };
  642. class QueryCIStatusFinishedEvent : public FSMEvent
  643. {
  644. public:
  645. QueryCIStatusFinishedEvent() : FSMEvent(USER_EVT_QUERY_CI_STATUS_FINISHED) {}
  646. ~QueryCIStatusFinishedEvent() {}
  647. SpReqAnsContext<CardReadAdapterService_QueryCIStatus_Req, CardReadAdapterService_QueryCIStatus_Ans>::Pointer ctx;
  648. virtual void OnUnhandled()
  649. {
  650. if (ctx != NULL)
  651. ctx->Answer(Error_InvalidState);
  652. }
  653. };
  654. class GetDevInfoEvent : public FSMEvent
  655. {
  656. public:
  657. GetDevInfoEvent() : FSMEvent(USER_EVT_GET_DEV_INFO){}
  658. ~GetDevInfoEvent(){}
  659. SpReqAnsContext<CardReadAdapterService_GetDevInfo_Req, CardReadAdapterService_GetDevInfo_Ans>::Pointer ctx;
  660. virtual void OnUnhandled()
  661. {
  662. if (ctx != NULL)
  663. {
  664. DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("GetDevInfo unhandled");
  665. ctx->Answer(Error_InvalidState);
  666. }
  667. }
  668. };
  669. class CCardReadAdapterFSM : public FSMImpl<CCardReadAdapterFSM>
  670. {
  671. public:
  672. enum { s0, s1, s2, s3, s4};
  673. BEGIN_FSM_STATE(CCardReadAdapterFSM)
  674. FSM_STATE_ENTRY(s0, "Init", s0_on_entry, s0_on_exit, s0_on_event)
  675. FSM_STATE_ENTRY(s1, "Initializing", s1_on_entry, s1_on_exit, s1_on_event)
  676. FSM_STATE_ENTRY(s2, "Idle", s2_on_entry, s2_on_exit, s2_on_event)
  677. FSM_STATE_ENTRY(s3, "Working", s3_on_entry, s3_on_exit, s3_on_event)
  678. FSM_STATE_ENTRY(s4, "Failed", s4_on_entry, s4_on_exit, s4_on_event)
  679. END_FSM_STATE()
  680. BEGIN_FSM_RULE(CCardReadAdapterFSM, s0)
  681. FSM_RULE_ENTRY(s0, s2, USER_EVT_TEST, 0)//oiltest
  682. FSM_RULE_ENTRY(s0, s1, USER_EVT_INIT, 0)
  683. FSM_RULE_ENTRY(s0, FSM_STATE_EXIT, USER_EVT_QUIT, 0)
  684. FSM_RULE_ENTRY(s1, s2, USER_EVT_INIT_FINISHED, 0)
  685. FSM_RULE_ENTRY(s1, s4, USER_EVT_INIT_FINISHED, 1)
  686. FSM_RULE_ENTRY(s1, FSM_STATE_EXIT, USER_EVT_QUIT, 0)
  687. FSM_RULE_ENTRY(s2, FSM_STATE_EXIT, USER_EVT_QUIT, 0)
  688. FSM_RULE_ENTRY(s2, s3, USER_EVT_READ, 0)
  689. FSM_RULE_ENTRY(s2, s3, USER_EVT_PREONLINE, 0)
  690. FSM_RULE_ENTRY(s2, s3, USER_EVT_POSTONLINE, 0)
  691. FSM_RULE_ENTRY(s2, s3, USER_EVT_EJECT, 0)
  692. FSM_RULE_ENTRY(s2, s3, USER_EVT_SET_SOME_FLAG, 0)
  693. FSM_RULE_ENTRY(s2, s3, USER_EVT_GET_DEV_INFO, 0)
  694. FSM_RULE_ENTRY(s2, s3, USER_EVT_QUERY_CARD_INFO, 0)
  695. FSM_RULE_ENTRY(s2, s3, USER_EVT_GET_MATERIAL, 0)
  696. FSM_RULE_ENTRY(s2, s3, USER_EVT_SET_MATERIAL, 0)
  697. FSM_RULE_ENTRY(s2, s3, USER_EVT_GET_SCI_INFO, 0)
  698. FSM_RULE_ENTRY(s2, s3, USER_EVT_OPEN_SAFELOCK, 0)
  699. FSM_RULE_ENTRY(s2, s3, USER_EVT_MAGTRANS_INIT, 0)
  700. FSM_RULE_ENTRY(s2, s3, USER_EVT_QUERY_CONN_INFO, 0)
  701. FSM_RULE_ENTRY(s2, s3, USER_EVT_SAM_IC_COMMAND, 0)
  702. FSM_RULE_ENTRY(s2, s3, USER_EVT_PREONLINE_ON_STORE, 0)
  703. FSM_RULE_ENTRY(s2, s3, USER_EVT_GET_ADD_CARD_INFO, 0)
  704. FSM_RULE_ENTRY(s2, s3, USER_EVT_PRINT_CARD_IM, 0)
  705. FSM_RULE_ENTRY(s2, s3, USER_EVT_QUERY_CI_STATUS, 0)
  706. FSM_RULE_ENTRY(s3, s2, USER_EVT_EXIT, 0)
  707. FSM_RULE_ENTRY(s3, s2, USER_EVT_READ_FINISHED, 0)
  708. FSM_RULE_ENTRY(s3, s2, USER_EVT_READ_FINISHED, 2)
  709. FSM_RULE_ENTRY(s3, s2, USER_EVT_PREONLINE_FINISHED, 0)
  710. FSM_RULE_ENTRY(s3, s2, USER_EVT_POSTONLINE_FINISHED, 0)
  711. FSM_RULE_ENTRY(s3, s2, USER_EVT_EJECT_FINISHED, 0)
  712. FSM_RULE_ENTRY(s3, s2, USER_EVT_WRITE_FINISHED,0)
  713. FSM_RULE_ENTRY(s3, s2, USER_EVT_SET_SOME_FLAG_FINISHED,0)
  714. FSM_RULE_ENTRY(s3, s2, USER_EVT_GET_DEV_INFO_FINISHED,0)
  715. FSM_RULE_ENTRY(s3, s2, USER_EVT_QUERY_CARD_INFO_FINISHED,0)
  716. FSM_RULE_ENTRY(s3, s2, USER_EVT_GET_MATERIAL_FINISHED,0)
  717. FSM_RULE_ENTRY(s3, s2, USER_EVT_SET_MATERIAL_FINISHED,0)
  718. FSM_RULE_ENTRY(s3, s2, USER_EVT_GET_SCI_INFO_FINISHED,0)
  719. FSM_RULE_ENTRY(s3, s2, USER_EVT_OPEN_SAFELOCK_FINISHED,0)
  720. FSM_RULE_ENTRY(s3, s2, USER_EVT_MAGTRANS_INIT_FINISHED,0)
  721. FSM_RULE_ENTRY(s3, s2, USER_EVT_QUERY_CONN_INFO_FINISHED,0)
  722. FSM_RULE_ENTRY(s3, s2, USER_EVT_SAM_IC_COMMAND_FINISHED, 0)
  723. FSM_RULE_ENTRY(s3, s2, USER_EVT_QUERY_PRINTER_STATUS_FINISHED, 0)
  724. FSM_RULE_ENTRY(s3, s2, USER_EVT_PRINT_FINISHED, 0)
  725. FSM_RULE_ENTRY(s3, s2, USER_EVT_QUERY_SCILIST_FINISHED, 0)
  726. FSM_RULE_ENTRY(s3, s2, USER_EVT_BIND_SCI_FINISHED, 0)
  727. FSM_RULE_ENTRY(s3, s2, USER_EVT_PREONLINE_ON_STORE_FINISHED, 0)
  728. FSM_RULE_ENTRY(s3, s2, USER_EVT_GET_ADD_CARD_INFO_FINISHED, 0)
  729. FSM_RULE_ENTRY(s3, s2, USER_EVT_PRINT_CARD_IM_FINISHED, 0)
  730. FSM_RULE_ENTRY(s3, s2, USER_EVT_QUERY_CI_STATUS_FINISHED, 0)
  731. FSM_RULE_ENTRY(s3, FSM_STATE_EXIT, USER_EVT_QUIT, 0)
  732. FSM_RULE_ENTRY(s4, FSM_STATE_EXIT, USER_EVT_QUIT, 0)
  733. END_FSM_RULE()
  734. CCardReadAdapterFSM() : m_pCardIssuer(NULL), m_pCardIssuerStore(NULL), m_pContactless(NULL), m_pHBClient(NULL){}
  735. ~CCardReadAdapterFSM(){}
  736. virtual ErrorCodeEnum OnInit();
  737. virtual ErrorCodeEnum OnExit();
  738. void s0_on_entry();
  739. void s0_on_exit();
  740. unsigned int s0_on_event(FSMEvent* event);
  741. void s1_on_entry();
  742. void s1_on_exit();
  743. unsigned int s1_on_event(FSMEvent* event);
  744. void s2_on_entry();
  745. void s2_on_exit();
  746. unsigned int s2_on_event(FSMEvent* event);
  747. void s3_on_entry();
  748. void s3_on_exit();
  749. unsigned int s3_on_event(FSMEvent* event);
  750. void s4_on_entry();
  751. void s4_on_exit();
  752. unsigned int s4_on_event(FSMEvent* event);
  753. void TransEntity(CCardReadAdapterEntity* pEty){ m_pEty = pEty; }
  754. int Initial();
  755. int DoWork(int type);
  756. int CardIssuerRead(SpReqAnsContext<CardReadAdapterService_Read_Req, CardReadAdapterService_Read_Ans>::Pointer ctx);
  757. int ContactlessCardRead(SpReqAnsContext<CardReadAdapterService_Read_Req, CardReadAdapterService_Read_Ans>::Pointer ctx);
  758. int IssueCard(SpReqAnsContext<CardReadAdapterService_Issue_Req, CardReadAdapterService_Issue_Ans>::Pointer ctx);
  759. void CancelRead();
  760. void ReadWaitMore();
  761. int WriteTrack(SpReqAnsContext<CardReadAdapterService_WriteTrack_Req, CardReadAdapterService_WriteTrack_Ans>::Pointer ctx);
  762. int PreOnline(SpReqAnsContext<CardReadAdapterService_PreOnline_Req, CardReadAdapterService_PreOnline_Ans>::Pointer ctx);
  763. int PostOnline(SpReqAnsContext<CardReadAdapterService_PostOnline_Req, CardReadAdapterService_PostOnline_Ans>::Pointer ctx);
  764. int EjectCard(SpReqAnsContext<CardReadAdapterService_Eject_Req, CardReadAdapterService_Eject_Ans>::Pointer ctx);
  765. int CaptureCard(SpReqAnsContext<CardReadAdapterService_Capture_Req, CardReadAdapterService_Capture_Ans>::Pointer ctx);
  766. int QueryCardInfo(SpReqAnsContext<CardReadAdapterService_QueryCardInfo_Req, CardReadAdapterService_QueryCardInfo_Ans>::Pointer ctx);
  767. void CheckAndReconnectSession();
  768. int SetSomeFlag(SpReqAnsContext<CardReadAdapterService_SetSomeFlag_Req, CardReadAdapterService_SetSomeFlag_Ans>::Pointer ctx);
  769. void DoExit();
  770. int GetMaterialCount(SpReqAnsContext<CardReadAdapterService_GetMaterialCount_Req, CardReadAdapterService_GetMaterialCount_Ans>::Pointer ctx);
  771. int SetMaterialCount(SpReqAnsContext<CardReadAdapterService_SetMaterialCount_Req, CardReadAdapterService_SetMaterialCount_Ans>::Pointer ctx);
  772. int GetSCIInfo(SpReqAnsContext<CardReadAdapterService_GetSCIInfo_Req, CardReadAdapterService_GetSCIInfo_Ans>::Pointer ctx);
  773. int OpenSafeLock(SpReqAnsContext<CardReadAdapterService_OpenSafeLock_Req, CardReadAdapterService_OpenSafeLock_Ans>::Pointer ctx);
  774. int MagTransferInit(SpReqAnsContext<CardReadAdapterService_MagTransferInit_Req, CardReadAdapterService_MagTransferInit_Ans>::Pointer ctx);
  775. int QueryConnInfo(SpReqAnsContext<CardReadAdapterService_QueryConnInfo_Req, CardReadAdapterService_QueryConnInfo_Ans>::Pointer ctx);
  776. int GetDevInfo(SpReqAnsContext<CardReadAdapterService_GetDevInfo_Req, CardReadAdapterService_GetDevInfo_Ans>::Pointer ctx);
  777. void BroadcastReadICing(int status);
  778. int SAMICCommand(SpReqAnsContext<CardReadAdapterService_SAMICCommand_Req, CardReadAdapterService_SAMICCommand_Ans>::Pointer ctx);
  779. int QueryPrinterStatus(SpReqAnsContext<CardReadAdapterService_QueryPrinterStatus_Req, CardReadAdapterService_QueryPrinterStatus_Ans>::Pointer ctx);
  780. int Print(SpReqAnsContext<CardReadAdapterService_Print_Req, CardReadAdapterService_Print_Ans>::Pointer ctx);
  781. int QuerySCIList(SpReqAnsContext<CardReadAdapterService_QuerySCIList_Req, CardReadAdapterService_QuerySCIList_Ans>::Pointer ctx);
  782. int BindSCI(SpReqAnsContext<CardReadAdapterService_BindSCI_Req, CardReadAdapterService_BindSCI_Ans>::Pointer ctx);
  783. int PreOnlineOnStore(SpReqAnsContext<CardReadAdapterService_PreOnlineOnStore_Req, CardReadAdapterService_PreOnlineOnStore_Ans>::Pointer ctx);
  784. int NotifyPreonline(SpReqAnsContext<CardReadAdapterService_NotifyPreonline_Req, CardReadAdapterService_NotifyPreonline_Ans>::Pointer ctx);
  785. int QueryCardInfoOnStore(SpReqAnsContext<CardReadAdapterService_QueryCardInfoOnStore_Req, CardReadAdapterService_QueryCardInfoOnStore_Ans>::Pointer ctx);
  786. int GetAddCardInfo(SpReqAnsContext<CardReadAdapterService_GetAddCardInfo_Req, CardReadAdapterService_GetAddCardInfo_Ans>::Pointer ctx);
  787. int Test1(SpReqAnsContext<CardReadAdapterService_Test1_Req, CardReadAdapterService_Test1_Ans>::Pointer ctx);
  788. int Test2(SpReqAnsContext<CardReadAdapterService_Test2_Req, CardReadAdapterService_Test2_Ans>::Pointer ctx);
  789. void SelfTest(EntityTestEnum eTestType, CSmartPointer<ITransactionContext> pTransactionContext);
  790. void SetReadCtx(SpReqAnsContext<CardReadAdapterService_Read_Req, CardReadAdapterService_Read_Ans>::Pointer ctx) { m_readCtx = ctx; }
  791. int LocalCallHeartBeat(int method, CBlob &bbSend, bool bTwoWay=false);
  792. bool GetAttachedTerminal(CSimpleStringA &csTerm);
  793. int CrossTermCall(SpReqAnsContext<CardReadAdapterService_CrossTermCall_Req, CardReadAdapterService_CrossTermCall_Ans>::Pointer ctx);
  794. void CrossTermInvokeInfo(SpOnewayCallContext<CardReadAdapterService_CrossTermInvokeInfo_Info>::Pointer ctx);
  795. void CancelReadForEntity(ModuleType eModule);
  796. int PrintCardIm(SpReqAnsContext<CardReadAdapterService_PrintCardImmediately_Req, CardReadAdapterService_PrintCardImmediately_Ans>::Pointer ctx);
  797. void QueryCurrFSMAndLastS2EventInfo(int &currFSM, int& event, int& param1)
  798. {
  799. currFSM = GetCurrState()->id;
  800. event = m_lastS2Event;
  801. param1 = m_lastS2EvtParam1;
  802. }
  803. SP::Module::Comm::What GetMachineType() {return m_eMachineType;}
  804. int QueryCIStatus(SpReqAnsContext<CardReadAdapterService_QueryCIStatus_Req, CardReadAdapterService_QueryCIStatus_Ans>::Pointer ctx);
  805. void WaitCardActive();
  806. protected:
  807. //LPIDCCARDDATA* lppCardData;
  808. int m_iInsertTries;
  809. int m_resetTries;
  810. int m_ejectTries;
  811. private:
  812. CCardReadAdapterEntity *m_pEty;
  813. CardIssuerStandService_ClientBase *m_pCardIssuer;
  814. CardIssuerStoreService_ClientBase* m_pCardIssuerStore;
  815. ContactlessCardService_ClientBase *m_pContactless;
  816. HeartBeatService_ClientBase* m_pHBClient;
  817. BusinessContext m_busCtx;
  818. SpReqAnsContext<CardReadAdapterService_Read_Req, CardReadAdapterService_Read_Ans>::Pointer m_readCtx;
  819. //m_lastModule:0~7
  820. //0:all; 1:CardIssuer; 2:ContactlessCard
  821. int m_lastModule,m_lastS2Event, m_lastS2EvtParam1;
  822. SP::Module::Comm::What m_eMachineType;
  823. WORD m_majorVerion,m_minorVerion;
  824. ///
  825. int m_resetTimes;
  826. bool m_devInit, m_bCancelAccept, m_bWaitingAccept, m_bWaitAccepteMore
  827. , m_bCDA, m_bIssuingExit, m_bCardIssued, m_bCaptureCfgFlag, m_bHasHopper[3]
  828. , m_bCardActiveNotify;
  829. ErrorCodeEnum m_testResult;
  830. //m_CardInit,m_CardRemains,m_CardIssued,m_CardMixed,m_CardPercent
  831. int m_CardCaptured, m_issueStatusFromFile, m_issueStatus, m_port, m_baudRate, m_currentHopper, m_scanSlot;
  832. CSimpleStringA m_CardBoxNoEx[3], m_PsbCodeEx[3], m_PsbNameEx[3], m_MaintainerEx[3], m_csMaintainTimeEx[3];
  833. int m_CardInitEx[3], m_CardPercentEx[3], m_remainsEx[3], m_issuedEx[3], m_mixedEx[3], m_hopperNum;
  834. DWORD m_MaintainTimeEx[3];
  835. BYTE m_connectType, m_r1[128], m_r2[128], m_r3[128], m_priKey[ONE_K / 2], m_devPubKey[ONE_K / 2], m_bdk[64], m_ksn[64];
  836. DevStateEnum m_eDevState;
  837. //CCardProcess *m_pCardProcess;
  838. char *m_pDataToARQC;
  839. long xxTest;
  840. CSimpleStringA m_currCardNo, m_captureReason, m_csMachineType, m_csSite, m_csDevSN, m_terminalNo;
  841. char m_AuthCode[2];
  842. SpReqAnsContext<CardReadAdapterService_PreOnlineOnStore_Req, CardReadAdapterService_PreOnlineOnStore_Ans>::Pointer m_crossCtx;
  843. ULONGLONG m_ullCrossStart;
  844. bool IsCardIssuerSessionOK();
  845. bool IsContactlessCardSessionOK();
  846. bool IsTheEntity(int module,ModuleType eModule);
  847. bool CheckHBSessionOrToConnect();
  848. //oilyang@20230614 跨及时因为卡片的实际交易发生在卡库,需要在发起端对返回的UserErrorCode做二次映射,方便客户理解提示信息
  849. DWORD MapErrorCodeWhileCallStore(DWORD eErrCode)
  850. {
  851. //eErrCode defined on CardIssuer_UserErrorCode.h
  852. switch (eErrCode)
  853. {
  854. case 0x20300240:
  855. case 0x22000240:
  856. return 0x203002E0;
  857. case 0x20300242:
  858. case 0x22000242:
  859. return 0x203002E1;
  860. case 0x20300243:
  861. case 0x22000243:
  862. case 0x203002a1:
  863. case 0x220002a1:
  864. return 0x203002E2;
  865. case 0x20300244:
  866. case 0x22000244:
  867. return 0x203002E3;
  868. case 0x20300246:
  869. case 0x22000246:
  870. return 0x203002E4;
  871. case 0x2030000D:
  872. case 0x2200000D:
  873. return 0x203002E5;
  874. default:
  875. return eErrCode;
  876. }
  877. }
  878. bool IsCardIssuerStore() {
  879. if (m_eMachineType == SP::Module::Comm::RVC_CardStore || m_eMachineType == SP::Module::Comm::RVC_CardPrinter) {
  880. return true;
  881. }
  882. else {
  883. return false;
  884. }
  885. }
  886. };
  887. struct InitTask : public ITaskSp
  888. {
  889. CCardReadAdapterFSM* fsm;
  890. InitTask(CCardReadAdapterFSM* f) : fsm(f) {}
  891. void Process()
  892. {
  893. FSMEvent *e = new FSMEvent(USER_EVT_INIT_FINISHED);
  894. e->param1 = fsm->Initial();
  895. fsm->PostEventFIFO(e);
  896. }
  897. };
  898. struct CardIssuerReadTask : public ITaskSp
  899. {
  900. CCardReadAdapterFSM* fsm;
  901. SpReqAnsContext<CardReadAdapterService_Read_Req, CardReadAdapterService_Read_Ans>::Pointer ctx;
  902. CardIssuerReadTask(CCardReadAdapterFSM* f) : fsm(f) {}
  903. void Process()
  904. {
  905. CardReadFinishedEvent *e = new CardReadFinishedEvent();
  906. e->ctx = ctx;
  907. e->param1 = fsm->CardIssuerRead(ctx);
  908. fsm->PostEventFIFO(e);
  909. }
  910. };
  911. struct ContactlessCardReadTask : public ITaskSp
  912. {
  913. CCardReadAdapterFSM* fsm;
  914. SpReqAnsContext<CardReadAdapterService_Read_Req, CardReadAdapterService_Read_Ans>::Pointer ctx;
  915. ContactlessCardReadTask(CCardReadAdapterFSM* f) : fsm(f) {}
  916. void Process()
  917. {
  918. CardReadFinishedEvent *e = new CardReadFinishedEvent();
  919. e->ctx = ctx;
  920. e->param1 = fsm->ContactlessCardRead(ctx);
  921. fsm->PostEventFIFO(e);
  922. }
  923. };
  924. struct WriteTask : public ITaskSp
  925. {
  926. CCardReadAdapterFSM* fsm;
  927. SpReqAnsContext<CardReadAdapterService_WriteTrack_Req, CardReadAdapterService_WriteTrack_Ans>::Pointer ctx;
  928. WriteTask(CCardReadAdapterFSM* f) : fsm(f) {}
  929. void Process()
  930. {
  931. CardWriteFinishedEvent *e = new CardWriteFinishedEvent();
  932. e->ctx = ctx;
  933. e->param1 = fsm->WriteTrack(ctx);
  934. fsm->PostEventFIFO(e);
  935. }
  936. };
  937. struct DoWorkTask : public ITaskSp
  938. {
  939. CCardReadAdapterFSM* fsm;
  940. int type;
  941. DoWorkTask(CCardReadAdapterFSM* f) : fsm(f) {}
  942. void Process()
  943. {
  944. //FSMEvent *e = new FSMEvent(USER_EVT_DO_WORK_FINISHED);
  945. //e->param1 = fsm->DoWork(type);
  946. //fsm->PostEventFIFO(e);
  947. }
  948. };
  949. struct TestCancelReadTask : public ITaskSp
  950. {
  951. CCardReadAdapterFSM* fsm;
  952. int type;
  953. TestCancelReadTask(CCardReadAdapterFSM* f) : fsm(f) {}
  954. void Process()
  955. {
  956. Sleep(10000);
  957. fsm->CancelRead();
  958. }
  959. };
  960. struct ReadWaitMoreTask : public ITaskSp
  961. {
  962. CCardReadAdapterFSM* fsm;
  963. int type;
  964. ReadWaitMoreTask(CCardReadAdapterFSM* f) : fsm(f) {}
  965. void Process()
  966. {
  967. fsm->ReadWaitMore();
  968. }
  969. };
  970. struct PreOnlineTask : public ITaskSp
  971. {
  972. SpReqAnsContext<CardReadAdapterService_PreOnline_Req, CardReadAdapterService_PreOnline_Ans>::Pointer ctx;
  973. CCardReadAdapterFSM* fsm;
  974. PreOnlineTask(CCardReadAdapterFSM* f) : fsm(f) {}
  975. void Process()
  976. {
  977. FSMEvent *e = new FSMEvent(USER_EVT_PREONLINE_FINISHED);
  978. e->param1 = fsm->PreOnline(ctx);
  979. fsm->PostEventFIFO(e);
  980. }
  981. };
  982. struct PostOnlineTask : public ITaskSp
  983. {
  984. SpReqAnsContext<CardReadAdapterService_PostOnline_Req, CardReadAdapterService_PostOnline_Ans>::Pointer ctx;
  985. CCardReadAdapterFSM* fsm;
  986. PostOnlineTask(CCardReadAdapterFSM* f) : fsm(f) {}
  987. void Process()
  988. {
  989. FSMEvent *e = new FSMEvent(USER_EVT_POSTONLINE_FINISHED);
  990. e->param1 = fsm->PostOnline(ctx);
  991. fsm->PostEventFIFO(e);
  992. }
  993. };
  994. struct IssueTask : public ITaskSp
  995. {
  996. SpReqAnsContext<CardReadAdapterService_Issue_Req, CardReadAdapterService_Issue_Ans>::Pointer ctx;
  997. CCardReadAdapterFSM* fsm;
  998. IssueTask(CCardReadAdapterFSM* f) : fsm(f) {}
  999. void Process()
  1000. {
  1001. FSMEvent *e = new FSMEvent(USER_EVT_ISSUE_FINISHED);
  1002. e->param1 = fsm->IssueCard(ctx);
  1003. fsm->PostEventFIFO(e);
  1004. }
  1005. };
  1006. struct EjectTask : public ITaskSp
  1007. {
  1008. SpReqAnsContext<CardReadAdapterService_Eject_Req, CardReadAdapterService_Eject_Ans>::Pointer ctx;
  1009. CCardReadAdapterFSM* fsm;
  1010. EjectTask(CCardReadAdapterFSM* f) : fsm(f) {}
  1011. void Process()
  1012. {
  1013. FSMEvent *e = new FSMEvent(USER_EVT_EJECT_FINISHED);
  1014. e->param1 = fsm->EjectCard(ctx);
  1015. fsm->PostEventFIFO(e);
  1016. }
  1017. };
  1018. struct CaptureTask : public ITaskSp
  1019. {
  1020. SpReqAnsContext<CardReadAdapterService_Capture_Req, CardReadAdapterService_Capture_Ans>::Pointer ctx;
  1021. CCardReadAdapterFSM* fsm;
  1022. CaptureTask(CCardReadAdapterFSM* f) : fsm(f) {}
  1023. void Process()
  1024. {
  1025. FSMEvent *e = new FSMEvent(USER_EVT_CAPTUREFINISHED);
  1026. e->param1 = fsm->CaptureCard(ctx);
  1027. fsm->PostEventFIFO(e);
  1028. }
  1029. };
  1030. struct CheckSessionTask : public ITaskSp
  1031. {
  1032. CCardReadAdapterFSM* fsm;
  1033. CheckSessionTask(CCardReadAdapterFSM* f) : fsm(f) {}
  1034. void Process()
  1035. {
  1036. fsm->CheckAndReconnectSession();
  1037. }
  1038. };
  1039. struct SetSomeFlagTask : public ITaskSp
  1040. {
  1041. CCardReadAdapterFSM* fsm;
  1042. SpReqAnsContext<CardReadAdapterService_SetSomeFlag_Req, CardReadAdapterService_SetSomeFlag_Ans>::Pointer ctx;
  1043. SetSomeFlagTask(CCardReadAdapterFSM* f) : fsm(f) {}
  1044. void Process()
  1045. {
  1046. FSMEvent *e = new FSMEvent(USER_EVT_SET_SOME_FLAG_FINISHED);
  1047. e->param1 = fsm->SetSomeFlag(ctx);
  1048. fsm->PostEventFIFO(e);
  1049. }
  1050. };
  1051. struct GetDevInfoTask : public ITaskSp
  1052. {
  1053. CCardReadAdapterFSM* fsm;
  1054. SpReqAnsContext<CardReadAdapterService_GetDevInfo_Req, CardReadAdapterService_GetDevInfo_Ans>::Pointer ctx;
  1055. GetDevInfoTask(CCardReadAdapterFSM* f) : fsm(f) {}
  1056. void Process()
  1057. {
  1058. FSMEvent *e = new FSMEvent(USER_EVT_GET_DEV_INFO_FINISHED);
  1059. e->param1 = fsm->GetDevInfo(ctx);
  1060. fsm->PostEventFIFO(e);
  1061. }
  1062. };
  1063. struct QueryCardInfoTask : public ITaskSp
  1064. {
  1065. CCardReadAdapterFSM* fsm;
  1066. SpReqAnsContext<CardReadAdapterService_QueryCardInfo_Req, CardReadAdapterService_QueryCardInfo_Ans>::Pointer ctx;
  1067. QueryCardInfoTask(CCardReadAdapterFSM* f) : fsm(f) {}
  1068. void Process()
  1069. {
  1070. FSMEvent *e = new FSMEvent(USER_EVT_QUERY_CARD_INFO_FINISHED);
  1071. e->param1 = fsm->QueryCardInfo(ctx);
  1072. fsm->PostEventFIFO(e);
  1073. }
  1074. };
  1075. struct GetMaterialCountTask : public ITaskSp
  1076. {
  1077. CCardReadAdapterFSM* fsm;
  1078. SpReqAnsContext<CardReadAdapterService_GetMaterialCount_Req, CardReadAdapterService_GetMaterialCount_Ans>::Pointer ctx;
  1079. GetMaterialCountTask(CCardReadAdapterFSM* f) : fsm(f) {}
  1080. void Process()
  1081. {
  1082. FSMEvent *e = new FSMEvent(USER_EVT_GET_MATERIAL_FINISHED);
  1083. e->param1 = fsm->GetMaterialCount(ctx);
  1084. fsm->PostEventFIFO(e);
  1085. }
  1086. };
  1087. struct SetMaterialCountTask : public ITaskSp
  1088. {
  1089. CCardReadAdapterFSM* fsm;
  1090. SpReqAnsContext<CardReadAdapterService_SetMaterialCount_Req, CardReadAdapterService_SetMaterialCount_Ans>::Pointer ctx;
  1091. SetMaterialCountTask(CCardReadAdapterFSM* f) : fsm(f) {}
  1092. void Process()
  1093. {
  1094. FSMEvent *e = new FSMEvent(USER_EVT_SET_MATERIAL_FINISHED);
  1095. e->param1 = fsm->SetMaterialCount(ctx);
  1096. fsm->PostEventFIFO(e);
  1097. }
  1098. };
  1099. struct GetSCIInfoTask : public ITaskSp
  1100. {
  1101. CCardReadAdapterFSM* fsm;
  1102. SpReqAnsContext<CardReadAdapterService_GetSCIInfo_Req, CardReadAdapterService_GetSCIInfo_Ans>::Pointer ctx;
  1103. GetSCIInfoTask(CCardReadAdapterFSM* f) : fsm(f) {}
  1104. void Process()
  1105. {
  1106. FSMEvent *e = new FSMEvent(USER_EVT_GET_SCI_INFO_FINISHED);
  1107. e->param1 = fsm->GetSCIInfo(ctx);
  1108. fsm->PostEventFIFO(e);
  1109. }
  1110. };
  1111. struct OpenSafeLockTask : public ITaskSp
  1112. {
  1113. CCardReadAdapterFSM* fsm;
  1114. SpReqAnsContext<CardReadAdapterService_OpenSafeLock_Req, CardReadAdapterService_OpenSafeLock_Ans>::Pointer ctx;
  1115. OpenSafeLockTask(CCardReadAdapterFSM* f) : fsm(f) {}
  1116. void Process()
  1117. {
  1118. FSMEvent *e = new FSMEvent(USER_EVT_OPEN_SAFELOCK_FINISHED);
  1119. e->param1 = fsm->OpenSafeLock(ctx);
  1120. fsm->PostEventFIFO(e);
  1121. }
  1122. };
  1123. struct MagTransferInitTask : public ITaskSp
  1124. {
  1125. CCardReadAdapterFSM* fsm;
  1126. SpReqAnsContext<CardReadAdapterService_MagTransferInit_Req, CardReadAdapterService_MagTransferInit_Ans>::Pointer ctx;
  1127. MagTransferInitTask(CCardReadAdapterFSM* f) : fsm(f) {}
  1128. void Process()
  1129. {
  1130. FSMEvent *e = new FSMEvent(USER_EVT_MAGTRANS_INIT_FINISHED);
  1131. e->param1 = fsm->MagTransferInit(ctx);
  1132. fsm->PostEventFIFO(e);
  1133. }
  1134. };
  1135. struct QueryConnInfoTask : public ITaskSp
  1136. {
  1137. CCardReadAdapterFSM* fsm;
  1138. SpReqAnsContext<CardReadAdapterService_QueryConnInfo_Req, CardReadAdapterService_QueryConnInfo_Ans>::Pointer ctx;
  1139. QueryConnInfoTask(CCardReadAdapterFSM* f) : fsm(f) {}
  1140. void Process()
  1141. {
  1142. FSMEvent *e = new FSMEvent(USER_EVT_QUERY_CONN_INFO_FINISHED);
  1143. e->param1 = fsm->QueryConnInfo(ctx);
  1144. fsm->PostEventFIFO(e);
  1145. }
  1146. };
  1147. struct DoExitTask : public ITaskSp
  1148. {
  1149. CCardReadAdapterFSM* fsm;
  1150. DoExitTask(CCardReadAdapterFSM* f) : fsm(f) {}
  1151. void Process()
  1152. {
  1153. fsm->DoExit();
  1154. }
  1155. };
  1156. struct SAMICCommandTask : public ITaskSp
  1157. {
  1158. CCardReadAdapterFSM* fsm;
  1159. SpReqAnsContext<CardReadAdapterService_SAMICCommand_Req, CardReadAdapterService_SAMICCommand_Ans>::Pointer ctx;
  1160. SAMICCommandTask(CCardReadAdapterFSM* f) : fsm(f) {}
  1161. void Process()
  1162. {
  1163. FSMEvent *e = new FSMEvent(USER_EVT_SAM_IC_COMMAND_FINISHED);
  1164. e->param1 = fsm->SAMICCommand(ctx);
  1165. fsm->PostEventFIFO(e);
  1166. }
  1167. };
  1168. struct QueryPrinterStatusTask : public ITaskSp
  1169. {
  1170. CCardReadAdapterFSM* fsm;
  1171. SpReqAnsContext<CardReadAdapterService_QueryPrinterStatus_Req, CardReadAdapterService_QueryPrinterStatus_Ans>::Pointer ctx;
  1172. QueryPrinterStatusTask(CCardReadAdapterFSM* f) : fsm(f) {}
  1173. void Process()
  1174. {
  1175. FSMEvent *e = new FSMEvent(USER_EVT_QUERY_PRINTER_STATUS_FINISHED);
  1176. e->param1 = fsm->QueryPrinterStatus(ctx);
  1177. fsm->PostEventFIFO(e);
  1178. }
  1179. };
  1180. struct PrintTask : public ITaskSp
  1181. {
  1182. CCardReadAdapterFSM* fsm;
  1183. SpReqAnsContext<CardReadAdapterService_Print_Req, CardReadAdapterService_Print_Ans>::Pointer ctx;
  1184. PrintTask(CCardReadAdapterFSM* f) : fsm(f) {}
  1185. void Process()
  1186. {
  1187. FSMEvent *e = new FSMEvent(USER_EVT_PRINT_FINISHED);
  1188. e->param1 = fsm->Print(ctx);
  1189. fsm->PostEventFIFO(e);
  1190. }
  1191. };
  1192. struct QuerySCIListTask : public ITaskSp
  1193. {
  1194. CCardReadAdapterFSM* fsm;
  1195. SpReqAnsContext<CardReadAdapterService_QuerySCIList_Req, CardReadAdapterService_QuerySCIList_Ans>::Pointer ctx;
  1196. QuerySCIListTask(CCardReadAdapterFSM* f) : fsm(f) {}
  1197. void Process()
  1198. {
  1199. FSMEvent *e = new FSMEvent(USER_EVT_QUERY_SCILIST_FINISHED);
  1200. e->param1 = fsm->QuerySCIList(ctx);
  1201. fsm->PostEventFIFO(e);
  1202. }
  1203. };
  1204. struct BindSCITask : public ITaskSp
  1205. {
  1206. CCardReadAdapterFSM* fsm;
  1207. SpReqAnsContext<CardReadAdapterService_BindSCI_Req, CardReadAdapterService_BindSCI_Ans>::Pointer ctx;
  1208. BindSCITask(CCardReadAdapterFSM* f) : fsm(f) {}
  1209. void Process()
  1210. {
  1211. FSMEvent *e = new FSMEvent(USER_EVT_BIND_SCI_FINISHED);
  1212. e->param1 = fsm->BindSCI(ctx);
  1213. fsm->PostEventFIFO(e);
  1214. }
  1215. };
  1216. struct PreOnlineOnStoreTask : public ITaskSp
  1217. {
  1218. CCardReadAdapterFSM* fsm;
  1219. SpReqAnsContext<CardReadAdapterService_PreOnlineOnStore_Req, CardReadAdapterService_PreOnlineOnStore_Ans>::Pointer ctx;
  1220. PreOnlineOnStoreTask(CCardReadAdapterFSM* f) : fsm(f) {}
  1221. void Process()
  1222. {
  1223. fsm->PreOnlineOnStore(ctx);
  1224. }
  1225. };
  1226. struct GetAddCardInfoTask : public ITaskSp
  1227. {
  1228. CCardReadAdapterFSM* fsm;
  1229. SpReqAnsContext<CardReadAdapterService_GetAddCardInfo_Req, CardReadAdapterService_GetAddCardInfo_Ans>::Pointer ctx;
  1230. GetAddCardInfoTask(CCardReadAdapterFSM* f) : fsm(f) {}
  1231. void Process()
  1232. {
  1233. FSMEvent *e = new FSMEvent(USER_EVT_GET_ADD_CARD_INFO_FINISHED);
  1234. e->param1 = fsm->GetAddCardInfo(ctx);
  1235. fsm->PostEventFIFO(e);
  1236. }
  1237. };
  1238. struct NotifyPreOnlineTask : public ITaskSp
  1239. {
  1240. CCardReadAdapterFSM* fsm;
  1241. SpReqAnsContext<CardReadAdapterService_NotifyPreonline_Req, CardReadAdapterService_NotifyPreonline_Ans>::Pointer ctx;
  1242. NotifyPreOnlineTask(CCardReadAdapterFSM* f) : fsm(f) {}
  1243. void Process()
  1244. {
  1245. FSMEvent* e = new FSMEvent(USER_EVT_PREONLINE_ON_STORE_FINISHED);
  1246. e->param1 = fsm->NotifyPreonline(ctx);
  1247. fsm->PostEventFIFO(e);
  1248. }
  1249. };
  1250. struct QueryCardInfoOnStoreTask : public ITaskSp
  1251. {
  1252. CCardReadAdapterFSM* fsm;
  1253. SpReqAnsContext<CardReadAdapterService_QueryCardInfoOnStore_Req, CardReadAdapterService_QueryCardInfoOnStore_Ans>::Pointer ctx;
  1254. QueryCardInfoOnStoreTask(CCardReadAdapterFSM* f) : fsm(f) {}
  1255. void Process()
  1256. {
  1257. FSMEvent *e = new FSMEvent(USER_EVT_QUERY_CARD_INFO_ON_STORE_FINISHED);
  1258. e->param1 = fsm->QueryCardInfoOnStore(ctx);
  1259. fsm->PostEventFIFO(e);
  1260. }
  1261. };
  1262. struct CrossTermCallTask : public ITaskSp
  1263. {
  1264. CCardReadAdapterFSM* fsm;
  1265. SpReqAnsContext<CardReadAdapterService_CrossTermCall_Req, CardReadAdapterService_CrossTermCall_Ans>::Pointer ctx;
  1266. CrossTermCallTask(CCardReadAdapterFSM* f) : fsm(f) {}
  1267. void Process()
  1268. {
  1269. FSMEvent *e = new FSMEvent(USER_EVT_CROSS_TERM_CALL_FINISHED);
  1270. e->param1 = fsm->CrossTermCall(ctx);
  1271. fsm->PostEventFIFO(e);
  1272. }
  1273. };
  1274. struct PrintCardImTask : public ITaskSp
  1275. {
  1276. CCardReadAdapterFSM* fsm;
  1277. SpReqAnsContext<CardReadAdapterService_PrintCardImmediately_Req, CardReadAdapterService_PrintCardImmediately_Ans>::Pointer ctx;
  1278. PrintCardImTask(CCardReadAdapterFSM* f) : fsm(f) {}
  1279. void Process()
  1280. {
  1281. FSMEvent* e = new FSMEvent(USER_EVT_PRINT_CARD_IM_FINISHED);
  1282. e->param1 = fsm->PrintCardIm(ctx);
  1283. fsm->PostEventFIFO(e);
  1284. }
  1285. };
  1286. struct QueryCIStatusTask : public ITaskSp
  1287. {
  1288. CCardReadAdapterFSM* fsm;
  1289. SpReqAnsContext<CardReadAdapterService_QueryCIStatus_Req, CardReadAdapterService_QueryCIStatus_Ans>::Pointer ctx;
  1290. QueryCIStatusTask(CCardReadAdapterFSM* f) : fsm(f) {}
  1291. void Process()
  1292. {
  1293. FSMEvent* e = new FSMEvent(USER_EVT_QUERY_CI_STATUS_FINISHED);
  1294. e->param1 = fsm->QueryCIStatus(ctx);
  1295. fsm->PostEventFIFO(e);
  1296. }
  1297. };
  1298. struct Test1Task : public ITaskSp
  1299. {
  1300. CCardReadAdapterFSM* fsm;
  1301. SpReqAnsContext<CardReadAdapterService_Test1_Req, CardReadAdapterService_Test1_Ans>::Pointer ctx;
  1302. Test1Task(CCardReadAdapterFSM* f) : fsm(f) {}
  1303. void Process()
  1304. {
  1305. FSMEvent *e = new FSMEvent(USER_EVT_TEST1_FINISHED);
  1306. e->param1 = fsm->Test1(ctx);
  1307. fsm->PostEventFIFO(e);
  1308. }
  1309. };
  1310. struct Test2Task : public ITaskSp
  1311. {
  1312. CCardReadAdapterFSM* fsm;
  1313. SpReqAnsContext<CardReadAdapterService_Test2_Req, CardReadAdapterService_Test2_Ans>::Pointer ctx;
  1314. Test2Task(CCardReadAdapterFSM* f) : fsm(f) {}
  1315. void Process()
  1316. {
  1317. FSMEvent *e = new FSMEvent(USER_EVT_TEST1_FINISHED);
  1318. e->param1 = fsm->Test2(ctx);
  1319. fsm->PostEventFIFO(e);
  1320. }
  1321. };
  1322. struct WaitCardActiveTask : public ITaskSp
  1323. {
  1324. CCardReadAdapterFSM* fsm;
  1325. WaitCardActiveTask(CCardReadAdapterFSM* f) : fsm(f) {}
  1326. void Process()
  1327. {
  1328. fsm->WaitCardActive();
  1329. }
  1330. };
  1331. #endif //__CARDREAD_ADAPTER_FSM_H