Files
H100PowerManger/src/bck/pPowerManger/UpperCommManager.h
T
2026-01-19 21:52:26 +08:00

118 lines
3.9 KiB
C++

#ifndef UPPER_COMM_MANAGER_H
#define UPPER_COMM_MANAGER_H
#include "MOOS/libMOOS/Thirdparty/AppCasting/AppCastingMOOSApp.h"
#include "pmSysvariable.h"
#include "driver.h"
#include "json/json.h"
#include <string>
#include <vector>
#include <map>
#include "upmsg/uPower_equInsState.h"
#include "upmsg/uDevice_secdistState.h"
#include "upmsg/uPower_equState.h"
#include "upmsg/uPower_disSysState.h"
#include "upmsg/uPower_currentState_st.h"
#include "upmsg/uPower_pmState.h"
#include "upmsg/uPower_fcsState.h"
#include "upmsg/uPower_liBatState.h"
#include "upmsg/uDevice_depth.h"
#include "upmsg/uExternComm_setOpCondition.h"
#include "upmsg/uExternComm_setOpMode.h"
#include "upmsg/uPlan_taskStart.h"
#include "upmsg/uPlan_planStop.h"
#include "upmsg/uExternComm_setDeviceSwitch.h"
#include "upmsg/uExternComm_setPowerSystem.h"
#include "upmsg/uPower_equState.h"
#include "upmsg/uPower_sysState.h"
#include "upmsg/uDetect_zdpVoltage_cmd.h"
#include "upmsg/uDetect_xcVoltage_cmd.h"
#include "upmsg/uDevice_thruster_st.h"
#define _DEBUG
using namespace std;
#define VAR_TO_STR(var) #var
//控制消息
#define DB_TO_PM_MSCMD "uPower_sysState_cmd"
#define DB_TO_PM_EQUIPMENTCMD "uPower_equState_cmd"
//决策消息
#define DB_TO_PM_DEEPTH "uDevice_depth_st"
// #define DB_TO_PM_MISSION "uPlan_taskStart_cmd"
#define DB_TO_PM_TASKSTOP "uPlan_planStop_st"
//外部通信消息
#define DB_TO_PM_SETOPCONDITION "uExternComm_setOpCondition_cmd"
#define DB_TO_PM_SETOPMODE "uExternComm_setOpMode_cmd"
#define DB_TO_PM_SETPMSYS "uExternComm_setPowerSystem_cmd"
#define DB_TO_PM_SETDEVSWITCH "uExternComm_setDeviceSwitch_cmd"
class PowerManger; // 前向声明
class UpperCommManager {
public:
UpperCommManager(PowerManger* powerManager);
~UpperCommManager(){};
// 周期调用
void processPeriodicTasks();
// 处理上位机消息
bool processUpperMsg(const std::string& key, const std::string& msg);
// 生成系统报告
void buildSystemReport();
public:
//定义上位机消息
uPower_equInsStateMsg m_equInsStateMsg;
uDevice_secdistStateMsg m_secdistStateMsg;
uPower_equStateMsg m_equStateMsg;
uPower_disSysStateMsg m_disSysStateMsg;
uPower_currentStateMsg m_currentStateMsg;
uPower_pmStateMsg m_pmStateMsg;
uPower_fcsStateMsg m_fcsStateMsg;
uPower_liBatStateMsg m_liBatStateMsg;
//上位机订阅消息
uDevice_depthMsg m_depthMsg;
uExternComm_setOpConditionMsg m_setOpConditionMsg;
uExternComm_setOpModeMsg m_setOpModeMsg;
uPlan_taskStartMsg m_taskStartMsg;
uPlan_planStopMsg m_taskStopMsg;
uExternComm_setDeviceSwitchMsg m_setDevSwitchMsg;
uExternComm_setPowerSystemMsg m_setPMSysMsg;
uPower_sysStateMsg m_sysStateMsg;
private:
PowerManger* m_pm;
MSControlCmd m_msCmd;
Driver m_driver;
#ifdef _DEBUG
public:
std::pair<string, string> m_equInsStateMsg_fb_degub;
std::pair<string, string> m_secdistStateMsg_cmd_debug;
std::pair<string, string> m_secdistStateMsg_fb_debug;
std::pair<string, string> m_equStateMsg_cmd_debug;
std::pair<string, string> m_equStateMsg_fb_debug;
std::pair<string, string> m_disSysStateMsg_st_debug;
std::pair<string, string> m_currentStateMsg_st_debug;
std::pair<string, string> m_pmStateMsg_fb_debug;
std::pair<string, string> m_fcsStateMsg_st_debug;
std::pair<string, string> m_liBatStateMsg_st_debug;
std::pair<string, string> m_depthMsg_st_debug;
std::pair<string, string> m_setOpConditionMsg_st_debug;
std::pair<string, string> m_setOpModeMsg_st_debug;
std::pair<string, string> m_taskStartMsg_st_debug;
std::pair<string, string> m_taskStopMsg_st_debug;
std::pair<string, string> m_setDevSwitchMsg_st_debug;
std::pair<string, string> m_setPMSysMsg_st_debug;
std::pair<string, string> m_sysStateMsg_st_debug;
#endif
// bool parseControlCmdFromJson(MSControlCmd &cmd, const std::string &strJson);
};
#endif // UPPER_COMM_MANAGER_H