CardReadAdapterFSM.h 45 KB

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