增加了消息读取的功能,并且添加了python测试脚本
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
#include "ACTable.h"
|
||||
#include "PowerManger.h"
|
||||
#include "MOOS/libMOOS/Utils/ConsoleColours.h"
|
||||
#include <memory>
|
||||
|
||||
using namespace std;
|
||||
|
||||
@@ -184,7 +185,61 @@ bool PowerManger::ListenLoopCCU()
|
||||
{
|
||||
int nRead = m_pCcuUdpComm->iRecieveMessage(Buff,sizeof(Buff));
|
||||
cout<<MOOS::ConsoleColours::yellow()<< "RECEVE DATA COUNT:" << nRead << MOOS::ConsoleColours::reset() << endl;
|
||||
|
||||
if(nRead > 0)
|
||||
{
|
||||
//判断消息
|
||||
char *header = new char[sizeof(m_header)];
|
||||
unsigned short id;
|
||||
memcpy(header,Buff,sizeof(m_header));
|
||||
if(!m_udpComm.getMsgId(header,id))
|
||||
{
|
||||
cout << "------------------" << endl;
|
||||
cout << "id:" << id << endl;
|
||||
cout << "getMsgId faile" << endl;
|
||||
}
|
||||
delete []header;
|
||||
//处理消息
|
||||
switch (id)
|
||||
{
|
||||
case 0x0051: //CCU_STATE_FB 0x0051
|
||||
msg_CcuStateFbMsg s;
|
||||
if(m_udpComm.getCcuState((char *)Buff,s))
|
||||
{
|
||||
cout << "------------------" << endl;
|
||||
cout << "id:" << s.header.id << endl;
|
||||
cout << "currentWorkCondition:" << (double)s.currentWorkCondition << endl;
|
||||
cout << "fcuState:" << s.fcuState << endl;
|
||||
cout << "fcuFaultLeve:" << s.fcuFaultLeve << endl;
|
||||
cout << "powerLimit:" << s.powerLimit << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
for(int i = 0;i < m_udpComm.sError.size();i++)
|
||||
cout << m_udpComm.sError[i] << endl;
|
||||
m_udpComm.sError.clear();
|
||||
}
|
||||
break;
|
||||
case 0x0040: //CCU_SET_PARM_FB 0x0040
|
||||
msg_CcuSetParmFbMsg p;
|
||||
if(m_udpComm.getCcuSetParmFb((char *)Buff,p))
|
||||
{
|
||||
cout << "------------------" << endl;
|
||||
cout << "id:" << p.header.id << endl;
|
||||
cout << "Flas:" << p.flag << endl;
|
||||
cout << "FailCode" << p.failureCode << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
for(int i = 0;i < m_udpComm.sError.size();i++)
|
||||
cout << m_udpComm.sError[i] << endl;
|
||||
m_udpComm.sError.clear();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user