增加了UDP通信和部分复合管控交互消息定义
This commit is contained in:
@@ -9,9 +9,17 @@
|
||||
#include "MBUtils.h"
|
||||
#include "ACTable.h"
|
||||
#include "PowerManger.h"
|
||||
#include "MOOS/libMOOS/Utils/ConsoleColours.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
bool _ListenCB(void * pParam)
|
||||
{
|
||||
PowerManger* pMe = (PowerManger* )pParam;
|
||||
return pMe->ListenLoopCCU();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
// Constructor()
|
||||
|
||||
@@ -75,7 +83,7 @@ bool PowerManger::Iterate()
|
||||
{
|
||||
AppCastingMOOSApp::Iterate();
|
||||
// Do your thing here!
|
||||
AppCastingMOOSApp::PostReport();
|
||||
//AppCastingMOOSApp::PostReport();
|
||||
return(true);
|
||||
}
|
||||
|
||||
@@ -111,8 +119,15 @@ bool PowerManger::OnStartUp()
|
||||
reportUnhandledConfigWarning(orig);
|
||||
|
||||
}
|
||||
|
||||
|
||||
registerVariables();
|
||||
|
||||
if(m_pCcuUdpComm = setUdpScoket(IPORT))
|
||||
MOOSTrace("UDP set succeed");
|
||||
else
|
||||
MOOSTrace("UDP set faile");
|
||||
m_ListenThread.Initialise(_ListenCB,this);
|
||||
m_ListenThread.Start();
|
||||
return(true);
|
||||
}
|
||||
|
||||
@@ -144,6 +159,32 @@ bool PowerManger::buildReport()
|
||||
return(true);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------
|
||||
// Procedure: setUdpScoket()
|
||||
XPCUdpSocket* PowerManger::setUdpScoket(long lPort)
|
||||
{
|
||||
XPCUdpSocket* pUdpSocket = new XPCUdpSocket(lPort);
|
||||
try
|
||||
{
|
||||
pUdpSocket->vBindSocket();
|
||||
}
|
||||
catch(const std::exception& e)
|
||||
{
|
||||
std::cerr << e.what() << '\n';
|
||||
return NULL;
|
||||
}
|
||||
return pUdpSocket;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool PowerManger::ListenLoopCCU()
|
||||
{
|
||||
unsigned char Buff[MAX_UDP_PKT_SIZE];
|
||||
cout << "------------------" << endl;
|
||||
while(!m_ListenThread.IsQuitRequested())
|
||||
{
|
||||
int nRead = m_pCcuUdpComm->iRecieveMessage(Buff,sizeof(Buff));
|
||||
cout<<MOOS::ConsoleColours::yellow()<< "RECEVE DATA COUNT:" << nRead << MOOS::ConsoleColours::reset() << endl;
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user