mod_cardissuer.h 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412
  1. #include "CardIssuerStore_server_g.h"
  2. #include "CardIssuerStore_def_g.h"
  3. #include "CardIssuerFSM.h"
  4. #include "DevEntityCommBase.hpp"
  5. using namespace CardIssuerStore;
  6. class CCardIssuerEntity;
  7. class CardIssuerStoreServerSession : public CardIssuerStoreService_ServerSessionBase
  8. {
  9. public:
  10. CardIssuerStoreServerSession(CCardIssuerEntity* pEntity):m_pEntity(pEntity){}
  11. virtual ~CardIssuerStoreServerSession(){}
  12. virtual void Handle_Read(SpReqAnsContext<CardIssuerStoreService_Read_Req, CardIssuerStoreService_Read_Ans>::Pointer ctx);
  13. virtual void Handle_Capture(SpReqAnsContext<CardIssuerStoreService_Capture_Req, CardIssuerStoreService_Capture_Ans>::Pointer ctx);
  14. virtual void Handle_Eject(SpReqAnsContext<CardIssuerStoreService_Eject_Req, CardIssuerStoreService_Eject_Ans>::Pointer ctx);
  15. virtual void Handle_PreOnline(SpReqAnsContext<CardIssuerStoreService_PreOnline_Req, CardIssuerStoreService_PreOnline_Ans>::Pointer ctx);
  16. virtual void Handle_PostOnline(SpReqAnsContext<CardIssuerStoreService_PostOnline_Req, CardIssuerStoreService_PostOnline_Ans>::Pointer ctx);
  17. virtual void Handle_Exit(SpOnewayCallContext<CardIssuerStoreService_Exit_Info>::Pointer ctx);
  18. virtual void Handle_SetIssueFlag(SpOnewayCallContext<CardIssuerStoreService_SetIssueFlag_Info>::Pointer ctx);
  19. virtual void Handle_QueryCardInfo(SpReqAnsContext<CardIssuerStoreService_QueryCardInfo_Req, CardIssuerStoreService_QueryCardInfo_Ans>::Pointer ctx);
  20. virtual void Handle_WriteTrack(SpReqAnsContext<CardIssuerStoreService_WriteTrack_Req, CardIssuerStoreService_WriteTrack_Ans>::Pointer ctx);
  21. virtual void Handle_GetMaterialCountEx(SpReqAnsContext<CardIssuerStoreService_GetMaterialCountEx_Req, CardIssuerStoreService_GetMaterialCountEx_Ans>::Pointer ctx);
  22. virtual void Handle_SetMaterialCountEx(SpReqAnsContext<CardIssuerStoreService_SetMaterialCountEx_Req, CardIssuerStoreService_SetMaterialCountEx_Ans>::Pointer ctx);
  23. virtual void Handle_SetSomeFlag(SpReqAnsContext<CardIssuerStoreService_SetSomeFlag_Req, CardIssuerStoreService_SetSomeFlag_Ans>::Pointer ctx);
  24. virtual void Handle_IssueEx(SpReqAnsContext<CardIssuerStoreService_IssueEx_Req, CardIssuerStoreService_IssueEx_Ans>::Pointer ctx);
  25. virtual void Handle_SAMICCommand(SpReqAnsContext<CardIssuerStoreService_SAMICCommand_Req, CardIssuerStoreService_SAMICCommand_Ans>::Pointer ctx);
  26. virtual void Handle_QueryCardInfoOnStore(SpReqAnsContext<CardIssuerStoreService_QueryCardInfoOnStore_Req, CardIssuerStoreService_QueryCardInfoOnStore_Ans>::Pointer ctx);
  27. virtual void Handle_GetAddCardInfo(SpReqAnsContext<CardIssuerStoreService_GetAddCardInfo_Req, CardIssuerStoreService_GetAddCardInfo_Ans>::Pointer ctx);
  28. virtual void Handle_PrintCardImmediately(SpReqAnsContext<CardIssuerStoreService_PrintCardImmediately_Req, CardIssuerStoreService_PrintCardImmediately_Ans>::Pointer ctx);
  29. virtual void Handle_QueryCIStatus(SpReqAnsContext<CardIssuerStoreService_QueryCIStatus_Req, CardIssuerStoreService_QueryCIStatus_Ans>::Pointer ctx);
  30. virtual void Handle_GetDevInfo(SpReqAnsContext<CardIssuerStoreService_GetDevInfo_Req, CardIssuerStoreService_GetDevInfo_Ans>::Pointer ctx);
  31. //JS接口定义
  32. // virtual void Handle_ReadJS(SpReqAnsContext<CardIssuerStoreService_ReadJS_Req, CardIssuerStoreService_ReadJS_Ans>::Pointer ctx);
  33. // virtual void Handle_PostOnlineJS(SpReqAnsContext<CardIssuerStoreService_PostOnlineJS_Req, CardIssuerStoreService_PostOnlineJS_Ans>::Pointer ctx);
  34. // virtual void Handle_EjectJS(SpReqAnsContext<CardIssuerStoreService_EjectJS_Req, CardIssuerStoreService_EjectJS_Ans>::Pointer ctx);
  35. virtual void Handle_CaptureJS(SpReqAnsContext<CardIssuerStoreService_CaptureJS_Req, CardIssuerStoreService_CaptureJS_Ans>::Pointer ctx);
  36. // virtual void Handle_QueryInternalHasCardJS(SpReqAnsContext<CardIssuerStoreService_QueryInternalHasCardJS_Req, CardIssuerStoreService_QueryInternalHasCardJS_Ans>::Pointer ctx);
  37. // virtual void Handle_IssueFromBoxJS(SpReqAnsContext<CardIssuerStoreService_IssueFromBoxJS_Req, CardIssuerStoreService_IssueFromBoxJS_Ans>::Pointer ctx);
  38. // virtual void Handle_IssueFromSlotJS(SpReqAnsContext<CardIssuerStoreService_IssueFromSlotJS_Req, CardIssuerStoreService_IssueFromSlotJS_Ans>::Pointer ctx);
  39. // virtual void Handle_SAMICCommandJS(SpReqAnsContext<CardIssuerStoreService_SAMICCommandJS_Req, CardIssuerStoreService_SAMICCommandJS_Ans>::Pointer ctx);
  40. // virtual void Handle_WriteTrackJS(SpReqAnsContext<CardIssuerStoreService_WriteTrackJS_Req, CardIssuerStoreService_WriteTrackJS_Ans>::Pointer ctx);
  41. // virtual void Handle_PrintCardImmediatelyJS(SpReqAnsContext<CardIssuerStoreService_PrintCardImmediatelyJS_Req, CardIssuerStoreService_PrintCardImmediatelyJS_Ans>::Pointer ctx);
  42. // virtual void Handle_PreOnlineCrossJS(SpReqAnsContext<CardIssuerStoreService_PreOnlineCrossJS_Req, CardIssuerStoreService_PreOnlineCrossJS_Ans>::Pointer ctx);
  43. virtual void Handle_ReadBatchCardInfoInRangeJS(SpReqAnsContext<CardIssuerStoreService_ReadBatchCardInfoInRangeJS_Req, CardIssuerStoreService_ReadBatchCardInfoInRangeJS_Ans>::Pointer ctx);
  44. virtual void Handle_GetCardInStoreJS(SpReqAnsContext<CardIssuerStoreService_GetCardInStoreJS_Req, CardIssuerStoreService_GetCardInStoreJS_Ans>::Pointer ctx);
  45. virtual void Handle_AddAndReadCardFromBoxJS(SpReqAnsContext<CardIssuerStoreService_AddAndReadCardFromBoxJS_Req, CardIssuerStoreService_AddAndReadCardFromBoxJS_Ans>::Pointer ctx);
  46. virtual void Handle_MoveAndReadCardFromSlotJS(SpReqAnsContext<CardIssuerStoreService_MoveAndReadCardFromSlotJS_Req, CardIssuerStoreService_MoveAndReadCardFromSlotJS_Ans>::Pointer ctx);
  47. virtual void Handle_MoveBacktoSlotJS(SpReqAnsContext<CardIssuerStoreService_MoveBacktoSlotJS_Req, CardIssuerStoreService_MoveBacktoSlotJS_Ans>::Pointer ctx);
  48. private:
  49. CCardIssuerEntity* m_pEntity;
  50. };
  51. class CCardIssuerEntity : public CDevAdptEntityBase, public ISysVarListener
  52. {
  53. public:
  54. CCardIssuerEntity() :bInitialized(false)
  55. {
  56. }
  57. virtual ~CCardIssuerEntity(){}
  58. virtual const char *GetEntityName() const { return "CardIssuerStore"; }
  59. virtual void OnPreStart(CAutoArray<CSimpleStringA> strArgs,CSmartPointer<ITransactionContext> pTransactionContext)
  60. {
  61. LOG_FUNCTION();
  62. ErrorCodeEnum eStart = m_fsm.Init(this);
  63. if (eStart == Error_Succeed)
  64. {
  65. }
  66. GetFunction()->RegistSysVarEvent("UIState", this);
  67. pTransactionContext->SendAnswer(eStart);
  68. }
  69. virtual void OnPreClose(EntityCloseCauseEnum eCloseCause,CSmartPointer<ITransactionContext> pTransactionContext)
  70. {
  71. ErrorCodeEnum Error = __OnStart(Error_Succeed);
  72. pTransactionContext->SendAnswer(Error);
  73. }
  74. virtual void OnPrePause(CSmartPointer<ITransactionContext> pTransactionContext)
  75. {
  76. ErrorCodeEnum Error = __OnPause(Error_Succeed,pTransactionContext);
  77. pTransactionContext->SendAnswer(Error);
  78. }
  79. virtual ErrorCodeEnum __OnStart(ErrorCodeEnum preOperationError)
  80. {
  81. return Error_Succeed;
  82. }
  83. virtual ErrorCodeEnum __OnPause(ErrorCodeEnum preOperationError, CSmartPointer<ITransactionContext> pTransactionContext)
  84. {
  85. return Error_Succeed;
  86. }
  87. virtual ErrorCodeEnum __OnClose(ErrorCodeEnum preOperationError)
  88. {
  89. return Error_Succeed;
  90. }
  91. virtual void OnSelfTest(EntityTestEnum eTestType,CSmartPointer<ITransactionContext> pTransactionContext)
  92. {
  93. m_fsm.SelfTest(eTestType,pTransactionContext);
  94. }
  95. virtual CServerSessionBase* OnNewSession(const char*,const char*)
  96. {
  97. DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("A new connecting request arrived.");
  98. m_bNewSessionInit = true;
  99. return new CardIssuerStoreServerSession(this);
  100. }
  101. void Read(SpReqAnsContext<CardIssuerStoreService_Read_Req, CardIssuerStoreService_Read_Ans>::Pointer ctx)
  102. {
  103. LOG_FUNCTION();
  104. CardReadEvent* e = new CardReadEvent();
  105. e->ctx = ctx;
  106. m_fsm.PostEventFIFO(e);
  107. }
  108. void Capture(SpReqAnsContext<CardIssuerStoreService_Capture_Req, CardIssuerStoreService_Capture_Ans>::Pointer ctx)
  109. {
  110. LOG_FUNCTION();
  111. CardCaptureEvent* e = new CardCaptureEvent();
  112. e->ctx = ctx;
  113. m_fsm.PostEventFIFO(e);
  114. }
  115. void Eject(SpReqAnsContext<CardIssuerStoreService_Eject_Req, CardIssuerStoreService_Eject_Ans>::Pointer ctx)
  116. {
  117. LOG_FUNCTION();
  118. CardEjectEvent* e = new CardEjectEvent();
  119. e->ctx = ctx;
  120. m_fsm.PostEventFIFO(e);
  121. }
  122. void PreOnline(SpReqAnsContext<CardIssuerStoreService_PreOnline_Req, CardIssuerStoreService_PreOnline_Ans>::Pointer ctx)
  123. {
  124. LOG_FUNCTION();
  125. if (!m_fsm.GetDevInitFlag()) {
  126. ctx->Answer(Error_DevNotAvailable, CardIssuerStore_UserErrorCode_DevOpen_Failed);
  127. }
  128. else {
  129. if (ctx->Req.reserved1.GetLength() > 0 && strnicmp("kaku#", (const char*)ctx->Req.reserved1, 5) == 0)
  130. {
  131. int state = m_fsm.GetFSMState();
  132. if (state == 9)
  133. {
  134. ctx->Answer(Error_DevNotAvailable, CardIssuerStore_UserErrorCode_EntityInFailState);
  135. return;
  136. }
  137. else if (state != 2 || m_fsm.CheckIsCrossPreOnline())//借用跨机标识来识别是否跨机中
  138. {
  139. ctx->Answer(Error_InvalidState, CardIssuerStore_UserErrorCode_CardActive_CardStore_Issuing);
  140. return;
  141. }
  142. }
  143. PreOnlineEvent* e = new PreOnlineEvent();
  144. e->ctx = ctx;
  145. m_fsm.PostEventFIFO(e);
  146. }
  147. }
  148. void PostOnline(SpReqAnsContext<CardIssuerStoreService_PostOnline_Req, CardIssuerStoreService_PostOnline_Ans>::Pointer ctx)
  149. {
  150. LOG_FUNCTION();
  151. PostOnlineEvent* e = new PostOnlineEvent();
  152. e->ctx = ctx;
  153. m_fsm.PostEventFIFO(e);
  154. }
  155. void Exit(SpOnewayCallContext<CardIssuerStoreService_Exit_Info>::Pointer ctx)
  156. {
  157. LOG_FUNCTION();
  158. m_bNewSessionInit = false;
  159. FSMEvent *evt = new FSMEvent(USER_EVT_EXIT);
  160. m_fsm.PostEventFIFO(evt);
  161. }
  162. void QueryCardInfo(SpReqAnsContext<CardIssuerStoreService_QueryCardInfo_Req, CardIssuerStoreService_QueryCardInfo_Ans>::Pointer ctx)
  163. {
  164. if (m_bNewSessionInit)
  165. {
  166. FSMEvent *pEvt = new FSMEvent(USER_EVT_EXIT);
  167. m_fsm.PostEventFIFO(pEvt);
  168. ctx->Ans.position = CI_MEDIA_NOTPRESENT;
  169. ctx->Answer(Error_Succeed);
  170. }
  171. else
  172. {
  173. ctx->Ans.position = m_fsm.QueryCardInfo();
  174. ctx->Answer(Error_Succeed);
  175. }
  176. }
  177. void WriteTrack(SpReqAnsContext<CardIssuerStoreService_WriteTrack_Req, CardIssuerStoreService_WriteTrack_Ans>::Pointer ctx)
  178. {
  179. CardWriteEvent *pEvt = new CardWriteEvent();
  180. pEvt->ctx = ctx;
  181. m_fsm.PostEventFIFO(pEvt);
  182. }
  183. void SetIssueFlag(SpOnewayCallContext<CardIssuerStoreService_SetIssueFlag_Info>::Pointer ctx){ m_fsm.FrontSetIssueFlag(true); }
  184. void GetMaterialCountEx(SpReqAnsContext<CardIssuerStoreService_GetMaterialCountEx_Req, CardIssuerStoreService_GetMaterialCountEx_Ans>::Pointer ctx)
  185. {
  186. m_bNewSessionInit = false;
  187. GetMaterialExEvent *pEvt = new GetMaterialExEvent();
  188. pEvt->ctx = ctx;
  189. m_fsm.PostEventFIFO(pEvt);
  190. }
  191. void SetMaterialCountEx(SpReqAnsContext<CardIssuerStoreService_SetMaterialCountEx_Req, CardIssuerStoreService_SetMaterialCountEx_Ans>::Pointer ctx)
  192. {
  193. m_bNewSessionInit = false;
  194. SetMaterialExEvent *pEvt = new SetMaterialExEvent();
  195. pEvt->ctx = ctx;
  196. m_fsm.PostEventFIFO(pEvt);
  197. }
  198. void SetSomeFlag(SpReqAnsContext<CardIssuerStoreService_SetSomeFlag_Req, CardIssuerStoreService_SetSomeFlag_Ans>::Pointer ctx)
  199. {
  200. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("set issue flag to %d", ctx->Req.IssueBusiness);
  201. if (ctx->Req.IssueBusiness == 1)
  202. m_fsm.FrontSetIssueFlag(true);
  203. else if (ctx->Req.IssueBusiness == 0)
  204. m_fsm.FrontSetIssueFlag(false);
  205. else if (ctx->Req.IssueBusiness == 2)//oilyang@20170621 query issue direction
  206. {
  207. ctx->Ans.reserved1.Init(1);
  208. ctx->Ans.reserved1[0] = (m_fsm.QueryIssueFlag() ? 0 : 1);//according to yzx
  209. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("issue direction:%d",ctx->Ans.reserved1[0]);//if 0 capture card eles eject card
  210. }
  211. else if (ctx->Req.IssueBusiness == 3)//oilyang@20181210
  212. {
  213. m_fsm.SetCancelByRFICFlag();
  214. }
  215. else if (ctx->Req.IssueBusiness == 4)//oilyang@20181220 get ic card account,for simple/lazy...
  216. {
  217. ctx->Ans.reserved2.Init(1);
  218. ctx->Ans.reserved2[0] = m_fsm.GetPreOnlineICCardNo();
  219. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("GetPreOnlineICCardNo:%d", ctx->Ans.reserved2[0].GetLength());
  220. }
  221. if (ctx->Req.reserved1.GetCount() > 0)
  222. {
  223. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("set hopper num:%d",ctx->Req.reserved1[0]);
  224. if (ctx->Req.reserved1[0] == 1)
  225. m_fsm.SetHopperNum(1);
  226. else if (ctx->Req.reserved1[0] == 3)
  227. m_fsm.SetHopperNum(3);
  228. }
  229. ctx->Answer(Error_Succeed);
  230. }
  231. void IssueEx(SpReqAnsContext<CardIssuerStoreService_IssueEx_Req, CardIssuerStoreService_IssueEx_Ans>::Pointer ctx)
  232. {
  233. LOG_FUNCTION();
  234. if (!m_fsm.GetDevInitFlag()) {
  235. ctx->Answer(Error_DevNotAvailable, CardIssuerStore_UserErrorCode_DevOpen_Failed);
  236. }
  237. else {
  238. m_bNewSessionInit = false;
  239. CardIssueExEvent* pEvt = new CardIssueExEvent();
  240. pEvt->ctx = ctx;
  241. m_fsm.PostEventFIFO(pEvt);
  242. }
  243. }
  244. void SAMICCommand(SpReqAnsContext<CardIssuerStoreService_SAMICCommand_Req, CardIssuerStoreService_SAMICCommand_Ans>::Pointer ctx)
  245. {
  246. LOG_FUNCTION();
  247. SAMICCommandEvent *pEvt = new SAMICCommandEvent();
  248. pEvt->ctx = ctx;
  249. m_fsm.PostEventFIFO(pEvt);
  250. }
  251. void QueryCardInfoOnStore(SpReqAnsContext<CardIssuerStoreService_QueryCardInfoOnStore_Req, CardIssuerStoreService_QueryCardInfoOnStore_Ans>::Pointer ctx)
  252. {
  253. if (!m_fsm.GetDevInitFlag()) {
  254. ctx->Answer(Error_DevNotAvailable, CardIssuerStore_UserErrorCode_DevOpen_Failed);
  255. }
  256. else
  257. {
  258. QueryCardInfoOnStoreEvent* pEvt = new QueryCardInfoOnStoreEvent();
  259. pEvt->ctx = ctx;
  260. m_fsm.PostEventFIFO(pEvt);
  261. }
  262. }
  263. void GetAddCardInfo(SpReqAnsContext<CardIssuerStoreService_GetAddCardInfo_Req, CardIssuerStoreService_GetAddCardInfo_Ans>::Pointer ctx)
  264. {
  265. if (!m_fsm.GetDevInitFlag()) {
  266. ctx->Answer(Error_DevNotAvailable, CardIssuerStore_UserErrorCode_DevOpen_Failed);
  267. }
  268. else
  269. {
  270. m_fsm.GetAddCardInfo(ctx);
  271. }
  272. }
  273. void PrintCardImmediately(SpReqAnsContext<CardIssuerStoreService_PrintCardImmediately_Req, CardIssuerStoreService_PrintCardImmediately_Ans>::Pointer ctx)
  274. {
  275. LOG_FUNCTION();
  276. PrintCardImEvent* pEvt = new PrintCardImEvent();
  277. pEvt->ctx = ctx;
  278. m_fsm.PostEventFIFO(pEvt);
  279. }
  280. void GetDevInfo(SpReqAnsContext<CardIssuerStoreService_GetDevInfo_Req, CardIssuerStoreService_GetDevInfo_Ans>::Pointer ctx)
  281. {
  282. ctx->Ans.state = m_fsm.GetDevState();
  283. //设备未正常打开时,直接报state=0;
  284. if (!m_fsm.GetDevInitFlag()) {
  285. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("GetDevInfo device is not open,state return 0");
  286. ctx->Ans.state = DEVICE_STATUS_NOT_READY;
  287. }
  288. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("GetDevInfo state=%d",ctx->Ans.state);
  289. ctx->Answer(Error_Succeed);
  290. }
  291. void QueryCIStatus(SpReqAnsContext<CardIssuerStoreService_QueryCIStatus_Req, CardIssuerStoreService_QueryCIStatus_Ans>::Pointer ctx)
  292. {
  293. m_fsm.QueryCIStatus(ctx);
  294. }
  295. //实体具体接口实现
  296. void CaptureJS(SpReqAnsContext<CardIssuerStoreService_CaptureJS_Req, CardIssuerStoreService_CaptureJS_Ans>::Pointer ctx)
  297. {
  298. LOG_FUNCTION();
  299. if (!m_fsm.GetDevInitFlag()) {
  300. ctx->Answer(Error_DevNotAvailable, CardIssuerStore_UserErrorCode_DevOpen_Failed);
  301. }
  302. else if(_stricmp(m_fsm.GetCurrStateName(), "Hold") != 0){
  303. //不符合请求调用,告知具体错误流程
  304. DWORD errCode = m_fsm.GetFsmStateErrCode();
  305. ctx->Answer(Error_Unexpect, errCode);
  306. }
  307. else {
  308. CaptureJSEvent* e = new CaptureJSEvent();
  309. e->ctx = ctx;
  310. m_fsm.PostEventFIFO(e);
  311. }
  312. }
  313. void ReadBatchCardInfoInRangeJS(SpReqAnsContext<CardIssuerStoreService_ReadBatchCardInfoInRangeJS_Req, CardIssuerStoreService_ReadBatchCardInfoInRangeJS_Ans>::Pointer ctx)
  314. {
  315. LOG_FUNCTION();
  316. if (!m_fsm.GetDevInitFlag()) {
  317. ctx->Answer(Error_DevNotAvailable, CardIssuerStore_UserErrorCode_DevOpen_Failed);
  318. }
  319. else if (_stricmp(m_fsm.GetCurrStateName(), "Idle") != 0) {
  320. //不符合请求调用,告知具体错误流程
  321. DWORD errCode = m_fsm.GetFsmStateErrCode();
  322. ctx->Answer(Error_Unexpect, errCode);
  323. }
  324. else {
  325. ReadBatchCardInfoInRangeJSEvent* pEvt = new ReadBatchCardInfoInRangeJSEvent();
  326. pEvt->ctx = ctx;
  327. m_fsm.PostEventFIFO(pEvt);
  328. }
  329. }
  330. void GetCardInStoreJS(SpReqAnsContext<CardIssuerStoreService_GetCardInStoreJS_Req, CardIssuerStoreService_GetCardInStoreJS_Ans>::Pointer ctx)
  331. {
  332. LOG_FUNCTION();
  333. m_fsm.GetCardInStoreJS(ctx);
  334. }
  335. void AddAndReadCardFromBoxJS(SpReqAnsContext<CardIssuerStoreService_AddAndReadCardFromBoxJS_Req, CardIssuerStoreService_AddAndReadCardFromBoxJS_Ans>::Pointer ctx)
  336. {
  337. LOG_FUNCTION();
  338. if (!m_fsm.GetDevInitFlag()) {
  339. ctx->Answer(Error_DevNotAvailable, CardIssuerStore_UserErrorCode_DevOpen_Failed);
  340. }
  341. else if (_stricmp(m_fsm.GetCurrStateName(), "Idle") != 0) {
  342. //不符合请求调用,告知具体错误流程
  343. DWORD errCode = m_fsm.GetFsmStateErrCode();
  344. ctx->Answer(Error_Unexpect, errCode);
  345. }
  346. else {
  347. AddAndReadCardFromBoxJSEvent* pEvt = new AddAndReadCardFromBoxJSEvent();
  348. pEvt->ctx = ctx;
  349. m_fsm.PostEventFIFO(pEvt);
  350. }
  351. }
  352. void MoveAndReadCardFromSlotJS(SpReqAnsContext<CardIssuerStoreService_MoveAndReadCardFromSlotJS_Req, CardIssuerStoreService_MoveAndReadCardFromSlotJS_Ans>::Pointer ctx)
  353. {
  354. LOG_FUNCTION();
  355. if (!m_fsm.GetDevInitFlag()) {
  356. ctx->Answer(Error_DevNotAvailable, CardIssuerStore_UserErrorCode_DevOpen_Failed);
  357. }
  358. else if (_stricmp(m_fsm.GetCurrStateName(), "Idle") != 0) {
  359. //不符合请求调用,告知具体错误流程
  360. DWORD errCode = m_fsm.GetFsmStateErrCode();
  361. ctx->Answer(Error_Unexpect, errCode);
  362. }
  363. else {
  364. MoveAndReadCardFromSlotJSEvent* pEvt = new MoveAndReadCardFromSlotJSEvent();
  365. pEvt->ctx = ctx;
  366. m_fsm.PostEventFIFO(pEvt);
  367. }
  368. }
  369. void MoveBacktoSlotJS(SpReqAnsContext<CardIssuerStoreService_MoveBacktoSlotJS_Req, CardIssuerStoreService_MoveBacktoSlotJS_Ans>::Pointer ctx)
  370. {
  371. LOG_FUNCTION();
  372. if (!m_fsm.GetDevInitFlag()) {
  373. ctx->Answer(Error_DevNotAvailable, CardIssuerStore_UserErrorCode_DevOpen_Failed);
  374. }
  375. else if (_stricmp(m_fsm.GetCurrStateName(), "Hold") != 0) {
  376. //不符合请求调用,告知具体错误流程
  377. DWORD errCode = m_fsm.GetFsmStateErrCode();
  378. ctx->Answer(Error_Unexpect, errCode);
  379. }
  380. else {
  381. MoveBacktoSlotJSEvent* pEvt = new MoveBacktoSlotJSEvent();
  382. pEvt->ctx = ctx;
  383. m_fsm.PostEventFIFO(pEvt);
  384. }
  385. }
  386. virtual void OnSysVarEvent(const char* pszKey, const char* pszValue, const char* pszOldValue, const char* pszEntityName);
  387. virtual bool IsService()const{return true;}
  388. virtual bool IsMultiThread()const{return true;}
  389. protected:
  390. private:
  391. CCardIssuerFSM m_fsm;
  392. bool bInitialized,m_bNewSessionInit;
  393. };