CardReadAdapterFSM.h 45 KB

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