128 lines
4.7 KiB
C++
128 lines
4.7 KiB
C++
#ifndef LOWER_COMM_MANAGER_H
|
|
#define LOWER_COMM_MANAGER_H
|
|
#define UNIX
|
|
|
|
#include "MOOS/libMOOS/Comms/XPCUdpSocket.h"
|
|
#include "MOOS/libMOOS/Utils/MOOSThread.h"
|
|
#include "MOOS/libMOOS/Utils/MOOSLock.h"
|
|
#include "../udpcomm/ccuUdpMsg.h"
|
|
#include "pmSysvariable.h"
|
|
#include <queue>
|
|
#include <map>
|
|
#include <functional>
|
|
#include <atomic>
|
|
#include <vector>
|
|
#include "udpcomm/udpComm.h"
|
|
#include <functional>
|
|
|
|
class PowerManger; // 前向声明
|
|
|
|
class LowerCommManager {
|
|
public:
|
|
LowerCommManager(PowerManger* pm, long myPort, long ccuPort, const std::string& cccHost);
|
|
~LowerCommManager();
|
|
|
|
//processPeriodicTasks
|
|
void processPeriodicTasks();
|
|
//clearMsgQueue
|
|
void clearMsgQueue();
|
|
|
|
public:
|
|
// 初始化UDP通信
|
|
bool initUdpComm();
|
|
|
|
// 更新设备状态
|
|
bool updatePoweSystemStates();
|
|
//================================断路器操作函数=======================================
|
|
template<typename CmdT, typename StateT>
|
|
bool operateBreakerGeneric(
|
|
char const* name,
|
|
char opt,
|
|
std::function<void(CmdT&)> fillCmd, // 填 cmd 对应字段
|
|
std::function<StateT()> readState // 读 pmCurrentState 对应字段
|
|
);
|
|
// 高电压母线
|
|
bool operate_HV_fuelCellCircuit_Breaker(char opt);
|
|
bool operate_HV_powerLithiumBattery_Breaker(char opt);
|
|
bool operate_HV_propulsionMotor_Breaker(char opt);
|
|
bool operate_HV_lithiumBatteryMeter_Breaker(char opt);
|
|
bool operate_HV_dcDc5Module_Breaker(char opt);
|
|
bool operate_HV_bowHighVoltageBox_Breaker(char opt);
|
|
bool operate_HV_sternFt45_Breaker(char opt);
|
|
bool operate_HV_sternRudder1_Breaker(char opt);
|
|
bool operate_HV_sternRudder2_Breaker(char opt);
|
|
bool operate_HV_fbReserved_Breaker(char opt);
|
|
bool operate_HV_tyzReserved_Breaker(char opt);
|
|
bool operate_HV_reserved_Breaker(char opt);
|
|
bool operate_HV_dcDc5_Breaker(char opt);
|
|
bool operate_HV_coolingSystem_Breaker(char opt);
|
|
// 高压汇流排
|
|
bool operate_HVA_bowFTDevice123Circuit_Breaker(char opt);
|
|
bool operate_HVA_actuatorCircuit_Breaker(char opt);
|
|
bool operate_HVA_mastSteeringGearControlBoxCircuit_Breaker(char opt);
|
|
bool operate_HVA_xczCircuit_Breaker(char opt);
|
|
bool operate_HVA_bowRudderControlBoxCircuit_Breaker(char opt);
|
|
bool operate_HVA_openWaterCoverStartCylinderCircuit_Breaker(char opt);
|
|
// 仪表母线
|
|
bool operate_LV_lithiumBatteryGroupInstrumentCircuit_Breaker(char opt);
|
|
bool operate_LV_bowLowVoltageDistributionBoxCircuit_Breaker(char opt);
|
|
bool operate_LV_unit4Dc48V_Breaker(char opt);
|
|
bool operate_LV_dcC1Panel_Breaker(char opt);
|
|
bool operate_LV_reservedCircuit1_Breaker(char opt);
|
|
bool operate_LV_reservedCircuit2_Breaker(char opt);
|
|
bool operate_LV_mergencyLithiumBatteryGroup2Circuit_Breaker(char opt);
|
|
// 仪表汇流排
|
|
bool operate_LVA_unit1Circuit_Breaker(char opt);
|
|
bool operate_LVA_unit2Circuit_Breaker(char opt);
|
|
bool operate_LVA_unit3Circuit_Breaker(char opt);
|
|
bool operate_LVA_unit5Circuit_Breaker(char opt);
|
|
bool operate_LVA_bowPZDeviceCircuit_Breaker(char opt);
|
|
bool operate_LVA_reservedCircuit1_Breaker(char opt);
|
|
bool operate_LVA_reservedCircuit2_Breaker(char opt);
|
|
bool operate_LVA_mergencyLithiumBatteryGroup1Circuit_Breaker(char opt);
|
|
|
|
//保持指令
|
|
void operate_hold();
|
|
//================================复合管控器操作函数====================================
|
|
// 发送CCU控制命令
|
|
bool sendCcuCommand(const ccuColCmd cmd);
|
|
bool sendDisSysCommand(const disSysBreakerList& cmd); //已废弃,不同时操作多个继电器设备
|
|
|
|
// 启动/停止监听线程
|
|
void startListenThread();
|
|
void stopListenThread();
|
|
void coutMsg(const msg_CcuStateFbMsg& p, std::ostream& os = std::cout);
|
|
|
|
//转换函数
|
|
char getBreakerOption(char cmd);
|
|
|
|
// 配电和CCU的反馈状态
|
|
msg_CcuStateFbMsg m_CcuCurrentState;
|
|
msg_disHighVolBusFbMsg m_disHighVolBusCurrentState;
|
|
msg_disHighAVolBusFbMsg m_disHighAVolBusCurrentState;
|
|
msg_disLowMainBusFbMsg m_disHighBVolBusCurrentState;
|
|
msg_disLowBusFbMsg m_disLowBusState;
|
|
// 配电和CCU的反馈状态时间戳
|
|
double msg_CcuStateFbMsg_Update_time;
|
|
// double msg_CcuSetParmFbMsg_Update_time;
|
|
double msg_disHighVolBusFbMsg_Update_time;
|
|
double msg_disHighAVolBusFbMsg_Update_time;
|
|
double msg_disHighBVolBusFbMsg_Update_time;
|
|
double msg_disLowBusFbMsg_Update_time;
|
|
public:
|
|
long m_port;
|
|
long m_ccuPort;
|
|
std::string m_ccuHost;
|
|
std::string m_host;
|
|
|
|
PowerManger* m_pm;
|
|
udpComm* m_udpComm;
|
|
|
|
CMOOSThread m_ListenThread;
|
|
int m_connectState;
|
|
|
|
// UDP监听线程函数
|
|
bool listenThreadFunc();
|
|
};
|
|
|
|
#endif // LOWER_COMM_MANAGER_H
|