#include "StdAfx.h"
|
#include "CHLightControls/LightControl_MVSol_TCP.h"
|
#include "MVXLC/nic.h"
|
#include "MVXLC/tcp.h"
|
|
CLightControl_MVSol_TCP::CLightControl_MVSol_TCP(int nIndex) : CLightControl(nIndex)
|
{
|
m_bConnected = FALSE;
|
|
m_pConnectorTcp = NULL;
|
m_pConnectorUdp = NULL;
|
}
|
|
|
CLightControl_MVSol_TCP::~CLightControl_MVSol_TCP(void)
|
{
|
if (m_pConnectorTcp)
|
{
|
delete m_pConnectorTcp;
|
m_pConnectorTcp = NULL;
|
}
|
|
if (m_pConnectorUdp)
|
{
|
delete m_pConnectorUdp;
|
m_pConnectorUdp = NULL;
|
}
|
}
|
|
//BOOL CLightControl_MVSol_TCP::Connect( const CLightControlInfo& controlInfo )
|
//{
|
// m_ControlInfo = controlInfo;
|
//
|
// m_pConnectorTcp = new MvxlcTcp(AfxGetMainWnd()->GetSafeHwnd());
|
// if (m_pConnectorTcp==NULL)
|
// {
|
// delete m_pConnectorTcp;
|
// m_pConnectorTcp = NULL;
|
// return FALSE;
|
// }
|
//
|
// if ((m_bConnected = m_pConnectorTcp->Connect(m_ControlInfo.GetConnectionPort(), 34700))==FALSE)
|
// return FALSE;
|
//
|
// return TRUE;
|
//}
|
|
void CLightControl_MVSol_TCP::Disconnect()
|
{
|
}
|
|
BOOL CLightControl_MVSol_TCP::GetLightLevel( int &nValue, int nChannel /*= 0*/ ) const
|
{
|
if (m_pConnectorTcp==NULL) return FALSE;
|
|
INT nRetValue = 0;
|
if (m_pConnectorTcp->GetBrightness(nChannel, &nRetValue) != kAck) return FALSE;
|
|
nValue = nRetValue;
|
|
return TRUE;
|
}
|
|
LONG CLightControl_MVSol_TCP::ConnectEx( const CLightControlInfo& controlInfo )
|
{
|
return TRUE;
|
}
|
|
void CLightControl_MVSol_TCP::DisconnectEx()
|
{
|
|
}
|
|
BOOL CLightControl_MVSol_TCP::GetLightLevel( double &dValue, int nChannel /*= 0*/ ) const
|
{
|
if (m_pConnectorTcp==NULL) return FALSE;
|
|
INT nRetValue = 0;
|
if (m_pConnectorTcp->GetBrightness(nChannel, &nRetValue) != kAck) return FALSE;
|
|
dValue = double(nRetValue);
|
|
return TRUE;
|
}
|
|
BOOL CLightControl_MVSol_TCP::GetLightStatus( int &nValue, int nChannel /*= 0*/ ) const
|
{
|
return TRUE;
|
}
|
|
BOOL CLightControl_MVSol_TCP::SetLightLevel( int nValue, int nChannel /*= 0*/ )
|
{
|
if (m_pConnectorTcp==NULL) return FALSE;
|
|
if (m_pConnectorTcp->SetBrightness(nChannel, nValue) != kAck) return FALSE;
|
|
return TRUE;
|
}
|
|
BOOL CLightControl_MVSol_TCP::SetLightLevel( double dValue, int nChannel /*= 0*/ )
|
{
|
if (m_pConnectorTcp==NULL) return FALSE;
|
|
if (m_pConnectorTcp->SetBrightness(nChannel, int(dValue)) != kAck) return FALSE;
|
|
return TRUE;
|
}
|
|
BOOL CLightControl_MVSol_TCP::SetLightStatus( int nValue, int nChannel /*= 0*/ )
|
{
|
return TRUE;
|
}
|
|
BOOL CLightControl_MVSol_TCP::SetLightOn()
|
{
|
return TRUE;
|
}
|
|
BOOL CLightControl_MVSol_TCP::SetLightOff()
|
{
|
return TRUE;
|
}
|
|
|
BOOL CLightControl_MVSol_TCP::SetLightOn(int Channel)
|
{
|
if (!m_bConnected) return FALSE;
|
|
return TRUE;
|
}
|
|
BOOL CLightControl_MVSol_TCP::SetLightOff(int Channel)
|
{
|
if (!m_bConnected) return FALSE;
|
|
return TRUE;
|
}
|
|
BOOL CLightControl_MVSol_TCP::SetLightAllOn()
|
{
|
if (!m_bConnected) return FALSE;
|
|
return TRUE;
|
}
|
|
BOOL CLightControl_MVSol_TCP::SetLightAllOff()
|
{
|
if (!m_bConnected) return FALSE;
|
|
return TRUE;
|
}
|
|
int CLightControl_MVSol_TCP::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;
|
}
|