CardReadAdapterFSM.h 43 KB

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