增加了UDP通信和部分复合管控交互消息定义
This commit is contained in:
Vendored
+53
-1
@@ -1,5 +1,57 @@
|
||||
{
|
||||
"files.associations": {
|
||||
"list": "cpp"
|
||||
"list": "cpp",
|
||||
"cctype": "cpp",
|
||||
"clocale": "cpp",
|
||||
"cmath": "cpp",
|
||||
"cstdarg": "cpp",
|
||||
"cstddef": "cpp",
|
||||
"cstdio": "cpp",
|
||||
"cstdlib": "cpp",
|
||||
"cstring": "cpp",
|
||||
"ctime": "cpp",
|
||||
"cwchar": "cpp",
|
||||
"cwctype": "cpp",
|
||||
"array": "cpp",
|
||||
"atomic": "cpp",
|
||||
"bit": "cpp",
|
||||
"*.tcc": "cpp",
|
||||
"compare": "cpp",
|
||||
"concepts": "cpp",
|
||||
"cstdint": "cpp",
|
||||
"deque": "cpp",
|
||||
"map": "cpp",
|
||||
"set": "cpp",
|
||||
"string": "cpp",
|
||||
"unordered_map": "cpp",
|
||||
"vector": "cpp",
|
||||
"exception": "cpp",
|
||||
"algorithm": "cpp",
|
||||
"functional": "cpp",
|
||||
"iterator": "cpp",
|
||||
"memory": "cpp",
|
||||
"memory_resource": "cpp",
|
||||
"numeric": "cpp",
|
||||
"random": "cpp",
|
||||
"string_view": "cpp",
|
||||
"system_error": "cpp",
|
||||
"tuple": "cpp",
|
||||
"type_traits": "cpp",
|
||||
"utility": "cpp",
|
||||
"fstream": "cpp",
|
||||
"initializer_list": "cpp",
|
||||
"iomanip": "cpp",
|
||||
"iosfwd": "cpp",
|
||||
"iostream": "cpp",
|
||||
"istream": "cpp",
|
||||
"limits": "cpp",
|
||||
"new": "cpp",
|
||||
"numbers": "cpp",
|
||||
"ostream": "cpp",
|
||||
"sstream": "cpp",
|
||||
"stdexcept": "cpp",
|
||||
"streambuf": "cpp",
|
||||
"cinttypes": "cpp",
|
||||
"typeinfo": "cpp"
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* @Author: zhaojingkui 1553836110@qq.com
|
||||
* @Date: 2024-10-22 16:47:01
|
||||
* @LastEditors: zhaojingkui 1553836110@qq.com
|
||||
* @LastEditTime: 2024-10-22 17:14:48
|
||||
* @LastEditTime: 2024-10-22 18:03:29
|
||||
* @FilePath: /H100PowerManger/src/pPowerManger/PowerManger.h
|
||||
* @Description:
|
||||
*
|
||||
@@ -17,32 +17,45 @@
|
||||
|
||||
#ifndef PowerManger_HEADER
|
||||
#define PowerManger_HEADER
|
||||
#define UNIX
|
||||
|
||||
#include "MOOS/libMOOS/Thirdparty/AppCasting/AppCastingMOOSApp.h"
|
||||
#include "MOOS/libMOOS/Utils/MOOSThread.h"
|
||||
#include "MOOS/libMOOS/Comms/XPCUdpSocket.h"
|
||||
#include "ccuUdpMsg.h"
|
||||
|
||||
#define IPORT 5000
|
||||
#define MAX_UDP_PKT_SIZE 65535
|
||||
class PowerManger : public AppCastingMOOSApp
|
||||
{
|
||||
public:
|
||||
PowerManger();
|
||||
~PowerManger();
|
||||
public:
|
||||
bool ListenLoopCCU();
|
||||
|
||||
protected: // Standard MOOSApp functions to overload
|
||||
bool OnNewMail(MOOSMSG_LIST &NewMail);
|
||||
bool Iterate();
|
||||
bool OnConnectToServer();
|
||||
bool OnStartUp();
|
||||
|
||||
protected: // Standard AppCastingMOOSApp function to overload
|
||||
bool buildReport();
|
||||
|
||||
protected:
|
||||
void registerVariables();
|
||||
|
||||
protected: // app function
|
||||
// bool _ListenCB();
|
||||
XPCUdpSocket* setUdpScoket(long lPort);
|
||||
|
||||
protected: // app variables
|
||||
long m_lPort;
|
||||
unsigned int m_nReceiveBufferSizeKB;
|
||||
unsigned int m_nSendBufferSizeKB;
|
||||
|
||||
XPCUdpSocket *m_pCcuUdpComm;
|
||||
|
||||
private: // Configuration variables
|
||||
CMOOSThread m_ListenThread;
|
||||
CMOOSThread m_SendThread;
|
||||
// CMOOSThread m_SendThread;
|
||||
private: // State variables
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,189 @@
|
||||
#ifndef CCUUDPMSG__H
|
||||
#define CCUUDPMSG__H
|
||||
|
||||
typedef unsigned int Checksum;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned char start1;
|
||||
unsigned char start2;
|
||||
unsigned short id;
|
||||
unsigned short length;
|
||||
} m_header;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned short year;
|
||||
unsigned short month;
|
||||
unsigned short day;
|
||||
unsigned short hour;
|
||||
unsigned short minute;
|
||||
unsigned short second;
|
||||
} m_date;
|
||||
//复合管控器操作指令
|
||||
typedef struct
|
||||
{
|
||||
m_header header;
|
||||
m_date date;
|
||||
unsigned char workCondition;
|
||||
unsigned char fcuCmd;
|
||||
unsigned char fcuPowerEfficiency;
|
||||
unsigned char fcuInsEfficiency;
|
||||
unsigned char insBatCmd;
|
||||
unsigned char powerBatCmd;
|
||||
unsigned char powerBatEfficiency;
|
||||
unsigned char heartbeat;
|
||||
unsigned char masterState;
|
||||
Checksum checkCode;
|
||||
} msg_CcuColCmdMsg;
|
||||
|
||||
//复合管控器参数设定指令
|
||||
typedef struct
|
||||
{
|
||||
m_header header;
|
||||
unsigned char insSocHold1;
|
||||
unsigned char insSocHold2;
|
||||
unsigned char insSocHold3;
|
||||
unsigned char fcuToInsLimit1;
|
||||
unsigned char fcuToinsLimit2;
|
||||
unsigned char powerSocHold1;
|
||||
unsigned char powerSocHold2;
|
||||
unsigned char powerSocHold3;
|
||||
unsigned char fcuToPowerLimit1;
|
||||
unsigned char fcuToPowerLimit2;
|
||||
Checksum checkCode;
|
||||
} msg_CcuSetParmMsg;
|
||||
|
||||
//配电指令
|
||||
typedef struct
|
||||
{
|
||||
m_header header;
|
||||
unsigned char dcb1;
|
||||
unsigned char dcb2;
|
||||
unsigned char dcb3;
|
||||
unsigned char dcb4;
|
||||
unsigned char dcb5;
|
||||
unsigned char sw1;
|
||||
unsigned char sw2;
|
||||
unsigned char qf1;
|
||||
unsigned char qf2;
|
||||
unsigned char qf3;
|
||||
unsigned char qf4;
|
||||
unsigned char qf5;
|
||||
unsigned char qf6;
|
||||
unsigned char qf7;
|
||||
unsigned char qf8;
|
||||
unsigned char qf9;
|
||||
unsigned char qf10;
|
||||
unsigned char qf11;
|
||||
unsigned char qf12;
|
||||
unsigned char qf13;
|
||||
unsigned char qf14;
|
||||
unsigned char qf15;
|
||||
unsigned char qf16;
|
||||
unsigned char qf17;
|
||||
unsigned char qf18;
|
||||
unsigned char qf19;
|
||||
unsigned char qf20;
|
||||
unsigned char qf21;
|
||||
unsigned char qf22;
|
||||
unsigned char qf23;
|
||||
unsigned char qf24;
|
||||
unsigned char qf25;
|
||||
unsigned char qf26;
|
||||
Checksum checkCode;
|
||||
} msg_disSysCmdMsg;
|
||||
|
||||
//复合管控参数设定反馈指令
|
||||
typedef struct
|
||||
{
|
||||
m_header header;
|
||||
unsigned char flag;
|
||||
unsigned char failureCode;
|
||||
Checksum checkCode;
|
||||
} msg_CcuSetParmFbMsg;
|
||||
|
||||
//复合管控状态反馈
|
||||
typedef struct
|
||||
{
|
||||
m_header header;
|
||||
unsigned char currentWorkCondition;
|
||||
unsigned char fcuState;
|
||||
unsigned char fcuFaultLeve;
|
||||
float powerLimit;
|
||||
float totalPowerGeneration;
|
||||
float ch4o;
|
||||
float o2;
|
||||
float fcuVoltage;
|
||||
float fcuCurrent;
|
||||
float o2Level;
|
||||
float placeholder1;
|
||||
float exchangerTemperature;
|
||||
float fcuOutPower;
|
||||
float fcuOutIns;
|
||||
float fcuVoltageIns;
|
||||
float fcuVoltagePower;
|
||||
float fcuCurrentIns;
|
||||
float fcuCurrentPower;
|
||||
float h2Concentration1;
|
||||
float h2Concentration2;
|
||||
float o2Concentration1;
|
||||
float o2Concentration2;
|
||||
float ch4oConcentration1;
|
||||
float ch4oConcentration2;
|
||||
float backpressure1;
|
||||
float backpressure2;
|
||||
unsigned char flameDetection;
|
||||
unsigned char fcuGZ_1L;
|
||||
unsigned char fcuGZ_1H;
|
||||
unsigned char fcuGZ_2L;
|
||||
unsigned char fcuGZ_2H;
|
||||
unsigned char fcuGZ_3L;
|
||||
unsigned char fcuGZ_3H;
|
||||
unsigned char insPosRelayState;
|
||||
unsigned char insNegRelayState;
|
||||
unsigned char powerPosRelayState;
|
||||
unsigned char powerNegRelayState;
|
||||
unsigned short insBatLimit;
|
||||
unsigned short powerBatLimit;
|
||||
unsigned char insBatSoc;
|
||||
unsigned char powerBatSoc;
|
||||
unsigned short insBatTotalElectricity;
|
||||
unsigned short powerBatTotalElectricity;
|
||||
unsigned short insBatCurrentElectricity;
|
||||
unsigned short powerBatCurrentElectricity;
|
||||
unsigned char insChargeState;
|
||||
unsigned char powerChargeState;
|
||||
unsigned short insLinkVoltage;
|
||||
unsigned short insPackVoltage;
|
||||
unsigned short insCurrent;
|
||||
unsigned short insPosInsulationResistance;
|
||||
unsigned short insNegInsulationResistance;
|
||||
unsigned short powerLinkVoltage;
|
||||
unsigned short powerPackVoltage;
|
||||
unsigned short powerCurrent;
|
||||
unsigned short powerPosInsulationResistance;
|
||||
unsigned short powerNegInsulationResistance;
|
||||
unsigned char insEmergencyStatusWord;
|
||||
unsigned char powerEmergencyStatusWord;
|
||||
unsigned char insAlarmIdentificationWord;
|
||||
unsigned char powerAlarmIdentificationWord;
|
||||
unsigned char insCurrentSocHold1;
|
||||
unsigned char insCurrentSocHold2;
|
||||
unsigned char insCurrentSocHold3;
|
||||
unsigned char fcuCurrentToInsLimit1;
|
||||
unsigned char fcuCurrentToinsLimit2;
|
||||
unsigned char powerCurrentSocHold1;
|
||||
unsigned char powerCurrentSocHold2;
|
||||
unsigned char powerCurrentSocHold3;
|
||||
unsigned char powerCurrentToInsLimit1;
|
||||
unsigned char powerCurrentToinsLimit2;
|
||||
float placeholder2;
|
||||
float placeholder3;
|
||||
float placeholder4;
|
||||
float placeholder5;
|
||||
Checksum checkCode;
|
||||
} msg_CcuStateFbMsg;
|
||||
|
||||
|
||||
#endif
|
||||
Binary file not shown.
Reference in New Issue
Block a user