CardReadAdapterFSM.h 44 KB

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