CardReadAdapterFSM.h 44 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406
  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_lastModule:0~7
  859. //0:all; 1:CardIssuer; 2:ContactlessCard; 4:CardSwiper
  860. int m_lastModule,m_lastS2Event, m_lastS2EvtParam1;
  861. SP::Module::Comm::What m_eMachineType;
  862. WORD m_majorVerion,m_minorVerion;
  863. ///
  864. int m_resetTimes;
  865. HMODULE m_hVerdorDll;
  866. //GUIConsoleService_ClientBase *m_pGUIConsoleClient;
  867. bool m_devInit, m_bCancelAccept, m_bWaitingAccept, m_bWaitAccepteMore
  868. , m_bCDA, m_bIssuingExit, m_bCardIssued, m_bCaptureCfgFlag, m_bHasHopper[3], m_bBTConncting
  869. , m_bCardActiveNotify;
  870. ErrorCodeEnum m_testResult;
  871. //m_CardInit,m_CardRemains,m_CardIssued,m_CardMixed,m_CardPercent
  872. int m_CardCaptured, m_issueStatusFromFile, m_issueStatus, m_port, m_baudRate, m_currentHopper, m_scanSlot;
  873. CSimpleStringA m_CardBoxNoEx[3], m_PsbCodeEx[3], m_PsbNameEx[3], m_MaintainerEx[3], m_csMaintainTimeEx[3];
  874. int m_CardInitEx[3], m_CardPercentEx[3], m_remainsEx[3], m_issuedEx[3], m_mixedEx[3], m_hopperNum;
  875. DWORD m_MaintainTimeEx[3];
  876. 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];
  877. DevStateEnum m_eDevState;
  878. CCardProcess *m_pCardProcess;
  879. char *m_pDataToARQC;
  880. long xxTest;
  881. CSimpleStringA m_currCardNo, m_captureReason, m_csMachineType, m_csSite, m_csDevSN, m_terminalNo, m_devSN;
  882. char m_AuthCode[2];
  883. bool m_bBTConnected;
  884. map<int, CtxInfo> m_mapCtx;
  885. SpReqAnsContext<CardReadAdapterService_PreOnlineOnStore_Req, CardReadAdapterService_PreOnlineOnStore_Ans>::Pointer m_crossCtx;
  886. ULONGLONG m_ullCrossStart;
  887. bool IsCardIssuerSessionOK();
  888. bool IsContactlessCardSessionOK();
  889. bool IsCardSwiperSessionOK();
  890. bool IsTheEntity(int module,ModuleType eModule);
  891. bool CheckHBSessionOrToConnect();
  892. //oilyang@20230614 跨及时因为卡片的实际交易发生在卡库,需要在发起端对返回的UserErrorCode做二次映射,方便客户理解提示信息
  893. DWORD MapErrorCodeWhileCallStore(DWORD eErrCode)
  894. {
  895. //eErrCode defined on CardIssuer_UserErrorCode.h
  896. switch (eErrCode)
  897. {
  898. case 0x20300240:
  899. return 0x203002E0;
  900. case 0x20300242:
  901. return 0x203002E1;
  902. case 0x20300243:
  903. case 0x203002a1:
  904. return 0x203002E2;
  905. case 0x20300244:
  906. return 0x203002E3;
  907. case 0x20300246:
  908. return 0x203002E4;
  909. case 0x2030000D:
  910. return 0x203002E5;
  911. default:
  912. return eErrCode;
  913. }
  914. }
  915. };
  916. struct InitTask : public ITaskSp
  917. {
  918. CCardReadAdapterFSM* fsm;
  919. InitTask(CCardReadAdapterFSM* f) : fsm(f) {}
  920. void Process()
  921. {
  922. FSMEvent *e = new FSMEvent(USER_EVT_INIT_FINISHED);
  923. e->param1 = fsm->Initial();
  924. fsm->PostEventFIFO(e);
  925. }
  926. };
  927. struct CardIssuerReadTask : public ITaskSp
  928. {
  929. CCardReadAdapterFSM* fsm;
  930. SpReqAnsContext<CardReadAdapterService_Read_Req, CardReadAdapterService_Read_Ans>::Pointer ctx;
  931. CardIssuerReadTask(CCardReadAdapterFSM* f) : fsm(f) {}
  932. void Process()
  933. {
  934. CardReadFinishedEvent *e = new CardReadFinishedEvent();
  935. e->ctx = ctx;
  936. e->param1 = fsm->CardIssuerRead(ctx);
  937. fsm->PostEventFIFO(e);
  938. }
  939. };
  940. struct ContactlessCardReadTask : public ITaskSp
  941. {
  942. CCardReadAdapterFSM* fsm;
  943. SpReqAnsContext<CardReadAdapterService_Read_Req, CardReadAdapterService_Read_Ans>::Pointer ctx;
  944. ContactlessCardReadTask(CCardReadAdapterFSM* f) : fsm(f) {}
  945. void Process()
  946. {
  947. CardReadFinishedEvent *e = new CardReadFinishedEvent();
  948. e->ctx = ctx;
  949. e->param1 = fsm->ContactlessCardRead(ctx);
  950. fsm->PostEventFIFO(e);
  951. }
  952. };
  953. struct CardSwiperReadTask : public ITaskSp
  954. {
  955. CCardReadAdapterFSM* fsm;
  956. SpReqAnsContext<CardReadAdapterService_Read_Req, CardReadAdapterService_Read_Ans>::Pointer ctx;
  957. CardSwiperReadTask(CCardReadAdapterFSM* f) : fsm(f) {}
  958. int x;
  959. void Process()
  960. {
  961. CardReadFinishedEvent *e = new CardReadFinishedEvent();
  962. e->ctx = ctx;
  963. e->param1 = fsm->CardSwiperRead(ctx,x);
  964. fsm->PostEventFIFO(e);
  965. }
  966. };
  967. struct WriteTask : public ITaskSp
  968. {
  969. CCardReadAdapterFSM* fsm;
  970. SpReqAnsContext<CardReadAdapterService_WriteTrack_Req, CardReadAdapterService_WriteTrack_Ans>::Pointer ctx;
  971. WriteTask(CCardReadAdapterFSM* f) : fsm(f) {}
  972. void Process()
  973. {
  974. CardWriteFinishedEvent *e = new CardWriteFinishedEvent();
  975. e->ctx = ctx;
  976. e->param1 = fsm->WriteTrack(ctx);
  977. fsm->PostEventFIFO(e);
  978. }
  979. };
  980. struct DoWorkTask : public ITaskSp
  981. {
  982. CCardReadAdapterFSM* fsm;
  983. int type;
  984. DoWorkTask(CCardReadAdapterFSM* f) : fsm(f) {}
  985. void Process()
  986. {
  987. //FSMEvent *e = new FSMEvent(USER_EVT_DO_WORK_FINISHED);
  988. //e->param1 = fsm->DoWork(type);
  989. //fsm->PostEventFIFO(e);
  990. }
  991. };
  992. struct TestCancelReadTask : public ITaskSp
  993. {
  994. CCardReadAdapterFSM* fsm;
  995. int type;
  996. TestCancelReadTask(CCardReadAdapterFSM* f) : fsm(f) {}
  997. void Process()
  998. {
  999. Sleep(10000);
  1000. fsm->CancelRead();
  1001. }
  1002. };
  1003. struct ReadWaitMoreTask : public ITaskSp
  1004. {
  1005. CCardReadAdapterFSM* fsm;
  1006. int type;
  1007. ReadWaitMoreTask(CCardReadAdapterFSM* f) : fsm(f) {}
  1008. void Process()
  1009. {
  1010. fsm->ReadWaitMore();
  1011. }
  1012. };
  1013. struct PreOnlineTask : public ITaskSp
  1014. {
  1015. SpReqAnsContext<CardReadAdapterService_PreOnline_Req, CardReadAdapterService_PreOnline_Ans>::Pointer ctx;
  1016. CCardReadAdapterFSM* fsm;
  1017. PreOnlineTask(CCardReadAdapterFSM* f) : fsm(f) {}
  1018. void Process()
  1019. {
  1020. FSMEvent *e = new FSMEvent(USER_EVT_PREONLINE_FINISHED);
  1021. e->param1 = fsm->PreOnline(ctx);
  1022. fsm->PostEventFIFO(e);
  1023. }
  1024. };
  1025. struct PostOnlineTask : public ITaskSp
  1026. {
  1027. SpReqAnsContext<CardReadAdapterService_PostOnline_Req, CardReadAdapterService_PostOnline_Ans>::Pointer ctx;
  1028. CCardReadAdapterFSM* fsm;
  1029. PostOnlineTask(CCardReadAdapterFSM* f) : fsm(f) {}
  1030. void Process()
  1031. {
  1032. FSMEvent *e = new FSMEvent(USER_EVT_POSTONLINE_FINISHED);
  1033. e->param1 = fsm->PostOnline(ctx);
  1034. fsm->PostEventFIFO(e);
  1035. }
  1036. };
  1037. struct IssueTask : public ITaskSp
  1038. {
  1039. SpReqAnsContext<CardReadAdapterService_Issue_Req, CardReadAdapterService_Issue_Ans>::Pointer ctx;
  1040. CCardReadAdapterFSM* fsm;
  1041. IssueTask(CCardReadAdapterFSM* f) : fsm(f) {}
  1042. void Process()
  1043. {
  1044. FSMEvent *e = new FSMEvent(USER_EVT_ISSUE_FINISHED);
  1045. e->param1 = fsm->IssueCard(ctx);
  1046. fsm->PostEventFIFO(e);
  1047. }
  1048. };
  1049. struct EjectTask : public ITaskSp
  1050. {
  1051. SpReqAnsContext<CardReadAdapterService_Eject_Req, CardReadAdapterService_Eject_Ans>::Pointer ctx;
  1052. CCardReadAdapterFSM* fsm;
  1053. EjectTask(CCardReadAdapterFSM* f) : fsm(f) {}
  1054. void Process()
  1055. {
  1056. FSMEvent *e = new FSMEvent(USER_EVT_EJECT_FINISHED);
  1057. e->param1 = fsm->EjectCard(ctx);
  1058. fsm->PostEventFIFO(e);
  1059. }
  1060. };
  1061. struct CaptureTask : public ITaskSp
  1062. {
  1063. SpReqAnsContext<CardReadAdapterService_Capture_Req, CardReadAdapterService_Capture_Ans>::Pointer ctx;
  1064. CCardReadAdapterFSM* fsm;
  1065. CaptureTask(CCardReadAdapterFSM* f) : fsm(f) {}
  1066. void Process()
  1067. {
  1068. FSMEvent *e = new FSMEvent(USER_EVT_CAPTUREFINISHED);
  1069. e->param1 = fsm->CaptureCard(ctx);
  1070. fsm->PostEventFIFO(e);
  1071. }
  1072. };
  1073. struct CheckSessionTask : public ITaskSp
  1074. {
  1075. CCardReadAdapterFSM* fsm;
  1076. CheckSessionTask(CCardReadAdapterFSM* f) : fsm(f) {}
  1077. void Process()
  1078. {
  1079. fsm->CheckAndReconnectSession();
  1080. }
  1081. };
  1082. struct SetSomeFlagTask : public ITaskSp
  1083. {
  1084. CCardReadAdapterFSM* fsm;
  1085. SpReqAnsContext<CardReadAdapterService_SetSomeFlag_Req, CardReadAdapterService_SetSomeFlag_Ans>::Pointer ctx;
  1086. SetSomeFlagTask(CCardReadAdapterFSM* f) : fsm(f) {}
  1087. void Process()
  1088. {
  1089. FSMEvent *e = new FSMEvent(USER_EVT_SET_SOME_FLAG_FINISHED);
  1090. e->param1 = fsm->SetSomeFlag(ctx);
  1091. fsm->PostEventFIFO(e);
  1092. }
  1093. };
  1094. struct GetDevInfoTask : public ITaskSp
  1095. {
  1096. CCardReadAdapterFSM* fsm;
  1097. SpReqAnsContext<CardReadAdapterService_GetDevInfo_Req, CardReadAdapterService_GetDevInfo_Ans>::Pointer ctx;
  1098. GetDevInfoTask(CCardReadAdapterFSM* f) : fsm(f) {}
  1099. void Process()
  1100. {
  1101. FSMEvent *e = new FSMEvent(USER_EVT_GET_DEV_INFO_FINISHED);
  1102. e->param1 = fsm->GetDevInfo(ctx);
  1103. fsm->PostEventFIFO(e);
  1104. }
  1105. };
  1106. struct QueryCardInfoTask : public ITaskSp
  1107. {
  1108. CCardReadAdapterFSM* fsm;
  1109. SpReqAnsContext<CardReadAdapterService_QueryCardInfo_Req, CardReadAdapterService_QueryCardInfo_Ans>::Pointer ctx;
  1110. QueryCardInfoTask(CCardReadAdapterFSM* f) : fsm(f) {}
  1111. void Process()
  1112. {
  1113. FSMEvent *e = new FSMEvent(USER_EVT_QUERY_CARD_INFO_FINISHED);
  1114. e->param1 = fsm->QueryCardInfo(ctx);
  1115. fsm->PostEventFIFO(e);
  1116. }
  1117. };
  1118. struct GetMaterialCountTask : public ITaskSp
  1119. {
  1120. CCardReadAdapterFSM* fsm;
  1121. SpReqAnsContext<CardReadAdapterService_GetMaterialCount_Req, CardReadAdapterService_GetMaterialCount_Ans>::Pointer ctx;
  1122. GetMaterialCountTask(CCardReadAdapterFSM* f) : fsm(f) {}
  1123. void Process()
  1124. {
  1125. FSMEvent *e = new FSMEvent(USER_EVT_GET_MATERIAL_FINISHED);
  1126. e->param1 = fsm->GetMaterialCount(ctx);
  1127. fsm->PostEventFIFO(e);
  1128. }
  1129. };
  1130. struct SetMaterialCountTask : public ITaskSp
  1131. {
  1132. CCardReadAdapterFSM* fsm;
  1133. SpReqAnsContext<CardReadAdapterService_SetMaterialCount_Req, CardReadAdapterService_SetMaterialCount_Ans>::Pointer ctx;
  1134. SetMaterialCountTask(CCardReadAdapterFSM* f) : fsm(f) {}
  1135. void Process()
  1136. {
  1137. FSMEvent *e = new FSMEvent(USER_EVT_SET_MATERIAL_FINISHED);
  1138. e->param1 = fsm->SetMaterialCount(ctx);
  1139. fsm->PostEventFIFO(e);
  1140. }
  1141. };
  1142. struct GetSCIInfoTask : public ITaskSp
  1143. {
  1144. CCardReadAdapterFSM* fsm;
  1145. SpReqAnsContext<CardReadAdapterService_GetSCIInfo_Req, CardReadAdapterService_GetSCIInfo_Ans>::Pointer ctx;
  1146. GetSCIInfoTask(CCardReadAdapterFSM* f) : fsm(f) {}
  1147. void Process()
  1148. {
  1149. FSMEvent *e = new FSMEvent(USER_EVT_GET_SCI_INFO_FINISHED);
  1150. e->param1 = fsm->GetSCIInfo(ctx);
  1151. fsm->PostEventFIFO(e);
  1152. }
  1153. };
  1154. struct OpenSafeLockTask : public ITaskSp
  1155. {
  1156. CCardReadAdapterFSM* fsm;
  1157. SpReqAnsContext<CardReadAdapterService_OpenSafeLock_Req, CardReadAdapterService_OpenSafeLock_Ans>::Pointer ctx;
  1158. OpenSafeLockTask(CCardReadAdapterFSM* f) : fsm(f) {}
  1159. void Process()
  1160. {
  1161. FSMEvent *e = new FSMEvent(USER_EVT_OPEN_SAFELOCK_FINISHED);
  1162. e->param1 = fsm->OpenSafeLock(ctx);
  1163. fsm->PostEventFIFO(e);
  1164. }
  1165. };
  1166. struct MagTransferInitTask : public ITaskSp
  1167. {
  1168. CCardReadAdapterFSM* fsm;
  1169. SpReqAnsContext<CardReadAdapterService_MagTransferInit_Req, CardReadAdapterService_MagTransferInit_Ans>::Pointer ctx;
  1170. MagTransferInitTask(CCardReadAdapterFSM* f) : fsm(f) {}
  1171. void Process()
  1172. {
  1173. FSMEvent *e = new FSMEvent(USER_EVT_MAGTRANS_INIT_FINISHED);
  1174. e->param1 = fsm->MagTransferInit(ctx);
  1175. fsm->PostEventFIFO(e);
  1176. }
  1177. };
  1178. struct QueryConnInfoTask : public ITaskSp
  1179. {
  1180. CCardReadAdapterFSM* fsm;
  1181. SpReqAnsContext<CardReadAdapterService_QueryConnInfo_Req, CardReadAdapterService_QueryConnInfo_Ans>::Pointer ctx;
  1182. QueryConnInfoTask(CCardReadAdapterFSM* f) : fsm(f) {}
  1183. void Process()
  1184. {
  1185. FSMEvent *e = new FSMEvent(USER_EVT_QUERY_CONN_INFO_FINISHED);
  1186. e->param1 = fsm->QueryConnInfo(ctx);
  1187. fsm->PostEventFIFO(e);
  1188. }
  1189. };
  1190. struct DoExitTask : public ITaskSp
  1191. {
  1192. CCardReadAdapterFSM* fsm;
  1193. DoExitTask(CCardReadAdapterFSM* f) : fsm(f) {}
  1194. void Process()
  1195. {
  1196. fsm->DoExit();
  1197. }
  1198. };
  1199. struct SAMICCommandTask : public ITaskSp
  1200. {
  1201. CCardReadAdapterFSM* fsm;
  1202. SpReqAnsContext<CardReadAdapterService_SAMICCommand_Req, CardReadAdapterService_SAMICCommand_Ans>::Pointer ctx;
  1203. SAMICCommandTask(CCardReadAdapterFSM* f) : fsm(f) {}
  1204. void Process()
  1205. {
  1206. FSMEvent *e = new FSMEvent(USER_EVT_SAM_IC_COMMAND_FINISHED);
  1207. e->param1 = fsm->SAMICCommand(ctx);
  1208. fsm->PostEventFIFO(e);
  1209. }
  1210. };
  1211. struct QueryPrinterStatusTask : public ITaskSp
  1212. {
  1213. CCardReadAdapterFSM* fsm;
  1214. SpReqAnsContext<CardReadAdapterService_QueryPrinterStatus_Req, CardReadAdapterService_QueryPrinterStatus_Ans>::Pointer ctx;
  1215. QueryPrinterStatusTask(CCardReadAdapterFSM* f) : fsm(f) {}
  1216. void Process()
  1217. {
  1218. FSMEvent *e = new FSMEvent(USER_EVT_QUERY_PRINTER_STATUS_FINISHED);
  1219. e->param1 = fsm->QueryPrinterStatus(ctx);
  1220. fsm->PostEventFIFO(e);
  1221. }
  1222. };
  1223. struct PrintTask : public ITaskSp
  1224. {
  1225. CCardReadAdapterFSM* fsm;
  1226. SpReqAnsContext<CardReadAdapterService_Print_Req, CardReadAdapterService_Print_Ans>::Pointer ctx;
  1227. PrintTask(CCardReadAdapterFSM* f) : fsm(f) {}
  1228. void Process()
  1229. {
  1230. FSMEvent *e = new FSMEvent(USER_EVT_PRINT_FINISHED);
  1231. e->param1 = fsm->Print(ctx);
  1232. fsm->PostEventFIFO(e);
  1233. }
  1234. };
  1235. struct QuerySCIListTask : public ITaskSp
  1236. {
  1237. CCardReadAdapterFSM* fsm;
  1238. SpReqAnsContext<CardReadAdapterService_QuerySCIList_Req, CardReadAdapterService_QuerySCIList_Ans>::Pointer ctx;
  1239. QuerySCIListTask(CCardReadAdapterFSM* f) : fsm(f) {}
  1240. void Process()
  1241. {
  1242. FSMEvent *e = new FSMEvent(USER_EVT_QUERY_SCILIST_FINISHED);
  1243. e->param1 = fsm->QuerySCIList(ctx);
  1244. fsm->PostEventFIFO(e);
  1245. }
  1246. };
  1247. struct BindSCITask : public ITaskSp
  1248. {
  1249. CCardReadAdapterFSM* fsm;
  1250. SpReqAnsContext<CardReadAdapterService_BindSCI_Req, CardReadAdapterService_BindSCI_Ans>::Pointer ctx;
  1251. BindSCITask(CCardReadAdapterFSM* f) : fsm(f) {}
  1252. void Process()
  1253. {
  1254. FSMEvent *e = new FSMEvent(USER_EVT_BIND_SCI_FINISHED);
  1255. e->param1 = fsm->BindSCI(ctx);
  1256. fsm->PostEventFIFO(e);
  1257. }
  1258. };
  1259. struct PreOnlineOnStoreTask : public ITaskSp
  1260. {
  1261. CCardReadAdapterFSM* fsm;
  1262. SpReqAnsContext<CardReadAdapterService_PreOnlineOnStore_Req, CardReadAdapterService_PreOnlineOnStore_Ans>::Pointer ctx;
  1263. PreOnlineOnStoreTask(CCardReadAdapterFSM* f) : fsm(f) {}
  1264. void Process()
  1265. {
  1266. fsm->PreOnlineOnStore(ctx);
  1267. }
  1268. };
  1269. struct GetAddCardInfoTask : public ITaskSp
  1270. {
  1271. CCardReadAdapterFSM* fsm;
  1272. SpReqAnsContext<CardReadAdapterService_GetAddCardInfo_Req, CardReadAdapterService_GetAddCardInfo_Ans>::Pointer ctx;
  1273. GetAddCardInfoTask(CCardReadAdapterFSM* f) : fsm(f) {}
  1274. void Process()
  1275. {
  1276. FSMEvent *e = new FSMEvent(USER_EVT_GET_ADD_CARD_INFO_FINISHED);
  1277. e->param1 = fsm->GetAddCardInfo(ctx);
  1278. fsm->PostEventFIFO(e);
  1279. }
  1280. };
  1281. struct NotifyPreOnlineTask : public ITaskSp
  1282. {
  1283. CCardReadAdapterFSM* fsm;
  1284. SpReqAnsContext<CardReadAdapterService_NotifyPreonline_Req, CardReadAdapterService_NotifyPreonline_Ans>::Pointer ctx;
  1285. NotifyPreOnlineTask(CCardReadAdapterFSM* f) : fsm(f) {}
  1286. void Process()
  1287. {
  1288. FSMEvent* e = new FSMEvent(USER_EVT_PREONLINE_ON_STORE_FINISHED);
  1289. e->param1 = fsm->NotifyPreonline(ctx);
  1290. fsm->PostEventFIFO(e);
  1291. }
  1292. };
  1293. struct QueryCardInfoOnStoreTask : public ITaskSp
  1294. {
  1295. CCardReadAdapterFSM* fsm;
  1296. SpReqAnsContext<CardReadAdapterService_QueryCardInfoOnStore_Req, CardReadAdapterService_QueryCardInfoOnStore_Ans>::Pointer ctx;
  1297. QueryCardInfoOnStoreTask(CCardReadAdapterFSM* f) : fsm(f) {}
  1298. void Process()
  1299. {
  1300. FSMEvent *e = new FSMEvent(USER_EVT_QUERY_CARD_INFO_ON_STORE_FINISHED);
  1301. e->param1 = fsm->QueryCardInfoOnStore(ctx);
  1302. fsm->PostEventFIFO(e);
  1303. }
  1304. };
  1305. struct CrossTermCallTask : public ITaskSp
  1306. {
  1307. CCardReadAdapterFSM* fsm;
  1308. SpReqAnsContext<CardReadAdapterService_CrossTermCall_Req, CardReadAdapterService_CrossTermCall_Ans>::Pointer ctx;
  1309. CrossTermCallTask(CCardReadAdapterFSM* f) : fsm(f) {}
  1310. void Process()
  1311. {
  1312. FSMEvent *e = new FSMEvent(USER_EVT_CROSS_TERM_CALL_FINISHED);
  1313. e->param1 = fsm->CrossTermCall(ctx);
  1314. fsm->PostEventFIFO(e);
  1315. }
  1316. };
  1317. struct PrintCardImTask : public ITaskSp
  1318. {
  1319. CCardReadAdapterFSM* fsm;
  1320. SpReqAnsContext<CardReadAdapterService_PrintCardImmediately_Req, CardReadAdapterService_PrintCardImmediately_Ans>::Pointer ctx;
  1321. PrintCardImTask(CCardReadAdapterFSM* f) : fsm(f) {}
  1322. void Process()
  1323. {
  1324. FSMEvent* e = new FSMEvent(USER_EVT_PRINT_CARD_IM_FINISHED);
  1325. e->param1 = fsm->PrintCardIm(ctx);
  1326. fsm->PostEventFIFO(e);
  1327. }
  1328. };
  1329. struct QueryCIStatusTask : public ITaskSp
  1330. {
  1331. CCardReadAdapterFSM* fsm;
  1332. SpReqAnsContext<CardReadAdapterService_QueryCIStatus_Req, CardReadAdapterService_QueryCIStatus_Ans>::Pointer ctx;
  1333. QueryCIStatusTask(CCardReadAdapterFSM* f) : fsm(f) {}
  1334. void Process()
  1335. {
  1336. FSMEvent* e = new FSMEvent(USER_EVT_QUERY_CI_STATUS_FINISHED);
  1337. e->param1 = fsm->QueryCIStatus(ctx);
  1338. fsm->PostEventFIFO(e);
  1339. }
  1340. };
  1341. struct Test1Task : public ITaskSp
  1342. {
  1343. CCardReadAdapterFSM* fsm;
  1344. SpReqAnsContext<CardReadAdapterService_Test1_Req, CardReadAdapterService_Test1_Ans>::Pointer ctx;
  1345. Test1Task(CCardReadAdapterFSM* f) : fsm(f) {}
  1346. void Process()
  1347. {
  1348. FSMEvent *e = new FSMEvent(USER_EVT_TEST1_FINISHED);
  1349. e->param1 = fsm->Test1(ctx);
  1350. fsm->PostEventFIFO(e);
  1351. }
  1352. };
  1353. struct Test2Task : public ITaskSp
  1354. {
  1355. CCardReadAdapterFSM* fsm;
  1356. SpReqAnsContext<CardReadAdapterService_Test2_Req, CardReadAdapterService_Test2_Ans>::Pointer ctx;
  1357. Test2Task(CCardReadAdapterFSM* f) : fsm(f) {}
  1358. void Process()
  1359. {
  1360. FSMEvent *e = new FSMEvent(USER_EVT_TEST1_FINISHED);
  1361. e->param1 = fsm->Test2(ctx);
  1362. fsm->PostEventFIFO(e);
  1363. }
  1364. };
  1365. struct WaitCardActiveTask : public ITaskSp
  1366. {
  1367. CCardReadAdapterFSM* fsm;
  1368. WaitCardActiveTask(CCardReadAdapterFSM* f) : fsm(f) {}
  1369. void Process()
  1370. {
  1371. fsm->WaitCardActive();
  1372. }
  1373. };
  1374. #endif //__CARDREAD_ADAPTER_FSM_H