#pragma once #include "LightControlInfo.h" class AFX_EXT_CLASS CLightControl { public: CLightControl(int nIndex) { m_nIndex = nIndex; m_pLC2P = NULL; m_nPortIndex = 1; m_nBaudRate = CBR_9600; m_bMultiCH = FALSE; m_bConnected = FALSE; } virtual ~CLightControl(void) { } // setter void SetLC2P(ILightControl2Parent* pLC2P) { m_pLC2P = pLC2P; } void SetDefaultValue(int nValue) { m_nDefaultValue = nValue; } // getter int GetControlType() const { return m_ControlInfo.GetControllerType(); } int GetPortIndex() const { return m_nPortIndex; } int GetBaudRate() const { return m_nBaudRate; } BOOL GetConnected() const { return m_bConnected; } int GetDefaultValue() const { return m_nDefaultValue; } virtual BOOL Connect(const CLightControlInfo& controlInfo) = 0; virtual LONG ConnectEx(const CLightControlInfo& controlInfo) = 0; // Multi Channel virtual void Disconnect() = 0; virtual void DisconnectEx() = 0; // Multi Channel virtual BOOL GetLightLevel(int &nValue, int nChannel = 0) const = 0; virtual BOOL GetLightLevel(double &dValue, int nChannel = 0) const = 0; virtual BOOL GetLightStatus(int &nValue, int nChannel = 0) const = 0; virtual BOOL SetLightLevel(int nValue, int nChannel = 0) = 0; virtual BOOL SetLightLevel(double dValue, int nChannel = 0) = 0; virtual BOOL SetLightStatus(int nValue, int nChannel = 0) = 0; virtual BOOL SetAllLightLevel(int nValue) = 0; ///virtual BOOL SetLightOn() = 0; ///virtual BOOL SetLightOff() = 0; virtual BOOL SetLightOn(int nChannel = 0) = 0; virtual BOOL SetLightOff(int nChannel = 0) = 0; virtual BOOL SetLightAllOn() = 0; virtual BOOL SetLightAllOff() = 0; virtual int GetStatus( int& nStatusCode, CString& strStatusMessage ) { if (GetConnected()==FALSE) { nStatusCode = LightStatus_NotConnected; strStatusMessage = _T("Not_Connected"); return 0; } nStatusCode = LightStatus_Connected; strStatusMessage = _T("Connected"); return 1; } protected: ILightControl2Parent* m_pLC2P; CLightControlInfo m_ControlInfo; int m_nIndex; int m_nPortIndex; int m_nBaudRate; BOOL m_bConnected; BOOL m_bMultiCH; // Multi Channel (True : 1, False : 0) int m_nDefaultValue; };