123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416 |
- #ifndef __CARDREAD_ADAPTER_FSM_H
- #define __CARDREAD_ADAPTER_FSM_H
- #pragma once
- #include "SpFSM.h"
- #include "CardReadAdapter_server_g.h"
- #include "CommEntityUtil.hpp"
- #include "CardIssuerClass.h"
- //#include "CardAssist.h"
- #include "CardIssuer_UserErrorCode.h"
- //#include "ICDataElement.h"
- using namespace CardReadAdapter;
- #include "CardIssuer_client_g.h"
- #include "CardIssuerStore_client_g.h"
- #include "ContactlessCard_client_g.h"
- #include "CardIssuer_msg_g.h"
- #include "CardIssuerStore_msg_g.h"
- #include "ContactlessCard_msg_g.h"
- #include "CardReadAdapter_msg_g.h"
- #include "HeartBeat_client_g.h"
- #include "CardReadAdapter_UserErrorCode.h"
- #include "DeviceCrossHelper.h"
- #include <map>
- using namespace std;
- using namespace HeartBeat;
- using namespace CardIssuer;
- using namespace CardIssuerStore;
- using namespace ContactlessCard;
- struct CtxInfo
- {
- int dataSize;
- LPVOID pCtx;
- };
- enum EvtType
- {
- USER_EVT_TEST = EVT_USER + 1,
- USER_EVT_QUIT,
- USER_EVT_INIT,
- USER_EVT_INIT_FINISHED,
- // USER_EVT_CARD_ACCEPT,
- // USER_EVT_CARD_ACCEPT_FINISHED,
- USER_EVT_READ,
- USER_EVT_READ_FINISHED,
- USER_EVT_READ_CANCEL,
- USER_EVT_READ_WAIT_MORE,
- USER_EVT_PREONLINE,
- USER_EVT_POSTONLINE,
- USER_EVT_PREONLINE_FINISHED,
- USER_EVT_POSTONLINE_FINISHED,
- USER_EVT_EJECT,
- USER_EVT_EJECT_FINISHED,
- USER_EVT_ISSUE,
- USER_EVT_ISSUE_FINISHED,
- USER_EVT_CAPTURE,
- USER_EVT_WAITFINISHED,
- USER_EVT_CAPTUREFINISHED,
- USER_EVT_WAITFETCHINGTIMEOUT,
- USER_EVT_RESET,
- USER_EVT_RESETFINISHED,
- USER_EVT_EXIT,
- USER_EVT_WRITE,
- USER_EVT_WRITE_FINISHED,
- USER_EVT_SET_SOME_FLAG,
- USER_EVT_SET_SOME_FLAG_FINISHED,
- USER_EVT_GET_DEV_INFO,
- USER_EVT_GET_DEV_INFO_FINISHED,
- USER_EVT_QUERY_CARD_INFO,
- USER_EVT_QUERY_CARD_INFO_FINISHED,
- USER_EVT_GET_MATERIAL,
- USER_EVT_GET_MATERIAL_FINISHED,
- USER_EVT_SET_MATERIAL,
- USER_EVT_SET_MATERIAL_FINISHED,
- USER_EVT_GET_SCI_INFO,
- USER_EVT_GET_SCI_INFO_FINISHED,
- USER_EVT_OPEN_SAFELOCK,
- USER_EVT_OPEN_SAFELOCK_FINISHED,
- USER_EVT_MAGTRANS_INIT,
- USER_EVT_MAGTRANS_INIT_FINISHED,
- USER_EVT_QUERY_CONN_INFO,
- USER_EVT_QUERY_CONN_INFO_FINISHED,
- USER_EVT_SAM_IC_COMMAND,
- USER_EVT_SAM_IC_COMMAND_FINISHED,
- USER_EVT_PREONLINE_ON_STORE,
- USER_EVT_PREONLINE_ON_STORE_FINISHED,
- USER_EVT_GET_ADD_CARD_INFO,
- USER_EVT_GET_ADD_CARD_INFO_FINISHED,
- USER_EVT_NOTIFY_PREONLINE,
- USER_EVT_NOTIFY_PREONLINE_FINISHED,
- USER_EVT_QUERY_CARD_INFO_ON_STORE,
- USER_EVT_QUERY_CARD_INFO_ON_STORE_FINISHED,
- USER_EVT_QUERY_PRINTER_STATUS,
- USER_EVT_QUERY_PRINTER_STATUS_FINISHED,
- USER_EVT_PRINT,
- USER_EVT_PRINT_FINISHED,
- USER_EVT_QUERY_SCILIST,
- USER_EVT_QUERY_SCILIST_FINISHED,
- USER_EVT_BIND_SCI,
- USER_EVT_BIND_SCI_FINISHED,
- USER_EVT_CROSS_TERM_CALL,
- USER_EVT_CROSS_TERM_CALL_FINISHED,
- USER_EVT_TEST1,
- USER_EVT_TEST1_FINISHED,
- USER_EVT_TEST2,
- USER_EVT_TEST2_FINISHED,
- USER_EVT_PRINT_CARD_IM,
- USER_EVT_PRINT_CARD_IM_FINISHED,
- USER_EVT_QUERY_CI_STATUS,
- USER_EVT_QUERY_CI_STATUS_FINISHED,
- };
- enum CardFromWhichEntity//卡片信息从哪个实体返回
- {
- Card_In_No_Where,
- Card_In_CardIssuer,
- Card_In_ContactlessCard,
- Card_In_CardSwiper,
- };
- enum CardProcStage//stage of card process
- {
- Card_ProcStage_Idle,
- Card_ProcStage_WaitForCard,
- Card_ProcStage_Read,
- Card_ProcStage_Eject,
- Card_ProcStage_Capture,
- };
- struct BusinessContext
- {
- CardFromWhichEntity eCardFromWhich;
- CardProcStage eCardProcStage;
- };
- enum ModuleType//从哪个实体读卡
- {
- Module_Any = 0,
- Module_CardIssuer = 1,
- Module_ContactlessCard = 2,
- Module_CardSwiper = 4,
- };
- enum CardPosType
- {
- CardPos_No_Card = 0,//0:检查超时,未发现设备有卡。
- CardPos_CardSwiper_Mag_Swipe,//1:CardSwiper刷卡
- CardPos_CardSwiper_IC_Insert,//2:CardSwiper插IC卡槽
- CardPos_CardSwiper_RFIC,//3 : CardSwiper非接卡
- CardPos_CardIssuer_Stand2S,//4:卡片在大机卡机里面
- CardPos_ContactlessCard,//5:卡片在大机非接上面
- CardPos_CardIssuer_Split,//6:卡片在便携发卡机里面
- //CardPos_No_Card = 0,//0:检查超时,未发现设备有卡。
- //CardPos_CardSwiper_Mag_OK,//1:CardSwiper刷卡且有磁道数据(至少有二磁道数据)
- //CardPos_CardSwiper_IC,//2:CardSwiper插IC卡
- //CardPos_CardSwiper_Mag_No_Track2,//3:CardSwiper刷卡,但二磁道数据缺失
- //CardPos_CardSwiper_RFIC,//4 : CardSwiper非接卡
- //CardPos_CardSwiper_Invalid,//5:CardSwiper插入接触卡, 卡面插反或无效卡
- //CardPos_CardSwiper_ID,//6:CardSwiper非接IC位发现身份证
- //CardPos_CardIssuer_Stand2S,//7:卡片在大机卡机里面
- //CardPos_ContactlessCard_OK,//8:卡片在大机非接上面
- //CardPos_ContactlessCard_ID,//9:在大机非接位发现身份证
- //CardPos_CardIssuer_Split,//10:卡片在便携发卡机里面
- };
- enum LightPos
- {
- LightPos_ALL = 0,
- LightPos_CardIssuer = 1,
- LightPos_ContactlessCard = 2,
- LightPos_CardSwiper_Mag = 4,
- LightPos_CardSwiper_IC = 8,
- LightPos_CardSwiper_RFIC = 16,
- LightPos_CardIssuer_Only_Mag = 32,
- };
- class CCardReadAdapterEntity;
- class CCardReadAdapterFSM;
- const int ONE_K = 1024;
- class CardIssueEvent : public FSMEvent
- {
- public:
- CardIssueEvent() : FSMEvent(USER_EVT_ISSUE){}
- ~CardIssueEvent(){}
- SpReqAnsContext<CardReadAdapterService_Issue_Req, CardReadAdapterService_Issue_Ans>::Pointer ctx;
- virtual void OnUnhandled()
- {
- if (ctx != NULL)
- {
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("card issue unhandled");
- ctx->Answer(Error_InvalidState);
- }
- }
- };
- class CancelReadEvent : public FSMEvent
- {
- public:
- CancelReadEvent() : FSMEvent(USER_EVT_READ_CANCEL){}
- ~CancelReadEvent(){}
- virtual void OnUnhandled()
- {
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("card cancel accept unhandled");
- }
- };
- class ReadWaitMoreEvent : public FSMEvent
- {
- public:
- ReadWaitMoreEvent() : FSMEvent(USER_EVT_READ_WAIT_MORE){}
- ~ReadWaitMoreEvent(){}
- virtual void OnUnhandled()
- {
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("ReadWaitMore unhandled");
- }
- };
- class CardReadEvent : public FSMEvent
- {
- public:
- CardReadEvent() : FSMEvent(USER_EVT_READ){}
- ~CardReadEvent(){}
- SpReqAnsContext<CardReadAdapterService_Read_Req, CardReadAdapterService_Read_Ans>::Pointer ctx;
- virtual void OnUnhandled()
- {
- if (ctx != NULL)
- {
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("card read unhandled");
- ctx->Answer(Error_InvalidState);
- }
- }
- protected:
- private:
- };
- class CardReadFinishedEvent : public FSMEvent
- {
- public:
- CardReadFinishedEvent() : FSMEvent(USER_EVT_READ_FINISHED){}
- ~CardReadFinishedEvent(){}
- SpReqAnsContext<CardReadAdapterService_Read_Req, CardReadAdapterService_Read_Ans>::Pointer ctx;
- virtual void OnUnhandled()
- {
- if (ctx != NULL)
- {
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("card read unhandled(new)");
- }
- }
- protected:
- private:
- };
- class ResetDeviceEvent : public FSMEvent
- {
- public:
- ResetDeviceEvent() : FSMEvent(USER_EVT_RESET){}
- ~ResetDeviceEvent(){}
- protected:
- private:
- };
- class ResetFinishedEvent : public FSMEvent
- {
- public:
- ResetFinishedEvent() : FSMEvent(USER_EVT_RESETFINISHED){}
- ~ResetFinishedEvent(){}
- protected:
- private:
- };
- class PreOnlineEvent : public FSMEvent
- {
- public:
- PreOnlineEvent() : FSMEvent(USER_EVT_PREONLINE){}
- ~PreOnlineEvent(){}
- SpReqAnsContext<CardReadAdapterService_PreOnline_Req, CardReadAdapterService_PreOnline_Ans>::Pointer ctx;
- virtual void OnUnhandled()
- {
- if (ctx != NULL)
- ctx->Answer(Error_InvalidState);
- }
- protected:
- private:
- };
- class PostOnlineEvent : public FSMEvent
- {
- public:
- PostOnlineEvent() : FSMEvent(USER_EVT_POSTONLINE){}
- ~PostOnlineEvent(){}
- SpReqAnsContext<CardReadAdapterService_PostOnline_Req, CardReadAdapterService_PostOnline_Ans>::Pointer ctx;
- virtual void OnUnhandled()
- {
- if (ctx != NULL)
- ctx->Answer(Error_InvalidState);
- }
- protected:
- private:
- };
- class CardCaptureEvent : public FSMEvent
- {
- public:
- CardCaptureEvent() : FSMEvent(USER_EVT_CAPTURE){}
- ~CardCaptureEvent(){}
- SpReqAnsContext<CardReadAdapterService_Capture_Req, CardReadAdapterService_Capture_Ans>::Pointer ctx;
- virtual void OnUnhandled()
- {
- if (ctx != NULL)
- ctx->Answer(Error_InvalidState);
- }
- protected:
- private:
- };
- class CardEjectEvent : public FSMEvent
- {
- public:
- CardEjectEvent() : FSMEvent(USER_EVT_EJECT){}
- ~CardEjectEvent(){}
- SpReqAnsContext<CardReadAdapterService_Eject_Req, CardReadAdapterService_Eject_Ans>::Pointer ctx;
- virtual void OnUnhandled()
- {
- if (ctx != NULL)
- ctx->Answer(Error_InvalidState);
- }
- protected:
- private:
- };
- class CardWriteEvent : public FSMEvent
- {
- public:
- CardWriteEvent() : FSMEvent(USER_EVT_WRITE){}
- ~CardWriteEvent(){}
- SpReqAnsContext<CardReadAdapterService_WriteTrack_Req, CardReadAdapterService_WriteTrack_Ans>::Pointer ctx;
- virtual void OnUnhandled()
- {
- if (ctx != NULL)
- {
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("card read unhandled");
- ctx->Answer(Error_InvalidState);
- }
- }
- protected:
- private:
- };
- class CardWriteFinishedEvent : public FSMEvent
- {
- public:
- CardWriteFinishedEvent() : FSMEvent(USER_EVT_WRITE_FINISHED){}
- ~CardWriteFinishedEvent(){}
- SpReqAnsContext<CardReadAdapterService_WriteTrack_Req, CardReadAdapterService_WriteTrack_Ans>::Pointer ctx;
- virtual void OnUnhandled()
- {
- if (ctx != NULL)
- {
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("card read unhandled(new)");
- }
- }
- };
- class SetSomeFlagEvent : public FSMEvent
- {
- public:
- SetSomeFlagEvent() : FSMEvent(USER_EVT_SET_SOME_FLAG){}
- ~SetSomeFlagEvent(){}
- SpReqAnsContext<CardReadAdapterService_SetSomeFlag_Req, CardReadAdapterService_SetSomeFlag_Ans>::Pointer ctx;
- virtual void OnUnhandled()
- {
- if (ctx != NULL)
- {
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("SetSomeFlag unhandled");
- ctx->Answer(Error_InvalidState);
- }
- }
- };
- class QueryCardInfoEvent : public FSMEvent
- {
- public:
- QueryCardInfoEvent() : FSMEvent(USER_EVT_QUERY_CARD_INFO){}
- ~QueryCardInfoEvent(){}
- SpReqAnsContext<CardReadAdapterService_QueryCardInfo_Req, CardReadAdapterService_QueryCardInfo_Ans>::Pointer ctx;
- virtual void OnUnhandled()
- {
- if (ctx != NULL)
- {
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("QueryCardInfo unhandled");
- ctx->Answer(Error_InvalidState);
- }
- }
- };
- class GetMaterialEvent : public FSMEvent
- {
- public:
- GetMaterialEvent() : FSMEvent(USER_EVT_GET_MATERIAL){}
- ~GetMaterialEvent(){}
- SpReqAnsContext<CardReadAdapterService_GetMaterialCount_Req, CardReadAdapterService_GetMaterialCount_Ans>::Pointer ctx;
- virtual void OnUnhandled()
- {
- if (ctx != NULL)
- ctx->Answer(Error_InvalidState);
- }
- protected:
- private:
- };
- class SetMaterialEvent : public FSMEvent
- {
- public:
- SetMaterialEvent() : FSMEvent(USER_EVT_SET_MATERIAL){}
- ~SetMaterialEvent(){}
- SpReqAnsContext<CardReadAdapterService_SetMaterialCount_Req, CardReadAdapterService_SetMaterialCount_Ans>::Pointer ctx;
- virtual void OnUnhandled()
- {
- if (ctx != NULL)
- ctx->Answer(Error_InvalidState);
- }
- protected:
- private:
- };
- class GetSCIInfoEvent : public FSMEvent
- {
- public:
- GetSCIInfoEvent() : FSMEvent(USER_EVT_GET_SCI_INFO){}
- ~GetSCIInfoEvent(){}
- SpReqAnsContext<CardReadAdapterService_GetSCIInfo_Req, CardReadAdapterService_GetSCIInfo_Ans>::Pointer ctx;
- virtual void OnUnhandled()
- {
- if (ctx != NULL)
- ctx->Answer(Error_InvalidState);
- }
- protected:
- private:
- };
- class OpenSafeLockEvent : public FSMEvent
- {
- public:
- OpenSafeLockEvent() : FSMEvent(USER_EVT_OPEN_SAFELOCK){}
- ~OpenSafeLockEvent(){}
- SpReqAnsContext<CardReadAdapterService_OpenSafeLock_Req, CardReadAdapterService_OpenSafeLock_Ans>::Pointer ctx;
- virtual void OnUnhandled()
- {
- if (ctx != NULL)
- ctx->Answer(Error_InvalidState);
- }
- protected:
- private:
- };
- class MagTransferInitEvent : public FSMEvent
- {
- public:
- MagTransferInitEvent() : FSMEvent(USER_EVT_MAGTRANS_INIT){}
- ~MagTransferInitEvent(){}
- SpReqAnsContext<CardReadAdapterService_MagTransferInit_Req, CardReadAdapterService_MagTransferInit_Ans>::Pointer ctx;
- virtual void OnUnhandled()
- {
- if (ctx != NULL)
- ctx->Answer(Error_InvalidState);
- }
- protected:
- private:
- };
- class QueryConnInfoEvent : public FSMEvent
- {
- public:
- QueryConnInfoEvent() : FSMEvent(USER_EVT_QUERY_CONN_INFO){}
- ~QueryConnInfoEvent(){}
- SpReqAnsContext<CardReadAdapterService_QueryConnInfo_Req, CardReadAdapterService_QueryConnInfo_Ans>::Pointer ctx;
- virtual void OnUnhandled()
- {
- if (ctx != NULL)
- ctx->Answer(Error_InvalidState);
- }
- protected:
- private:
- };
- class SAMICCommandEvent : public FSMEvent
- {
- public:
- SAMICCommandEvent() : FSMEvent(USER_EVT_SAM_IC_COMMAND){}
- ~SAMICCommandEvent(){}
- SpReqAnsContext<CardReadAdapterService_SAMICCommand_Req, CardReadAdapterService_SAMICCommand_Ans>::Pointer ctx;
- virtual void OnUnhandled()
- {
- if (ctx != NULL)
- ctx->Answer(Error_InvalidState);
- }
- };
- class QueryPrinterStatusEvent : public FSMEvent
- {
- public:
- QueryPrinterStatusEvent() : FSMEvent(USER_EVT_QUERY_PRINTER_STATUS){}
- ~QueryPrinterStatusEvent(){}
- SpReqAnsContext<CardReadAdapterService_QueryPrinterStatus_Req, CardReadAdapterService_QueryPrinterStatus_Ans>::Pointer ctx;
- virtual void OnUnhandled()
- {
- if (ctx != NULL)
- ctx->Answer(Error_InvalidState);
- }
- };
- class PrintEvent : public FSMEvent
- {
- public:
- PrintEvent() : FSMEvent(USER_EVT_PRINT){}
- ~PrintEvent(){}
- SpReqAnsContext<CardReadAdapterService_Print_Req, CardReadAdapterService_Print_Ans>::Pointer ctx;
- virtual void OnUnhandled()
- {
- if (ctx != NULL)
- ctx->Answer(Error_InvalidState);
- }
- };
- class QuerySCIListEvent : public FSMEvent
- {
- public:
- QuerySCIListEvent() : FSMEvent(USER_EVT_QUERY_SCILIST){}
- ~QuerySCIListEvent(){}
- SpReqAnsContext<CardReadAdapterService_QuerySCIList_Req, CardReadAdapterService_QuerySCIList_Ans>::Pointer ctx;
- virtual void OnUnhandled()
- {
- if (ctx != NULL)
- ctx->Answer(Error_InvalidState);
- }
- };
- class BindSCIEvent : public FSMEvent
- {
- public:
- BindSCIEvent() : FSMEvent(USER_EVT_BIND_SCI){}
- ~BindSCIEvent(){}
- SpReqAnsContext<CardReadAdapterService_BindSCI_Req, CardReadAdapterService_BindSCI_Ans>::Pointer ctx;
- virtual void OnUnhandled()
- {
- if (ctx != NULL)
- ctx->Answer(Error_InvalidState);
- }
- };
- class PreOnlineOnStoreEvent : public FSMEvent
- {
- public:
- PreOnlineOnStoreEvent() : FSMEvent(USER_EVT_PREONLINE_ON_STORE){}
- ~PreOnlineOnStoreEvent(){}
- SpReqAnsContext<CardReadAdapterService_PreOnlineOnStore_Req, CardReadAdapterService_PreOnlineOnStore_Ans>::Pointer ctx;
- virtual void OnUnhandled()
- {
- if (ctx != NULL)
- ctx->Answer(Error_InvalidState);
- }
- };
- class PreOnlineOnStoreFinishedEvent : public FSMEvent
- {
- public:
- PreOnlineOnStoreFinishedEvent() : FSMEvent(USER_EVT_PREONLINE_ON_STORE_FINISHED){}
- ~PreOnlineOnStoreFinishedEvent(){}
- SpReqAnsContext<CardReadAdapterService_PreOnlineOnStore_Req, CardReadAdapterService_PreOnlineOnStore_Ans>::Pointer ctx;
- virtual void OnUnhandled()
- {
- if (ctx != NULL)
- ctx->Answer(Error_InvalidState);
- }
- };
- class NotifyPreonlineEvent : public FSMEvent
- {
- public:
- NotifyPreonlineEvent() : FSMEvent(USER_EVT_NOTIFY_PREONLINE){}
- ~NotifyPreonlineEvent(){}
- SpReqAnsContext<CardReadAdapterService_NotifyPreonline_Req, CardReadAdapterService_NotifyPreonline_Ans>::Pointer ctx;
- virtual void OnUnhandled()
- {
- if (ctx != NULL)
- ctx->Answer(Error_InvalidState);
- }
- };
- class NotifyPreonlineFinishedEvent : public FSMEvent
- {
- public:
- NotifyPreonlineFinishedEvent() : FSMEvent(USER_EVT_NOTIFY_PREONLINE_FINISHED){}
- ~NotifyPreonlineFinishedEvent(){}
- SpReqAnsContext<CardReadAdapterService_NotifyPreonline_Req, CardReadAdapterService_NotifyPreonline_Ans>::Pointer ctx;
- virtual void OnUnhandled()
- {
- if (ctx != NULL)
- ctx->Answer(Error_InvalidState);
- }
- };
- class QueryCardInfoOnStoreEvent : public FSMEvent
- {
- public:
- QueryCardInfoOnStoreEvent() : FSMEvent(USER_EVT_QUERY_CARD_INFO_ON_STORE){}
- ~QueryCardInfoOnStoreEvent(){}
- SpReqAnsContext<CardReadAdapterService_QueryCardInfoOnStore_Req, CardReadAdapterService_QueryCardInfoOnStore_Ans>::Pointer ctx;
- virtual void OnUnhandled()
- {
- if (ctx != NULL)
- ctx->Answer(Error_InvalidState);
- }
- };
- class QueryCardInfoOnStoreFinishedEvent : public FSMEvent
- {
- public:
- QueryCardInfoOnStoreFinishedEvent() : FSMEvent(USER_EVT_QUERY_CARD_INFO_ON_STORE_FINISHED){}
- ~QueryCardInfoOnStoreFinishedEvent(){}
- SpReqAnsContext<CardReadAdapterService_QueryCardInfoOnStore_Req, CardReadAdapterService_QueryCardInfoOnStore_Ans>::Pointer ctx;
- virtual void OnUnhandled()
- {
- if (ctx != NULL)
- ctx->Answer(Error_InvalidState);
- }
- };
- class GetAddCardInfoEvent : public FSMEvent
- {
- public:
- GetAddCardInfoEvent() : FSMEvent(USER_EVT_GET_ADD_CARD_INFO){}
- ~GetAddCardInfoEvent(){}
- SpReqAnsContext<CardReadAdapterService_GetAddCardInfo_Req, CardReadAdapterService_GetAddCardInfo_Ans>::Pointer ctx;
- virtual void OnUnhandled()
- {
- if (ctx != NULL)
- ctx->Answer(Error_InvalidState);
- }
- };
- class GetAddCardInfoFinishedEvent : public FSMEvent
- {
- public:
- GetAddCardInfoFinishedEvent() : FSMEvent(USER_EVT_GET_ADD_CARD_INFO_FINISHED){}
- ~GetAddCardInfoFinishedEvent(){}
- SpReqAnsContext<CardReadAdapterService_GetAddCardInfo_Req, CardReadAdapterService_GetAddCardInfo_Ans>::Pointer ctx;
- virtual void OnUnhandled()
- {
- if (ctx != NULL)
- ctx->Answer(Error_InvalidState);
- }
- };
- class CrossTermCallEvent : public FSMEvent
- {
- public:
- CrossTermCallEvent() : FSMEvent(USER_EVT_CROSS_TERM_CALL){}
- ~CrossTermCallEvent(){}
- SpReqAnsContext<CardReadAdapterService_CrossTermCall_Req, CardReadAdapterService_CrossTermCall_Ans>::Pointer ctx;
- virtual void OnUnhandled()
- {
- if (ctx != NULL)
- ctx->Answer(Error_InvalidState);
- }
- };
- class PrintCardImEvent : public FSMEvent
- {
- public:
- PrintCardImEvent() : FSMEvent(USER_EVT_PRINT_CARD_IM) {}
- ~PrintCardImEvent() {}
- SpReqAnsContext<CardReadAdapterService_PrintCardImmediately_Req, CardReadAdapterService_PrintCardImmediately_Ans>::Pointer ctx;
- virtual void OnUnhandled()
- {
- if (ctx != NULL)
- ctx->Answer(Error_InvalidState);
- }
- };
- class PrintCardImFinishedEvent : public FSMEvent
- {
- public:
- PrintCardImFinishedEvent() : FSMEvent(USER_EVT_PRINT_CARD_IM_FINISHED) {}
- ~PrintCardImFinishedEvent() {}
- SpReqAnsContext<CardReadAdapterService_PrintCardImmediately_Req, CardReadAdapterService_PrintCardImmediately_Ans>::Pointer ctx;
- virtual void OnUnhandled()
- {
- if (ctx != NULL)
- ctx->Answer(Error_InvalidState);
- }
- };
- class QueryCIStatusEvent : public FSMEvent
- {
- public:
- QueryCIStatusEvent() : FSMEvent(USER_EVT_QUERY_CI_STATUS) {}
- ~QueryCIStatusEvent() {}
- SpReqAnsContext<CardReadAdapterService_QueryCIStatus_Req, CardReadAdapterService_QueryCIStatus_Ans>::Pointer ctx;
- virtual void OnUnhandled()
- {
- if (ctx != NULL)
- ctx->Answer(Error_InvalidState);
- }
- };
- class QueryCIStatusFinishedEvent : public FSMEvent
- {
- public:
- QueryCIStatusFinishedEvent() : FSMEvent(USER_EVT_QUERY_CI_STATUS_FINISHED) {}
- ~QueryCIStatusFinishedEvent() {}
- SpReqAnsContext<CardReadAdapterService_QueryCIStatus_Req, CardReadAdapterService_QueryCIStatus_Ans>::Pointer ctx;
- virtual void OnUnhandled()
- {
- if (ctx != NULL)
- ctx->Answer(Error_InvalidState);
- }
- };
- class GetDevInfoEvent : public FSMEvent
- {
- public:
- GetDevInfoEvent() : FSMEvent(USER_EVT_GET_DEV_INFO){}
- ~GetDevInfoEvent(){}
- SpReqAnsContext<CardReadAdapterService_GetDevInfo_Req, CardReadAdapterService_GetDevInfo_Ans>::Pointer ctx;
- virtual void OnUnhandled()
- {
- if (ctx != NULL)
- {
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("GetDevInfo unhandled");
- ctx->Answer(Error_InvalidState);
- }
- }
- };
- class CCardReadAdapterFSM : public FSMImpl<CCardReadAdapterFSM>
- {
- public:
- enum { s0, s1, s2, s3, s4};
- BEGIN_FSM_STATE(CCardReadAdapterFSM)
- FSM_STATE_ENTRY(s0, "Init", s0_on_entry, s0_on_exit, s0_on_event)
- FSM_STATE_ENTRY(s1, "Initializing", s1_on_entry, s1_on_exit, s1_on_event)
- FSM_STATE_ENTRY(s2, "Idle", s2_on_entry, s2_on_exit, s2_on_event)
- FSM_STATE_ENTRY(s3, "Working", s3_on_entry, s3_on_exit, s3_on_event)
- FSM_STATE_ENTRY(s4, "Failed", s4_on_entry, s4_on_exit, s4_on_event)
- END_FSM_STATE()
- BEGIN_FSM_RULE(CCardReadAdapterFSM, s0)
- FSM_RULE_ENTRY(s0, s2, USER_EVT_TEST, 0)//oiltest
- FSM_RULE_ENTRY(s0, s1, USER_EVT_INIT, 0)
- FSM_RULE_ENTRY(s0, FSM_STATE_EXIT, USER_EVT_QUIT, 0)
- FSM_RULE_ENTRY(s1, s2, USER_EVT_INIT_FINISHED, 0)
- FSM_RULE_ENTRY(s1, s4, USER_EVT_INIT_FINISHED, 1)
- FSM_RULE_ENTRY(s1, FSM_STATE_EXIT, USER_EVT_QUIT, 0)
- FSM_RULE_ENTRY(s2, FSM_STATE_EXIT, USER_EVT_QUIT, 0)
- FSM_RULE_ENTRY(s2, s3, USER_EVT_READ, 0)
- FSM_RULE_ENTRY(s2, s3, USER_EVT_PREONLINE, 0)
- FSM_RULE_ENTRY(s2, s3, USER_EVT_POSTONLINE, 0)
- FSM_RULE_ENTRY(s2, s3, USER_EVT_EJECT, 0)
- FSM_RULE_ENTRY(s2, s3, USER_EVT_SET_SOME_FLAG, 0)
- FSM_RULE_ENTRY(s2, s3, USER_EVT_GET_DEV_INFO, 0)
- FSM_RULE_ENTRY(s2, s3, USER_EVT_QUERY_CARD_INFO, 0)
- FSM_RULE_ENTRY(s2, s3, USER_EVT_GET_MATERIAL, 0)
- FSM_RULE_ENTRY(s2, s3, USER_EVT_SET_MATERIAL, 0)
- FSM_RULE_ENTRY(s2, s3, USER_EVT_GET_SCI_INFO, 0)
- FSM_RULE_ENTRY(s2, s3, USER_EVT_OPEN_SAFELOCK, 0)
- FSM_RULE_ENTRY(s2, s3, USER_EVT_MAGTRANS_INIT, 0)
- FSM_RULE_ENTRY(s2, s3, USER_EVT_QUERY_CONN_INFO, 0)
- FSM_RULE_ENTRY(s2, s3, USER_EVT_SAM_IC_COMMAND, 0)
- FSM_RULE_ENTRY(s2, s3, USER_EVT_PREONLINE_ON_STORE, 0)
- FSM_RULE_ENTRY(s2, s3, USER_EVT_GET_ADD_CARD_INFO, 0)
- FSM_RULE_ENTRY(s2, s3, USER_EVT_PRINT_CARD_IM, 0)
- FSM_RULE_ENTRY(s2, s3, USER_EVT_QUERY_CI_STATUS, 0)
- FSM_RULE_ENTRY(s3, s2, USER_EVT_EXIT, 0)
- FSM_RULE_ENTRY(s3, s2, USER_EVT_READ_FINISHED, 0)
- FSM_RULE_ENTRY(s3, s2, USER_EVT_READ_FINISHED, 2)
- FSM_RULE_ENTRY(s3, s2, USER_EVT_PREONLINE_FINISHED, 0)
- FSM_RULE_ENTRY(s3, s2, USER_EVT_POSTONLINE_FINISHED, 0)
- FSM_RULE_ENTRY(s3, s2, USER_EVT_EJECT_FINISHED, 0)
- FSM_RULE_ENTRY(s3, s2, USER_EVT_WRITE_FINISHED,0)
- FSM_RULE_ENTRY(s3, s2, USER_EVT_SET_SOME_FLAG_FINISHED,0)
- FSM_RULE_ENTRY(s3, s2, USER_EVT_GET_DEV_INFO_FINISHED,0)
- FSM_RULE_ENTRY(s3, s2, USER_EVT_QUERY_CARD_INFO_FINISHED,0)
- FSM_RULE_ENTRY(s3, s2, USER_EVT_GET_MATERIAL_FINISHED,0)
- FSM_RULE_ENTRY(s3, s2, USER_EVT_SET_MATERIAL_FINISHED,0)
- FSM_RULE_ENTRY(s3, s2, USER_EVT_GET_SCI_INFO_FINISHED,0)
- FSM_RULE_ENTRY(s3, s2, USER_EVT_OPEN_SAFELOCK_FINISHED,0)
- FSM_RULE_ENTRY(s3, s2, USER_EVT_MAGTRANS_INIT_FINISHED,0)
- FSM_RULE_ENTRY(s3, s2, USER_EVT_QUERY_CONN_INFO_FINISHED,0)
- FSM_RULE_ENTRY(s3, s2, USER_EVT_SAM_IC_COMMAND_FINISHED, 0)
- FSM_RULE_ENTRY(s3, s2, USER_EVT_QUERY_PRINTER_STATUS_FINISHED, 0)
- FSM_RULE_ENTRY(s3, s2, USER_EVT_PRINT_FINISHED, 0)
- FSM_RULE_ENTRY(s3, s2, USER_EVT_QUERY_SCILIST_FINISHED, 0)
- FSM_RULE_ENTRY(s3, s2, USER_EVT_BIND_SCI_FINISHED, 0)
- FSM_RULE_ENTRY(s3, s2, USER_EVT_PREONLINE_ON_STORE_FINISHED, 0)
- FSM_RULE_ENTRY(s3, s2, USER_EVT_GET_ADD_CARD_INFO_FINISHED, 0)
- FSM_RULE_ENTRY(s3, s2, USER_EVT_PRINT_CARD_IM_FINISHED, 0)
- FSM_RULE_ENTRY(s3, s2, USER_EVT_QUERY_CI_STATUS_FINISHED, 0)
- FSM_RULE_ENTRY(s3, FSM_STATE_EXIT, USER_EVT_QUIT, 0)
- FSM_RULE_ENTRY(s4, FSM_STATE_EXIT, USER_EVT_QUIT, 0)
- END_FSM_RULE()
- CCardReadAdapterFSM() : m_pCardIssuer(NULL), m_pCardIssuerStore(NULL), m_pContactless(NULL), m_pHBClient(NULL){}
- ~CCardReadAdapterFSM(){}
- virtual ErrorCodeEnum OnInit();
- virtual ErrorCodeEnum OnExit();
- //unsigned int sReady_on_event(FSMEvent* event)
- //{
- // if (event->iEvt == USER_EVT_READ) {
- // // new read task
- //
- // event->SetHandled();
- // return 0;
- // }
- //}
- void s0_on_entry();
- void s0_on_exit();
- unsigned int s0_on_event(FSMEvent* event);
- void s1_on_entry();
- void s1_on_exit();
- unsigned int s1_on_event(FSMEvent* event);
- void s2_on_entry();
- void s2_on_exit();
- unsigned int s2_on_event(FSMEvent* event);
- void s3_on_entry();
- void s3_on_exit();
- unsigned int s3_on_event(FSMEvent* event);
- void s4_on_entry();
- void s4_on_exit();
- unsigned int s4_on_event(FSMEvent* event);
- void TransEntity(CCardReadAdapterEntity* pEty){ m_pEty = pEty; }
- int Initial();
- int DoWork(int type);
- int CardIssuerRead(SpReqAnsContext<CardReadAdapterService_Read_Req, CardReadAdapterService_Read_Ans>::Pointer ctx);
- int ContactlessCardRead(SpReqAnsContext<CardReadAdapterService_Read_Req, CardReadAdapterService_Read_Ans>::Pointer ctx);
- int CardSwiperRead(SpReqAnsContext<CardReadAdapterService_Read_Req, CardReadAdapterService_Read_Ans>::Pointer ctx,int &eRetErr);
- int IssueCard(SpReqAnsContext<CardReadAdapterService_Issue_Req, CardReadAdapterService_Issue_Ans>::Pointer ctx);
- void CancelRead();
- void ReadWaitMore();
- int WriteTrack(SpReqAnsContext<CardReadAdapterService_WriteTrack_Req, CardReadAdapterService_WriteTrack_Ans>::Pointer ctx);
- int PreOnline(SpReqAnsContext<CardReadAdapterService_PreOnline_Req, CardReadAdapterService_PreOnline_Ans>::Pointer ctx);
- int PostOnline(SpReqAnsContext<CardReadAdapterService_PostOnline_Req, CardReadAdapterService_PostOnline_Ans>::Pointer ctx);
- int EjectCard(SpReqAnsContext<CardReadAdapterService_Eject_Req, CardReadAdapterService_Eject_Ans>::Pointer ctx);
- int CaptureCard(SpReqAnsContext<CardReadAdapterService_Capture_Req, CardReadAdapterService_Capture_Ans>::Pointer ctx);
- int QueryCardInfo(SpReqAnsContext<CardReadAdapterService_QueryCardInfo_Req, CardReadAdapterService_QueryCardInfo_Ans>::Pointer ctx);
- void CheckAndReconnectSession();
- int SetSomeFlag(SpReqAnsContext<CardReadAdapterService_SetSomeFlag_Req, CardReadAdapterService_SetSomeFlag_Ans>::Pointer ctx);
- void DoExit();
- int GetMaterialCount(SpReqAnsContext<CardReadAdapterService_GetMaterialCount_Req, CardReadAdapterService_GetMaterialCount_Ans>::Pointer ctx);
- int SetMaterialCount(SpReqAnsContext<CardReadAdapterService_SetMaterialCount_Req, CardReadAdapterService_SetMaterialCount_Ans>::Pointer ctx);
- int GetSCIInfo(SpReqAnsContext<CardReadAdapterService_GetSCIInfo_Req, CardReadAdapterService_GetSCIInfo_Ans>::Pointer ctx);
- int OpenSafeLock(SpReqAnsContext<CardReadAdapterService_OpenSafeLock_Req, CardReadAdapterService_OpenSafeLock_Ans>::Pointer ctx);
- int MagTransferInit(SpReqAnsContext<CardReadAdapterService_MagTransferInit_Req, CardReadAdapterService_MagTransferInit_Ans>::Pointer ctx);
- int QueryConnInfo(SpReqAnsContext<CardReadAdapterService_QueryConnInfo_Req, CardReadAdapterService_QueryConnInfo_Ans>::Pointer ctx);
- int GetDevInfo(SpReqAnsContext<CardReadAdapterService_GetDevInfo_Req, CardReadAdapterService_GetDevInfo_Ans>::Pointer ctx);
- void BroadcastReadICing(int status);
- int SAMICCommand(SpReqAnsContext<CardReadAdapterService_SAMICCommand_Req, CardReadAdapterService_SAMICCommand_Ans>::Pointer ctx);
- int QueryPrinterStatus(SpReqAnsContext<CardReadAdapterService_QueryPrinterStatus_Req, CardReadAdapterService_QueryPrinterStatus_Ans>::Pointer ctx);
- int Print(SpReqAnsContext<CardReadAdapterService_Print_Req, CardReadAdapterService_Print_Ans>::Pointer ctx);
- int QuerySCIList(SpReqAnsContext<CardReadAdapterService_QuerySCIList_Req, CardReadAdapterService_QuerySCIList_Ans>::Pointer ctx);
- int BindSCI(SpReqAnsContext<CardReadAdapterService_BindSCI_Req, CardReadAdapterService_BindSCI_Ans>::Pointer ctx);
- int PreOnlineOnStore(SpReqAnsContext<CardReadAdapterService_PreOnlineOnStore_Req, CardReadAdapterService_PreOnlineOnStore_Ans>::Pointer ctx);
- int NotifyPreonline(SpReqAnsContext<CardReadAdapterService_NotifyPreonline_Req, CardReadAdapterService_NotifyPreonline_Ans>::Pointer ctx);
- int QueryCardInfoOnStore(SpReqAnsContext<CardReadAdapterService_QueryCardInfoOnStore_Req, CardReadAdapterService_QueryCardInfoOnStore_Ans>::Pointer ctx);
- int GetAddCardInfo(SpReqAnsContext<CardReadAdapterService_GetAddCardInfo_Req, CardReadAdapterService_GetAddCardInfo_Ans>::Pointer ctx);
- int Test1(SpReqAnsContext<CardReadAdapterService_Test1_Req, CardReadAdapterService_Test1_Ans>::Pointer ctx);
- int Test2(SpReqAnsContext<CardReadAdapterService_Test2_Req, CardReadAdapterService_Test2_Ans>::Pointer ctx);
- void SelfTest(EntityTestEnum eTestType, CSmartPointer<ITransactionContext> pTransactionContext);
- void SetReadCtx(SpReqAnsContext<CardReadAdapterService_Read_Req, CardReadAdapterService_Read_Ans>::Pointer ctx) { m_readCtx = ctx; }
- bool IsRVCIL() { /*return (m_eMachineType == MachineType_RVC_IL);*/return false;}//oilyang@20190123 方案改了,这里暂时不需要了
- template <class TReq, class TAns>
- void SaveCtx(int methodID, CSmartPointer<SpReqAnsContext<TReq, TAns> > ctx)
- {
- m_mapCtx[methodID].pCtx = static_cast<void*>(ctx.GetRawPointer());
- }
- LPVOID GetCtx(int methodID)
- {
- if (m_mapCtx.find(methodID) != m_mapCtx.end())
- return m_mapCtx[methodID].pCtx;
- else
- return NULL;
- }
- int LocalCallHeartBeat(int method, CBlob &bbSend, bool bTwoWay=false);
- bool GetAttachedTerminal(CSimpleStringA &csTerm);
- int CrossTermCall(SpReqAnsContext<CardReadAdapterService_CrossTermCall_Req, CardReadAdapterService_CrossTermCall_Ans>::Pointer ctx);
- void CrossTermInvokeInfo(SpOnewayCallContext<CardReadAdapterService_CrossTermInvokeInfo_Info>::Pointer ctx);
- void CancelReadForEntity(ModuleType eModule);
- int PrintCardIm(SpReqAnsContext<CardReadAdapterService_PrintCardImmediately_Req, CardReadAdapterService_PrintCardImmediately_Ans>::Pointer ctx);
- void QueryCurrFSMAndLastS2EventInfo(int &currFSM, int& event, int& param1)
- {
- currFSM = GetCurrState()->id;
- event = m_lastS2Event;
- param1 = m_lastS2EvtParam1;
- }
- SP::Module::Comm::What GetMachineType() {return m_eMachineType;}
- int QueryCIStatus(SpReqAnsContext<CardReadAdapterService_QueryCIStatus_Req, CardReadAdapterService_QueryCIStatus_Ans>::Pointer ctx);
- void WaitCardActive();
- protected:
- //LPIDCCARDDATA* lppCardData;
- int m_iInsertTries;
- int m_resetTries;
- int m_ejectTries;
- private:
- CCardReadAdapterEntity *m_pEty;
- CardIssuerService_ClientBase *m_pCardIssuer;
- CardIssuerStoreService_ClientBase* m_pCardIssuerStore;
- ContactlessCardService_ClientBase *m_pContactless;
- HeartBeatService_ClientBase* m_pHBClient;
- BusinessContext m_busCtx;
- SpReqAnsContext<CardReadAdapterService_Read_Req, CardReadAdapterService_Read_Ans>::Pointer m_readCtx;
- //m_lastModule:0~7
- //0:all; 1:CardIssuer; 2:ContactlessCard; 4:CardSwiper
- int m_lastModule,m_lastS2Event, m_lastS2EvtParam1;
- SP::Module::Comm::What m_eMachineType;
- WORD m_majorVerion,m_minorVerion;
- ///
- int m_resetTimes;
- HMODULE m_hVerdorDll;
- //GUIConsoleService_ClientBase *m_pGUIConsoleClient;
- bool m_devInit, m_bCancelAccept, m_bWaitingAccept, m_bWaitAccepteMore
- , m_bCDA, m_bIssuingExit, m_bCardIssued, m_bCaptureCfgFlag, m_bHasHopper[3], m_bBTConncting
- , m_bCardActiveNotify;
- ErrorCodeEnum m_testResult;
- //m_CardInit,m_CardRemains,m_CardIssued,m_CardMixed,m_CardPercent
- int m_CardCaptured, m_issueStatusFromFile, m_issueStatus, m_port, m_baudRate, m_currentHopper, m_scanSlot;
- CSimpleStringA m_CardBoxNoEx[3], m_PsbCodeEx[3], m_PsbNameEx[3], m_MaintainerEx[3], m_csMaintainTimeEx[3];
- int m_CardInitEx[3], m_CardPercentEx[3], m_remainsEx[3], m_issuedEx[3], m_mixedEx[3], m_hopperNum;
- DWORD m_MaintainTimeEx[3];
- 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];
- DevStateEnum m_eDevState;
- //CCardProcess *m_pCardProcess;
- char *m_pDataToARQC;
- long xxTest;
- CSimpleStringA m_currCardNo, m_captureReason, m_csMachineType, m_csSite, m_csDevSN, m_terminalNo, m_devSN;
- char m_AuthCode[2];
- bool m_bBTConnected;
- map<int, CtxInfo> m_mapCtx;
- SpReqAnsContext<CardReadAdapterService_PreOnlineOnStore_Req, CardReadAdapterService_PreOnlineOnStore_Ans>::Pointer m_crossCtx;
- ULONGLONG m_ullCrossStart;
- bool IsCardIssuerSessionOK();
- bool IsContactlessCardSessionOK();
- bool IsCardSwiperSessionOK();
- bool IsTheEntity(int module,ModuleType eModule);
- bool CheckHBSessionOrToConnect();
- //oilyang@20230614 跨及时因为卡片的实际交易发生在卡库,需要在发起端对返回的UserErrorCode做二次映射,方便客户理解提示信息
- DWORD MapErrorCodeWhileCallStore(DWORD eErrCode)
- {
- //eErrCode defined on CardIssuer_UserErrorCode.h
- switch (eErrCode)
- {
- case 0x20300240:
- return 0x203002E0;
- case 0x20300242:
- return 0x203002E1;
- case 0x20300243:
- case 0x203002a1:
- return 0x203002E2;
- case 0x20300244:
- return 0x203002E3;
- case 0x20300246:
- return 0x203002E4;
- case 0x2030000D:
- return 0x203002E5;
- default:
- return eErrCode;
- }
- }
- bool IsCardIssuerStore() {
- if (m_eMachineType == SP::Module::Comm::RVC_CardStore || m_eMachineType == SP::Module::Comm::RVC_CardPrinter) {
- return true;
- }
- else {
- return false;
- }
- }
- };
- struct InitTask : public ITaskSp
- {
- CCardReadAdapterFSM* fsm;
- InitTask(CCardReadAdapterFSM* f) : fsm(f) {}
- void Process()
- {
- FSMEvent *e = new FSMEvent(USER_EVT_INIT_FINISHED);
- e->param1 = fsm->Initial();
- fsm->PostEventFIFO(e);
- }
- };
- struct CardIssuerReadTask : public ITaskSp
- {
- CCardReadAdapterFSM* fsm;
- SpReqAnsContext<CardReadAdapterService_Read_Req, CardReadAdapterService_Read_Ans>::Pointer ctx;
- CardIssuerReadTask(CCardReadAdapterFSM* f) : fsm(f) {}
- void Process()
- {
- CardReadFinishedEvent *e = new CardReadFinishedEvent();
- e->ctx = ctx;
- e->param1 = fsm->CardIssuerRead(ctx);
- fsm->PostEventFIFO(e);
- }
- };
- struct ContactlessCardReadTask : public ITaskSp
- {
- CCardReadAdapterFSM* fsm;
- SpReqAnsContext<CardReadAdapterService_Read_Req, CardReadAdapterService_Read_Ans>::Pointer ctx;
- ContactlessCardReadTask(CCardReadAdapterFSM* f) : fsm(f) {}
- void Process()
- {
- CardReadFinishedEvent *e = new CardReadFinishedEvent();
- e->ctx = ctx;
- e->param1 = fsm->ContactlessCardRead(ctx);
- fsm->PostEventFIFO(e);
- }
- };
- struct CardSwiperReadTask : public ITaskSp
- {
- CCardReadAdapterFSM* fsm;
- SpReqAnsContext<CardReadAdapterService_Read_Req, CardReadAdapterService_Read_Ans>::Pointer ctx;
- CardSwiperReadTask(CCardReadAdapterFSM* f) : fsm(f) {}
- int x;
- void Process()
- {
- CardReadFinishedEvent *e = new CardReadFinishedEvent();
- e->ctx = ctx;
- e->param1 = fsm->CardSwiperRead(ctx,x);
- fsm->PostEventFIFO(e);
- }
- };
- struct WriteTask : public ITaskSp
- {
- CCardReadAdapterFSM* fsm;
- SpReqAnsContext<CardReadAdapterService_WriteTrack_Req, CardReadAdapterService_WriteTrack_Ans>::Pointer ctx;
- WriteTask(CCardReadAdapterFSM* f) : fsm(f) {}
- void Process()
- {
- CardWriteFinishedEvent *e = new CardWriteFinishedEvent();
- e->ctx = ctx;
- e->param1 = fsm->WriteTrack(ctx);
- fsm->PostEventFIFO(e);
- }
- };
- struct DoWorkTask : public ITaskSp
- {
- CCardReadAdapterFSM* fsm;
- int type;
- DoWorkTask(CCardReadAdapterFSM* f) : fsm(f) {}
- void Process()
- {
- //FSMEvent *e = new FSMEvent(USER_EVT_DO_WORK_FINISHED);
- //e->param1 = fsm->DoWork(type);
- //fsm->PostEventFIFO(e);
- }
- };
- struct TestCancelReadTask : public ITaskSp
- {
- CCardReadAdapterFSM* fsm;
- int type;
- TestCancelReadTask(CCardReadAdapterFSM* f) : fsm(f) {}
- void Process()
- {
- Sleep(10000);
- fsm->CancelRead();
- }
- };
- struct ReadWaitMoreTask : public ITaskSp
- {
- CCardReadAdapterFSM* fsm;
- int type;
- ReadWaitMoreTask(CCardReadAdapterFSM* f) : fsm(f) {}
- void Process()
- {
- fsm->ReadWaitMore();
- }
- };
- struct PreOnlineTask : public ITaskSp
- {
- SpReqAnsContext<CardReadAdapterService_PreOnline_Req, CardReadAdapterService_PreOnline_Ans>::Pointer ctx;
- CCardReadAdapterFSM* fsm;
- PreOnlineTask(CCardReadAdapterFSM* f) : fsm(f) {}
- void Process()
- {
- FSMEvent *e = new FSMEvent(USER_EVT_PREONLINE_FINISHED);
- e->param1 = fsm->PreOnline(ctx);
- fsm->PostEventFIFO(e);
- }
- };
- struct PostOnlineTask : public ITaskSp
- {
- SpReqAnsContext<CardReadAdapterService_PostOnline_Req, CardReadAdapterService_PostOnline_Ans>::Pointer ctx;
- CCardReadAdapterFSM* fsm;
- PostOnlineTask(CCardReadAdapterFSM* f) : fsm(f) {}
- void Process()
- {
- FSMEvent *e = new FSMEvent(USER_EVT_POSTONLINE_FINISHED);
- e->param1 = fsm->PostOnline(ctx);
- fsm->PostEventFIFO(e);
- }
- };
- struct IssueTask : public ITaskSp
- {
- SpReqAnsContext<CardReadAdapterService_Issue_Req, CardReadAdapterService_Issue_Ans>::Pointer ctx;
- CCardReadAdapterFSM* fsm;
- IssueTask(CCardReadAdapterFSM* f) : fsm(f) {}
- void Process()
- {
- FSMEvent *e = new FSMEvent(USER_EVT_ISSUE_FINISHED);
- e->param1 = fsm->IssueCard(ctx);
- fsm->PostEventFIFO(e);
- }
- };
- struct EjectTask : public ITaskSp
- {
- SpReqAnsContext<CardReadAdapterService_Eject_Req, CardReadAdapterService_Eject_Ans>::Pointer ctx;
- CCardReadAdapterFSM* fsm;
- EjectTask(CCardReadAdapterFSM* f) : fsm(f) {}
- void Process()
- {
- FSMEvent *e = new FSMEvent(USER_EVT_EJECT_FINISHED);
- e->param1 = fsm->EjectCard(ctx);
- fsm->PostEventFIFO(e);
- }
- };
- struct CaptureTask : public ITaskSp
- {
- SpReqAnsContext<CardReadAdapterService_Capture_Req, CardReadAdapterService_Capture_Ans>::Pointer ctx;
- CCardReadAdapterFSM* fsm;
- CaptureTask(CCardReadAdapterFSM* f) : fsm(f) {}
- void Process()
- {
- FSMEvent *e = new FSMEvent(USER_EVT_CAPTUREFINISHED);
- e->param1 = fsm->CaptureCard(ctx);
- fsm->PostEventFIFO(e);
- }
- };
- struct CheckSessionTask : public ITaskSp
- {
- CCardReadAdapterFSM* fsm;
- CheckSessionTask(CCardReadAdapterFSM* f) : fsm(f) {}
- void Process()
- {
- fsm->CheckAndReconnectSession();
- }
- };
- struct SetSomeFlagTask : public ITaskSp
- {
- CCardReadAdapterFSM* fsm;
- SpReqAnsContext<CardReadAdapterService_SetSomeFlag_Req, CardReadAdapterService_SetSomeFlag_Ans>::Pointer ctx;
- SetSomeFlagTask(CCardReadAdapterFSM* f) : fsm(f) {}
- void Process()
- {
- FSMEvent *e = new FSMEvent(USER_EVT_SET_SOME_FLAG_FINISHED);
- e->param1 = fsm->SetSomeFlag(ctx);
- fsm->PostEventFIFO(e);
- }
- };
- struct GetDevInfoTask : public ITaskSp
- {
- CCardReadAdapterFSM* fsm;
- SpReqAnsContext<CardReadAdapterService_GetDevInfo_Req, CardReadAdapterService_GetDevInfo_Ans>::Pointer ctx;
- GetDevInfoTask(CCardReadAdapterFSM* f) : fsm(f) {}
- void Process()
- {
- FSMEvent *e = new FSMEvent(USER_EVT_GET_DEV_INFO_FINISHED);
- e->param1 = fsm->GetDevInfo(ctx);
- fsm->PostEventFIFO(e);
- }
- };
- struct QueryCardInfoTask : public ITaskSp
- {
- CCardReadAdapterFSM* fsm;
- SpReqAnsContext<CardReadAdapterService_QueryCardInfo_Req, CardReadAdapterService_QueryCardInfo_Ans>::Pointer ctx;
- QueryCardInfoTask(CCardReadAdapterFSM* f) : fsm(f) {}
- void Process()
- {
- FSMEvent *e = new FSMEvent(USER_EVT_QUERY_CARD_INFO_FINISHED);
- e->param1 = fsm->QueryCardInfo(ctx);
- fsm->PostEventFIFO(e);
- }
- };
- struct GetMaterialCountTask : public ITaskSp
- {
- CCardReadAdapterFSM* fsm;
- SpReqAnsContext<CardReadAdapterService_GetMaterialCount_Req, CardReadAdapterService_GetMaterialCount_Ans>::Pointer ctx;
- GetMaterialCountTask(CCardReadAdapterFSM* f) : fsm(f) {}
- void Process()
- {
- FSMEvent *e = new FSMEvent(USER_EVT_GET_MATERIAL_FINISHED);
- e->param1 = fsm->GetMaterialCount(ctx);
- fsm->PostEventFIFO(e);
- }
- };
- struct SetMaterialCountTask : public ITaskSp
- {
- CCardReadAdapterFSM* fsm;
- SpReqAnsContext<CardReadAdapterService_SetMaterialCount_Req, CardReadAdapterService_SetMaterialCount_Ans>::Pointer ctx;
- SetMaterialCountTask(CCardReadAdapterFSM* f) : fsm(f) {}
- void Process()
- {
- FSMEvent *e = new FSMEvent(USER_EVT_SET_MATERIAL_FINISHED);
- e->param1 = fsm->SetMaterialCount(ctx);
- fsm->PostEventFIFO(e);
- }
- };
- struct GetSCIInfoTask : public ITaskSp
- {
- CCardReadAdapterFSM* fsm;
- SpReqAnsContext<CardReadAdapterService_GetSCIInfo_Req, CardReadAdapterService_GetSCIInfo_Ans>::Pointer ctx;
- GetSCIInfoTask(CCardReadAdapterFSM* f) : fsm(f) {}
- void Process()
- {
- FSMEvent *e = new FSMEvent(USER_EVT_GET_SCI_INFO_FINISHED);
- e->param1 = fsm->GetSCIInfo(ctx);
- fsm->PostEventFIFO(e);
- }
- };
- struct OpenSafeLockTask : public ITaskSp
- {
- CCardReadAdapterFSM* fsm;
- SpReqAnsContext<CardReadAdapterService_OpenSafeLock_Req, CardReadAdapterService_OpenSafeLock_Ans>::Pointer ctx;
- OpenSafeLockTask(CCardReadAdapterFSM* f) : fsm(f) {}
- void Process()
- {
- FSMEvent *e = new FSMEvent(USER_EVT_OPEN_SAFELOCK_FINISHED);
- e->param1 = fsm->OpenSafeLock(ctx);
- fsm->PostEventFIFO(e);
- }
- };
- struct MagTransferInitTask : public ITaskSp
- {
- CCardReadAdapterFSM* fsm;
- SpReqAnsContext<CardReadAdapterService_MagTransferInit_Req, CardReadAdapterService_MagTransferInit_Ans>::Pointer ctx;
- MagTransferInitTask(CCardReadAdapterFSM* f) : fsm(f) {}
- void Process()
- {
- FSMEvent *e = new FSMEvent(USER_EVT_MAGTRANS_INIT_FINISHED);
- e->param1 = fsm->MagTransferInit(ctx);
- fsm->PostEventFIFO(e);
- }
- };
- struct QueryConnInfoTask : public ITaskSp
- {
- CCardReadAdapterFSM* fsm;
- SpReqAnsContext<CardReadAdapterService_QueryConnInfo_Req, CardReadAdapterService_QueryConnInfo_Ans>::Pointer ctx;
- QueryConnInfoTask(CCardReadAdapterFSM* f) : fsm(f) {}
- void Process()
- {
- FSMEvent *e = new FSMEvent(USER_EVT_QUERY_CONN_INFO_FINISHED);
- e->param1 = fsm->QueryConnInfo(ctx);
- fsm->PostEventFIFO(e);
- }
- };
- struct DoExitTask : public ITaskSp
- {
- CCardReadAdapterFSM* fsm;
- DoExitTask(CCardReadAdapterFSM* f) : fsm(f) {}
- void Process()
- {
- fsm->DoExit();
- }
- };
- struct SAMICCommandTask : public ITaskSp
- {
- CCardReadAdapterFSM* fsm;
- SpReqAnsContext<CardReadAdapterService_SAMICCommand_Req, CardReadAdapterService_SAMICCommand_Ans>::Pointer ctx;
- SAMICCommandTask(CCardReadAdapterFSM* f) : fsm(f) {}
- void Process()
- {
- FSMEvent *e = new FSMEvent(USER_EVT_SAM_IC_COMMAND_FINISHED);
- e->param1 = fsm->SAMICCommand(ctx);
- fsm->PostEventFIFO(e);
- }
- };
- struct QueryPrinterStatusTask : public ITaskSp
- {
- CCardReadAdapterFSM* fsm;
- SpReqAnsContext<CardReadAdapterService_QueryPrinterStatus_Req, CardReadAdapterService_QueryPrinterStatus_Ans>::Pointer ctx;
- QueryPrinterStatusTask(CCardReadAdapterFSM* f) : fsm(f) {}
- void Process()
- {
- FSMEvent *e = new FSMEvent(USER_EVT_QUERY_PRINTER_STATUS_FINISHED);
- e->param1 = fsm->QueryPrinterStatus(ctx);
- fsm->PostEventFIFO(e);
- }
- };
- struct PrintTask : public ITaskSp
- {
- CCardReadAdapterFSM* fsm;
- SpReqAnsContext<CardReadAdapterService_Print_Req, CardReadAdapterService_Print_Ans>::Pointer ctx;
- PrintTask(CCardReadAdapterFSM* f) : fsm(f) {}
- void Process()
- {
- FSMEvent *e = new FSMEvent(USER_EVT_PRINT_FINISHED);
- e->param1 = fsm->Print(ctx);
- fsm->PostEventFIFO(e);
- }
- };
- struct QuerySCIListTask : public ITaskSp
- {
- CCardReadAdapterFSM* fsm;
- SpReqAnsContext<CardReadAdapterService_QuerySCIList_Req, CardReadAdapterService_QuerySCIList_Ans>::Pointer ctx;
- QuerySCIListTask(CCardReadAdapterFSM* f) : fsm(f) {}
- void Process()
- {
- FSMEvent *e = new FSMEvent(USER_EVT_QUERY_SCILIST_FINISHED);
- e->param1 = fsm->QuerySCIList(ctx);
- fsm->PostEventFIFO(e);
- }
- };
- struct BindSCITask : public ITaskSp
- {
- CCardReadAdapterFSM* fsm;
- SpReqAnsContext<CardReadAdapterService_BindSCI_Req, CardReadAdapterService_BindSCI_Ans>::Pointer ctx;
- BindSCITask(CCardReadAdapterFSM* f) : fsm(f) {}
- void Process()
- {
- FSMEvent *e = new FSMEvent(USER_EVT_BIND_SCI_FINISHED);
- e->param1 = fsm->BindSCI(ctx);
- fsm->PostEventFIFO(e);
- }
- };
- struct PreOnlineOnStoreTask : public ITaskSp
- {
- CCardReadAdapterFSM* fsm;
- SpReqAnsContext<CardReadAdapterService_PreOnlineOnStore_Req, CardReadAdapterService_PreOnlineOnStore_Ans>::Pointer ctx;
- PreOnlineOnStoreTask(CCardReadAdapterFSM* f) : fsm(f) {}
- void Process()
- {
- fsm->PreOnlineOnStore(ctx);
- }
- };
- struct GetAddCardInfoTask : public ITaskSp
- {
- CCardReadAdapterFSM* fsm;
- SpReqAnsContext<CardReadAdapterService_GetAddCardInfo_Req, CardReadAdapterService_GetAddCardInfo_Ans>::Pointer ctx;
- GetAddCardInfoTask(CCardReadAdapterFSM* f) : fsm(f) {}
- void Process()
- {
- FSMEvent *e = new FSMEvent(USER_EVT_GET_ADD_CARD_INFO_FINISHED);
- e->param1 = fsm->GetAddCardInfo(ctx);
- fsm->PostEventFIFO(e);
- }
- };
- struct NotifyPreOnlineTask : public ITaskSp
- {
- CCardReadAdapterFSM* fsm;
- SpReqAnsContext<CardReadAdapterService_NotifyPreonline_Req, CardReadAdapterService_NotifyPreonline_Ans>::Pointer ctx;
- NotifyPreOnlineTask(CCardReadAdapterFSM* f) : fsm(f) {}
- void Process()
- {
- FSMEvent* e = new FSMEvent(USER_EVT_PREONLINE_ON_STORE_FINISHED);
- e->param1 = fsm->NotifyPreonline(ctx);
- fsm->PostEventFIFO(e);
- }
- };
- struct QueryCardInfoOnStoreTask : public ITaskSp
- {
- CCardReadAdapterFSM* fsm;
- SpReqAnsContext<CardReadAdapterService_QueryCardInfoOnStore_Req, CardReadAdapterService_QueryCardInfoOnStore_Ans>::Pointer ctx;
- QueryCardInfoOnStoreTask(CCardReadAdapterFSM* f) : fsm(f) {}
- void Process()
- {
- FSMEvent *e = new FSMEvent(USER_EVT_QUERY_CARD_INFO_ON_STORE_FINISHED);
- e->param1 = fsm->QueryCardInfoOnStore(ctx);
- fsm->PostEventFIFO(e);
- }
- };
- struct CrossTermCallTask : public ITaskSp
- {
- CCardReadAdapterFSM* fsm;
- SpReqAnsContext<CardReadAdapterService_CrossTermCall_Req, CardReadAdapterService_CrossTermCall_Ans>::Pointer ctx;
- CrossTermCallTask(CCardReadAdapterFSM* f) : fsm(f) {}
- void Process()
- {
- FSMEvent *e = new FSMEvent(USER_EVT_CROSS_TERM_CALL_FINISHED);
- e->param1 = fsm->CrossTermCall(ctx);
- fsm->PostEventFIFO(e);
- }
- };
- struct PrintCardImTask : public ITaskSp
- {
- CCardReadAdapterFSM* fsm;
- SpReqAnsContext<CardReadAdapterService_PrintCardImmediately_Req, CardReadAdapterService_PrintCardImmediately_Ans>::Pointer ctx;
- PrintCardImTask(CCardReadAdapterFSM* f) : fsm(f) {}
- void Process()
- {
- FSMEvent* e = new FSMEvent(USER_EVT_PRINT_CARD_IM_FINISHED);
- e->param1 = fsm->PrintCardIm(ctx);
- fsm->PostEventFIFO(e);
- }
- };
- struct QueryCIStatusTask : public ITaskSp
- {
- CCardReadAdapterFSM* fsm;
- SpReqAnsContext<CardReadAdapterService_QueryCIStatus_Req, CardReadAdapterService_QueryCIStatus_Ans>::Pointer ctx;
- QueryCIStatusTask(CCardReadAdapterFSM* f) : fsm(f) {}
- void Process()
- {
- FSMEvent* e = new FSMEvent(USER_EVT_QUERY_CI_STATUS_FINISHED);
- e->param1 = fsm->QueryCIStatus(ctx);
- fsm->PostEventFIFO(e);
- }
- };
- struct Test1Task : public ITaskSp
- {
- CCardReadAdapterFSM* fsm;
- SpReqAnsContext<CardReadAdapterService_Test1_Req, CardReadAdapterService_Test1_Ans>::Pointer ctx;
- Test1Task(CCardReadAdapterFSM* f) : fsm(f) {}
- void Process()
- {
- FSMEvent *e = new FSMEvent(USER_EVT_TEST1_FINISHED);
- e->param1 = fsm->Test1(ctx);
- fsm->PostEventFIFO(e);
- }
- };
- struct Test2Task : public ITaskSp
- {
- CCardReadAdapterFSM* fsm;
- SpReqAnsContext<CardReadAdapterService_Test2_Req, CardReadAdapterService_Test2_Ans>::Pointer ctx;
- Test2Task(CCardReadAdapterFSM* f) : fsm(f) {}
- void Process()
- {
- FSMEvent *e = new FSMEvent(USER_EVT_TEST1_FINISHED);
- e->param1 = fsm->Test2(ctx);
- fsm->PostEventFIFO(e);
- }
- };
- struct WaitCardActiveTask : public ITaskSp
- {
- CCardReadAdapterFSM* fsm;
- WaitCardActiveTask(CCardReadAdapterFSM* f) : fsm(f) {}
- void Process()
- {
- fsm->WaitCardActive();
- }
- };
- #endif //__CARDREAD_ADAPTER_FSM_H
|