mod_cardissuer.h 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450
  1. #include "CardIssuer_server_g.h"
  2. #include "CardIssuer_def_g.h"
  3. #include "CardIssuerFSM.h"
  4. using namespace CardIssuer;
  5. //#pragma comment(lib,"CardIssuer.lib")
  6. class CCardIssuerEntity;
  7. class CardIssuerServerSession : public CardIssuerService_ServerSessionBase
  8. {
  9. public:
  10. CardIssuerServerSession(CCardIssuerEntity* pEntity):m_pEntity(pEntity){}
  11. virtual ~CardIssuerServerSession(){}
  12. virtual void Handle_Insert(SpReqAnsContext<CardIssuerService_Insert_Req, CardIssuerService_Insert_Ans>::Pointer ctx);
  13. virtual void Handle_Read(SpReqAnsContext<CardIssuerService_Read_Req, CardIssuerService_Read_Ans>::Pointer ctx);
  14. virtual void Handle_Capture(SpReqAnsContext<CardIssuerService_Capture_Req, CardIssuerService_Capture_Ans>::Pointer ctx);
  15. virtual void Handle_Eject(SpReqAnsContext<CardIssuerService_Eject_Req, CardIssuerService_Eject_Ans>::Pointer ctx);
  16. virtual void Handle_CancelInsert(SpOnewayCallContext<CardIssuerService_CancelInsert_Info>::Pointer ctx);
  17. virtual void Handle_InsertWaitMore(SpOnewayCallContext<CardIssuerService_InsertWaitMore_Info>::Pointer ctx);
  18. virtual void Handle_Issue(SpReqAnsContext<CardIssuerService_Issue_Req, CardIssuerService_Issue_Ans>::Pointer ctx);
  19. virtual void Handle_PreOnline(SpReqAnsContext<CardIssuerService_PreOnline_Req, CardIssuerService_PreOnline_Ans>::Pointer ctx);
  20. virtual void Handle_PostOnline(SpReqAnsContext<CardIssuerService_PostOnline_Req, CardIssuerService_PostOnline_Ans>::Pointer ctx);
  21. virtual void Handle_Exit(SpOnewayCallContext<CardIssuerService_Exit_Info>::Pointer ctx);
  22. virtual void Handle_GetMaterialCount(SpReqAnsContext<CardIssuerService_GetMaterialCount_Req, CardIssuerService_GetMaterialCount_Ans>::Pointer ctx);
  23. virtual void Handle_SetMaterialCount(SpReqAnsContext<CardIssuerService_SetMaterialCount_Req, CardIssuerService_SetMaterialCount_Ans>::Pointer ctx);
  24. virtual void Handle_SetIssueFlag(SpOnewayCallContext<CardIssuerService_SetIssueFlag_Info>::Pointer ctx);
  25. virtual void Handle_ReadEx(SpReqAnsContext<CardIssuerService_ReadEx_Req, CardIssuerService_ReadEx_Ans>::Pointer ctx);
  26. virtual void Handle_QueryCardInfo(SpReqAnsContext<CardIssuerService_QueryCardInfo_Req, CardIssuerService_QueryCardInfo_Ans>::Pointer ctx);
  27. virtual void Handle_WriteTrack(SpReqAnsContext<CardIssuerService_WriteTrack_Req, CardIssuerService_WriteTrack_Ans>::Pointer ctx);
  28. virtual void Handle_GetMaterialCountEx(SpReqAnsContext<CardIssuerService_GetMaterialCountEx_Req, CardIssuerService_GetMaterialCountEx_Ans>::Pointer ctx);
  29. virtual void Handle_SetMaterialCountEx(SpReqAnsContext<CardIssuerService_SetMaterialCountEx_Req, CardIssuerService_SetMaterialCountEx_Ans>::Pointer ctx);
  30. virtual void Handle_SetSomeFlag(SpReqAnsContext<CardIssuerService_SetSomeFlag_Req, CardIssuerService_SetSomeFlag_Ans>::Pointer ctx);
  31. virtual void Handle_GetSCIInfo(SpReqAnsContext<CardIssuerService_GetSCIInfo_Req, CardIssuerService_GetSCIInfo_Ans>::Pointer ctx);
  32. virtual void Handle_IssueEx(SpReqAnsContext<CardIssuerService_IssueEx_Req, CardIssuerService_IssueEx_Ans>::Pointer ctx);
  33. virtual void Handle_OpenSafeLock(SpReqAnsContext<CardIssuerService_OpenSafeLock_Req, CardIssuerService_OpenSafeLock_Ans>::Pointer ctx);
  34. virtual void Handle_SAMICCommand(SpReqAnsContext<CardIssuerService_SAMICCommand_Req, CardIssuerService_SAMICCommand_Ans>::Pointer ctx);
  35. virtual void Handle_QueryPrinterStatus(SpReqAnsContext<CardIssuerService_QueryPrinterStatus_Req, CardIssuerService_QueryPrinterStatus_Ans>::Pointer ctx);
  36. virtual void Handle_Print(SpReqAnsContext<CardIssuerService_Print_Req, CardIssuerService_Print_Ans>::Pointer ctx);
  37. virtual void Handle_QuerySCIList(SpReqAnsContext<CardIssuerService_QuerySCIList_Req, CardIssuerService_QuerySCIList_Ans>::Pointer ctx);
  38. virtual void Handle_BindSCI(SpReqAnsContext<CardIssuerService_BindSCI_Req, CardIssuerService_BindSCI_Ans>::Pointer ctx);
  39. virtual void Handle_PreOnlineOnStore(SpReqAnsContext<CardIssuerService_PreOnlineOnStore_Req, CardIssuerService_PreOnlineOnStore_Ans>::Pointer ctx);
  40. virtual void Handle_NotifyPreonline(SpReqAnsContext<CardIssuerService_NotifyPreonline_Req, CardIssuerService_NotifyPreonline_Ans>::Pointer ctx);
  41. virtual void Handle_QueryCardInfoOnStore(SpReqAnsContext<CardIssuerService_QueryCardInfoOnStore_Req, CardIssuerService_QueryCardInfoOnStore_Ans>::Pointer ctx);
  42. virtual void Handle_GetAddCardInfo(SpReqAnsContext<CardIssuerService_GetAddCardInfo_Req, CardIssuerService_GetAddCardInfo_Ans>::Pointer ctx);
  43. virtual void Handle_PrintCardImmediately(SpReqAnsContext<CardIssuerService_PrintCardImmediately_Req, CardIssuerService_PrintCardImmediately_Ans>::Pointer ctx);
  44. virtual void Handle_QueryCIStatus(SpReqAnsContext<CardIssuerService_QueryCIStatus_Req, CardIssuerService_QueryCIStatus_Ans>::Pointer ctx);
  45. virtual void Handle_GetDevInfo(SpReqAnsContext<CardIssuerService_GetDevInfo_Req, CardIssuerService_GetDevInfo_Ans>::Pointer ctx);
  46. private:
  47. CCardIssuerEntity* m_pEntity;
  48. };
  49. class CCardIssuerEntity : public CDevAdptEntityBase,public ISysVarListener
  50. {
  51. public:
  52. CCardIssuerEntity() :bInitialized(false)
  53. {
  54. //MessageBoxA(NULL, "", "", MB_OK);
  55. }
  56. virtual ~CCardIssuerEntity(){}
  57. virtual const char *GetEntityName() const { return "CardIssuer"; }
  58. virtual void OnPreStart(CAutoArray<CSimpleStringA> strArgs,CSmartPointer<ITransactionContext> pTransactionContext)
  59. {
  60. LOG_FUNCTION();
  61. //MessageBoxA(0,0,0,0);
  62. ErrorCodeEnum eStart = m_fsm.Init(this);
  63. if (eStart == Error_Succeed)
  64. {
  65. }
  66. GetFunction()->RegistSysVarEvent("UIState", this);
  67. pTransactionContext->SendAnswer(eStart);
  68. //ErrorCodeEnum Error = __OnStart(Error_Succeed);
  69. //pTransactionContext->SendAnswer(Error);
  70. }
  71. virtual void OnPreClose(EntityCloseCauseEnum eCloseCause,CSmartPointer<ITransactionContext> pTransactionContext)
  72. {
  73. ErrorCodeEnum Error = __OnStart(Error_Succeed);
  74. pTransactionContext->SendAnswer(Error);
  75. }
  76. virtual void OnPrePause(CSmartPointer<ITransactionContext> pTransactionContext)
  77. {
  78. ErrorCodeEnum Error = __OnPause(Error_Succeed,pTransactionContext);
  79. pTransactionContext->SendAnswer(Error);
  80. }
  81. virtual ErrorCodeEnum __OnStart(ErrorCodeEnum preOperationError)
  82. {
  83. return Error_Succeed;
  84. }
  85. virtual ErrorCodeEnum __OnPause(ErrorCodeEnum preOperationError, CSmartPointer<ITransactionContext> pTransactionContext)
  86. {
  87. return Error_Succeed;
  88. }
  89. virtual ErrorCodeEnum __OnClose(ErrorCodeEnum preOperationError)
  90. {
  91. return Error_Succeed;
  92. }
  93. virtual void OnSelfTest(EntityTestEnum eTestType,CSmartPointer<ITransactionContext> pTransactionContext)
  94. {
  95. m_fsm.SelfTest(eTestType,pTransactionContext);
  96. }
  97. virtual CServerSessionBase* OnNewSession(const char*,const char*)
  98. {
  99. DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("A new connecting request arrived.");
  100. m_bNewSessionInit = true;
  101. return new CardIssuerServerSession(this);
  102. }
  103. void Insert(SpReqAnsContext<CardIssuerService_Insert_Req, CardIssuerService_Insert_Ans>::Pointer ctx)
  104. {
  105. LOG_FUNCTION();
  106. if (!m_fsm.GetDevInitFlag()) {
  107. ctx->Answer(Error_DevNotAvailable);
  108. LogWarn(Severity_Middle, Error_DevNotAvailable, CardIssuer_UserErrorCode_DevOpenFailed_Insert, "Insert but DevOpen failed.");
  109. }
  110. else
  111. {
  112. m_bNewSessionInit = false;
  113. m_fsm.SetExitFlag(false);
  114. CardAcceptEvent* e = new CardAcceptEvent();
  115. e->ctx = ctx;
  116. m_fsm.PostEventFIFO(e);
  117. }
  118. }
  119. void Read(SpReqAnsContext<CardIssuerService_Read_Req, CardIssuerService_Read_Ans>::Pointer ctx)
  120. {
  121. LOG_FUNCTION();
  122. CardReadEvent* e = new CardReadEvent();
  123. e->ctx = ctx;
  124. m_fsm.PostEventFIFO(e);
  125. }
  126. void Capture(SpReqAnsContext<CardIssuerService_Capture_Req, CardIssuerService_Capture_Ans>::Pointer ctx)
  127. {
  128. LOG_FUNCTION();
  129. CardCaptureEvent* e = new CardCaptureEvent();
  130. e->ctx = ctx;
  131. m_fsm.PostEventFIFO(e);
  132. }
  133. void Eject(SpReqAnsContext<CardIssuerService_Eject_Req, CardIssuerService_Eject_Ans>::Pointer ctx)
  134. {
  135. LOG_FUNCTION();
  136. CardEjectEvent* e = new CardEjectEvent();
  137. e->ctx = ctx;
  138. m_fsm.PostEventFIFO(e);
  139. }
  140. void CancelInsert(SpOnewayCallContext<CardIssuerService_CancelInsert_Info>::Pointer ctx)
  141. {
  142. LOG_FUNCTION();
  143. CancelAcceptEvent *e = new CancelAcceptEvent();
  144. m_fsm.PostEventFIFO(e);
  145. }
  146. void InsertWaitMore(SpOnewayCallContext<CardIssuerService_InsertWaitMore_Info>::Pointer ctx)
  147. {
  148. LOG_FUNCTION();
  149. if (m_fsm.GetWaitFlag())
  150. m_fsm.SetWaitMore();
  151. }
  152. void Issue(SpReqAnsContext<CardIssuerService_Issue_Req, CardIssuerService_Issue_Ans>::Pointer ctx)
  153. {
  154. LOG_FUNCTION();
  155. m_bNewSessionInit = false;
  156. CardIssueEvent *pEvt = new CardIssueEvent();
  157. pEvt->ctx = ctx;
  158. m_fsm.PostEventFIFO(pEvt);
  159. }
  160. void PreOnline(SpReqAnsContext<CardIssuerService_PreOnline_Req, CardIssuerService_PreOnline_Ans>::Pointer ctx)
  161. {
  162. LOG_FUNCTION();
  163. if (!m_fsm.GetDevInitFlag()) {
  164. ctx->Answer(Error_DevNotAvailable);
  165. }
  166. else {
  167. if (ctx->Req.reserved1.GetLength() > 0 && strnicmp("kaku#", (const char*)ctx->Req.reserved1, 5) == 0)
  168. {
  169. int state = m_fsm.GetFSMState();
  170. if (state == 9)
  171. {
  172. ctx->Answer(Error_BridgeNotOK);
  173. return;
  174. }
  175. else if (state != 2)
  176. {
  177. ctx->Answer(Error_InvalidState);
  178. return;
  179. }
  180. }
  181. PreOnlineEvent* e = new PreOnlineEvent();
  182. e->ctx = ctx;
  183. m_fsm.PostEventFIFO(e);
  184. }
  185. }
  186. void PostOnline(SpReqAnsContext<CardIssuerService_PostOnline_Req, CardIssuerService_PostOnline_Ans>::Pointer ctx)
  187. {
  188. LOG_FUNCTION();
  189. PostOnlineEvent* e = new PostOnlineEvent();
  190. e->ctx = ctx;
  191. m_fsm.PostEventFIFO(e);
  192. }
  193. void Exit(SpOnewayCallContext<CardIssuerService_Exit_Info>::Pointer ctx)
  194. {
  195. LOG_FUNCTION();
  196. m_bNewSessionInit = false;
  197. FSMEvent *evt = new FSMEvent(USER_EVT_EXIT);
  198. m_fsm.PostEventFIFO(evt);
  199. }
  200. void GetMaterialCount(SpReqAnsContext<CardIssuerService_GetMaterialCount_Req, CardIssuerService_GetMaterialCount_Ans>::Pointer ctx)
  201. {
  202. m_bNewSessionInit = false;
  203. GetMaterialEvent *pEvt = new GetMaterialEvent();
  204. pEvt->ctx = ctx;
  205. m_fsm.PostEventFIFO(pEvt);
  206. }
  207. void SetMaterialCount(SpReqAnsContext<CardIssuerService_SetMaterialCount_Req, CardIssuerService_SetMaterialCount_Ans>::Pointer ctx)
  208. {
  209. m_bNewSessionInit = false;
  210. SetMaterialEvent *pEvt = new SetMaterialEvent();
  211. pEvt->ctx = ctx;
  212. m_fsm.PostEventFIFO(pEvt);
  213. }
  214. void QueryCardInfo(SpReqAnsContext<CardIssuerService_QueryCardInfo_Req, CardIssuerService_QueryCardInfo_Ans>::Pointer ctx)
  215. {
  216. if (m_bNewSessionInit)
  217. {
  218. FSMEvent *pEvt = new FSMEvent(USER_EVT_EXIT);
  219. m_fsm.PostEventFIFO(pEvt);
  220. ctx->Ans.position = CI_MEDIA_NOTPRESENT;
  221. ctx->Answer(Error_Succeed);
  222. }
  223. else
  224. {
  225. ctx->Ans.position = m_fsm.QueryCardInfo();
  226. ctx->Answer(Error_Succeed);
  227. }
  228. }
  229. void WriteTrack(SpReqAnsContext<CardIssuerService_WriteTrack_Req, CardIssuerService_WriteTrack_Ans>::Pointer ctx)
  230. {
  231. CardWriteEvent *pEvt = new CardWriteEvent();
  232. pEvt->ctx = ctx;
  233. m_fsm.PostEventFIFO(pEvt);
  234. }
  235. void SetIssueFlag(SpOnewayCallContext<CardIssuerService_SetIssueFlag_Info>::Pointer ctx){ m_fsm.FrontSetIssueFlag(true); }
  236. void GetMaterialCountEx(SpReqAnsContext<CardIssuerService_GetMaterialCountEx_Req, CardIssuerService_GetMaterialCountEx_Ans>::Pointer ctx)
  237. {
  238. m_bNewSessionInit = false;
  239. GetMaterialExEvent *pEvt = new GetMaterialExEvent();
  240. pEvt->ctx = ctx;
  241. m_fsm.PostEventFIFO(pEvt);
  242. }
  243. void SetMaterialCountEx(SpReqAnsContext<CardIssuerService_SetMaterialCountEx_Req, CardIssuerService_SetMaterialCountEx_Ans>::Pointer ctx)
  244. {
  245. m_bNewSessionInit = false;
  246. SetMaterialExEvent *pEvt = new SetMaterialExEvent();
  247. pEvt->ctx = ctx;
  248. m_fsm.PostEventFIFO(pEvt);
  249. }
  250. void SetSomeFlag(SpReqAnsContext<CardIssuerService_SetSomeFlag_Req, CardIssuerService_SetSomeFlag_Ans>::Pointer ctx)
  251. {
  252. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("set issue flag to %d", ctx->Req.IssueBusiness);
  253. if (ctx->Req.IssueBusiness == 1)
  254. m_fsm.FrontSetIssueFlag(true);
  255. else if (ctx->Req.IssueBusiness == 0)
  256. m_fsm.FrontSetIssueFlag(false);
  257. else if (ctx->Req.IssueBusiness == 2)//oilyang@20170621 query issue direction
  258. {
  259. ctx->Ans.reserved1.Init(1);
  260. ctx->Ans.reserved1[0] = (m_fsm.QueryIssueFlag() ? 0 : 1);//according to yzx
  261. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("issue direction:%d",ctx->Ans.reserved1[0]);//if 0 capture card eles eject card
  262. }
  263. else if (ctx->Req.IssueBusiness == 3)//oilyang@20181210
  264. {
  265. m_fsm.SetCancelByRFICFlag();
  266. }
  267. else if (ctx->Req.IssueBusiness == 4)//oilyang@20181220 get ic card account,for simple/lazy...
  268. {
  269. ctx->Ans.reserved2.Init(1);
  270. ctx->Ans.reserved2[0] = m_fsm.GetPreOnlineICCardNo();
  271. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("GetPreOnlineICCardNo:%d", ctx->Ans.reserved2[0].GetLength());
  272. }
  273. if (ctx->Req.reserved1.GetCount() > 0)
  274. {
  275. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("set hopper num:%d",ctx->Req.reserved1[0]);
  276. if (ctx->Req.reserved1[0] == 1)
  277. m_fsm.SetHopperNum(1);
  278. else if (ctx->Req.reserved1[0] == 3)
  279. m_fsm.SetHopperNum(3);
  280. }
  281. ctx->Answer(Error_Succeed);
  282. }
  283. void GetSCIInfo(SpReqAnsContext<CardIssuerService_GetSCIInfo_Req, CardIssuerService_GetSCIInfo_Ans>::Pointer ctx)
  284. {
  285. char *pDevSN = NULL;
  286. pDevSN = new char[32];
  287. ZeroMemory(pDevSN, 32);
  288. int ret = m_fsm.GetSCIInfo(pDevSN);
  289. if (ret < 0)
  290. {
  291. DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("wrong devsn ,ret %d",ret);
  292. ctx->Answer(Error_Unexpect);
  293. if (pDevSN != NULL)
  294. delete[]pDevSN;
  295. return;
  296. }
  297. ctx->Ans.connected = 1;
  298. ctx->Ans.DevSN = pDevSN;
  299. ctx->Answer(Error_Succeed);
  300. if (pDevSN != NULL)
  301. delete[]pDevSN;
  302. }
  303. void IssueEx(SpReqAnsContext<CardIssuerService_IssueEx_Req, CardIssuerService_IssueEx_Ans>::Pointer ctx)
  304. {
  305. LOG_FUNCTION();
  306. if (!m_fsm.GetDevInitFlag()) {
  307. ctx->Answer(Error_DevNotAvailable);
  308. }
  309. else {
  310. m_bNewSessionInit = false;
  311. CardIssueExEvent* pEvt = new CardIssueExEvent();
  312. pEvt->ctx = ctx;
  313. m_fsm.PostEventFIFO(pEvt);
  314. }
  315. }
  316. void OpenSafeLock(SpReqAnsContext<CardIssuerService_OpenSafeLock_Req, CardIssuerService_OpenSafeLock_Ans>::Pointer ctx)
  317. {
  318. OpenSafeLockEvent *pEvt = new OpenSafeLockEvent();
  319. pEvt->ctx = ctx;
  320. m_fsm.PostEventFIFO(pEvt);
  321. }
  322. void SAMICCommand(SpReqAnsContext<CardIssuerService_SAMICCommand_Req, CardIssuerService_SAMICCommand_Ans>::Pointer ctx)
  323. {
  324. LOG_FUNCTION();
  325. SAMICCommandEvent *pEvt = new SAMICCommandEvent();
  326. pEvt->ctx = ctx;
  327. m_fsm.PostEventFIFO(pEvt);
  328. }
  329. void QueryPrinterStatus(SpReqAnsContext<CardIssuerService_QueryPrinterStatus_Req, CardIssuerService_QueryPrinterStatus_Ans>::Pointer ctx)
  330. {
  331. ctx->Answer(Error_NotImpl);
  332. }
  333. void Print(SpReqAnsContext<CardIssuerService_Print_Req, CardIssuerService_Print_Ans>::Pointer ctx)
  334. {
  335. LOG_FUNCTION();
  336. PrintEvent *pEvt = new PrintEvent();
  337. pEvt->ctx = ctx;
  338. m_fsm.PostEventFIFO(pEvt);
  339. }
  340. void QuerySCIList(SpReqAnsContext<CardIssuerService_QuerySCIList_Req, CardIssuerService_QuerySCIList_Ans>::Pointer ctx)
  341. {
  342. QuerySCIListEvent *pEvt = new QuerySCIListEvent();
  343. pEvt->ctx = ctx;
  344. m_fsm.PostEventFIFO(pEvt);
  345. }
  346. void BindSCI(SpReqAnsContext<CardIssuerService_BindSCI_Req, CardIssuerService_BindSCI_Ans>::Pointer ctx)
  347. {
  348. BindSCIEvent *pEvt = new BindSCIEvent();
  349. pEvt->ctx = ctx;
  350. m_fsm.PostEventFIFO(pEvt);
  351. }
  352. void PreOnlineOnStore(SpReqAnsContext<CardIssuerService_PreOnlineOnStore_Req, CardIssuerService_PreOnlineOnStore_Ans>::Pointer ctx)
  353. {
  354. PreOnlineOnStoreEvent *pEvt = new PreOnlineOnStoreEvent();
  355. pEvt->ctx = ctx;
  356. m_fsm.PostEventFIFO(pEvt);
  357. }
  358. void NotifyPreonline(SpReqAnsContext<CardIssuerService_NotifyPreonline_Req, CardIssuerService_NotifyPreonline_Ans>::Pointer ctx)
  359. {
  360. m_fsm.NotifyPreOnline(ctx->Req.errCode,ctx->Req.findCard,ctx->Req.cardPos,ctx->Req.data);
  361. ctx->Answer(Error_Succeed);
  362. }
  363. void QueryCardInfoOnStore(SpReqAnsContext<CardIssuerService_QueryCardInfoOnStore_Req, CardIssuerService_QueryCardInfoOnStore_Ans>::Pointer ctx)
  364. {
  365. if (!m_fsm.GetDevInitFlag()) {
  366. ctx->Answer(Error_DevNotAvailable);
  367. }
  368. else
  369. {
  370. QueryCardInfoOnStoreEvent* pEvt = new QueryCardInfoOnStoreEvent();
  371. pEvt->ctx = ctx;
  372. m_fsm.PostEventFIFO(pEvt);
  373. }
  374. }
  375. void GetAddCardInfo(SpReqAnsContext<CardIssuerService_GetAddCardInfo_Req, CardIssuerService_GetAddCardInfo_Ans>::Pointer ctx)
  376. {
  377. m_fsm.GetAddCardInfo(ctx);
  378. }
  379. void PrintCardImmediately(SpReqAnsContext<CardIssuerService_PrintCardImmediately_Req, CardIssuerService_PrintCardImmediately_Ans>::Pointer ctx)
  380. {
  381. LOG_FUNCTION();
  382. PrintCardImEvent* pEvt = new PrintCardImEvent();
  383. pEvt->ctx = ctx;
  384. m_fsm.PostEventFIFO(pEvt);
  385. }
  386. void GetDevInfo(SpReqAnsContext<CardIssuerService_GetDevInfo_Req, CardIssuerService_GetDevInfo_Ans>::Pointer ctx)
  387. {
  388. ctx->Ans.state = m_fsm.GetDevState();
  389. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("GetDevInfo %d",ctx->Ans.state);
  390. ctx->Answer(Error_Succeed);
  391. }
  392. void GetSCINo(CSimpleStringA &sciNo)
  393. {
  394. m_fsm.GetSCINo(sciNo);
  395. }
  396. void QueryCIStatus(SpReqAnsContext<CardIssuerService_QueryCIStatus_Req, CardIssuerService_QueryCIStatus_Ans>::Pointer ctx)
  397. {
  398. m_fsm.QueryCIStatus(ctx);
  399. }
  400. virtual void OnSysVarEvent(const char* pszKey, const char* pszValue, const char* pszOldValue, const char* pszEntityName);
  401. virtual bool IsService()const{return true;}
  402. virtual bool IsMultiThread()const{return true;}
  403. protected:
  404. private:
  405. CardIssuerClass* m_pCardIss;
  406. CCardIssuerFSM m_fsm;
  407. bool bInitialized,m_bNewSessionInit;
  408. //LONG m_lenAPDU;
  409. //BYTE m_APDUsendBuf[512];
  410. private:
  411. // void ConstructAPDU(BYTE cls,BYTE ins,BYTE p1,BYTE p2,BYTE lc,LPBYTE data,LPBYTE le)
  412. //{
  413. // LOG_FUNCTION();
  414. // m_lenAPDU = 0;
  415. // m_APDUsendBuf[0] = cls;
  416. // m_APDUsendBuf[1] = ins;
  417. // m_APDUsendBuf[2] = p1;
  418. // m_APDUsendBuf[3] = p2;
  419. // m_lenAPDU = 4;
  420. // if (lc != NULL && data != NULL)
  421. // {
  422. // m_APDUsendBuf[4] = lc;
  423. // m_lenAPDU++;
  424. // if (lc != 0)
  425. // {
  426. // memcpy(m_APDUsendBuf+m_lenAPDU,data,lc);
  427. // m_lenAPDU += lc;
  428. // }
  429. // }
  430. // if (le != NULL)
  431. // m_APDUsendBuf[m_lenAPDU++] = (*le);
  432. // if (!data)
  433. // {
  434. // delete[] data;
  435. // data = NULL;
  436. // }
  437. // Dbg("cmd len[%d]",m_lenAPDU);
  438. //}
  439. };