CardReadAdapterFSM.h 44 KB

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