123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273 |
- #ifndef __MOD_GPIO_H
- #define __MOD_GPIO_H
- #include "modVer.h"
- #include "SpBase.h"
- #include "GpioClass.h"
- #include "Gpio_server_g.h"
- #include "EventCode.h"
- #include "Gpio_UserErrorCode.h"
- #include "DevFSMCommBase.hpp"
- #include "CommEntityUtil.hpp"
- using namespace std;
- using namespace Gpio;
- #define GpioService_LogCode_Detect_DoorOpen "QLR0402209A1"
- #define GpioService_LogCode_Detect_PhonePickup "QLR0402209A2"
- #define GpioService_LogCode_Detect_CardMouseJam "QLR0402209A3"
- #define GpioService_LogCode_Detect_DoorClose "QLR0402209A4"
- #define GpioService_LogCode_Detect_PhonePutDown "QLR0402209A5"
- enum OutputMode{
- OM_POSITIVE_LEVEL,
- OM_POSITIVE_FLICKER,
- OM_NEGATIVE_FLICKER
- };
- enum StopMode{
- SM_CALLTRIGGER,
- SM_TIMEOUT,
- SM_CYCLE
- };
- enum PinPort {
- VIBRATIONSENSOR, /**震动探测器*/
- OPENSENSOR, /*开机箱门感应器*/
- PICKUPSENSOR, /*话机感应器*/
- MOVESENSOR, /**人体探测感应器*/
- CARDGATESENSOR, /**发卡器卡嘴感应器*/
- };
- /*用于标识等挂机等状态,布尔型不能满足,需要有一个初始状态*/
- enum PinActiveStatus
- {
- UnknownStatus,
- InActive,
- Actived
- };
- struct OutDrivingInfo
- {
- ULONG Port;
- int OutputMode;
- int StopMode;
- int SetTime;
- int ResetTime;
- int TimeOut;
- };
- struct ReceivingInfo
- {
- ULONG Port;
- int ContinuousTriggerTime;
- };
- enum LightSeq {
- UNKNOWN_DEVICE,
- CARDREADER,
- CARDREADER_RED,
- IDCERTIFICATE,
- PINPAD,
- PINPADLIGHT,
- SHAKEDETECT,
- SWITCHINDUCTOR,
- PHONEPICKUP,
- MOVEDETECT,
- CARDGATEDETECT,
- HEADLIGHT,
- HEADLIGHT_RED,
- CONTACTLESSCARD,
- HEADLIGHT_ASSIST,
- HSPSCANNER,
- FINGERPRINT
- };
- /** 添加注释:对应规格说明书中的引脚信号,这里是从0开始,适应程序 [Gifur@202494]*/
- enum DevicePinSeq
- {
- PIN_CARD_READER_LIGHT = 0,
- PIN_USB_CONTROL_SWITCH, //已下线
- PIN_IDCERTIFICATE_LIGHT,
- PIN_PINPAD_LIGHT,
- PIN_HEAD_LIGHT,
- PIN_TROUBLE_LIGHT = 5,
- PIN_CARD_ISSUE_MAINTAIN_LIGHT,
- PIN_USB_CONTROL_LIGHT,//已下线
- PIN_CONTACELESS_LIGHT,
- PIN_RESERVED1, //RESERVED未使用,下同
- PIN_FINGERPRINT_LIGHT = 10,
- PIN_RESERVED2,
- PIN_HSPSCANNER_PREVIEW_LIGHT,
- PIN_RESERVED3,
- PIN_RESERVED4,
- PIN_RESERVED5 = 15,
- PIN_DETECT_SHAKE = 16,
- PIN_DETECT_OPENDOOR,
- PIN_DETECT_PHONE,
- PIN_DETECT_BODY,
- PIN_HSPSCANNER_LIGHT = 25
- };
- struct GpioService_Set_Info
- {
- int devseq;
- int mode;
- int close;
- };
- class CGpioEntity;
- class CGpioServiceSession : public GpioService_ServerSessionBase
- {
- public:
- CGpioServiceSession(CGpioEntity* pEntity):m_pEntity(pEntity){};
- virtual void Handle_GetDevInfo(SpReqAnsContext<GpioService_GetDevInfo_Req,
- GpioService_GetDevInfo_Ans>::Pointer ctx);
- virtual void Handle_Exit(SpOnewayCallContext<GpioService_Exit_Info>::Pointer ctx);
- private:
- CGpioEntity* m_pEntity;
- };
- struct SetContextInfo
- {
- ULONG timerID;
- ULONG pinSeq;
- int setTime;
- int resetTime;
- int timeout;
- };
- struct GetContextInfo
- {
- ULONG timerID;
- };
- class CGpioEntity : public CDevAdptEntityBase, public ILogListener, ISysVarListener
- {
- public:
- //0000 0000 0000 0010 0110 1111 1100 0000
- CGpioEntity():m_ePickUpFlag(UnknownStatus)
- ,m_bVibrationFlag(false),m_bOpenFlag(false),m_bMoveFlag(false),m_bCardGateFlag(false)
- , m_pLogListener(NULL), m_bHeadLightFlag(false), m_headlightDevPort(4), m_moveHoldTimes(0)
- , m_moveDisappearTimes(0),m_eMachineType(SP::Module::Comm::RVC_UNKNOWN)
- , m_bNewVersion(FALSE), m_bFuncVer2(FALSE)
- , m_bOpened(false), m_bOpening(true), m_btLastRevcInput(-1), m_iInWhatPage(PageType_Init)
- {
- memset(m_btOutputStatus,0,MAX_PORT_NUM*sizeof(BYTE));
- }
- virtual ~CGpioEntity(){}
- virtual const char* GetEntityName()const {return "Gpio";}
- const char* GetEntityVersion() const { return MODULE_VERSION_FULL; }
-
- virtual void OnPreStart(CAutoArray<CSimpleStringA> strArgs, CSmartPointer<ITransactionContext> pTransactionContext);
- virtual void OnPrePause(CSmartPointer<ITransactionContext> pTransactionContext)
- {
- pTransactionContext->SendAnswer(Error_Succeed);
- }
- virtual void OnPreClose(EntityCloseCauseEnum eCloseCause,CSmartPointer<ITransactionContext> pTransactionContext)
- {
- if(m_hDevHelper != nullptr) m_hDevHelper.TearDown();
- pTransactionContext->SendAnswer(Error_Succeed);
- }
- virtual CServerSessionBase *OnNewSession(const char* /*pszRemoteEntityName*/, const char * pszClass)
- {
- return new CGpioServiceSession(this);
- }
- void OnSelfTest(EntityTestEnum eTestType, CSmartPointer<ITransactionContext> pTransactionContext);
- virtual bool IsService()const { return true; }
- virtual bool IsMultiThread()const { return false; }
- virtual void OnSysVarEvent(const char* pszKey,
- const char* pszValue, const char* pszOldValue, const char* pszEntityName);
- void GetDevInfo(SpReqAnsContext<GpioService_GetDevInfo_Req,
- GpioService_GetDevInfo_Ans>::Pointer ctx);
- void Exit(SpOnewayCallContext<GpioService_Exit_Info>::Pointer ctx) {}
- //////////////////////////////////////////////////////////////////////////
- ErrorCodeEnum Initial();
- void OnPositiveFlickerSetTimerout(void *pData);
- void OnPositiveFlickerResetTimerout(void *pData);
- void OnEventDetect(void* pData);
- //开了一个监听线程,用于监听震动、开关门等事件
- void StartDetectWorkThread();
- void Set(GpioService_Set_Info info);
- void SetEx(GpioService_Set_Info info);
- bool SetOutDriving(GpioService_Set_Info req, OutDrivingInfo od, ULONG iIndex, ULONG devSeq);
- void WritePin(DWORD dwPinSeq,bool bHighLevel);
- virtual void OnLog(const CAutoArray<CUUID> &SubIDs, const CUUID nLogID,const LogTypeEnum eLogType, const SeverityLevelEnum eLevel,
- const DWORD dwSysError,const DWORD dwUserCode,const DWORD dwEntityInstanceID, const WORD wEntityDevelID,
- const CAutoArray<DWORD> &Param, const char *pszEntityName, const char *pszModuleName,const char *pszMessage, const linkContext& pLinkInfo);
- void ToLogRootINIInfo();
- void ToLogWarnInfoAboutTerm(const AdapterInfo& m_adapterInfo);
- void SetErrorAndLog(ErrorCodeEnum errCode, DWORD userCode, CSimpleStringA devApi, CSimpleStringA funPath, bool bInBusiness = false, int costTime = 0, CSimpleStringA logCode = "", CSimpleStringA context = "");
- public:
- CUUID m_uuidHealth, m_uuidCR, m_uuidIDC, m_uuidFP, m_uuidKB, m_uuidCA, m_uuidCC, m_uuidDD, m_uuidCS;
- CUUID m_uuidHSPscanner;
- private:
- bool DetectBit(ULONG data, int pos);
- bool IsInBusiness() const { return (m_iInWhatPage == PageType_Other); }
- void SetInWhatPage(int iPageType) { m_iInWhatPage = iPageType; }
- private:
- DevAdptLibHelper<GpioClass> m_hDevHelper;
- SP::Module::Comm::What m_eMachineType;
- BYTE m_btOutputStatus[MAX_PORT_NUM];
- BOOL m_bNewVersion;
- BOOL m_bFuncVer2;
- BYTE m_btLastRevcInput;
- bool m_bVibrationFlag,m_bOpenFlag,m_bMoveFlag,m_bCardGateFlag;
- PinActiveStatus m_ePickUpFlag;
- unsigned long m_PickUpTimeStamp;
- unsigned long m_PutDownTimeStamp;
- unsigned long m_DoorOpenTimeStamp;
- unsigned long m_DoorCloseTimeStamp;
- bool m_bHeadLightFlag;
- int m_headlightDevPort;
- unsigned long m_moveHoldTimes, m_moveDisappearTimes;
- ILogListener *m_pLogListener;
- AdapterInfo m_adapterInfo;
- bool m_bOpened;
- bool m_bOpening;
- int m_iInWhatPage/*在哪个页面,区分首页,用户桌面,其他页*/;
- };
- template<class T>
- class TimerOutHelper : public ITimerListener
- {
- public:
- typedef void (T::*FuncTimer)(void *pUserdata);
- TimerOutHelper(T *p, FuncTimer pTimerFunc, void *pUserData, bool bDeleteSelf = false)
- : m_pObject(p), m_pUserData(pUserData), m_pTimer(pTimerFunc), m_bDeleteSelf(bDeleteSelf) {}
- virtual void OnTimeout(DWORD dwTimerID)
- {
- (m_pObject->*m_pTimer)(m_pUserData);
- if (m_bDeleteSelf)
- delete this;
- }
- private:
- void *m_pUserData;
- T *m_pObject;
- FuncTimer m_pTimer;
- bool m_bDeleteSelf;
- };
- #endif //__MOD_GPIO_H
|