#pragma once //#pragma warning(disable:4251) #include #include #include "string.h" #include"CRS232.h" #ifdef LAMP_EXPORTS #define LAMP_DLL_API __declspec(dllexport) #else #define LAMP_DLL_API //__declspec(dllimport) #endif typedef struct _LIGHT_STRUCT { int ChannelIndex; int LightValue; }LIGHT_STRUCT; //设备类型 enum Lamp_Ctltype { LAMP_CST = 1 , LIGTH_HONGREN}; #define LIGTH_BASE_ERROR (SERIAL_PORT_BASE_ERROR+10000) typedef enum { DEVICE_BASE_FAIL = LIGTH_BASE_ERROR, LIGTH_TYPE_FAIL, //RTU_ERR_ORDER, //RTU_ERR_ADDR, //RTU_ERR_DATA, //RTU_ERR_CONN, //RTU_ERR_WRITE, //RTU_ERR_READ_NULL, //RTU_ERR_RECV, //RTU_ERR_PARITY, COM_PORT_FAIL, } LIGTHERR; class LAMP_DLL_API ILamp { public: typedef struct _LIGHT_STRUCT { string addrs; ILamp* pLigth; }ILAMP_LST; protected: bool m_bIsInitSuccess; Lamp_Ctltype m_iLightType; //设备类型 string m_strLightName; bool m_bEnable; //灯光控制器禁止/启用 ILamp(Lamp_Ctltype iLightType,string strLightName); ~ILamp(); public: // 获取单实例对象 static long GetInstance(const char* ipAddress, Lamp_Ctltype iLigthType, ILamp **ligth); virtual string GetErrText(long errid); virtual long Init(unsigned long iPort); //初始化 virtual long Init(const char* ipAddress); //初始化 virtual void UnInit() = 0;//关闭 bool IsInitSuccess() { return m_bIsInitSuccess; }; public: virtual long SetLight(std::vector vecLight, unsigned char iMaxSendNum = 3) = 0; virtual long SetLight(int ChannelIndex, int LightValue, unsigned char iMaxSendNum = 3) = 0; virtual long GetLight(int ChannelIndex,int &LightValue, unsigned char iMaxSendNum = 3) = 0; private: static std::mutex m_Mutex; static std::vector m_vecLamp; static ILamp* GetLamp(string addrs); };