CardReadAdapterFSM.h 45 KB

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