LED设置光度
CString strlight;
CString strip;
int nDatLen;
int nRet ;
BYTE szBuf[512];
DlgSetLightLevel LightLevle( &m_light );
if ( IDOK == LightLevle.DoModal() )
{
int nParseRet = 0;
HOBJECT hObj = CP5200_CommData_Create( 1 , 0xff, IPStringToValue( _T("255.255.255.255") ) );
if(hObj)
{
BYTE szInfo[ 24 ];
memset(szInfo, 27, 24);
for ( int j = 0 ; j < 24 ; j ++ )
{
szInfo[ j ] = m_light.m_lingleve ;
}
nDatLen = CP5200_MakeWriteBrightnessData(hObj, szBuf, sizeof(szBuf), szInfo );
if(nDatLen > 0)
{
POSITION pos = m_listCtrlSign.GetFirstSelectedItemPosition() ;
if ( !pos)
{
MessageBox( " please Select Sign" , MB_OK );
return;
}
else
{
int nindex = m_listCtrlSign.GetNextSelectedItem( pos );
CSign *pSign = ( CSign * )m_listCtrlSign.GetItemData( nindex );
strip = pSign->GetIP();
}
nRet = CP5200_Net_Init( IPStringToValue( strip ) ,5200, IPStringToValue( _T("255.255.255.255")), 600 );//网络初始化
CP5200_Net_Connect();
if( CP5200_Net_IsConnected() )//网络连接
{
nRet = CP5200_Net_Write(szBuf, nDatLen );//写数据
if ( nRet == 1 )
{
nRet = CP5200_Net_Read(szBuf, nDatLen );//接收数据
}
else
{
return ;
}
if(nRet > 0)
{
nRet = CP5200_ParseWriteBrightnessRet ( hObj , szBuf , nDatLen );//
}
else
{
return;
}
}
}
CP5200_CommData_Destroy(hObj);
CString Strtemp;
Strtemp = nRet > 0 ? "Set Light Level: OK" : "Set Light Level: Fail";
AfxMessageBox( Strtemp );
Sethistory( Strtemp );
HistoryWrite( Strtemp );
}
Sleep(1000);
}