123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146 |
- #pragma once
- #define LOGICDEVICE_API
- #include <uuid/uuid.h>
- #include "Definitions.h"
- #include "ResDataObject.h"
- #include "logger.h"
- #include "DPC.h"
- #include "CcosLock.h"
- //#ifndef GUID
- //typedef struct _GUID {
- // unsigned int Data1;
- // unsigned int Data2;
- // unsigned int Data3;
- // char Data4[8];
- //} GUID;
- //#endif
- typedef enum _SyslogLevel {
- Syslog_Debug = 0,
- Syslog_Information = 1,
- Syslog_Warning = 2,
- Syslog_Recoverable = 3,
- Syslog_Error = 4,
- Syslog_Fatal = 5,
- Syslog_Telegram = 6,
- Syslog_XReset = 7,
- Syslog_MAX
- }SYSLOGLEVEL;
- #define SYSLOG_DEBUG(Code,format,...) SystemLog(Syslog_Debug,Code,format,__VA_ARGS__)
- #define SYSLOG_INFO(Code,format,...) SystemLog(Syslog_Information,Code,format,__VA_ARGS__)
- #define SYSLOG_WARNING(Code,format,...) SystemLog(Syslog_Warning,Code,format,__VA_ARGS__)
- #define SYSLOG_ERROR(Code,format,...) SystemLog(Syslog_Error,Code,format,__VA_ARGS__)
- #define SYSLOG_FATAL(Code,format,...) SystemLog(Syslog_Fatal,Code,format,__VA_ARGS__)
- class LogicDevice;
- class LOGICDEVICE_API LogicDeviceSysIF
- {
- protected:
- LogicDevice *m_pLogicDev;
- public:
- LogicDeviceSysIF(void);
- virtual ~LogicDeviceSysIF(void);
- //init
- void SetLogicDevice(LogicDevice *p);
- LogicDevice* GetLogicDevice();
- //Command In and Out
- //notify from lower layer
- virtual RET_STATUS CmdFromLogicDev(ResDataObject *pCmd);
- //notify to lower layer
- virtual RET_STATUS CmdToLogicDev(ResDataObject *pCmd);
- };
- class LOGICDEVICE_API LogicDevice : public CcosLock
- {
- //friend class LogicDeviceSysIF;
- LogicDeviceSysIF *m_pSysLogic;
- protected:
- Logger *m_pLogger;
- char *m_pDevInstance;
- ResDataObject *m_pResErrorList;
- pthread_cond_t m_EvtNotify;
- pthread_mutex_t m_EvtMutex;
- // Linux替换: 使用信号量
- sem_t m_SemphRequest;
- sem_t m_SemphPublish;
- DriverDPC *m_pDrvDPC;//设备对象的HOST
- RET_STATUS SystemLog(SYSLOGLEVEL Level, const char *pCode, const char* fmt, ...);
- RET_STATUS IoSystemLog(int Level, const char* pCode, const char* pContext,size_t ContextSize, const char* pAppId = "");
- bool CheckFeatureLicense(const char *pszFeatureId);
-
- virtual RET_STATUS HW_ACTION AddErrorMessageBase(const char* DevInstance, const char* Code, int &Level, const char* ResInfo, const char* Description, int nMessageType = 0, const char* pAppId = "");
- public:
- LogicDevice(void);
- virtual ~LogicDevice(void);
- //1. init part
- void SYSTEM_CALL SetSysLogicDevice(LogicDeviceSysIF PARAM_IN *pLogic);
- void SYSTEM_CALL SetLogHandle(Logger PARAM_IN *pLogger);
- //2. common part
- Logger *GetLogHandle();
- void SetDrvDPC(DriverDPC *pDPC);
- DriverDPC *GetDrvDPC();
- HANDLE GetEvtHandle();
- void NotifyDrvThread();
- virtual RET_STATUS SYSTEM_CALL EvtProcedure();//m_EvtNotify事件发生后,由上层驱动线程进行调入.
- //use windows Thread Priorities
- //THREAD_PRIORITY_NONE (use common thread)
- //THREAD_PRIORITY_IDLE (use independent thread with priority)
- //THREAD_PRIORITY_LOWEST (...)
- //THREAD_PRIORITY_BELOW_NORMAL(...)
- //THREAD_PRIORITY_NORMAL(...)
- //THREAD_PRIORITY_ABOVE_NORMAL(...)
- //THREAD_PRIORITY_HIGHEST (...)
- //THREAD_PRIORITY_TIME_CRITICAL(...)
- virtual int SYSTEM_CALL GetDevice_Thread_Priority();//return THREAD_PRIORITY_NONE
- //get device type,returns device type GUID
- virtual bool SYSTEM_CALL GetDeviceType(GUID &DevType) = 0;
- virtual void SYSTEM_CALL CompleteInit();
- virtual void SYSTEM_CALL CompleteUnInit();
- //get device resource
- virtual RET_STATUS SYSTEM_CALL GetDeviceResource(ResDataObject PARAM_OUT *pDeviceResource);
- //3. command
- //normal sync routine,Request to device and response from device
- virtual RET_STATUS SYSTEM_CALL Request(ResDataObject PARAM_IN *pRequest, ResDataObject PARAM_OUT *pResponse) = 0;
- //upper layer ------------------------------> lower layer
- //app -> service -> framework -> logicdevice -> hw
- //notify to lower layer
- virtual RET_STATUS SYSTEM_CALL CmdToLogicDev(ResDataObject PARAM_IN *pCmd) = 0;
- //notify from lower layer
- RET_STATUS HW_ACTION CmdFromLogicDev(ResDataObject PARAM_IN *pCmd);
- virtual RET_STATUS HW_ACTION AddErrorMessageUnicode(const char* DevInstance, const char* Code, int &Level, const wchar_t* ResInfo, const wchar_t* Description, int nMessageType = 0);
- virtual RET_STATUS HW_ACTION AddErrorMessage(const char* DevInstance, const char* Code, int &Level, const char* ResInfo, const char* Description, int nMessageType = 0, const char* pAppId = "");
- virtual RET_STATUS HW_ACTION AddErrorMessage(const char* Code, int &Level, const char* ResInfo, int nMessageType = 0, const char* pAppId = "");
- virtual RET_STATUS HW_ACTION DelErrorMessage(const char* DevInstance, const char* Code, int &Level, const char* ResInfo, const char* Description, int nMessageType = 0);
- virtual RET_STATUS HW_ACTION DelErrorMessage(const char* Code, int &Level, const char* ResInfo, int nMessageType = 0);
- };
|