mod_FingerPrint.h 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. #ifndef MOD_FINGERPRINT_H
  2. #define MOD_FINGERPRINT_H
  3. #include "FingerPrintFSM.h"
  4. #include "FingerPrint_server_g.h"
  5. #include "modVer.h"
  6. #ifdef RVC_OS_WIN
  7. #else
  8. #include "SpTest.h"
  9. #endif
  10. class CFingerPrintEntity;
  11. class FingerPrintServerSession : public FingerPrint::FingerPrintService_ServerSessionBase
  12. {
  13. public:
  14. FingerPrintServerSession(CFingerPrintEntity* pEntity) : m_pEntity(pEntity){}
  15. virtual ~FingerPrintServerSession(){}
  16. virtual void Handle_GetImageAndFeature(SpReqAnsContext<FingerPrintService_GetImageAndFeature_Req, FingerPrintService_GetImageAndFeature_Ans>::Pointer ctx);
  17. virtual void Handle_GetImageAndFeatureEx(SpReqAnsContext<FingerPrintService_GetImageAndFeatureEx_Req, FingerPrintService_GetImageAndFeatureEx_Ans>::Pointer ctx);
  18. virtual void Handle_GetFingerPrint(SpReqAnsContext<FingerPrintService_GetFingerPrint_Req, FingerPrintService_GetFingerPrint_Ans>::Pointer ctx);
  19. virtual void Handle_GenerateTemplate(SpReqAnsContext<FingerPrintService_GenerateTemplate_Req, FingerPrintService_GenerateTemplate_Ans>::Pointer ctx);
  20. virtual void Handle_CancelRegister(SpOnewayCallContext<FingerPrintService_CancelRegister_Info>::Pointer ctx);
  21. virtual void Handle_CancelMatch(SpOnewayCallContext<FingerPrintService_CancelMatch_Info>::Pointer ctx);
  22. virtual void Handle_GetDevInfo(SpReqAnsContext<FingerPrintService_GetDevInfo_Req, FingerPrintService_GetDevInfo_Ans>::Pointer ctx);
  23. virtual void Handle_GetDevStatus(SpReqAnsContext<FingerPrintService_GetDevStatus_Req, FingerPrintService_GetDevStatus_Ans>::Pointer ctx);
  24. virtual void Handle_Match(SpReqAnsContext<FingerPrintService_Match_Req, FingerPrintService_Match_Ans>::Pointer ctx);
  25. virtual void Handle_Exit(SpOnewayCallContext<FingerPrintService_Exit_Info>::Pointer ctx);
  26. private:
  27. CFingerPrintEntity* m_pEntity;
  28. };
  29. class CFingerPrintEntity : public CDevAdptEntityBase, public ISysVarListener
  30. {
  31. public:
  32. CFingerPrintEntity(){}
  33. virtual ~CFingerPrintEntity(){}
  34. virtual const char *GetEntityName() const { return "FingerPrint"; }
  35. virtual bool IsService() const {return true;}
  36. #ifdef RVC_OS_WIN
  37. #else
  38. virtual const char* GetEntityVersion() const { return MODULE_VERSION_FULL; }
  39. ON_ENTITYT_TEST()
  40. #endif
  41. virtual void OnPreStart(CAutoArray<CSimpleStringA> strArgs,CSmartPointer<ITransactionContext> pTransactionContext)
  42. {
  43. LOG_FUNCTION();
  44. ErrorCodeEnum ec = m_fsm.Init(this);
  45. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("OnPreStart, Init:%d", ec);
  46. GetFunction()->RegistSysVarEvent("FWBReConn", this);
  47. GetFunction()->RegistSysVarEvent("UIState", this);
  48. pTransactionContext->SendAnswer(ec);
  49. }
  50. virtual void OnPrePause(CSmartPointer<ITransactionContext> pTransactionContext)
  51. {
  52. LOG_FUNCTION();
  53. pTransactionContext->SendAnswer(Error_Succeed);
  54. }
  55. virtual void OnPreContinue(CSmartPointer<ITransactionContext> pTransactionContext)
  56. {
  57. LOG_FUNCTION();
  58. pTransactionContext->SendAnswer(Error_Succeed);
  59. }
  60. virtual void OnPreClose(EntityCloseCauseEnum eCloseCause, CSmartPointer<ITransactionContext> pTransactionContext)
  61. {
  62. LOG_FUNCTION();
  63. m_fsm.OnExit();
  64. pTransactionContext->SendAnswer(Error_Succeed);
  65. }
  66. virtual void OnSelfTest(EntityTestEnum eTestType, CSmartPointer<ITransactionContext> pTransactionContext)
  67. {
  68. //LOG_FUNCTION();
  69. m_fsm.SelfTest(eTestType, pTransactionContext);
  70. }
  71. virtual CServerSessionBase* OnNewSession(const char* , const char * )
  72. {
  73. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("A new connecting request arrived.");
  74. m_bNewSessionInit = true;
  75. return new FingerPrintServerSession(this);
  76. }
  77. //废弃
  78. void GetImageAndFeature(SpReqAnsContext<FingerPrintService_GetImageAndFeature_Req, FingerPrintService_GetImageAndFeature_Ans>::Pointer ctx)
  79. {
  80. //ScanEvent* e = new ScanEvent();
  81. //e->ctx = ctx;
  82. //m_fsm.PostEventFIFO(e);
  83. LogWarn(Severity_Low, Error_Unexpect, LOG_ERR_FINGERPRINT_REQUEST_REFUSE, "web invoke GetImageAndFeature request refuse");
  84. ctx->Answer(Error_Exception);
  85. }
  86. //废弃
  87. void GetImageAndFeatureEx(SpReqAnsContext<FingerPrintService_GetImageAndFeatureEx_Req, FingerPrintService_GetImageAndFeatureEx_Ans>::Pointer ctx)
  88. {
  89. //ScanExEvent* e = new ScanExEvent();
  90. //e->ctx = ctx;
  91. //m_fsm.PostEventFIFO(e);
  92. LogWarn(Severity_Low, Error_Unexpect, LOG_ERR_FINGERPRINT_REQUEST_REFUSE, "web invoke GetImageAndFeatureEx request refuse");
  93. ctx->Answer(Error_Exception);
  94. }
  95. //有用:扫描指纹(73294)
  96. void GetFingerPrint(SpReqAnsContext<FingerPrintService_GetFingerPrint_Req, FingerPrintService_GetFingerPrint_Ans>::Pointer ctx)
  97. {
  98. if(!m_fsm.GetDevInitFlag()){
  99. ctx->Answer(Error_DevNotAvailable);
  100. LogWarn(Severity_Middle, Error_DevNotAvailable, FingerPrint_UserErrorCode_DevOpen_Failed_Registe, "GetFingerPrint but DevOpen failed.");
  101. }
  102. else{
  103. GetFingerEvent* e = new GetFingerEvent();
  104. e->ctx = ctx;
  105. m_fsm.PostEventFIFO(e);
  106. }
  107. }
  108. //有用:生成指纹模板(161)
  109. void GenerateTemplate(SpReqAnsContext<FingerPrintService_GenerateTemplate_Req, FingerPrintService_GenerateTemplate_Ans>::Pointer ctx)
  110. {
  111. GenerateTemplateEvent* e = new GenerateTemplateEvent();
  112. e->ctx = ctx;
  113. m_fsm.PostEventFIFO(e);
  114. }
  115. //有用:取消注册(7066)
  116. void CancelRegister(SpOnewayCallContext<FingerPrintService_CancelRegister_Info>::Pointer ctx)
  117. {
  118. CancelRegisterEvent* e = new CancelRegisterEvent();
  119. m_fsm.PostEventFIFO(e);
  120. }
  121. //有用:取消对比(56)
  122. void CancelMatch(SpOnewayCallContext<FingerPrintService_CancelMatch_Info>::Pointer ctx)
  123. {
  124. CancelMatchEvent* e = new CancelMatchEvent();
  125. m_fsm.PostEventFIFO(e);
  126. }
  127. //废弃
  128. void CheckAndMatch(SpReqAnsContext<FingerPrintService_Match_Req, FingerPrintService_Match_Ans>::Pointer ctx)
  129. {
  130. //MatchEvent* e = new MatchEvent();
  131. //e->ctx = ctx;
  132. //m_fsm.PostEventFIFO(e);
  133. LogWarn(Severity_Low, Error_Unexpect, LOG_ERR_FINGERPRINT_REQUEST_REFUSE, "web invoke CheckAndMatch request refuse");
  134. ctx->Answer(Error_Exception);
  135. }
  136. //设备安装状态使用
  137. void GetDevInfo(SpReqAnsContext<FingerPrintService_GetDevInfo_Req, FingerPrintService_GetDevInfo_Ans>::Pointer ctx)
  138. {
  139. DevCategoryInfo devCatInfo;
  140. m_fsm.GetDevCatInfo(devCatInfo);
  141. ctx->Ans.model = devCatInfo.szModel;
  142. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("GetDevInfo model is:%s", (const char*)ctx->Ans.model);
  143. ctx->Ans.state = (int)m_fsm.GetDevState();
  144. ctx->Answer(Error_Succeed);
  145. }
  146. //废弃
  147. void GetDevStatus(SpReqAnsContext<FingerPrintService_GetDevStatus_Req, FingerPrintService_GetDevStatus_Ans>::Pointer ctx)
  148. {
  149. int status = 0;
  150. m_fsm.GetDevState(status);
  151. ctx->Ans.status = status;
  152. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("FingerPrint state is:%d", status);
  153. ctx->Answer(Error_Succeed);
  154. }
  155. //废弃
  156. void Exit(SpOnewayCallContext<FingerPrintService_Exit_Info>::Pointer ctx)
  157. {
  158. FSMEvent* e = new FSMEvent(USER_EVT_EXIT);
  159. m_fsm.PostEventFIFO(e);
  160. }
  161. virtual void OnSysVarEvent(const char *pszKey,
  162. const char *pszValue, const char *pszOldValue, const char *pszEntityName);
  163. private:
  164. CFingerPrintFSM m_fsm;
  165. bool m_bNewSessionInit;
  166. };
  167. #endif