#pragma once #include #include #include "HsmsAction.h" #include #include #include #include "CCollectionEvent.h" #define EQCONSTANT_VALUE_MAX 64 #define COMMAND_NAME_MAX 64 #define COMMAND_VALUE_MAX 64 #define REPORT_NAME_MAX 64 #define VALUE_NAME_MAX 64 #define ER_NOERROR 0 #define ER_NOTSELECT -1 #define ER_BUSY -2 #define ER_PARAM_ERROR -3 /* * ³£Á¿Êý¾Ý½á¹¹ */ typedef struct _EQConstant { unsigned int id; char szValue[EQCONSTANT_VALUE_MAX]; } EQConstant; /* * Command Êý¾Ý½á¹¹ */ typedef struct _CommandParameter { char szName[COMMAND_NAME_MAX]; char szValue[COMMAND_VALUE_MAX]; } CommandParameter; /* * Report Êý¾Ý½á¹¹ */ typedef struct _REPORT { char szName[REPORT_NAME_MAX]; unsigned int id; } REPORT; /* * Value Êý¾Ý½á¹¹ */ typedef struct _VALUE { char szName[VALUE_NAME_MAX]; unsigned int id; } VALUE; typedef std::function SECSEQOFFLINE; typedef std::function&)> SECSEQCONSTANTREQUEST; typedef std::function&)> SECSCommand; typedef std::function DATETIMESYNC; typedef std::function& ids)> EDEVENTREPORT; typedef std::function EDALARMREPORT; typedef struct _SECSListener { SECSEQOFFLINE onEQOffLine; SECSEQOFFLINE onEQOnLine; SECSEQCONSTANTREQUEST onEQConstantRequest; SECSEQCONSTANTREQUEST onEQConstantSend; SECSCommand onCommand; DATETIMESYNC onDatetimeSync; EDEVENTREPORT onEnableDisableEventReport; EDALARMREPORT onEnableDisableAlarmReport; } SECSListener; class CModel; class CHsmsPassive { public: CHsmsPassive(); ~CHsmsPassive(); public: /* ÉèÖûúÆ÷ÐͺŠ×î´ó³¤¶È 20 bytes */ void setEquipmentModelType(const char* pszMode); /* ÉèÖÃÈí¼þ°æ±¾ºÅ ×î´ó³¤¶È 20 bytes */ void setSoftRev(const char* pszRev); /* Ìí¼ÓReport */ void addReport(unsigned int id, const char* pszName); // Á¬½ÓReport void linkEventReport(unsigned int RPTID, unsigned int CEID); // È¡ÏûÁ¬½Óreport void unlinkEventReport(unsigned int CEID); unsigned int getCEID(int RPTID); // define Report void defineReport(unsigned int VID, unsigned int RPTID); // È¡Ïû define report void deleteReport(unsigned int RPTID); // È¡Ïû/ɾ³ýËùÓÐ define report void deleteAllReport(); // ´ÓÎļþÖмÓÔØCVariableÁбí int loadVarialbleList(const char* pszFilepath); void setListener(SECSListener listener); unsigned OnCimWork(); void OnTimer(UINT nTimerid); void setActionTimeout(int nSecond); int init(CModel* pModel, const char* pszName, unsigned int port); int term(); public: /* request¿ªÍ·µÄº¯ÊýΪÖ÷¶¯·¢ËÍÊý¾ÝµÄº¯Êý */ int requestAreYouThere(); int requestAlarmReport(int ALCD, int ALID, const char* ALTX); int requestEventReportSend(unsigned int DATAID, unsigned int RPTID, const std::vector& values); private: void replyAck(int s, int f, unsigned int systemBytes, BYTE ack, const char* pszAckName); /* reply¿ªÍ·µÄº¯ÊýΪ»Ø¸´º¯Êý */ int replyAreYouThere(IMessage* pRecv); int replyEstablishCommunications(IMessage* pRecv); int replyOnLine(IMessage* pRecv); int replyOffLine(IMessage* pRecv); int replyEquipmentConstantRequest(IMessage* pRecv); int replyEquipmentConstantSend(IMessage* pRecv); int replyDatetime(IMessage* pRecv); int replyDefineReport(IMessage* pRecv); int replyLinkEventReport(IMessage* pRecv); int replyEanbleDisableEventReport(IMessage* pRecv); int replyCommand(IMessage* pRecv); int replyEanbleDisableAlarmReport(IMessage* pRecv); int replyQueryPPIDList(IMessage* pRecv); int replyTerminalDisplay(IMessage* pRecv); private: inline void Lock() { EnterCriticalSection(&m_criticalSection); } inline void Unlock() { LeaveCriticalSection(&m_criticalSection); } int onRecvMsg(IMessage* pMessage); void clearAllVariabel(); private: CModel* m_pModel; IPassive* m_pPassive; int m_nActionTimeout; unsigned int m_nSystemByte; unsigned short m_nSessionId; BOOL m_bAreYouThereRequest; std::string m_strEquipmentModelType; std::string m_strSoftRev; CRITICAL_SECTION m_criticalSection; std::list m_listAction; std::list m_listActionSent; private: SECSListener m_listener; BOOL m_bCimWorking; HANDLE m_hCimWorkEvent; HANDLE m_hCimWorkThreadHandle; unsigned m_nCimWorkThrdaddr; private: // RPTID to CEID std::map m_mapReportIdToCEID; // RPTID to Report std::map m_mapReport; // VID to RPTID std::map m_mapValueIdToPRTID; // VID to Report std::map m_mapValue; // CVariable vector std::vector m_variabels; };