修改了次级配电协议,优化消息结构
This commit is contained in:
@@ -1,9 +0,0 @@
|
||||
//------------------------------------------------
|
||||
// pPMtest config block
|
||||
|
||||
ProcessConfig = pPMtest
|
||||
{
|
||||
AppTick = 4
|
||||
CommsTick = 4
|
||||
}
|
||||
|
||||
@@ -1,30 +1 @@
|
||||
{
|
||||
"backpressure1_fp32": 0.0,
|
||||
"backpressure2_fp32": 0.0,
|
||||
"ch4oConcent1_fp32": 0.0,
|
||||
"ch4oConcent2_fp32": 0.0,
|
||||
"ch4o_fp32": 0.0,
|
||||
"excTemp_fp32": 0.0,
|
||||
"faultCode1_uint16": 0,
|
||||
"faultCode2_uint16": 0,
|
||||
"faultCode3_uint16": 0,
|
||||
"fcuCurIns_fp32": 0.0,
|
||||
"fcuCurPower_fp32": 0.0,
|
||||
"fcuCur_fp32": 0.0,
|
||||
"fcuFaultLeve_uint8": 0,
|
||||
"fcuOutIns_fp32": 0.0,
|
||||
"fcuOutPower_fp32": 0.0,
|
||||
"fcuState_uint8": 0,
|
||||
"fcuVolIns_fp32": 0.0,
|
||||
"fcuVolPower_fp32": 0.0,
|
||||
"fcuVol_fp32": 0.0,
|
||||
"flameDet_uint8": 0,
|
||||
"h2Concent1_fp32": 0.0,
|
||||
"h2Concent2_fp32": 0.0,
|
||||
"o2Concent1_fp32": 0.0,
|
||||
"o2Concent2_fp32": 0.0,
|
||||
"o2Level_fp32": 0.0,
|
||||
"o2_fp32": 0.0,
|
||||
"powLimit_fp32": 0.0,
|
||||
"powerGen_fp32": 0.0
|
||||
}
|
||||
null
|
||||
@@ -1,38 +1 @@
|
||||
{
|
||||
"fcuCurToInsLimit1_uint8": 0,
|
||||
"fcuCurToinsLimit2_uint8": 0,
|
||||
"insBatCurElect_uint16": 0,
|
||||
"insBatLimit_uint16": 0,
|
||||
"insBatSoc_uint8": 0,
|
||||
"insBatTotalElect_uint16": 0,
|
||||
"insChargeState_uint8": 0,
|
||||
"insCurSocHold1_uint8": 0,
|
||||
"insCurSocHold2_uint8": 0,
|
||||
"insCurSocHold3_uint8": 0,
|
||||
"insCurrent_uint16": 0,
|
||||
"insLinkVol_uint16": 0,
|
||||
"insNegRelayState_uint8": 0,
|
||||
"insNegRes_uint16": 0,
|
||||
"insPackVol_uint16": 0,
|
||||
"insPosRelayState_uint8": 0,
|
||||
"insPosRes_uint16": 0,
|
||||
"insfaultCode_uint8": 0,
|
||||
"powBatCurElect_uint16": 0,
|
||||
"powBatSoc_uint8": 0,
|
||||
"powBatTotalElect_uint16": 0,
|
||||
"powChargeState_uint8": 0,
|
||||
"powCurSocHold1_uint8": 0,
|
||||
"powCurSocHold2_uint8": 0,
|
||||
"powCurSocHold3_uint8": 0,
|
||||
"powCurToInsLimit1_uint8": 0,
|
||||
"powCurToinsLimit2_uint8": 0,
|
||||
"powCur_uint16": 0,
|
||||
"powLinkVol_uint16": 0,
|
||||
"powNegRelayState_uint8": 0,
|
||||
"powNegRes_uint16": 0,
|
||||
"powPosRelayState_uint8": 0,
|
||||
"powPosRes_uint16": 0,
|
||||
"powerBatLimit_uint16": 0,
|
||||
"powerPackVol_uint16": 0,
|
||||
"powfaultCode_uint8": 0
|
||||
}
|
||||
null
|
||||
@@ -18,8 +18,25 @@ endif (${WIN32})
|
||||
# Find SQLite3 package
|
||||
# find_package(SQLite3 REQUIRED)
|
||||
|
||||
SET(FSMLIB_SRC
|
||||
fsm/PowerManagerFsm.cpp # 更新静态库的源文件路径
|
||||
fsm/CruiseMode.cpp
|
||||
fsm/DJMode.cpp
|
||||
fsm/FaultState.cpp
|
||||
fsm/FloatAdjust.cpp
|
||||
fsm/FloatDown.cpp
|
||||
fsm/HighSpeedMode.cpp
|
||||
fsm/InitState.cpp
|
||||
fsm/RemoteControl.cpp
|
||||
fsm/ShoreBasedReady.cpp
|
||||
fsm/StandbyState.cpp
|
||||
fsm/SurfaceSurvey.cpp
|
||||
fsm/UnderwaterSurvey.cpp
|
||||
fsm/WaterBasedReady.cpp
|
||||
)
|
||||
|
||||
SET(SRC
|
||||
PowerManagerFsm.cpp
|
||||
${FSMLIB_SRC}
|
||||
PowerManger.cpp
|
||||
PowerManger_Info.cpp
|
||||
udpComm.cpp
|
||||
@@ -55,9 +72,6 @@ SET(SQLITEDB_SRC
|
||||
SQLiteDB.cpp
|
||||
)
|
||||
|
||||
SET(FSMLIB_SRC
|
||||
PowerManagerFsm.cpp)
|
||||
|
||||
SET(DRIVER_SRC
|
||||
driver.cpp)
|
||||
|
||||
|
||||
@@ -77,8 +77,11 @@ bool LowerCommManager::initUdpComm(){
|
||||
}
|
||||
void LowerCommManager::processPeriodicTasks() {
|
||||
sendCcuCommand(m_pm->m_CcuColCmd);
|
||||
//延时5ms
|
||||
usleep(5000);
|
||||
sendDisSysCommand(m_pm->m_targetDisBreakerState);
|
||||
m_udpComm->clearMsgQueue();
|
||||
|
||||
}
|
||||
|
||||
bool LowerCommManager::sendCcuCommand(const ccuColCmd cmd){
|
||||
@@ -105,6 +108,7 @@ bool LowerCommManager::sendDisSysCommand(const disSysBreakerList& cmd){
|
||||
a.reservedCircuitBreaker = getBreakerOption(cmd.bus1Breaker.reservedCircuitBreaker);
|
||||
a.fbReservedCircuitBreaker = getBreakerOption(cmd.bus1Breaker.fbReservedCircuitBreaker);
|
||||
m_udpComm->sendDisSysCmd(a);
|
||||
usleep(5000);
|
||||
//b. 高压汇流排A断路器
|
||||
disHighAVolBusCmd b;
|
||||
b.bowFTDevice123CircuitBreaker = getBreakerOption(cmd.bus2Breaker.bowFTDevice123CircuitBreaker);
|
||||
@@ -114,6 +118,7 @@ bool LowerCommManager::sendDisSysCommand(const disSysBreakerList& cmd){
|
||||
b.bowRudderControlBoxCircuitBreaker = getBreakerOption(cmd.bus2Breaker.bowRudderControlBoxCircuitBreaker);
|
||||
b.openWaterCoverStartCylinderCircuitBreaker = getBreakerOption(cmd.bus2Breaker.openWaterCoverStartCylinderCircuitBreaker);
|
||||
m_udpComm->sendDisSysCmd(b);
|
||||
usleep(5000);
|
||||
//c. 高压汇流排B断路器
|
||||
disHighBVolBusCmd c;
|
||||
c.lithiumBatteryGroupInstrumentCircuitBreaker = getBreakerOption(cmd.bus3Breaker.lithiumBatteryGroupInstrumentCircuitBreaker);
|
||||
@@ -124,6 +129,7 @@ bool LowerCommManager::sendDisSysCommand(const disSysBreakerList& cmd){
|
||||
c.reservedCircuitBreaker2 = getBreakerOption(cmd.bus3Breaker.reservedCircuitBreaker2);
|
||||
c.emergencyLithiumBatteryGroup2CircuitBreaker = getBreakerOption(cmd.bus3Breaker.emergencyLithiumBatteryGroup2CircuitBreaker);
|
||||
m_udpComm->sendDisSysCmd(c);
|
||||
usleep(5000);
|
||||
//d. 闭合低压汇流排断路器
|
||||
disLowBusCmd d;
|
||||
d.unit1CircuitBreaker = getBreakerOption(cmd.bus4Breaker.unit1CircuitBreaker);
|
||||
@@ -135,6 +141,7 @@ bool LowerCommManager::sendDisSysCommand(const disSysBreakerList& cmd){
|
||||
d.reservedCircuitBreaker2 = getBreakerOption(cmd.bus4Breaker.reservedCircuitBreaker2);
|
||||
d.emergencyLithiumBatteryGroup1CircuitBreaker = getBreakerOption(cmd.bus4Breaker.emergencyLithiumBatteryGroup1CircuitBreaker);
|
||||
m_udpComm->sendDisSysCmd(d);
|
||||
usleep(5000);
|
||||
//将指令写入数据库
|
||||
// m_pm->m_db->insertDisSysCmd(a);
|
||||
// m_pm->m_db->insertDisSysCmd(b);
|
||||
@@ -157,6 +164,8 @@ bool LowerCommManager::updatePoweSystemStates(){
|
||||
m_udpComm->popMsgFormQueue(time,m_CcuCurrentState);
|
||||
m_pm->m_pmCurrentState.ccustate = m_CcuCurrentState.data;
|
||||
// m_db->insertCcuData(m_CcuCurrentState.data); //写入数据库
|
||||
//DEBUG
|
||||
coutMsg(m_CcuCurrentState);
|
||||
msg_CcuStateFbMsg_Update_time = time;
|
||||
}
|
||||
if(!m_udpComm->m_qReceiveDisHighVolBusBuffer.empty())
|
||||
@@ -256,7 +265,7 @@ bool LowerCommManager::listenThreadFunc()
|
||||
try
|
||||
{
|
||||
int nRead = m_udpComm->udpScoket->iRecieveMessage(Buff, sizeof(Buff));
|
||||
//cout<<MOOS::ConsoleColours::yellow()<< "RECEVE DATA COUNT:" << nRead << MOOS::ConsoleColours::reset() << endl;
|
||||
cout<<MOOS::ConsoleColours::yellow()<< "RECEVE DATA COUNT:" << nRead << MOOS::ConsoleColours::reset() << endl;
|
||||
if(nRead > 0)
|
||||
{
|
||||
try {
|
||||
@@ -342,3 +351,112 @@ bool LowerCommManager::checkConnection()
|
||||
{
|
||||
m_pm->connectState =5;
|
||||
}
|
||||
|
||||
void LowerCommManager::coutMsg(const msg_CcuStateFbMsg& p, std::ostream& os){
|
||||
os << std::hex << std::setfill('0') << std::uppercase;
|
||||
|
||||
os << "起始符1 (start1): 0x" << std::setw(2) << static_cast<int>(p.header.start1) << "\n";
|
||||
os << "起始符2 (start2): 0x" << std::setw(2) << static_cast<int>(p.header.start2) << "\n";
|
||||
os << "标识符 (identifier): 0x" << std::setw(4) << p.header.id << "\n";
|
||||
os << std::dec << "数据长度 (length): " << p.header.length << "\n";
|
||||
|
||||
|
||||
os << "运行模式 (fc_mode): 0x" << std::hex << std::setw(2) << static_cast<int>(p.data.fc_mode) << "\n";
|
||||
os << "燃料电池状态 (fc_status): 0x" << std::setw(2) << static_cast<int>(p.data.fc_status) << "\n";
|
||||
os << "故障等级 (fc_fault_level): 0x" << std::setw(2) << static_cast<int>(p.data.fc_fault_level) << "\n";
|
||||
|
||||
os << std::dec;
|
||||
os << "输出功率限制 (output_power_limit): " << p.data.output_power_limit << " W\n";
|
||||
os << "累计发电时间 (total_generation_time): " << p.data.total_generation_time * 0.1 << " 小时\n";
|
||||
os << "发电总功率 (total_generation_power): " << p.data.total_generation_power << " W\n";
|
||||
os << "一级故障字 (fault_level_1): 0x" << std::hex << p.data.fault_level_1 << "\n";
|
||||
os << "二级故障字 (fault_level_2): 0x" << p.data.fault_level_2 << "\n";
|
||||
os << "三级故障字 (fault_level_3): 0x" << p.data.fault_level_3 << "\n";
|
||||
os << "四级故障字 (fault_level_4): 0x" << p.data.fault_level_4 << "\n";
|
||||
|
||||
os << std::dec;
|
||||
os << "储氢剩余容量 (hydrogen_capacity): " << static_cast<int>(p.data.hydrogen_capacity) << "%\n";
|
||||
os << "液氧剩余容量 (liquid_oxygen_capacity): " << static_cast<int>(p.data.liquid_oxygen_capacity) << "%\n";
|
||||
os << "钯膜最高温度 (palladium_temp): " << p.data.palladium_temp << " ℃\n";
|
||||
os << "主水路压力 (main_pipe_pressure): " << p.data.main_pipe_pressure * 0.01 << " kPa\n";
|
||||
os << "辅水路压力 (aux_pipe_pressure): " << p.data.aux_pipe_pressure * 0.01 << " kPa\n";
|
||||
|
||||
os << "舱室压力1 (cabin_pressure1): " << p.data.cabin_pressure1 * 0.01 << " kPa\n";
|
||||
os << "舱室压力2 (cabin_pressure2): " << p.data.cabin_pressure2 * 0.01 << " kPa\n";
|
||||
os << "舱室温度1 (cabin_temp1): " << p.data.cabin_temp1 * 0.01 << " ℃\n";
|
||||
os << "舱室温度2 (cabin_temp2): " << p.data.cabin_temp2 * 0.01 << " ℃\n";
|
||||
os << "舱室湿度1 (cabin_humidity1): " << p.data.cabin_humidity1 * 0.01 << " %RH\n";
|
||||
os << "舱室湿度2 (cabin_humidity2): " << p.data.cabin_humidity2 * 0.01 << " %RH\n";
|
||||
|
||||
os << "火焰探测器1状态 (flame_detector1): 0x" << std::hex << static_cast<int>(p.data.flame_detector1) << "\n";
|
||||
os << "火焰探测器2状态 (flame_detector2): 0x" << static_cast<int>(p.data.flame_detector2) << "\n";
|
||||
|
||||
os << std::dec;
|
||||
os << "氢气浓度1 (h2_concentration1): " << p.data.h2_concentration1 * 0.01 << "% LEL\n";
|
||||
os << "氢气浓度2 (h2_concentration2): " << p.data.h2_concentration2 * 0.01 << "% LEL\n";
|
||||
os << "氢气浓度3 (h2_concentration3): " << p.data.h2_concentration3 * 0.01 << "% LEL\n";
|
||||
os << "氧气浓度1 (o2_concentration1): " << p.data.o2_concentration1 * 0.01 << "% LEL\n";
|
||||
os << "氧气浓度2 (o2_concentration2): " << p.data.o2_concentration2 * 0.01 << "% LEL\n";
|
||||
os << "甲醇浓度1 (ch3oh_concentration1): " << p.data.ch3oh_concentration1 * 0.01 << "% LEL\n";
|
||||
os << "甲醇浓度2 (ch3oh_concentration2): " << p.data.ch3oh_concentration2 * 0.01 << "% LEL\n";
|
||||
|
||||
for (int i = 0; i < 18; ++i)
|
||||
os << "保留字段 reserved1[" << i << "]: 0x" << std::hex << p.data.reserved1[i] << "\n";
|
||||
|
||||
for (int i = 0; i < 6; ++i)
|
||||
os << "动力电池报警标志 dyn_alarm_flag[" << i << "]: 0x" << std::hex << static_cast<int>(p.data.dyn_alarm_flag[i]) << "\n";
|
||||
for (int i = 0; i < 6; ++i)
|
||||
os << "仪表电池报警标志 ins_alarm_flag[" << i << "]: 0x" << std::hex << static_cast<int>(p.data.ins_alarm_flag[i]) << "\n";
|
||||
|
||||
os << "仪表正极/充电继电器状态 (ins_relay_status1): 0x" << std::hex << static_cast<int>(p.data.ins_relay_status1) << "\n";
|
||||
os << "仪表预充/负极继电器状态 (ins_relay_status2): 0x" << static_cast<int>(p.data.ins_relay_status2) << "\n";
|
||||
os << "动力正极/充电继电器状态 (dyn_relay_status1): 0x" << static_cast<int>(p.data.dyn_relay_status1) << "\n";
|
||||
os << "动力预充/负极继电器状态 (dyn_relay_status2): 0x" << static_cast<int>(p.data.dyn_relay_status2) << "\n";
|
||||
|
||||
os << std::dec;
|
||||
os << "仪表最大放电功率 (ins_max_discharge_power): " << p.data.ins_max_discharge_power * 0.05 << " kW\n";
|
||||
os << "动力最大放电功率 (dyn_max_discharge_power): " << p.data.dyn_max_discharge_power * 0.05 << " kW\n";
|
||||
|
||||
os << "仪表SOC (ins_soc): " << static_cast<int>(p.data.ins_soc) << "%\n";
|
||||
os << "动力SOC (dyn_soc): " << static_cast<int>(p.data.dyn_soc) << "%\n";
|
||||
|
||||
os << "仪表电池总能量 (ins_total_energy): " << p.data.ins_total_energy << " kWh\n";
|
||||
os << "动力电池总能量 (dyn_total_energy): " << p.data.dyn_total_energy << " kWh\n";
|
||||
|
||||
os << "仪表输入功率 (ins_power_input): " << p.data.ins_power_input << " kW\n";
|
||||
os << "动力输入功率 (dyn_power_input): " << p.data.dyn_power_input << " kW\n";
|
||||
|
||||
os << "仪表充电状态 (ins_charge_status): 0x" << std::hex << static_cast<int>(p.data.ins_charge_status) << "\n";
|
||||
os << "动力充电状态 (dyn_charge_status): 0x" << static_cast<int>(p.data.dyn_charge_status) << "\n";
|
||||
|
||||
os << std::dec;
|
||||
os << "仪表LINK电压: " << p.data.ins_voltage_link * 0.01 << " V\n";
|
||||
os << "仪表PACK电压: " << p.data.ins_voltage_pack * 0.01 << " V\n";
|
||||
os << "仪表电流: " << p.data.ins_current * 0.01 << " A\n";
|
||||
os << "仪表正端绝缘电阻: " << p.data.ins_resistance_pos << " kΩ\n";
|
||||
os << "仪表负端绝缘电阻: " << p.data.ins_resistance_neg << " kΩ\n";
|
||||
os << "动力LINK电压: " << p.data.dyn_voltage_link * 0.01 << " V\n";
|
||||
os << "动力PACK电压: " << p.data.dyn_voltage_pack * 0.01 << " V\n";
|
||||
os << "动力电流: " << p.data.dyn_current * 0.01 << " A\n";
|
||||
os << "动力正端绝缘电阻: " << p.data.dyn_resistance_pos << " kΩ\n";
|
||||
os << "动力负端绝缘电阻: " << p.data.dyn_resistance_neg << " kΩ\n";
|
||||
|
||||
os << "仪表紧急状态 (ins_emergency_status): 0x" << std::hex << static_cast<int>(p.data.ins_emergency_status) << "\n";
|
||||
os << "动力紧急状态 (dyn_emergency_status): 0x" << static_cast<int>(p.data.dyn_emergency_status) << "\n";
|
||||
|
||||
for (int i = 0; i < 2; ++i)
|
||||
os << "保留字段 reserved2[" << i << "]: 0x" << std::hex << static_cast<int>(p.data.reserved2[i]) << "\n";
|
||||
for (int i = 0; i < 6; ++i)
|
||||
os << "SOC门限值 ins_soc_threshold" << i+1 << ": 0x" << std::hex << static_cast<int>(p.data.ins_soc_threshold1) << "\n";
|
||||
for (int i = 0; i < 4; ++i)
|
||||
os << "功率限制 ins_power_limit" << i+1 << ": 0x" << std::hex << static_cast<int>(p.data.ins_power_limit1) << "\n";
|
||||
|
||||
os << "设备在线状态1 (device_online_flag1): 0x" << std::hex << p.data.device_online_flag1 << "\n";
|
||||
os << "设备在线状态2 (device_online_flag2): 0x" << p.data.device_online_flag2 << "\n";
|
||||
|
||||
// os << "保留字段 reserved3: 0x" << p.data.reserved1 << "\n";
|
||||
os << "主机心跳 (reserved4): 0x" << p.data.heartbeat << "\n";
|
||||
os << "校验和 (checksum): 0x" << p.checkCode << "\n";
|
||||
|
||||
os << std::dec;
|
||||
}
|
||||
@@ -46,6 +46,7 @@ public:
|
||||
// 启动/停止监听线程
|
||||
void startListenThread();
|
||||
void stopListenThread();
|
||||
void coutMsg(const msg_CcuStateFbMsg& p, std::ostream& os = std::cout);
|
||||
|
||||
//转换函数
|
||||
char getBreakerOption(char cmd);
|
||||
|
||||
@@ -126,6 +126,8 @@ bool PowerManger::Iterate()
|
||||
AppCastingMOOSApp::Iterate();
|
||||
// 打印当前状态
|
||||
// cout << " Current State : " << (int)PowerManagerFsm::current_state_ptr->getCurrentState();
|
||||
CycleTriggeredEvent cycleEvent;
|
||||
PowerManagerFsm::dispatch(cycleEvent);
|
||||
faultLevel = getFaultLevel();
|
||||
if (m_ticker++ % 5 == 0)
|
||||
{
|
||||
@@ -263,14 +265,15 @@ bool PowerManger::writeDataToDB()
|
||||
|
||||
int PowerManger::checkError()
|
||||
{
|
||||
//TODO:更新协议
|
||||
//1.检查复合管控器状态
|
||||
if(m_pmCurrentState.ccustate.fcuGZ_1H != 0 ||
|
||||
m_pmCurrentState.ccustate.fcuGZ_1L != 0 ||
|
||||
m_pmCurrentState.ccustate.fcuGZ_2H != 0 ||
|
||||
m_pmCurrentState.ccustate.fcuGZ_2L != 0 ||
|
||||
m_pmCurrentState.ccustate.fcuGZ_3H != 0 ||
|
||||
m_pmCurrentState.ccustate.fcuGZ_3L != 0 ||
|
||||
m_pmCurrentState.ccustate.insEmergencyStatusWord != 0)
|
||||
// if(m_pmCurrentState.ccustate.fcuGZ_1H != 0 ||
|
||||
// m_pmCurrentState.ccustate.fcuGZ_1L != 0 ||
|
||||
// m_pmCurrentState.ccustate.fcuGZ_2H != 0 ||
|
||||
// m_pmCurrentState.ccustate.fcuGZ_2L != 0 ||
|
||||
// m_pmCurrentState.ccustate.fcuGZ_3H != 0 ||
|
||||
// m_pmCurrentState.ccustate.fcuGZ_3L != 0 ||
|
||||
// m_pmCurrentState.ccustate.insEmergencyStatusWord != 0)
|
||||
return 0;
|
||||
//2.检查断路器状态
|
||||
}
|
||||
|
||||
@@ -31,16 +31,16 @@
|
||||
#include "json/json.h"
|
||||
#include "udpComm.h"
|
||||
#include "pmSysvariable.h"
|
||||
#include "PowerManagerFsm.hpp"
|
||||
#include "fsm/PowerManagerFsm.hpp"
|
||||
// #include "SQLiteDB.h"
|
||||
#include "driver.h"
|
||||
#include "LowerCommManager.h"
|
||||
#include "UpperCommManager.h"
|
||||
|
||||
|
||||
#define IPORT 5000
|
||||
#define CCUPORT 5001
|
||||
#define CCUHOST "127.0.0.1"
|
||||
#define IPORT 5001
|
||||
#define CCUPORT 7000
|
||||
#define CCUHOST "192.168.0.140"
|
||||
#define MAX_UDP_PKT_SIZE 65535
|
||||
#define SKEW_TOLERANCE 5
|
||||
|
||||
@@ -115,7 +115,6 @@ class PowerManger : public AppCastingMOOSApp
|
||||
LowerCommManager* m_lowerCommManager;
|
||||
UpperCommManager* m_upperCommManager;
|
||||
|
||||
// // 状态机实例
|
||||
// PowerManagerFsm m_fsm;
|
||||
|
||||
public:
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#include "UpperCommManager.h"
|
||||
#include "PowerManger.h"
|
||||
#include "driver.h"
|
||||
#include "PowerManagerFsm.hpp"
|
||||
#include "fsm/PowerManagerFsm.hpp"
|
||||
|
||||
UpperCommManager::UpperCommManager(PowerManger* pm) : m_pm(pm) {}
|
||||
UpperCommManager::UpperCommManager(PowerManger* pm) : m_pm(pm) {};
|
||||
|
||||
bool UpperCommManager::processUpperMsg(const string& key, const string& strJson) {
|
||||
if(key == DB_TO_PM_MSCMD) {
|
||||
@@ -15,10 +15,28 @@ bool UpperCommManager::processUpperMsg(const string& key, const string& strJson)
|
||||
}
|
||||
else if(key == DB_TO_PM_EQUIPMENTCMD) {
|
||||
m_pm->m_MSDriverCmd = getEquipmentCmd(key, strJson);
|
||||
vector<DriverCommand> devCmdExt = m_pm->m_driver.loadDriverIdFromJson(strJson);
|
||||
if (devCmdExt.empty()) {
|
||||
LOG_F(WARNING, "控制指令");
|
||||
}
|
||||
else {
|
||||
for (auto& cmd : devCmdExt) {
|
||||
DevCmdExt event(cmd.id, cmd.cmd);
|
||||
PowerManagerFsm::dispatch(event);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else if(key == DB_TO_PM_SUBDISSTATE) {
|
||||
m_pm->m_subDisSysState = getSubDisState(key, strJson);
|
||||
// else if(key == DB_TO_PM_SUBDISSTATE) {
|
||||
// m_pm->m_subDisSysState = getSubDisState(key, strJson);
|
||||
// return true;
|
||||
// }
|
||||
// 次级配电状态处理
|
||||
else if(key == m_secdistStateMsg.key_fb) {
|
||||
m_secdistStateMsg.parseMsg(strJson, m_pm->m_subDisSysState);
|
||||
//debug 接受到次级配电状态,自动更新到设备状态
|
||||
//TODO:自动更新到设备状态
|
||||
//m_pm->m_subDisSysState = m_pm->m_deviceState;
|
||||
return true;
|
||||
}
|
||||
else if(key == DB_TO_PM_DEEPTH) {
|
||||
@@ -97,6 +115,7 @@ const DriverTable UpperCommManager::getEquipmentCmd(const std::string& key, cons
|
||||
if (m_pm->m_driver.loadDriverTableFromJson(msg, cmd) < 0) {
|
||||
cout << MOOS::ConsoleColours::Red << "get equipment cmd error:" << msg
|
||||
<< MOOS::ConsoleColours::reset << endl;
|
||||
LOG_F(WARNING, "get equipment cmd error:%s", msg.c_str());
|
||||
}
|
||||
return cmd;
|
||||
}
|
||||
@@ -107,6 +126,7 @@ const DriverTable UpperCommManager::getSubDisState(const std::string& key, const
|
||||
if (m_pm->m_driver.loadDriverTableFromJson(msg, state) < 0) {
|
||||
cout << MOOS::ConsoleColours::Red << "get sub dis state error:" << msg
|
||||
<< MOOS::ConsoleColours::reset << endl;
|
||||
LOG_F(WARNING, "get sub dis state error:%s", msg.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,21 +140,22 @@ const int UpperCommManager::getDeepth(const std::string& key, const std::string&
|
||||
std::istringstream stream(msg);
|
||||
if (!Json::parseFromStream(builder, stream, &root, &errs)) {
|
||||
std::cerr << "JSON解析失败: " << errs << std::endl;
|
||||
LOG_F(WARNING, "JSON解析失败: %s", errs.c_str());
|
||||
return -1;
|
||||
}
|
||||
|
||||
// 检查并读取深度数组
|
||||
if (root.isMember("value_array_uint16") && root["value_array_uint16"].isArray()) {
|
||||
const Json::Value& array = root["value_array_uint16"];
|
||||
if (root.isMember("value_array_int32") && root["value_array_int32"].isArray()) {
|
||||
const Json::Value& array = root["value_array_int32"];
|
||||
if (array.size() >= 3) {
|
||||
// 计算三个深度值的平均值
|
||||
deepth = (array[0].asInt() + array[1].asInt() + array[2].asInt()) / 3;
|
||||
} else {
|
||||
std::cerr << "深度数组元素不足3个" << std::endl;
|
||||
LOG_F(WARNING, "深度数组元素不足3个");
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
std::cerr << "JSON格式错误" << std::endl;
|
||||
LOG_F(WARNING, "缺少或类型不匹配: value_array_int32");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -291,11 +312,6 @@ DeviceSwitchCmd UpperCommManager::getSetDevSwitch(const std::string& key, const
|
||||
return false;
|
||||
}
|
||||
|
||||
const std::string UpperCommManager::getCurrentEquState(DriverTable& driver)
|
||||
{
|
||||
return m_pm->m_driver.saveDriverTableToJson(&driver);
|
||||
}
|
||||
|
||||
const std::string UpperCommManager::getSubDisCmd(DriverTable& driver)
|
||||
{
|
||||
return m_pm->m_driver.saveDriverTableToJson(&driver);
|
||||
@@ -304,10 +320,15 @@ const std::string UpperCommManager::getSubDisCmd(DriverTable& driver)
|
||||
void UpperCommManager::processPeriodicTasks() {
|
||||
buildSystemReport();
|
||||
std::string strJson;
|
||||
strJson = getCurrentEquState(m_pm->m_currentDriverState);
|
||||
m_pm->sendNotification(PM_TO_DB_EQUIPMENTSTATE, strJson);
|
||||
strJson = getSubDisCmd(m_pm->m_subDisSysCmd);
|
||||
m_pm->sendNotification(PM_TO_DB_SUBDISCMD, strJson);
|
||||
//发送当前设备状态
|
||||
strJson = m_equStateMsg.buildMsg(m_pm->m_currentDriverState);
|
||||
m_pm->sendNotification(m_equStateMsg.key, strJson);
|
||||
//发送次级配电指令 修改后的代码
|
||||
// strJson = getSubDisCmd(m_pm->m_subDisSysCmd);
|
||||
strJson = m_secdistStateMsg.buildMsg(m_pm->m_subDisSysCmd);
|
||||
m_pm->sendNotification(m_secdistStateMsg.key_cmd, strJson);
|
||||
//发送仪表电状态
|
||||
m_pm->sendNotification(m_equInsStateMsg.key,m_equInsStateMsg.buildMsg(m_pm->m_subDisSysState));
|
||||
}
|
||||
bool UpperCommManager::parseControlCmdFromJson(MSControlCmd &cmd, const std::string &strJson)
|
||||
{
|
||||
@@ -354,394 +375,21 @@ bool UpperCommManager::parseControlCmdFromJson(MSControlCmd &cmd, const std::str
|
||||
return true; // 成功
|
||||
}
|
||||
void UpperCommManager::buildSystemReport() {
|
||||
string suffix;
|
||||
Json::Value pms;
|
||||
Json::Value fcs;
|
||||
Json::Value lbs;
|
||||
Json::Value dis;
|
||||
// 构建能源系统报告
|
||||
//1.构建系统状态报告
|
||||
suffix = getTypeName(typeid(m_pm->workCondition).name());
|
||||
pms[VAR_TO_STR(workCondition)+suffix] = m_pm->workCondition;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->currentMod).name());
|
||||
pms[VAR_TO_STR(currentMod)+suffix] = m_pm->currentMod;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->powerState).name());
|
||||
pms[VAR_TO_STR(powerState)+suffix] = m_pm->powerState;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->faultLevel).name());
|
||||
pms[VAR_TO_STR(faultLevel)+suffix] = m_pm->faultLevel;
|
||||
|
||||
Json::Value faultCode_array;
|
||||
for(auto val : m_pm->faultCode)
|
||||
{
|
||||
faultCode_array.append(val);
|
||||
}
|
||||
pms[VAR_TO_STR(faultCode_array)] = faultCode_array;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->soc).name());
|
||||
pms["soc_uint16"] = m_pm->soc;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->sustainableTime).name());
|
||||
pms["sustainableTime_int64"] = m_pm->sustainableTime;
|
||||
|
||||
pms["leakage_uint8"] = m_pm->m_leakage;
|
||||
|
||||
//2.构建燃料电池状态报告
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.fcuState).name());
|
||||
fcs[VAR_TO_STR(fcuState)+suffix] = m_pm->m_pmCurrentState.ccustate.fcuState;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.fcuFaultLeve).name());
|
||||
fcs[VAR_TO_STR(fcuFaultLeve)+suffix] = m_pm->m_pmCurrentState.ccustate.fcuFaultLeve;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.powerLimit).name());
|
||||
fcs[VAR_TO_STR(powLimit)+suffix] = m_pm->m_pmCurrentState.ccustate.powerLimit;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.totalPowerGeneration).name());
|
||||
fcs[VAR_TO_STR(powerGen)+suffix] = m_pm->m_pmCurrentState.ccustate.totalPowerGeneration;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.ch4o).name());
|
||||
fcs[VAR_TO_STR(ch4o)+suffix] = m_pm->m_pmCurrentState.ccustate.ch4o;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.o2).name());
|
||||
fcs[VAR_TO_STR(o2)+suffix] = m_pm->m_pmCurrentState.ccustate.o2;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.fcuVoltage).name());
|
||||
fcs[VAR_TO_STR(fcuVol)+suffix] = m_pm->m_pmCurrentState.ccustate.fcuVoltage;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.fcuCurrent).name());
|
||||
fcs[VAR_TO_STR(fcuCur)+suffix] = m_pm->m_pmCurrentState.ccustate.fcuCurrent;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.o2Level).name());
|
||||
fcs[VAR_TO_STR(o2Level)+suffix] = m_pm->m_pmCurrentState.ccustate.o2Level;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.exchangerTemperature).name());
|
||||
fcs[VAR_TO_STR(excTemp)+suffix] = m_pm->m_pmCurrentState.ccustate.exchangerTemperature;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.fcuOutPower).name());
|
||||
fcs[VAR_TO_STR(fcuOutPower)+suffix] = m_pm->m_pmCurrentState.ccustate.fcuOutPower;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.fcuOutIns).name());
|
||||
fcs[VAR_TO_STR(fcuOutIns)+suffix] = m_pm->m_pmCurrentState.ccustate.fcuOutIns;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.fcuVoltageIns).name());
|
||||
fcs[VAR_TO_STR(fcuVolIns)+suffix] = m_pm->m_pmCurrentState.ccustate.fcuVoltageIns;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.fcuVoltagePower).name());
|
||||
fcs[VAR_TO_STR(fcuVolPower)+suffix] = m_pm->m_pmCurrentState.ccustate.fcuVoltagePower;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.fcuCurrentIns).name());
|
||||
fcs[VAR_TO_STR(fcuCurIns)+suffix] = m_pm->m_pmCurrentState.ccustate.fcuCurrentIns;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.fcuCurrentPower).name());
|
||||
fcs[VAR_TO_STR(fcuCurPower)+suffix] = m_pm->m_pmCurrentState.ccustate.fcuCurrentPower;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.h2Concentration1).name());
|
||||
fcs[VAR_TO_STR(h2Concent1)+suffix] = m_pm->m_pmCurrentState.ccustate.h2Concentration1;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.h2Concentration2).name());
|
||||
fcs[VAR_TO_STR(h2Concent2)+suffix] = m_pm->m_pmCurrentState.ccustate.h2Concentration2;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.o2Concentration1).name());
|
||||
fcs[VAR_TO_STR(o2Concent1)+suffix] = m_pm->m_pmCurrentState.ccustate.o2Concentration1;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.o2Concentration2).name());
|
||||
fcs[VAR_TO_STR(o2Concent2)+suffix] = m_pm->m_pmCurrentState.ccustate.o2Concentration2;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.ch4oConcentration1).name());
|
||||
fcs[VAR_TO_STR(ch4oConcent1)+suffix] = m_pm->m_pmCurrentState.ccustate.ch4oConcentration1;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.ch4oConcentration2).name());
|
||||
fcs[VAR_TO_STR(ch4oConcent2)+suffix] = m_pm->m_pmCurrentState.ccustate.ch4oConcentration2;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.backpressure1).name());
|
||||
fcs[VAR_TO_STR(backpressure1)+suffix] = m_pm->m_pmCurrentState.ccustate.backpressure1;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.backpressure2).name());
|
||||
fcs[VAR_TO_STR(backpressure2)+suffix] = m_pm->m_pmCurrentState.ccustate.backpressure2;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.flameDetection).name());
|
||||
fcs[VAR_TO_STR(flameDet)+suffix] = m_pm->m_pmCurrentState.ccustate.flameDetection;
|
||||
|
||||
unsigned short faultCode1;
|
||||
unsigned short faultCode2;
|
||||
unsigned short faultCode3;
|
||||
faultCode1 = (m_pm->m_pmCurrentState.ccustate.fcuGZ_1H << 8) | m_pm->m_pmCurrentState.ccustate.fcuGZ_1L;
|
||||
faultCode2 = (m_pm->m_pmCurrentState.ccustate.fcuGZ_2H << 8) | m_pm->m_pmCurrentState.ccustate.fcuGZ_2L;
|
||||
faultCode3 = (m_pm->m_pmCurrentState.ccustate.fcuGZ_3H << 8) | m_pm->m_pmCurrentState.ccustate.fcuGZ_3L;
|
||||
|
||||
suffix = getTypeName(typeid(faultCode1).name());
|
||||
fcs[VAR_TO_STR(faultCode1)+suffix] = faultCode1;
|
||||
suffix = getTypeName(typeid(faultCode2).name());
|
||||
fcs[VAR_TO_STR(faultCode2)+suffix] = faultCode2;
|
||||
suffix = getTypeName(typeid(faultCode3).name());
|
||||
fcs[VAR_TO_STR(faultCode3)+suffix] = faultCode3;
|
||||
|
||||
//4.构建动力锂电池状态报告
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.insPosRelayState).name());
|
||||
lbs[VAR_TO_STR(insPosRelayState)+suffix] = m_pm->m_pmCurrentState.ccustate.insPosRelayState;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.insNegRelayState).name());
|
||||
lbs[VAR_TO_STR(insNegRelayState)+suffix] = m_pm->m_pmCurrentState.ccustate.insNegRelayState;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.powerPosRelayState).name());
|
||||
lbs[VAR_TO_STR(powPosRelayState)+suffix] = m_pm->m_pmCurrentState.ccustate.powerPosRelayState;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.powerNegRelayState).name());
|
||||
lbs[VAR_TO_STR(powNegRelayState)+suffix] = m_pm->m_pmCurrentState.ccustate.powerNegRelayState;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.insBatLimit).name());
|
||||
lbs[VAR_TO_STR(insBatLimit)+suffix] = m_pm->m_pmCurrentState.ccustate.insBatLimit;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.powerBatLimit).name());
|
||||
lbs[VAR_TO_STR(powerBatLimit)+suffix] = m_pm->m_pmCurrentState.ccustate.powerBatLimit;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.insBatSoc).name());
|
||||
lbs[VAR_TO_STR(insBatSoc)+suffix] = m_pm->m_pmCurrentState.ccustate.insBatSoc;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.powerBatSoc).name());
|
||||
lbs[VAR_TO_STR(powBatSoc)+suffix] = m_pm->m_pmCurrentState.ccustate.powerBatSoc;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.insBatTotalElectricity).name());
|
||||
lbs[VAR_TO_STR(insBatTotalElect)+suffix] = m_pm->m_pmCurrentState.ccustate.insBatTotalElectricity;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.powerBatTotalElectricity).name());
|
||||
lbs[VAR_TO_STR(powBatTotalElect)+suffix] = m_pm->m_pmCurrentState.ccustate.powerBatTotalElectricity;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.insBatCurrentElectricity).name());
|
||||
lbs[VAR_TO_STR(insBatCurElect)+suffix] = m_pm->m_pmCurrentState.ccustate.insBatCurrentElectricity;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.powerBatCurrentElectricity).name());
|
||||
lbs[VAR_TO_STR(powBatCurElect)+suffix] = m_pm->m_pmCurrentState.ccustate.powerBatCurrentElectricity;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.insChargeState).name());
|
||||
lbs[VAR_TO_STR(insChargeState)+suffix] = m_pm->m_pmCurrentState.ccustate.insChargeState;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.powerChargeState).name());
|
||||
lbs[VAR_TO_STR(powChargeState)+suffix] = m_pm->m_pmCurrentState.ccustate.powerChargeState;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.insLinkVoltage).name());
|
||||
lbs[VAR_TO_STR(insLinkVol)+suffix] = m_pm->m_pmCurrentState.ccustate.insLinkVoltage;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.insPackVoltage).name());
|
||||
lbs[VAR_TO_STR(insPackVol)+suffix] = m_pm->m_pmCurrentState.ccustate.insPackVoltage;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.insCurrent).name());
|
||||
lbs[VAR_TO_STR(insCurrent)+suffix] = m_pm->m_pmCurrentState.ccustate.insCurrent;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.insPosInsulationResistance).name());
|
||||
lbs[VAR_TO_STR(insPosRes)+suffix] = m_pm->m_pmCurrentState.ccustate.insPosInsulationResistance;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.insNegInsulationResistance).name());
|
||||
lbs[VAR_TO_STR(insNegRes)+suffix] = m_pm->m_pmCurrentState.ccustate.insNegInsulationResistance;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.powerLinkVoltage).name());
|
||||
lbs[VAR_TO_STR(powLinkVol)+suffix] = m_pm->m_pmCurrentState.ccustate.powerLinkVoltage;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.powerPackVoltage).name());
|
||||
lbs[VAR_TO_STR(powerPackVol)+suffix] = m_pm->m_pmCurrentState.ccustate.powerPackVoltage;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.powerCurrent).name());
|
||||
lbs[VAR_TO_STR(powCur)+suffix] = m_pm->m_pmCurrentState.ccustate.powerCurrent;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.powerPosInsulationResistance).name());
|
||||
lbs[VAR_TO_STR(powPosRes)+suffix] = m_pm->m_pmCurrentState.ccustate.powerPosInsulationResistance;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.powerNegInsulationResistance).name());
|
||||
lbs[VAR_TO_STR(powNegRes)+suffix] = m_pm->m_pmCurrentState.ccustate.powerNegInsulationResistance;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.insCurrentSocHold1).name());
|
||||
lbs[VAR_TO_STR(insCurSocHold1)+suffix] = m_pm->m_pmCurrentState.ccustate.insCurrentSocHold1;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.insCurrentSocHold2).name());
|
||||
lbs[VAR_TO_STR(insCurSocHold2)+suffix] = m_pm->m_pmCurrentState.ccustate.insCurrentSocHold2;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.insCurrentSocHold3).name());
|
||||
lbs[VAR_TO_STR(insCurSocHold3)+suffix] = m_pm->m_pmCurrentState.ccustate.insCurrentSocHold3;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.fcuCurrentToInsLimit1).name());
|
||||
lbs[VAR_TO_STR(fcuCurToInsLimit1)+suffix] = m_pm->m_pmCurrentState.ccustate.fcuCurrentToInsLimit1;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.fcuCurrentToinsLimit2).name());
|
||||
lbs[VAR_TO_STR(fcuCurToinsLimit2)+suffix] = m_pm->m_pmCurrentState.ccustate.fcuCurrentToinsLimit2;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.powerCurrentSocHold1).name());
|
||||
lbs[VAR_TO_STR(powCurSocHold1)+suffix] = m_pm->m_pmCurrentState.ccustate.powerCurrentSocHold1;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.powerCurrentSocHold2).name());
|
||||
lbs[VAR_TO_STR(powCurSocHold2)+suffix] = m_pm->m_pmCurrentState.ccustate.powerCurrentSocHold2;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.powerCurrentSocHold3).name());
|
||||
lbs[VAR_TO_STR(powCurSocHold3)+suffix] = m_pm->m_pmCurrentState.ccustate.powerCurrentSocHold3;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.powerCurrentToInsLimit1).name());
|
||||
lbs[VAR_TO_STR(powCurToInsLimit1)+suffix] = m_pm->m_pmCurrentState.ccustate.powerCurrentToInsLimit1;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.powerCurrentToinsLimit2).name());
|
||||
lbs[VAR_TO_STR(powCurToinsLimit2)+suffix] = m_pm->m_pmCurrentState.ccustate.powerCurrentToinsLimit2;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.insAlarmIdentificationWord).name());
|
||||
lbs[VAR_TO_STR(insfaultCode)+suffix] = m_pm->m_pmCurrentState.ccustate.insAlarmIdentificationWord;
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.powerAlarmIdentificationWord).name());
|
||||
lbs[VAR_TO_STR(powfaultCode)+suffix] = m_pm->m_pmCurrentState.ccustate.powerAlarmIdentificationWord;
|
||||
|
||||
//5.构建配电系统状态报告
|
||||
disBus1Breaker* pdis1=new disBus1Breaker;
|
||||
disBus2Breaker* pdis2=new disBus2Breaker;
|
||||
disBus3Breaker* pdis3=new disBus3Breaker;
|
||||
disBus4Breaker* pdis4=new disBus4Breaker;
|
||||
|
||||
*pdis1 = m_pm->m_currentDisBreakerState.bus1Breaker;
|
||||
*pdis2 = m_pm->m_currentDisBreakerState.bus2Breaker;
|
||||
*pdis3 = m_pm->m_currentDisBreakerState.bus3Breaker;
|
||||
*pdis4 = m_pm->m_currentDisBreakerState.bus4Breaker;
|
||||
|
||||
dis["HVolBusBreaker_uint16"] = *(unsigned short*)pdis1;
|
||||
dis["HVolABusBreaker_unit16"] = *(unsigned short*)pdis2;
|
||||
dis["HVolBBusBreaker_unit16"] = *(unsigned short*)pdis3;
|
||||
dis["LVolBusBreaker_uint16"] = *(unsigned short*)pdis4;
|
||||
|
||||
//TODO: 构建配电系统故障码
|
||||
Json::Value faultCodeDis_array;
|
||||
for(auto val : m_pm->faultCode)
|
||||
{
|
||||
faultCodeDis_array.append(val);
|
||||
}
|
||||
dis[VAR_TO_STR(faultCode_array)] = faultCodeDis_array;
|
||||
|
||||
|
||||
Json::Value currentBusState;
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.bus1State.powerBusVoltage).name());
|
||||
currentBusState[VAR_TO_STR(HVBpowerBusVol)+suffix] = m_pm->m_pmCurrentState.bus1State.powerBusVoltage;
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.bus1State.dcDc5ModuleCurrent).name());
|
||||
currentBusState[VAR_TO_STR(HVBdcDc5Cur)+suffix] = m_pm->m_pmCurrentState.bus1State.dcDc5ModuleCurrent;
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.bus1State.powerBusCurrent).name());
|
||||
currentBusState[VAR_TO_STR(HVBpowerBusCur)+suffix] = m_pm->m_pmCurrentState.bus1State.powerBusCurrent;
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.bus1State.busbarAVoltage).name());
|
||||
currentBusState[VAR_TO_STR(HVBbusAVol)+suffix] = m_pm->m_pmCurrentState.bus1State.busbarAVoltage;
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.bus1State.propulsionMotorControlBoxCurrent).name());
|
||||
currentBusState[VAR_TO_STR(HVBmotorCur)+suffix] = m_pm->m_pmCurrentState.bus1State.propulsionMotorControlBoxCurrent;
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.bus1State.busbarACurrent).name());
|
||||
currentBusState[VAR_TO_STR(HVBbusACur)+suffix] = m_pm->m_pmCurrentState.bus1State.busbarACurrent;
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.bus1State.lithiumBatteryGroupMeterCurrent).name());
|
||||
currentBusState[VAR_TO_STR(HVBbatGroupCur)+suffix] = m_pm->m_pmCurrentState.bus1State.lithiumBatteryGroupMeterCurrent;
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.bus1State.bowHighVoltageDistributionBoxCurrent).name());
|
||||
currentBusState[VAR_TO_STR(HVBbowHVolDisBoxCur)+suffix] = m_pm->m_pmCurrentState.bus1State.bowHighVoltageDistributionBoxCurrent;
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.bus1State.sternFTDevice45Current).name());
|
||||
currentBusState[VAR_TO_STR(HVBFTDev45Cur)+suffix] = m_pm->m_pmCurrentState.bus1State.sternFTDevice45Current;
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.bus1State.tyzReservedSwitchCurrent).name());
|
||||
currentBusState[VAR_TO_STR(HVBtyzCur)+suffix] = m_pm->m_pmCurrentState.bus1State.tyzReservedSwitchCurrent;
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.bus1State.sternRudderSwitch1Current).name());
|
||||
currentBusState[VAR_TO_STR(HVBsternRud1Cur)+suffix] = m_pm->m_pmCurrentState.bus1State.sternRudderSwitch1Current;
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.bus1State.reservedCurrent1).name());
|
||||
currentBusState[VAR_TO_STR(HVBreservedCur1)+suffix] = m_pm->m_pmCurrentState.bus1State.reservedCurrent1;
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.bus1State.sternRudderSwitch2Current).name());
|
||||
currentBusState[VAR_TO_STR(HVBsternRud2Cur)+suffix] = m_pm->m_pmCurrentState.bus1State.sternRudderSwitch2Current;
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.bus1State.reservedCurrent2).name());
|
||||
currentBusState[VAR_TO_STR(HVBreservedCur2)+suffix] = m_pm->m_pmCurrentState.bus1State.reservedCurrent2;
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.bus1State.fbReservedSwitchCurrent).name());
|
||||
currentBusState[VAR_TO_STR(HVBfbCur)+suffix] = m_pm->m_pmCurrentState.bus1State.fbReservedSwitchCurrent;
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.bus1State.reservedCurrent3).name());
|
||||
currentBusState[VAR_TO_STR(HVBreservedCur3)+suffix] = m_pm->m_pmCurrentState.bus1State.reservedCurrent3;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.bus2State.busbarBVoltage).name());
|
||||
currentBusState[VAR_TO_STR(HVABbusBVol)+suffix] = m_pm->m_pmCurrentState.bus2State.busbarBVoltage;
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.bus2State.busbarBCurrent).name());
|
||||
currentBusState[VAR_TO_STR(HVABbusBCur)+suffix] = m_pm->m_pmCurrentState.bus2State.busbarBCurrent;
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.bus2State.bowFTDevice123Current).name());
|
||||
currentBusState[VAR_TO_STR(HVABFTDev123Cur)+suffix] = m_pm->m_pmCurrentState.bus2State.bowFTDevice123Current;
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.bus2State.actuatorCurrent).name());
|
||||
currentBusState[VAR_TO_STR(HVABactCur)+suffix] = m_pm->m_pmCurrentState.bus2State.actuatorCurrent;
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.bus2State.mastSteeringGearControlBoxCurrent).name());
|
||||
currentBusState[VAR_TO_STR(HVABmastSteGeaCur)+suffix] = m_pm->m_pmCurrentState.bus2State.mastSteeringGearControlBoxCurrent;
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.bus2State.xczCurrent).name());
|
||||
currentBusState[VAR_TO_STR(HVABxczCur)+suffix] = m_pm->m_pmCurrentState.bus2State.xczCurrent;
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.bus2State.bowRudderControlBoxCurrent).name());
|
||||
currentBusState[VAR_TO_STR(HVABbowRudCur)+suffix] = m_pm->m_pmCurrentState.bus2State.bowRudderControlBoxCurrent;
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.bus2State.openWaterCoverStartCylinderCurrent).name());
|
||||
currentBusState[VAR_TO_STR(HVABopenWaterCur)+suffix] = m_pm->m_pmCurrentState.bus2State.openWaterCoverStartCylinderCurrent;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.bus3State.instrumentBusbarVoltage).name());
|
||||
currentBusState[VAR_TO_STR(HVBBinsBusVol)+suffix] = m_pm->m_pmCurrentState.bus3State.instrumentBusbarVoltage;
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.bus3State.bowLowVoltageDistributionBoxCurrent).name());
|
||||
currentBusState[VAR_TO_STR(HVBBbowLowVolDisBoxCur)+suffix] = m_pm->m_pmCurrentState.bus3State.bowLowVoltageDistributionBoxCurrent;
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.bus3State.dcC1InstrumentDC48VCurrent).name());
|
||||
currentBusState[VAR_TO_STR(HVBBdcC1InsCur)+suffix] = m_pm->m_pmCurrentState.bus3State.dcC1InstrumentDC48VCurrent;
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.bus3State.reservedCurrent1).name());
|
||||
currentBusState[VAR_TO_STR(HVBBreservedCur1)+suffix] = m_pm->m_pmCurrentState.bus3State.reservedCurrent1;
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.bus3State.emergencyLithiumBatteryGroup2Current).name());
|
||||
currentBusState[VAR_TO_STR(HVBBemerBatCur)+suffix] = m_pm->m_pmCurrentState.bus3State.emergencyLithiumBatteryGroup2Current;
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.bus3State.lithiumBatteryGroupInstrumentCurrent).name());
|
||||
currentBusState[VAR_TO_STR(HVBBbatInsCur)+suffix] = m_pm->m_pmCurrentState.bus3State.lithiumBatteryGroupInstrumentCurrent;
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.bus3State.unit4InstrumentDC48VCurrent).name());
|
||||
currentBusState[VAR_TO_STR(HVBBunit4Cur)+suffix] = m_pm->m_pmCurrentState.bus3State.unit4InstrumentDC48VCurrent;
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.bus3State.reservedCurrent2).name());
|
||||
currentBusState[VAR_TO_STR(HVBBreservedCur2)+suffix] = m_pm->m_pmCurrentState.bus3State.reservedCurrent2;
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.bus3State.emergency2BusbarVoltage).name());
|
||||
currentBusState[VAR_TO_STR(HVBBemer2BusVol)+suffix] = m_pm->m_pmCurrentState.bus3State.emergency2BusbarVoltage;
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.bus3State.compositeEnergyManagementSystemEmergencyDC48VCurrent).name());
|
||||
currentBusState[VAR_TO_STR(HVBBCCUCur)+suffix] = m_pm->m_pmCurrentState.bus3State.compositeEnergyManagementSystemEmergencyDC48VCurrent;
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.bus3State.fuelCellSecuritySystemEmergencyDC48VCurrent).name());
|
||||
currentBusState[VAR_TO_STR(HVBBFCSSecurSysCur)+suffix] = m_pm->m_pmCurrentState.bus3State.fuelCellSecuritySystemEmergencyDC48VCurrent;
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.bus3State.plcControlPowerCurrent).name());
|
||||
currentBusState[VAR_TO_STR(HVBBplcCur)+suffix] = m_pm->m_pmCurrentState.bus3State.plcControlPowerCurrent;
|
||||
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.bus4State.instrumentBusbarVoltage).name());
|
||||
currentBusState[VAR_TO_STR(LVBinsBusVol)+suffix] = m_pm->m_pmCurrentState.bus4State.instrumentBusbarVoltage;
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.bus4State.instrumentBusbarCurrent).name());
|
||||
currentBusState[VAR_TO_STR(LVBBinsBusCur)+suffix] = m_pm->m_pmCurrentState.bus4State.instrumentBusbarCurrent;
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.bus4State.unit1Current).name());
|
||||
currentBusState[VAR_TO_STR(LVBBunit1Cur)+suffix] = m_pm->m_pmCurrentState.bus4State.unit1Current;
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.bus4State.unit2Current).name());
|
||||
currentBusState[VAR_TO_STR(LVBBunit2Cur)+suffix] = m_pm->m_pmCurrentState.bus4State.unit2Current;
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.bus4State.unit3Current).name());
|
||||
currentBusState[VAR_TO_STR(LVBBunit3Cur)+suffix] = m_pm->m_pmCurrentState.bus4State.unit3Current;
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.bus4State.unit5Current).name());
|
||||
currentBusState[VAR_TO_STR(LVBBunit5Cur)+suffix] = m_pm->m_pmCurrentState.bus4State.unit5Current;
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.bus4State.bowPZDeviceCurrent).name());
|
||||
currentBusState[VAR_TO_STR(LVBBbowPZDevCur)+suffix] = m_pm->m_pmCurrentState.bus4State.bowPZDeviceCurrent;
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.bus4State.emergencyLithiumBatteryGroup1Current).name());
|
||||
currentBusState[VAR_TO_STR(LVBBemerBatCur)+suffix] = m_pm->m_pmCurrentState.bus4State.emergencyLithiumBatteryGroup1Current;
|
||||
suffix = getTypeName(typeid(m_pm->m_pmCurrentState.bus4State.emergency1BusbarVoltage).name());
|
||||
currentBusState[VAR_TO_STR(LVBBemerBusVol)+suffix] = m_pm->m_pmCurrentState.bus4State.emergency1BusbarVoltage;
|
||||
|
||||
// dis["currentBusState"] = currentBusState;
|
||||
|
||||
// pms[VAR_TO_STR(fcs_obj)] = fcs;
|
||||
// pms[VAR_TO_STR(lbs_obj)] = lbs;
|
||||
// pms[VAR_TO_STR(dis_obj)] = dis;
|
||||
|
||||
m_pm->sendNotification(PM_TO_DB_STATE, pms.toStyledString());
|
||||
m_pm->sendNotification(PM_TO_DB_FCSSTATE, fcs.toStyledString());
|
||||
m_pm->sendNotification(PM_TO_DB_LIBATSTATE, lbs.toStyledString());
|
||||
m_pm->sendNotification(PM_TO_DB_DISSTATE, dis.toStyledString());
|
||||
m_pm->sendNotification(PM_TO_DB_CURRENTSTATE, currentBusState.toStyledString());
|
||||
|
||||
// 使用StreamWriterBuilder来设置保持插入顺序
|
||||
Json::StreamWriterBuilder builder;
|
||||
builder["indentation"] = " "; // 设置不缩进,保持紧凑格式
|
||||
builder["enableYAMLCompatibility"] = true; // 保持插入顺序
|
||||
|
||||
// 将Json::Value对象转换为字符串
|
||||
string pathFile = "/home/zjk/project/H100/H100PowerManger/data/msg/";
|
||||
string jsonStr = Json::writeString(builder, pms);
|
||||
|
||||
saveStringToJsonFile(jsonStr, pathFile+PM_TO_DB_STATE+".json");
|
||||
|
||||
jsonStr = Json::writeString(builder, fcs);
|
||||
saveStringToJsonFile(jsonStr, pathFile+PM_TO_DB_FCSSTATE+".json");
|
||||
|
||||
jsonStr = Json::writeString(builder, lbs);
|
||||
saveStringToJsonFile(jsonStr, pathFile+PM_TO_DB_LIBATSTATE+".json");
|
||||
|
||||
jsonStr = Json::writeString(builder, dis);
|
||||
saveStringToJsonFile(jsonStr, pathFile+PM_TO_DB_DISSTATE + ".json");
|
||||
|
||||
jsonStr = Json::writeString(builder, currentBusState);
|
||||
saveStringToJsonFile(jsonStr, pathFile+PM_TO_DB_CURRENTSTATE + ".json");
|
||||
|
||||
// return true;
|
||||
m_pmStateMsg.state.workCondition = m_pm->workCondition;
|
||||
m_pmStateMsg.state.currentMod = m_pm->currentMod;
|
||||
m_pmStateMsg.state.powerState = m_pm->powerState;
|
||||
m_pmStateMsg.state.faultLevel = m_pm->faultLevel;
|
||||
m_pmStateMsg.state.faultCode = m_pm->faultCode;
|
||||
m_pmStateMsg.state.soc = m_pm->soc;
|
||||
m_pmStateMsg.state.sustainableTime = m_pm->sustainableTime;
|
||||
m_pmStateMsg.state.m_leakage = m_pm->m_leakage;
|
||||
m_pmStateMsg.state.m_faultNum = m_pm->m_faultNum;
|
||||
|
||||
m_pm->sendNotification(m_pmStateMsg.key, m_pmStateMsg.buildMsg());
|
||||
m_pm->sendNotification(m_fcsStateMsg.key, m_fcsStateMsg.buildMsg(m_pm->m_pmCurrentState.ccustate));
|
||||
m_pm->sendNotification(m_liBatStateMsg.key, m_liBatStateMsg.buildMsg(m_pm->m_pmCurrentState.ccustate));
|
||||
m_pm->sendNotification(m_disSysStateMsg.key, m_disSysStateMsg.buildMsg(m_pm->m_currentDisBreakerState));
|
||||
m_pm->sendNotification(m_currentStateMsg.key, m_currentStateMsg.buildMsg(m_pm->m_pmCurrentState));
|
||||
}
|
||||
bool UpperCommManager::saveStringToJsonFile(const string &strJson, const string &filePath)
|
||||
{
|
||||
@@ -756,35 +404,3 @@ bool UpperCommManager::saveStringToJsonFile(const string &strJson, const string
|
||||
return false;
|
||||
}
|
||||
}
|
||||
string UpperCommManager::getTypeName(const string typeName)
|
||||
{
|
||||
// 映射类型名称到指定的字符串
|
||||
if (typeName == "i" || typeName == "c") {
|
||||
return "_int8";
|
||||
} else if (typeName == "h" || typeName == "C") {
|
||||
return "_uint8";
|
||||
} else if (typeName == "s" || typeName == "S") {
|
||||
return "_int16";
|
||||
} else if (typeName == "t" || typeName == "T") {
|
||||
return "_uint16";
|
||||
} else if (typeName == "i" || typeName == "I") {
|
||||
return "_int32";
|
||||
} else if (typeName == "j" || typeName == "J") {
|
||||
return "_uint32";
|
||||
} else if (typeName == "x" || typeName == "X") {
|
||||
return "_int64";
|
||||
} else if (typeName == "f" || typeName == "F") {
|
||||
return "_fp32";
|
||||
} else if (typeName == "d" || typeName == "D") {
|
||||
return "_fp64";
|
||||
} else if (typeName == "b" || typeName == "B") {
|
||||
return "_bool";
|
||||
} else if (typeName == "NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE") {
|
||||
return "_str";
|
||||
} else if (typeName == "St6vector" || typeName == "St5deque" || typeName == "St4list" || typeName == "St4pair") {
|
||||
return "_array";
|
||||
} else {
|
||||
// 默认情况
|
||||
return "_obj";
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,14 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include "msg/uPower_equInsState.h"
|
||||
#include "msg/uDevice_secdistState.h"
|
||||
#include "msg/uPower_equState.h"
|
||||
#include "msg/uPower_disSysState.h"
|
||||
#include "msg/uPower_currentState_st.h"
|
||||
#include "msg/uPower_pmState.h"
|
||||
#include "msg/uPower_fcsState.h"
|
||||
#include "msg/uPower_liBatState.h"
|
||||
using namespace std;
|
||||
#define VAR_TO_STR(var) #var
|
||||
//能源管理反馈的消息
|
||||
@@ -18,7 +26,6 @@ using namespace std;
|
||||
#define PM_TO_DB_FCSSTATE "uPower_fcsState_st"
|
||||
|
||||
#define PM_TO_DB_SUBDISCMD "uPower_secdistState_cmd"
|
||||
#define PM_TO_DB_EQUIPMENTSTATE "uPower_equState_fb"
|
||||
|
||||
//控制消息
|
||||
#define DB_TO_PM_MSCMD "uPower_sysState_cmd"
|
||||
@@ -65,19 +72,25 @@ public:
|
||||
int getSetPMSys(const std::string& key, const std::string& msg);
|
||||
DeviceSwitchCmd getSetDevSwitch(const std::string& key, const std::string& msg);
|
||||
|
||||
const std::string getCurrentEquState(DriverTable& driver);
|
||||
const std::string getSubDisCmd(DriverTable& driver);
|
||||
// 其他公共函数
|
||||
string getTypeName(const string typeName);
|
||||
bool saveStringToJsonFile(const string &strJson, const string &filePath);
|
||||
|
||||
|
||||
private:
|
||||
PowerManger* m_pm;
|
||||
MSControlCmd m_msCmd;
|
||||
Driver m_driver;
|
||||
//定义上位机消息
|
||||
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;
|
||||
|
||||
|
||||
// 从JSON解析控制命令
|
||||
bool parseControlCmdFromJson(MSControlCmd &cmd, const std::string &strJson);
|
||||
};
|
||||
|
||||
|
||||
@@ -8,9 +8,9 @@
|
||||
#define DIS_MSG_HEAD1 0x40
|
||||
#define DIS_MSG_HEAD2 0x40
|
||||
|
||||
#define CCU_CMD_ID 0x0050
|
||||
#define CCU_SET_PARM_ID 0x0051
|
||||
#define CCU_STATE_FB_ID 0x0041
|
||||
#define CCU_CMD_ID 0x0040
|
||||
#define CCU_SET_PARM_ID 0x0041
|
||||
#define CCU_STATE_FB_ID 0x0051
|
||||
#define CCU_SET_PARM_FB_ID 0x0040
|
||||
|
||||
#define DIS_HVBUS_FB_ID 0x0005
|
||||
|
||||
+121
-67
@@ -763,6 +763,60 @@ int Driver::SafeReadUInt(const Json::Value& root, const std::string& key, unsign
|
||||
return 0; // 成功读取
|
||||
}
|
||||
|
||||
vector<DriverCommand> Driver::loadDriverIdFromJson(const std::string &strJson) {
|
||||
Json::CharReaderBuilder builder;
|
||||
Json::Value root;
|
||||
std::string errs;
|
||||
vector<DriverCommand> driverCmd;
|
||||
|
||||
// 解析JSON字符串
|
||||
std::istringstream s(strJson);
|
||||
if (!Json::parseFromStream(builder, s, &root, &errs)) {
|
||||
std::cerr << "JSON解析失败: " << errs << std::endl;
|
||||
return driverCmd;
|
||||
}
|
||||
// 设备字段名到ID的映射
|
||||
const std::map<std::string, int> fieldToId = {
|
||||
{"depth1", 18}, {"depth2", 19}, {"depth3", 20},
|
||||
{"overDeep1", 21}, {"overDeep2", 22},
|
||||
{"ctd1", 23}, {"ctd2", 24}, {"soundVeloc", 25},
|
||||
{"commMast", 40}, {"ins", 57}, {"ntp", 58},
|
||||
{"inputWaterSensor1", 59}, {"inputWaterSensor2", 60}, {"inputWaterSensor3", 61},
|
||||
{"singleBeamSonar1", 0}, {"singleBeamSonar2", 1}, {"singleBeamSonar3", 2},
|
||||
{"singleBeamSonar4", 3}, {"singleBeamSonar5", 4}, {"singleBeamSonar6", 5},
|
||||
{"singleBeamSonar7", 6}, {"singleBeamSonar8", 7}, {"forwardSonar", 8},
|
||||
{"DVL", 43}, {"lowFreqSonar", 36}, {"USBL", 42},
|
||||
{"bowCover1", 9}, {"bowCover2", 10}, {"bowCover3", 11},
|
||||
{"bowCover4", 12}, {"bowCover5", 13}, {"bowCover6", 14},
|
||||
{"bowRudderDeploy", 15}, {"bowRudderServo1", 16}, {"bowRudderServo2", 17},
|
||||
{"bowWaterlnet1", 27}, {"bowWaterlnet2", 28}, {"bowWaterlnet3", 29},
|
||||
{"bowWaterlnet4", 30}, {"bowWaterlnet5", 31}, {"bowWaterlnet6", 32},
|
||||
{"bowWaterlnet7", 33}, {"bowWaterlnet8", 34}, {"waterInject", 26},
|
||||
{"mastLiftingServo", 41}, {"buoyancyAdjust1", 44}, {"buoyancyAdjust2", 45},
|
||||
{"buoyancyAdjust3", 46}, {"buoyancyAdjust4", 47}, {"buoyancyAdjust5", 48},
|
||||
{"sternRudderServo1", 49}, {"sternRudderServo2", 50}, {"sternRudderServo3", 51},
|
||||
{"sternRudderServo4", 52}, {"thruster", 53}, {"bowThrow", 54},
|
||||
{"sternThrow", 55}, {"photoSensor", 38}, {"electSensor", 39},
|
||||
{"launchControler", 37}, {"sideSonar", 35}, {"buoyage", 56}
|
||||
};
|
||||
|
||||
// 检查每个字段,如果存在且值发生变化,则添加到返回向量中
|
||||
for (const auto& [field, id] : fieldToId) {
|
||||
if (root.isMember(field)) {
|
||||
unsigned char newValue = root[field].asUInt();
|
||||
// unsigned char& currentValue = *((unsigned char*)&table + offsetof(DriverTable, depth1) +
|
||||
// (fieldToId.at(field) - 18) * sizeof(unsigned char));
|
||||
|
||||
DriverCommand cmd;
|
||||
cmd.id = id;
|
||||
cmd.cmd = newValue;
|
||||
driverCmd.push_back(cmd);
|
||||
}
|
||||
}
|
||||
|
||||
return driverCmd;
|
||||
}
|
||||
|
||||
int Driver::loadDriverTableFromJson(const std::string &strJson, DriverTable& table)
|
||||
{
|
||||
Json::CharReaderBuilder builder;
|
||||
@@ -775,198 +829,198 @@ int Driver::loadDriverTableFromJson(const std::string &strJson, DriverTable& tab
|
||||
{
|
||||
std::cerr << "JSON解析失败: " << errs << std::endl;
|
||||
return -3; // 解析失败
|
||||
}
|
||||
|
||||
}
|
||||
// 读取 JSON 数据并填充结构体,逐个字段检查
|
||||
int error_code = 0;
|
||||
|
||||
error_code = SafeReadUInt(root, "depth1", table.depth1);
|
||||
error_code = SafeReadUInt(root, "depth1_uint8", table.depth1);
|
||||
if (error_code != 0) return error_code;
|
||||
|
||||
error_code = SafeReadUInt(root, "depth2", table.depth2);
|
||||
error_code = SafeReadUInt(root, "depth2_uint8", table.depth2);
|
||||
if (error_code != 0) return error_code;
|
||||
|
||||
error_code = SafeReadUInt(root, "depth3", table.depth3);
|
||||
error_code = SafeReadUInt(root, "depth3_uint8", table.depth3);
|
||||
if (error_code != 0) return error_code;
|
||||
|
||||
error_code = SafeReadUInt(root, "overDeep1", table.overDeep1);
|
||||
// error_code = SafeReadUInt(root, "overDeep1_uint8", table.overDeep1);
|
||||
// if (error_code != 0) return error_code;
|
||||
|
||||
// error_code = SafeReadUInt(root, "overDeep2_uint8", table.overDeep2);
|
||||
// if (error_code != 0) return error_code;
|
||||
|
||||
error_code = SafeReadUInt(root, "ctd1_uint8", table.ctd1);
|
||||
if (error_code != 0) return error_code;
|
||||
|
||||
error_code = SafeReadUInt(root, "overDeep2", table.overDeep2);
|
||||
error_code = SafeReadUInt(root, "ctd2_uint8", table.ctd2);
|
||||
if (error_code != 0) return error_code;
|
||||
|
||||
error_code = SafeReadUInt(root, "ctd1", table.ctd1);
|
||||
error_code = SafeReadUInt(root, "soundVeloc_uint8", table.soundVeloc);
|
||||
if (error_code != 0) return error_code;
|
||||
|
||||
error_code = SafeReadUInt(root, "ctd2", table.ctd2);
|
||||
error_code = SafeReadUInt(root, "commDev_uint8", table.commMast);
|
||||
if (error_code != 0) return error_code;
|
||||
|
||||
error_code = SafeReadUInt(root, "soundVeloc", table.soundVeloc);
|
||||
error_code = SafeReadUInt(root, "ins_uint8", table.ins);
|
||||
if (error_code != 0) return error_code;
|
||||
|
||||
error_code = SafeReadUInt(root, "commMast", table.commMast);
|
||||
error_code = SafeReadUInt(root, "ntp_uint8", table.ntp);
|
||||
if (error_code != 0) return error_code;
|
||||
|
||||
error_code = SafeReadUInt(root, "ins", table.ins);
|
||||
error_code = SafeReadUInt(root, "inputWaterSensor1_uint8", table.inputWaterSensor1);
|
||||
if (error_code != 0) return error_code;
|
||||
|
||||
error_code = SafeReadUInt(root, "ntp", table.ntp);
|
||||
error_code = SafeReadUInt(root, "inputWaterSensor2_uint8", table.inputWaterSensor2);
|
||||
if (error_code != 0) return error_code;
|
||||
|
||||
error_code = SafeReadUInt(root, "inputWaterSensor1", table.inputWaterSensor1);
|
||||
if (error_code != 0) return error_code;
|
||||
|
||||
error_code = SafeReadUInt(root, "inputWaterSensor2", table.inputWaterSensor2);
|
||||
if (error_code != 0) return error_code;
|
||||
|
||||
error_code = SafeReadUInt(root, "inputWaterSensor3", table.inputWaterSensor3);
|
||||
error_code = SafeReadUInt(root, "inputWaterSensor3_uint8", table.inputWaterSensor3);
|
||||
if (error_code != 0) return error_code;
|
||||
|
||||
// 水声设备
|
||||
error_code = SafeReadUInt(root, "singleBeamSonar1", table.singleBeamSonar1);
|
||||
error_code = SafeReadUInt(root, "singleBeamSonar1_uint8", table.singleBeamSonar1);
|
||||
if (error_code != 0) return error_code;
|
||||
|
||||
error_code = SafeReadUInt(root, "singleBeamSonar2", table.singleBeamSonar2);
|
||||
error_code = SafeReadUInt(root, "singleBeamSonar2_uint8", table.singleBeamSonar2);
|
||||
if (error_code != 0) return error_code;
|
||||
|
||||
error_code = SafeReadUInt(root, "singleBeamSonar3", table.singleBeamSonar3);
|
||||
error_code = SafeReadUInt(root, "singleBeamSonar3_uint8", table.singleBeamSonar3);
|
||||
if (error_code != 0) return error_code;
|
||||
|
||||
error_code = SafeReadUInt(root, "singleBeamSonar4", table.singleBeamSonar4);
|
||||
error_code = SafeReadUInt(root, "singleBeamSonar4_uint8", table.singleBeamSonar4);
|
||||
if (error_code != 0) return error_code;
|
||||
|
||||
error_code = SafeReadUInt(root, "singleBeamSonar5", table.singleBeamSonar5);
|
||||
error_code = SafeReadUInt(root, "singleBeamSonar5_uint8", table.singleBeamSonar5);
|
||||
if (error_code != 0) return error_code;
|
||||
|
||||
error_code = SafeReadUInt(root, "singleBeamSonar6", table.singleBeamSonar6);
|
||||
error_code = SafeReadUInt(root, "singleBeamSonar6_uint8", table.singleBeamSonar6);
|
||||
if (error_code != 0) return error_code;
|
||||
|
||||
error_code = SafeReadUInt(root, "singleBeamSonar7", table.singleBeamSonar7);
|
||||
error_code = SafeReadUInt(root, "singleBeamSonar7_uint8", table.singleBeamSonar7);
|
||||
if (error_code != 0) return error_code;
|
||||
|
||||
error_code = SafeReadUInt(root, "singleBeamSonar8", table.singleBeamSonar8);
|
||||
error_code = SafeReadUInt(root, "singleBeamSonar8_uint8", table.singleBeamSonar8);
|
||||
if (error_code != 0) return error_code;
|
||||
|
||||
error_code = SafeReadUInt(root, "forwardSonar", table.forwardSonar);
|
||||
error_code = SafeReadUInt(root, "forwardSonar_uint8", table.forwardSonar);
|
||||
if (error_code != 0) return error_code;
|
||||
|
||||
error_code = SafeReadUInt(root, "DVL", table.DVL);
|
||||
error_code = SafeReadUInt(root, "DVL_uint8", table.DVL);
|
||||
if (error_code != 0) return error_code;
|
||||
|
||||
error_code = SafeReadUInt(root, "lowFreqSonar", table.lowFreqSonar);
|
||||
error_code = SafeReadUInt(root, "lowFreqSonar_uint8", table.lowFreqSonar);
|
||||
if (error_code != 0) return error_code;
|
||||
|
||||
error_code = SafeReadUInt(root, "USBL", table.USBL);
|
||||
error_code = SafeReadUInt(root, "USBL_uint8", table.USBL);
|
||||
if (error_code != 0) return error_code;
|
||||
|
||||
// 执行机构
|
||||
error_code = SafeReadUInt(root, "bowWaterlnet1", table.bowWaterlnet1);
|
||||
error_code = SafeReadUInt(root, "bowWaterlnet1_uint8", table.bowWaterlnet1);
|
||||
if (error_code != 0) return error_code;
|
||||
|
||||
error_code = SafeReadUInt(root, "bowWaterlnet2", table.bowWaterlnet2);
|
||||
error_code = SafeReadUInt(root, "bowWaterlnet2_uint8", table.bowWaterlnet2);
|
||||
if (error_code != 0) return error_code;
|
||||
|
||||
error_code = SafeReadUInt(root, "bowWaterlnet3", table.bowWaterlnet3);
|
||||
error_code = SafeReadUInt(root, "bowWaterlnet3_uint8", table.bowWaterlnet3);
|
||||
if (error_code != 0) return error_code;
|
||||
|
||||
error_code = SafeReadUInt(root, "bowWaterlnet4", table.bowWaterlnet4);
|
||||
error_code = SafeReadUInt(root, "bowWaterlnet4_uint8", table.bowWaterlnet4);
|
||||
if (error_code != 0) return error_code;
|
||||
|
||||
error_code = SafeReadUInt(root, "bowWaterlnet5", table.bowWaterlnet5);
|
||||
error_code = SafeReadUInt(root, "bowWaterlnet5_uint8", table.bowWaterlnet5);
|
||||
if (error_code != 0) return error_code;
|
||||
|
||||
error_code = SafeReadUInt(root, "bowWaterlnet6", table.bowWaterlnet6);
|
||||
error_code = SafeReadUInt(root, "bowWaterlnet6_uint8", table.bowWaterlnet6);
|
||||
if (error_code != 0) return error_code;
|
||||
|
||||
error_code = SafeReadUInt(root, "bowWaterlnet7", table.bowWaterlnet7);
|
||||
error_code = SafeReadUInt(root, "bowWaterlnet7_uint8", table.bowWaterlnet7);
|
||||
if (error_code != 0) return error_code;
|
||||
|
||||
error_code = SafeReadUInt(root, "bowWaterlnet8", table.bowWaterlnet8);
|
||||
error_code = SafeReadUInt(root, "bowWaterlnet8_uint8", table.bowWaterlnet8);
|
||||
if (error_code != 0) return error_code;
|
||||
|
||||
error_code = SafeReadUInt(root, "bowRudderDeploy", table.bowRudderDeploy);
|
||||
error_code = SafeReadUInt(root, "bowRudderDeploy_uint8", table.bowRudderDeploy);
|
||||
if (error_code != 0) return error_code;
|
||||
|
||||
error_code = SafeReadUInt(root, "bowRudderServo1", table.bowRudderServo1);
|
||||
error_code = SafeReadUInt(root, "bowRudderServo1_uint8", table.bowRudderServo1);
|
||||
if (error_code != 0) return error_code;
|
||||
|
||||
error_code = SafeReadUInt(root, "bowRudderServo2", table.bowRudderServo2);
|
||||
error_code = SafeReadUInt(root, "bowRudderServo2_uint8", table.bowRudderServo2);
|
||||
if (error_code != 0) return error_code;
|
||||
|
||||
error_code = SafeReadUInt(root, "bowCover1", table.bowCover1);
|
||||
error_code = SafeReadUInt(root, "bowCover1_uint8", table.bowCover1);
|
||||
if (error_code != 0) return error_code;
|
||||
|
||||
error_code = SafeReadUInt(root, "bowCover2", table.bowCover2);
|
||||
error_code = SafeReadUInt(root, "bowCover2_uint8", table.bowCover2);
|
||||
if (error_code != 0) return error_code;
|
||||
|
||||
error_code = SafeReadUInt(root, "bowCover3", table.bowCover3);
|
||||
error_code = SafeReadUInt(root, "bowCover3_uint8", table.bowCover3);
|
||||
if (error_code != 0) return error_code;
|
||||
|
||||
error_code = SafeReadUInt(root, "bowCover4", table.bowCover4);
|
||||
error_code = SafeReadUInt(root, "bowCover4_uint8", table.bowCover4);
|
||||
if (error_code != 0) return error_code;
|
||||
|
||||
error_code = SafeReadUInt(root, "bowCover5", table.bowCover5);
|
||||
error_code = SafeReadUInt(root, "bowCover5_uint8", table.bowCover5);
|
||||
if (error_code != 0) return error_code;
|
||||
|
||||
error_code = SafeReadUInt(root, "bowCover6", table.bowCover6);
|
||||
error_code = SafeReadUInt(root, "bowCover6_uint8", table.bowCover6);
|
||||
if (error_code != 0) return error_code;
|
||||
|
||||
error_code = SafeReadUInt(root, "waterInject", table.waterInject);
|
||||
error_code = SafeReadUInt(root, "waterInject_uint8", table.waterInject);
|
||||
if (error_code != 0) return error_code;
|
||||
|
||||
error_code = SafeReadUInt(root, "mastLiftingServo", table.mastLiftingServo);
|
||||
error_code = SafeReadUInt(root, "mastLiftingServo_uint8", table.mastLiftingServo);
|
||||
if (error_code != 0) return error_code;
|
||||
|
||||
error_code = SafeReadUInt(root, "buoyancyAdjust1", table.buoyancyAdjust1);
|
||||
error_code = SafeReadUInt(root, "buoyancyAdjust1_uint8", table.buoyancyAdjust1);
|
||||
if (error_code != 0) return error_code;
|
||||
|
||||
error_code = SafeReadUInt(root, "buoyancyAdjust2", table.buoyancyAdjust2);
|
||||
error_code = SafeReadUInt(root, "buoyancyAdjust2_uint8", table.buoyancyAdjust2);
|
||||
if (error_code != 0) return error_code;
|
||||
|
||||
error_code = SafeReadUInt(root, "buoyancyAdjust3", table.buoyancyAdjust3);
|
||||
error_code = SafeReadUInt(root, "buoyancyAdjust3_uint8", table.buoyancyAdjust3);
|
||||
if (error_code != 0) return error_code;
|
||||
|
||||
error_code = SafeReadUInt(root, "buoyancyAdjust4", table.buoyancyAdjust4);
|
||||
error_code = SafeReadUInt(root, "buoyancyAdjust4_uint8", table.buoyancyAdjust4);
|
||||
if (error_code != 0) return error_code;
|
||||
|
||||
error_code = SafeReadUInt(root, "buoyancyAdjust5", table.buoyancyAdjust5);
|
||||
error_code = SafeReadUInt(root, "buoyancyAdjust5_uint8", table.buoyancyAdjust5);
|
||||
if (error_code != 0) return error_code;
|
||||
|
||||
error_code = SafeReadUInt(root, "sternRudderServo1", table.sternRudderServo1);
|
||||
error_code = SafeReadUInt(root, "sternRudderServo1_uint8", table.sternRudderServo1);
|
||||
if (error_code != 0) return error_code;
|
||||
|
||||
error_code = SafeReadUInt(root, "sternRudderServo2", table.sternRudderServo2);
|
||||
error_code = SafeReadUInt(root, "sternRudderServo2_uint8", table.sternRudderServo2);
|
||||
if (error_code != 0) return error_code;
|
||||
|
||||
error_code = SafeReadUInt(root, "sternRudderServo3", table.sternRudderServo3);
|
||||
error_code = SafeReadUInt(root, "sternRudderServo3_uint8", table.sternRudderServo3);
|
||||
if (error_code != 0) return error_code;
|
||||
|
||||
error_code = SafeReadUInt(root, "sternRudderServo4", table.sternRudderServo4);
|
||||
error_code = SafeReadUInt(root, "sternRudderServo4_uint8", table.sternRudderServo4);
|
||||
if (error_code != 0) return error_code;
|
||||
|
||||
error_code = SafeReadUInt(root, "thruster", table.thruster);
|
||||
error_code = SafeReadUInt(root, "thruster_uint8", table.thruster);
|
||||
if (error_code != 0) return error_code;
|
||||
|
||||
error_code = SafeReadUInt(root, "bowThrow", table.bowThrow);
|
||||
error_code = SafeReadUInt(root, "bowThrow_uint8", table.bowThrow);
|
||||
if (error_code != 0) return error_code;
|
||||
|
||||
error_code = SafeReadUInt(root, "sternThrow", table.sternThrow);
|
||||
error_code = SafeReadUInt(root, "sternThrow_uint8", table.sternThrow);
|
||||
if (error_code != 0) return error_code;
|
||||
|
||||
// 负载
|
||||
error_code = SafeReadUInt(root, "photoSensor", table.photoSensor);
|
||||
error_code = SafeReadUInt(root, "photoSensor_uint8", table.photoSensor);
|
||||
if (error_code != 0) return error_code;
|
||||
|
||||
error_code = SafeReadUInt(root, "electSensor", table.electSensor);
|
||||
error_code = SafeReadUInt(root, "electSensor_uint8", table.electSensor);
|
||||
if (error_code != 0) return error_code;
|
||||
|
||||
error_code = SafeReadUInt(root, "launchControler", table.launchControler);
|
||||
error_code = SafeReadUInt(root, "launchControler_uint8", table.launchControler);
|
||||
if (error_code != 0) return error_code;
|
||||
|
||||
error_code = SafeReadUInt(root, "sideSonar", table.sideSonar);
|
||||
error_code = SafeReadUInt(root, "sideSonar_uint8", table.sideSonar);
|
||||
if (error_code != 0) return error_code;
|
||||
|
||||
error_code = SafeReadUInt(root, "buoyage", table.buoyage);
|
||||
error_code = SafeReadUInt(root, "buoyage_uint8", table.buoyage);
|
||||
if (error_code != 0) return error_code;
|
||||
|
||||
return 0; // 返回0表示所有数据成功读取
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include "json/json.h"
|
||||
#include "iostream"
|
||||
#include <sstream>
|
||||
|
||||
#include <vector>
|
||||
|
||||
#define DRIVER_POWER_OFF 0x00
|
||||
#define DRIVER_FULL_POWER_ON 0x01
|
||||
@@ -11,6 +11,7 @@
|
||||
#define DRIVER_MOTIVE_POWER_ON 0x03
|
||||
#define DRIVER_STANDBY 0x04
|
||||
|
||||
using namespace std;
|
||||
struct DriverTable
|
||||
{
|
||||
unsigned char depth1;
|
||||
@@ -80,6 +81,13 @@ struct DriverTable
|
||||
unsigned char buoyage;
|
||||
};
|
||||
|
||||
struct DriverCommand
|
||||
{
|
||||
int id;
|
||||
int cmd;
|
||||
};
|
||||
|
||||
|
||||
class Driver
|
||||
{
|
||||
public:
|
||||
@@ -115,6 +123,7 @@ public:
|
||||
|
||||
std::string saveDriverTableToJson(const DriverTable* driverTable);
|
||||
int loadDriverTableFromJson(const std::string &strJson, DriverTable& table);
|
||||
vector<DriverCommand> loadDriverIdFromJson(const std::string &strJson);
|
||||
|
||||
int SafeReadUInt(const Json::Value& root, const std::string& key, unsigned char& value);
|
||||
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
#include "PowerManagerFsm.hpp"
|
||||
|
||||
void CruiseMode::entry() {
|
||||
PowerManagerFsm::entry();
|
||||
pm->workCondition = WorkCondition::CHANING;
|
||||
pm->m_driver.getCRUISE_MODEable(&pm->m_subDisSysCmd);
|
||||
//依次接入执行机构动力电设备
|
||||
//TODO:接入执行机构动力电设备
|
||||
|
||||
//TODO:解除非必要动力电设备
|
||||
pm->workCondition = WorkCondition::CRUISE_MODE;
|
||||
LOG_F(INFO, "进入巡航模式");
|
||||
}
|
||||
|
||||
// CruiseMode实现
|
||||
void CruiseMode::react(MasterCommandEvent const &) {
|
||||
PowerManagerFsm::handelPowerCmd();
|
||||
PowerManagerFsm::handleModCmd();
|
||||
PowerManagerFsm::handleWorkCmd();
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
#include "PowerManagerFsm.hpp"
|
||||
|
||||
|
||||
// DJMode实现
|
||||
void DJMode::react(MasterCommandEvent const &) {
|
||||
PowerManagerFsm::handelPowerCmd();
|
||||
PowerManagerFsm::handleModCmd();
|
||||
PowerManagerFsm::handleWorkCmd();
|
||||
}
|
||||
|
||||
void DJMode::entry() {
|
||||
PowerManagerFsm::entry();
|
||||
pm->workCondition = WorkCondition::DJ_MODE;
|
||||
LOG_F(INFO, "进入DJ模式");
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
#include "PowerManagerFsm.hpp"
|
||||
|
||||
// FaultState实现
|
||||
void FaultState::entry() {
|
||||
PowerManagerFsm::entry();
|
||||
// PowerManagerFsm::pm->printState("FaultState", "进入故障状态");
|
||||
if(pm->m_missionState.type == TaskType::THROW_LOAD)
|
||||
{
|
||||
LOG_F(INFO, "检测到抛载,所有水声探测设备");
|
||||
}
|
||||
else
|
||||
{
|
||||
// LOG_F(INFO, "检测到抛载,所有水声设备关闭");
|
||||
}
|
||||
}
|
||||
|
||||
void FaultState::react(FaultEvent const & e) {
|
||||
LOG_F(INFO, "FaultState 处理故障事件");
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
#include "PowerManagerFsm.hpp"
|
||||
|
||||
// FloatAdjust实现
|
||||
void FloatAdjust::react(MasterCommandEvent const &) {
|
||||
PowerManagerFsm::handelPowerCmd();
|
||||
PowerManagerFsm::handleModCmd();
|
||||
PowerManagerFsm::handleWorkCmd();
|
||||
}
|
||||
|
||||
void FloatAdjust::entry() {
|
||||
PowerManagerFsm::entry();
|
||||
pm->workCondition = WorkCondition::CHANING;
|
||||
//与巡航模式相同
|
||||
pm->m_driver.getCRUISE_MODEable(&pm->m_subDisSysCmd);
|
||||
//依次接入执行机构动力电设备
|
||||
//TODO:接入执行机构动力电设备
|
||||
|
||||
//TODO:解除非必要动力电设备
|
||||
pm->workCondition = WorkCondition::BUOYANCY_ADJUST;
|
||||
LOG_F(INFO, "进入浮调模式");
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
#include "PowerManagerFsm.hpp"
|
||||
|
||||
void FloatDown::entry() {
|
||||
PowerManagerFsm::entry();
|
||||
//与巡航模式相同
|
||||
pm->m_driver.getCRUISE_MODEable(&pm->m_subDisSysCmd);
|
||||
//依次接入执行机构动力电设备
|
||||
//TODO:接入执行机构动力电设备
|
||||
|
||||
//TODO:解除非必要动力电设备
|
||||
pm->workCondition = WorkCondition::ASCEND_DESCEND;
|
||||
LOG_F(INFO, "进入上浮下潜模式");
|
||||
}
|
||||
|
||||
// FloatDown实现
|
||||
void FloatDown::react(MasterCommandEvent const &) {
|
||||
PowerManagerFsm::handelPowerCmd();
|
||||
PowerManagerFsm::handleModCmd();
|
||||
PowerManagerFsm::handleWorkCmd();
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
#include "PowerManagerFsm.hpp"
|
||||
|
||||
void HighSpeedMode::entry() {
|
||||
PowerManagerFsm::entry();
|
||||
pm->workCondition = WorkCondition::HIGH_SPEED_MODE;
|
||||
LOG_F(INFO, "进入高速模式");
|
||||
}
|
||||
|
||||
// HighSpeedMode实现
|
||||
void HighSpeedMode::react(MasterCommandEvent const &) {
|
||||
PowerManagerFsm::handelPowerCmd();
|
||||
PowerManagerFsm::handleModCmd();
|
||||
PowerManagerFsm::handleWorkCmd();
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
#include "PowerManagerFsm.hpp"
|
||||
|
||||
// InitState实现
|
||||
void InitState::entry() {
|
||||
PowerManagerFsm::entry();
|
||||
LOG_F(INFO, "进入初始化状态");
|
||||
pm->initControlCmd();
|
||||
transit<StandbyState>();
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "PowerManagerFsm.hpp"
|
||||
#include "PowerManger.h"
|
||||
#include "loguru.hpp"
|
||||
#include "../PowerManger.h"
|
||||
#include "../loguru.hpp"
|
||||
#include <string>
|
||||
#include "MOOS/libMOOS/Utils/MOOSUtilityFunctions.h"
|
||||
|
||||
@@ -13,10 +13,8 @@ void PowerManagerFsm::react(TaskStopEvent const &e) {
|
||||
};
|
||||
|
||||
void PowerManagerFsm::react(CycleTriggeredEvent const &){
|
||||
if(pm->currentMod != RunMode::Debug)
|
||||
{
|
||||
|
||||
}
|
||||
// 更新当前设备状态
|
||||
pm->m_currentDriverState = pm->m_currentDriverState;
|
||||
}
|
||||
bool PowerManagerFsm::handPowerProtection(DevCmdExt const &e){
|
||||
if(pm->workCondition > WorkCondition::REMOTE_CONTROL){
|
||||
@@ -42,6 +40,10 @@ bool PowerManagerFsm::handPowerProtection(DevCmdExt const &e){
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PowerManagerFsm::react(DeviceCmd const &){
|
||||
LOG_F(INFO, "DeviceCmd received");
|
||||
}
|
||||
void PowerManagerFsm::react(TaskStartEvent const &e){
|
||||
LOG_F(INFO, "TaskStartEvent received - type: %d, enableBowRudder: %d, enableBuoyancyAdjustment: %d", e.type, e.enableBowRudder, e.enableBuoyancyAdjustment);
|
||||
switch (e.type)
|
||||
@@ -1736,32 +1738,6 @@ void PowerManagerFsm::react(DevCmdExt const &e) {
|
||||
}
|
||||
}
|
||||
|
||||
void StandbyState::react(DevCmdExt const &e)
|
||||
{
|
||||
LOG_F(INFO, "StandbyState::react(DevCmdExt const &e)");
|
||||
//正常模式下,不允许执行DevCmdExt
|
||||
if (pm->currentMod == RunMode::Normal )
|
||||
{
|
||||
LOG_F(INFO, "正常模式下,不允许执行DevCmdExt");
|
||||
}
|
||||
else if (pm->currentMod == RunMode::Test)
|
||||
{
|
||||
if(handPowerProtection(e))
|
||||
PowerManagerFsm::react(e);
|
||||
else
|
||||
LOG_F(INFO, "DevCmdExt 执行失败");
|
||||
}
|
||||
else if (pm->currentMod == RunMode::Debug)
|
||||
{
|
||||
LOG_F(INFO, "调试模式下,直接执行DevCmdExt");
|
||||
PowerManagerFsm::react(e);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_F(INFO, "当前模式未知");
|
||||
}
|
||||
}
|
||||
|
||||
void PowerManagerFsm::basicNavigationFault(FaultEvent const &e)
|
||||
{
|
||||
LOG_F(INFO, "basicNavigationFault");
|
||||
@@ -2042,51 +2018,9 @@ void PowerManagerFsm::react(FaultEvent const &e)
|
||||
emergencySystemFault(e);
|
||||
sensorSystemFault(e);
|
||||
}
|
||||
// InitState实现
|
||||
void InitState::entry() {
|
||||
PowerManagerFsm::entry();
|
||||
LOG_F(INFO, "进入初始化状态");
|
||||
pm->initControlCmd();
|
||||
transit<StandbyState>();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void StandbyState::react(StandbyEvent const &) {
|
||||
transit<StandbyState>();
|
||||
}
|
||||
void StandbyState::react(MasterCommandEvent const &) {
|
||||
PowerManagerFsm::handelPowerCmd();
|
||||
PowerManagerFsm::handleModCmd();
|
||||
PowerManagerFsm::handleWorkCmd();
|
||||
}
|
||||
|
||||
void StandbyState::handlePowerOn() {
|
||||
LOG_F(INFO,"动力电上电");
|
||||
PowerManagerFsm::pm->m_CcuColCmd.powerBatCmd = 0x10;
|
||||
if(PowerManagerFsm::pm->m_pmCurrentState.ccustate.fcuState == 0x04)
|
||||
PowerManagerFsm::pm->m_CcuColCmd.fcuCmd = 0x02;
|
||||
}
|
||||
|
||||
// FaultState实现
|
||||
void FaultState::entry() {
|
||||
PowerManagerFsm::entry();
|
||||
// PowerManagerFsm::pm->printState("FaultState", "进入故障状态");
|
||||
if(pm->m_missionState.type == TaskType::THROW_LOAD)
|
||||
{
|
||||
LOG_F(INFO, "检测到抛载,所有水声探测设备");
|
||||
}
|
||||
else
|
||||
{
|
||||
// LOG_F(INFO, "检测到抛载,所有水声设备关闭");
|
||||
}
|
||||
}
|
||||
|
||||
void FaultState::react(FaultEvent const & e) {
|
||||
LOG_F(INFO, "FaultState 处理故障事件");
|
||||
}
|
||||
|
||||
|
||||
void PowerManagerFsm::handelPowerCmd(){
|
||||
switch (pm->m_msCmd.powerCMD)
|
||||
{
|
||||
@@ -2209,259 +2143,4 @@ void PowerManagerFsm::handleDeviceCmd() {
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 设置初始状态
|
||||
// ShoreBasedReady实现
|
||||
void ShoreBasedReady::react(MasterCommandEvent const &) {
|
||||
PowerManagerFsm::handelPowerCmd();
|
||||
PowerManagerFsm::handleModCmd();
|
||||
PowerManagerFsm::handleWorkCmd();
|
||||
}
|
||||
|
||||
// StandbyState实现
|
||||
void StandbyState::entry() {
|
||||
PowerManagerFsm::entry();
|
||||
pm->m_driver.getSTANDBYTable(&pm->m_subDisSysCmd);
|
||||
pm->m_CcuColCmd.fcuCmd = FcuCommand::Stop;
|
||||
pm->m_CcuColCmd.powerBatCmd = BatteryCommand::Stop;
|
||||
pm->workCondition = WorkCondition::STANDBY;
|
||||
LOG_F(INFO, "WorkCondition %d", pm->workCondition);
|
||||
}
|
||||
|
||||
void ShoreBasedReady::entry() {
|
||||
PowerManagerFsm::entry();
|
||||
pm->m_driver.getSHORE_BASED_READYable(&pm->m_subDisSysCmd);
|
||||
pm->m_CcuColCmd.powerBatCmd = BatteryCommand::Start;
|
||||
pm->workCondition = WorkCondition::CHANING;
|
||||
//依次接入执行机构动力电设备
|
||||
//TODO:接入执行机构动力电设备
|
||||
pm->workCondition = WorkCondition::SHORE_BASED_READY;
|
||||
LOG_F(INFO, "进入岸基备航状态");
|
||||
}
|
||||
|
||||
void WaterBasedReady::entry() {
|
||||
PowerManagerFsm::entry();
|
||||
pm->workCondition = WorkCondition::CHANING;
|
||||
pm->m_driver.getWATER_BASED_READYable(&pm->m_subDisSysCmd);
|
||||
pm->m_CcuColCmd.powerBatCmd = BatteryCommand::Start;
|
||||
//依次接入执行机构动力电设备
|
||||
//TODO:接入执行机构动力电设备
|
||||
pm->workCondition = WorkCondition::WATER_BASED_READY;
|
||||
LOG_F(INFO, "进入水中备航状态");
|
||||
}
|
||||
|
||||
void CruiseMode::entry() {
|
||||
PowerManagerFsm::entry();
|
||||
pm->workCondition = WorkCondition::CHANING;
|
||||
pm->m_driver.getCRUISE_MODEable(&pm->m_subDisSysCmd);
|
||||
//依次接入执行机构动力电设备
|
||||
//TODO:接入执行机构动力电设备
|
||||
|
||||
//TODO:解除非必要动力电设备
|
||||
pm->workCondition = WorkCondition::CRUISE_MODE;
|
||||
LOG_F(INFO, "进入巡航模式");
|
||||
}
|
||||
|
||||
void FloatAdjust::entry() {
|
||||
PowerManagerFsm::entry();
|
||||
pm->workCondition = WorkCondition::CHANING;
|
||||
//与巡航模式相同
|
||||
pm->m_driver.getCRUISE_MODEable(&pm->m_subDisSysCmd);
|
||||
//依次接入执行机构动力电设备
|
||||
//TODO:接入执行机构动力电设备
|
||||
|
||||
//TODO:解除非必要动力电设备
|
||||
pm->workCondition = WorkCondition::BUOYANCY_ADJUST;
|
||||
LOG_F(INFO, "进入浮调模式");
|
||||
}
|
||||
|
||||
void FloatDown::entry() {
|
||||
PowerManagerFsm::entry();
|
||||
//与巡航模式相同
|
||||
pm->m_driver.getCRUISE_MODEable(&pm->m_subDisSysCmd);
|
||||
//依次接入执行机构动力电设备
|
||||
//TODO:接入执行机构动力电设备
|
||||
|
||||
//TODO:解除非必要动力电设备
|
||||
pm->workCondition = WorkCondition::ASCEND_DESCEND;
|
||||
LOG_F(INFO, "进入上浮下潜模式");
|
||||
}
|
||||
|
||||
|
||||
// FloatDown实现
|
||||
void FloatDown::react(MasterCommandEvent const &) {
|
||||
PowerManagerFsm::handelPowerCmd();
|
||||
PowerManagerFsm::handleModCmd();
|
||||
PowerManagerFsm::handleWorkCmd();
|
||||
}
|
||||
|
||||
// WaterBasedReady实现
|
||||
void WaterBasedReady::react(MasterCommandEvent const &) {
|
||||
PowerManagerFsm::handelPowerCmd();
|
||||
PowerManagerFsm::handleModCmd();
|
||||
PowerManagerFsm::handleWorkCmd();
|
||||
}
|
||||
|
||||
|
||||
|
||||
// CruiseMode实现
|
||||
void CruiseMode::react(MasterCommandEvent const &) {
|
||||
PowerManagerFsm::handelPowerCmd();
|
||||
PowerManagerFsm::handleModCmd();
|
||||
PowerManagerFsm::handleWorkCmd();
|
||||
}
|
||||
|
||||
|
||||
|
||||
// HighSpeedMode实现
|
||||
void HighSpeedMode::react(MasterCommandEvent const &) {
|
||||
PowerManagerFsm::handelPowerCmd();
|
||||
PowerManagerFsm::handleModCmd();
|
||||
PowerManagerFsm::handleWorkCmd();
|
||||
}
|
||||
|
||||
void HighSpeedMode::entry() {
|
||||
PowerManagerFsm::entry();
|
||||
pm->workCondition = WorkCondition::HIGH_SPEED_MODE;
|
||||
LOG_F(INFO, "进入高速模式");
|
||||
}
|
||||
|
||||
// FloatAdjust实现
|
||||
void FloatAdjust::react(MasterCommandEvent const &) {
|
||||
PowerManagerFsm::handelPowerCmd();
|
||||
PowerManagerFsm::handleModCmd();
|
||||
PowerManagerFsm::handleWorkCmd();
|
||||
}
|
||||
|
||||
// UnderwaterSurvey实现
|
||||
void UnderwaterSurvey::react(MasterCommandEvent const &) {
|
||||
PowerManagerFsm::handelPowerCmd();
|
||||
PowerManagerFsm::handleModCmd();
|
||||
PowerManagerFsm::handleWorkCmd();
|
||||
}
|
||||
|
||||
void UnderwaterSurvey::entry() {
|
||||
PowerManagerFsm::entry();
|
||||
pm->workCondition = WorkCondition::UNDERWATER_RECON;
|
||||
LOG_F(INFO, "进入水下侦查模式");
|
||||
}
|
||||
|
||||
// SurfaceSurvey实现
|
||||
void SurfaceSurvey::react(MasterCommandEvent const &) {
|
||||
PowerManagerFsm::handelPowerCmd();
|
||||
PowerManagerFsm::handleModCmd();
|
||||
PowerManagerFsm::handleWorkCmd();
|
||||
}
|
||||
|
||||
void SurfaceSurvey::entry() {
|
||||
PowerManagerFsm::entry();
|
||||
pm->workCondition = WorkCondition::SURFACE_RECON;
|
||||
LOG_F(INFO, "进入水面侦查模式");
|
||||
}
|
||||
|
||||
// DJMode实现
|
||||
void DJMode::react(MasterCommandEvent const &) {
|
||||
PowerManagerFsm::handelPowerCmd();
|
||||
PowerManagerFsm::handleModCmd();
|
||||
PowerManagerFsm::handleWorkCmd();
|
||||
}
|
||||
|
||||
void DJMode::entry() {
|
||||
PowerManagerFsm::entry();
|
||||
pm->workCondition = WorkCondition::DJ_MODE;
|
||||
LOG_F(INFO, "进入DJ模式");
|
||||
}
|
||||
|
||||
// RemoteControl实现
|
||||
void RemoteControl::react(MasterCommandEvent const &) {
|
||||
PowerManagerFsm::handelPowerCmd();
|
||||
PowerManagerFsm::handleModCmd();
|
||||
PowerManagerFsm::handleWorkCmd();
|
||||
}
|
||||
|
||||
void RemoteControl::entry() {
|
||||
PowerManagerFsm::entry();
|
||||
pm->workCondition = WorkCondition::REMOTE_CONTROL;
|
||||
LOG_F(INFO, "进入遥控工况");
|
||||
}
|
||||
|
||||
|
||||
|
||||
// void StandbyState::react(TaskStart const &)
|
||||
// {
|
||||
// LOG_F(INFO, "接收到任务启动信息");
|
||||
// //日志保存错误
|
||||
// LOG_F(WARNING, "待机状态无法直接启动任务");
|
||||
// }
|
||||
//岸基备航
|
||||
// void ShoreBasedReady::react(TaskStart const &)
|
||||
// {
|
||||
// LOG_F(INFO, "接收到任务启动信息");
|
||||
// //日志保存错误
|
||||
// LOG_F(WARNING, "岸基备航状态无法直接启动任务");
|
||||
// }
|
||||
// //水中备航
|
||||
// void WaterBasedReady::react(TaskStart const &)
|
||||
// {
|
||||
// LOG_F(INFO, "接收到任务启动信息");
|
||||
// LOG_F(INFO, "开始执行启动任务");
|
||||
// }
|
||||
|
||||
// //遥控工况
|
||||
// void RemoteControl::react(TaskStart const &)
|
||||
// {
|
||||
// LOG_F(INFO, "接收到任务启动信息");
|
||||
// LOG_F(INFO, "开始执行启动任务");
|
||||
// }
|
||||
|
||||
// //巡航模式
|
||||
// void CruiseMode::react(TaskStart const &)
|
||||
// {
|
||||
// LOG_F(INFO, "接收到任务启动信息");
|
||||
// LOG_F(INFO, "进入巡航模式");
|
||||
// }
|
||||
|
||||
// //高速模式
|
||||
// void HighSpeedMode::react(TaskStart const &)
|
||||
// {
|
||||
// LOG_F(INFO, "接收到任务启动信息");
|
||||
// LOG_F(INFO, "进入高速模式");
|
||||
// }
|
||||
|
||||
// //浮调模式
|
||||
// void FloatAdjust::react(TaskStart const &)
|
||||
// {
|
||||
// LOG_F(INFO, "接收到任务启动信息");
|
||||
// LOG_F(INFO, "进入浮调模式");
|
||||
// }
|
||||
|
||||
// //水下侦查
|
||||
// void UnderwaterSurvey::react(TaskStart const &)
|
||||
// {
|
||||
// LOG_F(INFO, "接收到任务启动信息");
|
||||
// LOG_F(INFO, "进入水下侦查模式");
|
||||
// }
|
||||
|
||||
// //水面侦查
|
||||
// void SurfaceSurvey::react(TaskStart const &)
|
||||
// {
|
||||
// LOG_F(INFO, "接收到任务启动信息");
|
||||
// LOG_F(INFO, "进入水面侦查模式");
|
||||
// }
|
||||
|
||||
// //DJ模式
|
||||
// void DJMode::react(TaskStart const &)
|
||||
// {
|
||||
// LOG_F(INFO, "接收到任务启动信息");
|
||||
// LOG_F(INFO, "进入DJ模式");
|
||||
// }
|
||||
|
||||
// // 上浮下潜
|
||||
// void FloatDown::react(TaskStart const &)
|
||||
// {
|
||||
// LOG_F(INFO, "接收到任务启动信息");
|
||||
// LOG_F(INFO, "进入上浮下潜模式");
|
||||
// }
|
||||
|
||||
|
||||
FSM_INITIAL_STATE(PowerManagerFsm, InitState);
|
||||
@@ -1,15 +1,15 @@
|
||||
#ifndef POWER_MANAGER_FSM_HPP
|
||||
#define POWER_MANAGER_FSM_HPP
|
||||
#include "tinyfsm.hpp"
|
||||
#include "loguru.hpp"
|
||||
#include "../loguru.hpp"
|
||||
#include <iostream>
|
||||
#include <chrono> // 新增头文件
|
||||
#include <iomanip> // 新增头文件
|
||||
#include <ctime> // 新增头文件,用于localtime函数
|
||||
#include <cxxabi.h> // 新增头文件,用于demangle功能
|
||||
#include "pmSysvariable.h"
|
||||
#include "driver.h"
|
||||
#include "PowerManger.h"
|
||||
#include "../pmSysvariable.h"
|
||||
#include "../driver.h"
|
||||
#include "../PowerManger.h"
|
||||
// 前向声明
|
||||
class PowerManger;
|
||||
|
||||
@@ -73,7 +73,7 @@ public:
|
||||
virtual void react(InitEvent const &) {};
|
||||
virtual void react(StandbyEvent const &) { };
|
||||
virtual void react(MasterCommandEvent const &) { LOG_F(INFO, "MasterCommandEvent");};
|
||||
virtual void react(DeviceCmd const &) { LOG_F(INFO, "DeviceCmd"); };
|
||||
virtual void react(DeviceCmd const &);
|
||||
virtual void react(DevCmdExt const &e);
|
||||
virtual void react(TaskStartEvent const &e);
|
||||
virtual void react(FaultEvent const &e);
|
||||
@@ -180,17 +180,6 @@ class CruiseMode : public PowerManagerFsm {
|
||||
private:
|
||||
// void handlePowerCommands();
|
||||
};
|
||||
|
||||
// 高速模式
|
||||
class HighSpeedMode : public PowerManagerFsm {
|
||||
public:
|
||||
void entry() override;
|
||||
void react(MasterCommandEvent const &) override;
|
||||
// void react(DeviceCmd const &) override;
|
||||
// void react(TaskStart const &) override;
|
||||
private:
|
||||
// void handlePowerCommands();
|
||||
};
|
||||
// 上浮下潜
|
||||
class FloatDown : public PowerManagerFsm {
|
||||
public:
|
||||
@@ -201,6 +190,17 @@ class FloatDown : public PowerManagerFsm {
|
||||
private:
|
||||
// void handlePowerCommands();
|
||||
};
|
||||
// 高速模式
|
||||
class HighSpeedMode : public PowerManagerFsm {
|
||||
public:
|
||||
void entry() override;
|
||||
void react(MasterCommandEvent const &) override;
|
||||
// void react(DeviceCmd const &) override;
|
||||
// void react(TaskStart const &) override;
|
||||
private:
|
||||
// void handlePowerCommands();
|
||||
};
|
||||
|
||||
// 浮调模式
|
||||
class FloatAdjust : public PowerManagerFsm {
|
||||
public:
|
||||
@@ -0,0 +1,16 @@
|
||||
#include "PowerManagerFsm.hpp"
|
||||
|
||||
// RemoteControl实现
|
||||
void RemoteControl::react(MasterCommandEvent const &) {
|
||||
PowerManagerFsm::handelPowerCmd();
|
||||
PowerManagerFsm::handleModCmd();
|
||||
PowerManagerFsm::handleWorkCmd();
|
||||
}
|
||||
|
||||
void RemoteControl::entry() {
|
||||
PowerManagerFsm::entry();
|
||||
pm->workCondition = WorkCondition::REMOTE_CONTROL;
|
||||
LOG_F(INFO, "进入遥控工况");
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
#include "PowerManagerFsm.hpp"
|
||||
|
||||
// ShoreBasedReady实现
|
||||
void ShoreBasedReady::react(MasterCommandEvent const &) {
|
||||
PowerManagerFsm::handelPowerCmd();
|
||||
PowerManagerFsm::handleModCmd();
|
||||
PowerManagerFsm::handleWorkCmd();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ShoreBasedReady::entry() {
|
||||
PowerManagerFsm::entry();
|
||||
pm->m_driver.getSHORE_BASED_READYable(&pm->m_subDisSysCmd);
|
||||
pm->m_CcuColCmd.powerBatCmd = BatteryCommand::Start;
|
||||
pm->workCondition = WorkCondition::CHANING;
|
||||
//依次接入执行机构动力电设备
|
||||
//TODO:接入执行机构动力电设备
|
||||
pm->workCondition = WorkCondition::SHORE_BASED_READY;
|
||||
LOG_F(INFO, "进入岸基备航状态");
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
#include "PowerManagerFsm.hpp"
|
||||
|
||||
// StandbyState实现
|
||||
void StandbyState::entry() {
|
||||
PowerManagerFsm::entry();
|
||||
pm->m_driver.getSTANDBYTable(&pm->m_subDisSysCmd);
|
||||
pm->m_CcuColCmd.fcuCmd = FcuCommand::Stop;
|
||||
// pm->m_CcuColCmd.powerBatCmd = BatteryCommand::Stop;
|
||||
pm->m_CcuColCmd.powerBatCmd = BatteryCommand::Start;
|
||||
pm->workCondition = WorkCondition::STANDBY;
|
||||
LOG_F(INFO, "WorkCondition %d", pm->workCondition);
|
||||
}
|
||||
void StandbyState::react(StandbyEvent const &) {
|
||||
transit<StandbyState>();
|
||||
}
|
||||
void StandbyState::react(MasterCommandEvent const &) {
|
||||
PowerManagerFsm::handelPowerCmd();
|
||||
PowerManagerFsm::handleModCmd();
|
||||
PowerManagerFsm::handleWorkCmd();
|
||||
}
|
||||
|
||||
void StandbyState::react(DevCmdExt const &e)
|
||||
{
|
||||
LOG_F(INFO, "StandbyState::react(DevCmdExt const &e)");
|
||||
//正常模式下,不允许执行DevCmdExt
|
||||
if (pm->currentMod == RunMode::Normal )
|
||||
{
|
||||
LOG_F(INFO, "正常模式下,不允许执行DevCmdExt");
|
||||
}
|
||||
else if (pm->currentMod == RunMode::Test)
|
||||
{
|
||||
if(handPowerProtection(e))
|
||||
PowerManagerFsm::react(e);
|
||||
else
|
||||
LOG_F(INFO, "DevCmdExt 执行失败");
|
||||
}
|
||||
else if (pm->currentMod == RunMode::Debug)
|
||||
{
|
||||
LOG_F(INFO, "调试模式下,直接执行DevCmdExt");
|
||||
PowerManagerFsm::react(e);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_F(INFO, "当前模式未知");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void StandbyState::handlePowerOn() {
|
||||
LOG_F(INFO,"动力电上电");
|
||||
//TODO: 电源上电 更新协议
|
||||
// PowerManagerFsm::pm->m_CcuColCmd.powerBatCmd = 0x10;
|
||||
// if(PowerManagerFsm::pm->m_pmCurrentState.ccustate.fcuState == 0x04)
|
||||
// PowerManagerFsm::pm->m_CcuColCmd.fcuCmd = 0x02;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
#include "PowerManagerFsm.hpp"
|
||||
|
||||
// SurfaceSurvey实现
|
||||
void SurfaceSurvey::react(MasterCommandEvent const &) {
|
||||
PowerManagerFsm::handelPowerCmd();
|
||||
PowerManagerFsm::handleModCmd();
|
||||
PowerManagerFsm::handleWorkCmd();
|
||||
}
|
||||
|
||||
void SurfaceSurvey::entry() {
|
||||
PowerManagerFsm::entry();
|
||||
pm->workCondition = WorkCondition::SURFACE_RECON;
|
||||
LOG_F(INFO, "进入水面侦查模式");
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
#include "PowerManagerFsm.hpp"
|
||||
|
||||
void UnderwaterSurvey::entry() {
|
||||
PowerManagerFsm::entry();
|
||||
pm->workCondition = WorkCondition::UNDERWATER_RECON;
|
||||
LOG_F(INFO, "进入水下侦查模式");
|
||||
}
|
||||
|
||||
|
||||
// UnderwaterSurvey实现
|
||||
void UnderwaterSurvey::react(MasterCommandEvent const &) {
|
||||
PowerManagerFsm::handelPowerCmd();
|
||||
PowerManagerFsm::handleModCmd();
|
||||
PowerManagerFsm::handleWorkCmd();
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
#include "PowerManagerFsm.hpp"
|
||||
|
||||
|
||||
void WaterBasedReady::entry() {
|
||||
PowerManagerFsm::entry();
|
||||
pm->workCondition = WorkCondition::CHANING;
|
||||
pm->m_driver.getWATER_BASED_READYable(&pm->m_subDisSysCmd);
|
||||
pm->m_CcuColCmd.powerBatCmd = BatteryCommand::Start;
|
||||
//依次接入执行机构动力电设备
|
||||
//TODO:接入执行机构动力电设备
|
||||
pm->workCondition = WorkCondition::WATER_BASED_READY;
|
||||
LOG_F(INFO, "进入水中备航状态");
|
||||
}
|
||||
|
||||
// WaterBasedReady实现
|
||||
void WaterBasedReady::react(MasterCommandEvent const &) {
|
||||
PowerManagerFsm::handelPowerCmd();
|
||||
PowerManagerFsm::handleModCmd();
|
||||
PowerManagerFsm::handleWorkCmd();
|
||||
}
|
||||
@@ -0,0 +1,451 @@
|
||||
#ifndef UDEVICE_SECDISTSTATE_H
|
||||
#define UDEVICE_SECDISTSTATE_H
|
||||
#include <string>
|
||||
#include <json/json.h>
|
||||
#include "../driver.h"
|
||||
#include "../loguru.hpp"
|
||||
|
||||
class uDevice_secdistStateMsg
|
||||
{
|
||||
private:
|
||||
/* data */
|
||||
public:
|
||||
uDevice_secdistStateMsg(){};
|
||||
~uDevice_secdistStateMsg(){};
|
||||
std::string key_fb = "uDevice_secdistState_st";
|
||||
std::string key_cmd = "uPower_secdistState_cmd";
|
||||
|
||||
struct DeviceSecdistState
|
||||
{
|
||||
// UNIT1
|
||||
u_int8_t bowCover1;
|
||||
u_int8_t bowCover2;
|
||||
u_int8_t bowCover3;
|
||||
u_int8_t bowCover4;
|
||||
u_int8_t bowCover5;
|
||||
u_int8_t bowCover6;
|
||||
u_int8_t singleBeamSonar1;
|
||||
u_int8_t singleBeamSonar2;
|
||||
u_int8_t singleBeamSonar3;
|
||||
u_int8_t singleBeamSonar4;
|
||||
u_int8_t singleBeamSonar5;
|
||||
u_int8_t singleBeamSonar6;
|
||||
u_int8_t forwardSonar;
|
||||
u_int8_t depth3;
|
||||
u_int8_t soundVeloc;
|
||||
u_int8_t bowRudderServo;
|
||||
u_int8_t bowRudderDeploy;
|
||||
u_int8_t ctd1;
|
||||
u_int8_t waterInject;
|
||||
|
||||
// UNIT2
|
||||
u_int8_t sideSonar;
|
||||
u_int8_t bowWaterInet1;
|
||||
u_int8_t bowWaterInet2;
|
||||
u_int8_t bowWaterInet3;
|
||||
u_int8_t bowWaterInet4;
|
||||
u_int8_t bowWaterInet5;
|
||||
u_int8_t bowWaterInet6;
|
||||
u_int8_t bowWaterInet7;
|
||||
u_int8_t bowWaterInet8;
|
||||
u_int8_t launchControler;
|
||||
u_int8_t electSensor;
|
||||
u_int8_t lowFreqSonar;
|
||||
|
||||
// UNIT3
|
||||
u_int8_t buoyancyAdjust1;
|
||||
u_int8_t buoyancyAdjust2;
|
||||
u_int8_t buoyancyAdjust3;
|
||||
u_int8_t USBL;
|
||||
u_int8_t depth1;
|
||||
u_int8_t commDev;
|
||||
u_int8_t mastLiftingServo;
|
||||
u_int8_t DVL;
|
||||
u_int8_t ADCP;
|
||||
u_int8_t inOutLetWater1;
|
||||
u_int8_t inOutLetWater2;
|
||||
|
||||
// UNIT4
|
||||
u_int8_t singleBeamSonar7;
|
||||
u_int8_t singleBeamSonar8;
|
||||
u_int8_t buoyage;
|
||||
u_int8_t bowThrow;
|
||||
u_int8_t depth2;
|
||||
u_int8_t thruster;
|
||||
u_int8_t dragSonar;
|
||||
u_int8_t haulingMachine;
|
||||
u_int8_t buoyancyAdjust4;
|
||||
u_int8_t buoyancyAdjust5;
|
||||
u_int8_t sternRudderServo1;
|
||||
u_int8_t sternRudderServo2;
|
||||
u_int8_t sternRudderServo3;
|
||||
u_int8_t sternRudderServo4;
|
||||
u_int8_t ctd2;
|
||||
u_int8_t commDevStern;
|
||||
u_int8_t inOutLetWater3;
|
||||
|
||||
// UNIT5
|
||||
u_int8_t secINS;
|
||||
u_int8_t photoSensor;
|
||||
u_int8_t sternThrow;
|
||||
u_int8_t mainINS;
|
||||
} deviceSecdistState;
|
||||
|
||||
|
||||
|
||||
bool parseSecdistStateFromJson(DeviceSecdistState &state, const std::string &strJson){
|
||||
Json::Value root;
|
||||
Json::CharReaderBuilder readerBuilder;
|
||||
std::unique_ptr<Json::CharReader> reader(readerBuilder.newCharReader());
|
||||
std::string errors;
|
||||
|
||||
if(!reader->parse(strJson.c_str(), strJson.c_str() + strJson.length(), &root, &errors)){
|
||||
LOG_F(ERROR, "Failed to parse JSON: %s", errors.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
auto checkField = [&root](const std::string& field) -> bool {
|
||||
if(!root.isMember(field) || !root[field].isUInt()) {
|
||||
// std::cerr << "Missing or invalid field: " << field << std::endl;
|
||||
LOG_F(ERROR, "Missing or invalid field: %s", field.c_str());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
bool ok = true;
|
||||
|
||||
// UNIT1
|
||||
if(!checkField("bowCover1_uint8")) ok=false; state.bowCover1 = root["bowCover1_uint8"].asUInt();
|
||||
if(!checkField("bowCover2_uint8")) ok=false; state.bowCover2 = root["bowCover2_uint8"].asUInt();
|
||||
if(!checkField("bowCover3_uint8")) ok=false; state.bowCover3 = root["bowCover3_uint8"].asUInt();
|
||||
if(!checkField("bowCover4_uint8")) ok=false; state.bowCover4 = root["bowCover4_uint8"].asUInt();
|
||||
if(!checkField("bowCover5_uint8")) ok=false; state.bowCover5 = root["bowCover5_uint8"].asUInt();
|
||||
if(!checkField("bowCover6_uint8")) ok=false; state.bowCover6 = root["bowCover6_uint8"].asUInt();
|
||||
if(!checkField("singleBeamSonar1_uint8")) ok=false; state.singleBeamSonar1 = root["singleBeamSonar1_uint8"].asUInt();
|
||||
if(!checkField("singleBeamSonar2_uint8")) ok=false; state.singleBeamSonar2 = root["singleBeamSonar2_uint8"].asUInt();
|
||||
if(!checkField("singleBeamSonar3_uint8")) ok=false; state.singleBeamSonar3 = root["singleBeamSonar3_uint8"].asUInt();
|
||||
if(!checkField("singleBeamSonar4_uint8")) ok=false; state.singleBeamSonar4 = root["singleBeamSonar4_uint8"].asUInt();
|
||||
if(!checkField("singleBeamSonar5_uint8")) ok=false; state.singleBeamSonar5 = root["singleBeamSonar5_uint8"].asUInt();
|
||||
if(!checkField("singleBeamSonar6_uint8")) ok=false; state.singleBeamSonar6 = root["singleBeamSonar6_uint8"].asUInt();
|
||||
if(!checkField("forwardSonar_uint8")) ok=false; state.forwardSonar = root["forwardSonar_uint8"].asUInt();
|
||||
if(!checkField("depth3_uint8")) ok=false; state.depth3 = root["depth3_uint8"].asUInt();
|
||||
if(!checkField("soundVeloc_uint8")) ok=false; state.soundVeloc = root["soundVeloc_uint8"].asUInt();
|
||||
if(!checkField("bowRudderServo_uint8")) ok=false; state.bowRudderServo = root["bowRudderServo_uint8"].asUInt();
|
||||
if(!checkField("bowRudderDeploy_uint8")) ok=false; state.bowRudderDeploy = root["bowRudderDeploy_uint8"].asUInt();
|
||||
if(!checkField("ctd1_uint8")) ok=false; state.ctd1 = root["ctd1_uint8"].asUInt();
|
||||
if(!checkField("waterInject_uint8")) ok=false; state.waterInject = root["waterInject_uint8"].asUInt();
|
||||
|
||||
// UNIT2
|
||||
if(!checkField("sideSonar_uint8")) ok=false; state.sideSonar = root["sideSonar_uint8"].asUInt();
|
||||
if(!checkField("bowWaterInet1_uint8")) ok=false; state.bowWaterInet1 = root["bowWaterInet1_uint8"].asUInt();
|
||||
if(!checkField("bowWaterInet2_uint8")) ok=false; state.bowWaterInet2 = root["bowWaterInet2_uint8"].asUInt();
|
||||
if(!checkField("bowWaterInet3_uint8")) ok=false; state.bowWaterInet3 = root["bowWaterInet3_uint8"].asUInt();
|
||||
if(!checkField("bowWaterInet4_uint8")) ok=false; state.bowWaterInet4 = root["bowWaterInet4_uint8"].asUInt();
|
||||
if(!checkField("bowWaterInet5_uint8")) ok=false; state.bowWaterInet5 = root["bowWaterInet5_uint8"].asUInt();
|
||||
if(!checkField("bowWaterInet6_uint8")) ok=false; state.bowWaterInet6 = root["bowWaterInet6_uint8"].asUInt();
|
||||
if(!checkField("bowWaterInet7_uint8")) ok=false; state.bowWaterInet7 = root["bowWaterInet7_uint8"].asUInt();
|
||||
if(!checkField("bowWaterInet8_uint8")) ok=false; state.bowWaterInet8 = root["bowWaterInet8_uint8"].asUInt();
|
||||
if(!checkField("launchControler_uint8")) ok=false; state.launchControler = root["launchControler_uint8"].asUInt();
|
||||
if(!checkField("electSensor_uint8")) ok=false; state.electSensor = root["electSensor_uint8"].asUInt();
|
||||
if(!checkField("lowFreqSonar_uint8")) ok=false; state.lowFreqSonar = root["lowFreqSonar_uint8"].asUInt();
|
||||
|
||||
// UNIT3
|
||||
if(!checkField("buoyancyAdjust1_uint8")) ok=false; state.buoyancyAdjust1 = root["buoyancyAdjust1_uint8"].asUInt();
|
||||
if(!checkField("buoyancyAdjust2_uint8")) ok=false; state.buoyancyAdjust2 = root["buoyancyAdjust2_uint8"].asUInt();
|
||||
if(!checkField("buoyancyAdjust3_uint8")) ok=false; state.buoyancyAdjust3 = root["buoyancyAdjust3_uint8"].asUInt();
|
||||
if(!checkField("USBL_uint8")) ok=false; state.USBL = root["USBL_uint8"].asUInt();
|
||||
if(!checkField("depth1_uint8")) ok=false; state.depth1 = root["depth1_uint8"].asUInt();
|
||||
if(!checkField("commDev_uint8")) ok=false; state.commDev = root["commDev_uint8"].asUInt();
|
||||
if(!checkField("mastLiftingServo_uint8")) ok=false; state.mastLiftingServo = root["mastLiftingServo_uint8"].asUInt();
|
||||
if(!checkField("DVL_uint8")) ok=false; state.DVL = root["DVL_uint8"].asUInt();
|
||||
if(!checkField("ADCP_uint8")) ok=false; state.ADCP = root["ADCP_uint8"].asUInt();
|
||||
if(!checkField("inOutLetWater1_uint8")) ok=false; state.inOutLetWater1 = root["inOutLetWater1_uint8"].asUInt();
|
||||
if(!checkField("inOutLetWater2_uint8")) ok=false; state.inOutLetWater2 = root["inOutLetWater2_uint8"].asUInt();
|
||||
|
||||
// UNIT4
|
||||
if(!checkField("singleBeamSonar7_uint8")) ok=false; state.singleBeamSonar7 = root["singleBeamSonar7_uint8"].asUInt();
|
||||
if(!checkField("singleBeamSonar8_uint8")) ok=false; state.singleBeamSonar8 = root["singleBeamSonar8_uint8"].asUInt();
|
||||
if(!checkField("buoyage_uint8")) ok=false; state.buoyage = root["buoyage_uint8"].asUInt();
|
||||
if(!checkField("bowThrow_uint8")) ok=false; state.bowThrow = root["bowThrow_uint8"].asUInt();
|
||||
if(!checkField("depth2_uint8")) ok=false; state.depth2 = root["depth2_uint8"].asUInt();
|
||||
if(!checkField("thruster_uint8")) ok=false; state.thruster = root["thruster_uint8"].asUInt();
|
||||
if(!checkField("dragSonar_uint8")) ok=false; state.dragSonar = root["dragSonar_uint8"].asUInt();
|
||||
if(!checkField("haulingMachine_uint8")) ok=false; state.haulingMachine = root["haulingMachine_uint8"].asUInt();
|
||||
if(!checkField("buoyancyAdjust4_uint8")) ok=false; state.buoyancyAdjust4 = root["buoyancyAdjust4_uint8"].asUInt();
|
||||
if(!checkField("buoyancyAdjust5_uint8")) ok=false; state.buoyancyAdjust5 = root["buoyancyAdjust5_uint8"].asUInt();
|
||||
if(!checkField("sternRudderServo1_uint8")) ok=false; state.sternRudderServo1 = root["sternRudderServo1_uint8"].asUInt();
|
||||
if(!checkField("sternRudderServo2_uint8")) ok=false; state.sternRudderServo2 = root["sternRudderServo2_uint8"].asUInt();
|
||||
if(!checkField("sternRudderServo3_uint8")) ok=false; state.sternRudderServo3 = root["sternRudderServo3_uint8"].asUInt();
|
||||
if(!checkField("sternRudderServo4_uint8")) ok=false; state.sternRudderServo4 = root["sternRudderServo4_uint8"].asUInt();
|
||||
if(!checkField("ctd2_uint8")) ok=false; state.ctd2 = root["ctd2_uint8"].asUInt();
|
||||
if(!checkField("commDevStern_uint8")) ok=false; state.commDevStern = root["commDevStern_uint8"].asUInt();
|
||||
if(!checkField("inOutLetWater3_uint8")) ok=false; state.inOutLetWater3 = root["inOutLetWater3_uint8"].asUInt();
|
||||
|
||||
// UNIT5
|
||||
if(!checkField("secINS_uint8")) ok=false; state.secINS = root["secINS_uint8"].asUInt();
|
||||
if(!checkField("photoSensor_uint8")) ok=false; state.photoSensor = root["photoSensor_uint8"].asUInt();
|
||||
if(!checkField("sternThrow_uint8")) ok=false; state.sternThrow = root["sternThrow_uint8"].asUInt();
|
||||
if(!checkField("mainINS_uint8")) ok=false; state.mainINS = root["mainINS_uint8"].asUInt();
|
||||
|
||||
return ok;
|
||||
};
|
||||
std::string buildSecdistStateToJson(DeviceSecdistState &state){
|
||||
Json::Value root;
|
||||
|
||||
// UNIT1
|
||||
root["bowCover1_uint8"] = state.bowCover1;
|
||||
root["bowCover2_uint8"] = state.bowCover2;
|
||||
root["bowCover3_uint8"] = state.bowCover3;
|
||||
root["bowCover4_uint8"] = state.bowCover4;
|
||||
root["bowCover5_uint8"] = state.bowCover5;
|
||||
root["bowCover6_uint8"] = state.bowCover6;
|
||||
root["singleBeamSonar1_uint8"] = state.singleBeamSonar1;
|
||||
root["singleBeamSonar2_uint8"] = state.singleBeamSonar2;
|
||||
root["singleBeamSonar3_uint8"] = state.singleBeamSonar3;
|
||||
root["singleBeamSonar4_uint8"] = state.singleBeamSonar4;
|
||||
root["singleBeamSonar5_uint8"] = state.singleBeamSonar5;
|
||||
root["singleBeamSonar6_uint8"] = state.singleBeamSonar6;
|
||||
root["forwardSonar_uint8"] = state.forwardSonar;
|
||||
root["depth3_uint8"] = state.depth3;
|
||||
root["soundVeloc_uint8"] = state.soundVeloc;
|
||||
root["bowRudderServo_uint8"] = state.bowRudderServo;
|
||||
root["bowRudderDeploy_uint8"] = state.bowRudderDeploy;
|
||||
root["ctd1_uint8"] = state.ctd1;
|
||||
root["waterInject_uint8"] = state.waterInject;
|
||||
|
||||
// UNIT2
|
||||
root["sideSonar_uint8"] = state.sideSonar;
|
||||
root["bowWaterInet1_uint8"] = state.bowWaterInet1;
|
||||
root["bowWaterInet2_uint8"] = state.bowWaterInet2;
|
||||
root["bowWaterInet3_uint8"] = state.bowWaterInet3;
|
||||
root["bowWaterInet4_uint8"] = state.bowWaterInet4;
|
||||
root["bowWaterInet5_uint8"] = state.bowWaterInet5;
|
||||
root["bowWaterInet6_uint8"] = state.bowWaterInet6;
|
||||
root["bowWaterInet7_uint8"] = state.bowWaterInet7;
|
||||
root["bowWaterInet8_uint8"] = state.bowWaterInet8;
|
||||
root["launchControler_uint8"] = state.launchControler;
|
||||
root["electSensor_uint8"] = state.electSensor;
|
||||
root["lowFreqSonar_uint8"] = state.lowFreqSonar;
|
||||
|
||||
// UNIT3
|
||||
root["buoyancyAdjust1_uint8"] = state.buoyancyAdjust1;
|
||||
root["buoyancyAdjust2_uint8"] = state.buoyancyAdjust2;
|
||||
root["buoyancyAdjust3_uint8"] = state.buoyancyAdjust3;
|
||||
root["USBL_uint8"] = state.USBL;
|
||||
root["depth1_uint8"] = state.depth1;
|
||||
root["commDev_uint8"] = state.commDev;
|
||||
root["mastLiftingServo_uint8"] = state.mastLiftingServo;
|
||||
root["DVL_uint8"] = state.DVL;
|
||||
root["ADCP_uint8"] = state.ADCP;
|
||||
root["inOutLetWater1_uint8"] = state.inOutLetWater1;
|
||||
root["inOutLetWater2_uint8"] = state.inOutLetWater2;
|
||||
|
||||
// UNIT4
|
||||
root["singleBeamSonar7_uint8"] = state.singleBeamSonar7;
|
||||
root["singleBeamSonar8_uint8"] = state.singleBeamSonar8;
|
||||
root["buoyage_uint8"] = state.buoyage;
|
||||
root["bowThrow_uint8"] = state.bowThrow;
|
||||
root["depth2_uint8"] = state.depth2;
|
||||
root["thruster_uint8"] = state.thruster;
|
||||
root["dragSonar_uint8"] = state.dragSonar;
|
||||
root["haulingMachine_uint8"] = state.haulingMachine;
|
||||
root["buoyancyAdjust4_uint8"] = state.buoyancyAdjust4;
|
||||
root["buoyancyAdjust5_uint8"] = state.buoyancyAdjust5;
|
||||
root["sternRudderServo1_uint8"] = state.sternRudderServo1;
|
||||
root["sternRudderServo2_uint8"] = state.sternRudderServo2;
|
||||
root["sternRudderServo3_uint8"] = state.sternRudderServo3;
|
||||
root["sternRudderServo4_uint8"] = state.sternRudderServo4;
|
||||
root["ctd2_uint8"] = state.ctd2;
|
||||
root["commDevStern_uint8"] = state.commDevStern;
|
||||
root["inOutLetWater3_uint8"] = state.inOutLetWater3;
|
||||
|
||||
// UNIT5
|
||||
root["secINS_uint8"] = state.secINS;
|
||||
root["photoSensor_uint8"] = state.photoSensor;
|
||||
root["sternThrow_uint8"] = state.sternThrow;
|
||||
root["mainINS_uint8"] = state.mainINS;
|
||||
|
||||
Json::StreamWriterBuilder writerBuilder;
|
||||
writerBuilder.settings_["indentation"] = ""; // 紧凑格式,无缩进
|
||||
return Json::writeString(writerBuilder, root);
|
||||
};
|
||||
|
||||
bool converFromDriverTable(DeviceSecdistState &state,const DriverTable &driver){
|
||||
// UNIT1
|
||||
state.bowCover1 = driver.bowCover1;
|
||||
state.bowCover2 = driver.bowCover2;
|
||||
state.bowCover3 = driver.bowCover3;
|
||||
state.bowCover4 = driver.bowCover4;
|
||||
state.bowCover5 = driver.bowCover5;
|
||||
state.bowCover6 = driver.bowCover6;
|
||||
state.singleBeamSonar1 = driver.singleBeamSonar1;
|
||||
state.singleBeamSonar2 = driver.singleBeamSonar2;
|
||||
state.singleBeamSonar3 = driver.singleBeamSonar3;
|
||||
state.singleBeamSonar4 = driver.singleBeamSonar4;
|
||||
state.singleBeamSonar5 = driver.singleBeamSonar5;
|
||||
state.singleBeamSonar6 = driver.singleBeamSonar6;
|
||||
state.forwardSonar = driver.forwardSonar;
|
||||
state.depth3 = driver.depth3;
|
||||
state.soundVeloc = driver.soundVeloc;
|
||||
state.bowRudderServo = driver.bowRudderServo1 | driver.bowRudderServo2;
|
||||
state.bowRudderDeploy = driver.bowRudderDeploy;
|
||||
state.ctd1 = driver.ctd1;
|
||||
state.waterInject = driver.waterInject;
|
||||
|
||||
// UNIT2
|
||||
state.sideSonar = driver.sideSonar;
|
||||
state.bowWaterInet1 = driver.bowWaterlnet1;
|
||||
state.bowWaterInet2 = driver.bowWaterlnet2;
|
||||
state.bowWaterInet3 = driver.bowWaterlnet3;
|
||||
state.bowWaterInet4 = driver.bowWaterlnet4;
|
||||
state.bowWaterInet5 = driver.bowWaterlnet5;
|
||||
state.bowWaterInet6 = driver.bowWaterlnet6;
|
||||
state.bowWaterInet7 = driver.bowWaterlnet7;
|
||||
state.bowWaterInet8 = driver.bowWaterlnet8;
|
||||
state.launchControler = driver.launchControler;
|
||||
state.electSensor = driver.electSensor;
|
||||
state.lowFreqSonar = driver.lowFreqSonar;
|
||||
|
||||
// UNIT3
|
||||
state.buoyancyAdjust1 = driver.buoyancyAdjust1;
|
||||
state.buoyancyAdjust2 = driver.buoyancyAdjust2;
|
||||
state.buoyancyAdjust3 = driver.buoyancyAdjust3;
|
||||
state.USBL = driver.USBL;
|
||||
state.depth1 = driver.depth1;
|
||||
state.commDev = driver.commMast;
|
||||
state.mastLiftingServo = driver.mastLiftingServo;
|
||||
state.DVL = driver.DVL;
|
||||
state.ADCP = driver.DVL; // Assuming ADCP is same as DVL
|
||||
state.inOutLetWater1 = driver.inputWaterSensor1;
|
||||
state.inOutLetWater2 = driver.inputWaterSensor2;
|
||||
|
||||
// UNIT4
|
||||
state.singleBeamSonar7 = driver.singleBeamSonar7;
|
||||
state.singleBeamSonar8 = driver.singleBeamSonar8;
|
||||
state.buoyage = driver.buoyage;
|
||||
state.bowThrow = driver.bowThrow;
|
||||
state.depth2 = driver.depth2;
|
||||
state.thruster = driver.thruster;
|
||||
state.haulingMachine = 0; // No corresponding field in DriverTable
|
||||
state.buoyancyAdjust4 = driver.buoyancyAdjust4;
|
||||
state.buoyancyAdjust5 = driver.buoyancyAdjust5;
|
||||
state.sternRudderServo1 = driver.sternRudderServo1;
|
||||
state.sternRudderServo2 = driver.sternRudderServo2;
|
||||
state.sternRudderServo3 = driver.sternRudderServo3;
|
||||
state.sternRudderServo4 = driver.sternRudderServo4;
|
||||
state.ctd2 = driver.ctd2;
|
||||
state.commDevStern = 0; // No corresponding field in DriverTable
|
||||
state.inOutLetWater3 = driver.inputWaterSensor3;
|
||||
|
||||
// UNIT5
|
||||
state.secINS = driver.ins;
|
||||
state.photoSensor = driver.photoSensor;
|
||||
state.sternThrow = driver.sternThrow;
|
||||
state.mainINS = driver.ins;
|
||||
|
||||
// 未映射字段
|
||||
// driver.overDeep1
|
||||
// driver.overDeep2
|
||||
// driver.ntp
|
||||
state.dragSonar = 0; // Assuming dragSonar is same as lowFreqSonar
|
||||
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
bool converToDriverTable(const DeviceSecdistState &state, DriverTable &driver){
|
||||
// UNIT1
|
||||
driver.bowCover1 = state.bowCover1;
|
||||
driver.bowCover2 = state.bowCover2;
|
||||
driver.bowCover3 = state.bowCover3;
|
||||
driver.bowCover4 = state.bowCover4;
|
||||
driver.bowCover5 = state.bowCover5;
|
||||
driver.bowCover6 = state.bowCover6;
|
||||
driver.singleBeamSonar1 = state.singleBeamSonar1;
|
||||
driver.singleBeamSonar2 = state.singleBeamSonar2;
|
||||
driver.singleBeamSonar3 = state.singleBeamSonar3;
|
||||
driver.singleBeamSonar4 = state.singleBeamSonar4;
|
||||
driver.singleBeamSonar5 = state.singleBeamSonar5;
|
||||
driver.singleBeamSonar6 = state.singleBeamSonar6;
|
||||
driver.forwardSonar = state.forwardSonar;
|
||||
driver.depth3 = state.depth3;
|
||||
driver.soundVeloc = state.soundVeloc;
|
||||
driver.bowRudderServo1 = state.bowRudderServo;
|
||||
driver.bowRudderServo2 = state.bowRudderServo;
|
||||
driver.bowRudderDeploy = state.bowRudderDeploy;
|
||||
driver.ctd1 = state.ctd1;
|
||||
driver.waterInject = state.waterInject;
|
||||
|
||||
// UNIT2
|
||||
driver.sideSonar = state.sideSonar;
|
||||
driver.bowWaterlnet1 = state.bowWaterInet1;
|
||||
driver.bowWaterlnet2 = state.bowWaterInet2;
|
||||
driver.bowWaterlnet3 = state.bowWaterInet3;
|
||||
driver.bowWaterlnet4 = state.bowWaterInet4;
|
||||
driver.bowWaterlnet5 = state.bowWaterInet5;
|
||||
driver.bowWaterlnet6 = state.bowWaterInet6;
|
||||
driver.bowWaterlnet7 = state.bowWaterInet7;
|
||||
driver.bowWaterlnet8 = state.bowWaterInet8;
|
||||
driver.launchControler = state.launchControler;
|
||||
driver.electSensor = state.electSensor;
|
||||
driver.lowFreqSonar = state.lowFreqSonar;
|
||||
|
||||
// UNIT3
|
||||
driver.buoyancyAdjust1 = state.buoyancyAdjust1;
|
||||
driver.buoyancyAdjust2 = state.buoyancyAdjust2;
|
||||
driver.buoyancyAdjust3 = state.buoyancyAdjust3;
|
||||
driver.USBL = state.USBL;
|
||||
driver.depth1 = state.depth1;
|
||||
driver.commMast = state.commDev;
|
||||
driver.ntp = 1;
|
||||
driver.mastLiftingServo = state.mastLiftingServo;
|
||||
driver.DVL = state.DVL;
|
||||
driver.inputWaterSensor1 = state.inOutLetWater1;
|
||||
driver.inputWaterSensor2 = state.inOutLetWater2;
|
||||
driver.overDeep1 = (state.depth1 == 1) ? 1 : 0;
|
||||
driver.overDeep2 = (state.depth2 == 1 || state.depth3 == 1) ? 1 : 0;
|
||||
|
||||
// UNIT4
|
||||
driver.singleBeamSonar7 = state.singleBeamSonar7;
|
||||
driver.singleBeamSonar8 = state.singleBeamSonar8;
|
||||
driver.buoyage = state.buoyage;
|
||||
driver.bowThrow = state.bowThrow;
|
||||
driver.depth2 = state.depth2;
|
||||
driver.thruster = state.thruster;
|
||||
driver.buoyancyAdjust4 = state.buoyancyAdjust4;
|
||||
driver.buoyancyAdjust5 = state.buoyancyAdjust5;
|
||||
driver.sternRudderServo1 = state.sternRudderServo1;
|
||||
driver.sternRudderServo2 = state.sternRudderServo2;
|
||||
driver.sternRudderServo3 = state.sternRudderServo3;
|
||||
driver.sternRudderServo4 = state.sternRudderServo4;
|
||||
driver.ctd2 = state.ctd2;
|
||||
driver.inputWaterSensor3 = state.inOutLetWater3;
|
||||
|
||||
// UNIT5
|
||||
driver.ins = state.secINS | state.mainINS;
|
||||
driver.photoSensor = state.photoSensor;
|
||||
driver.sternThrow = state.sternThrow;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string buildMsg(DriverTable &driver){
|
||||
DeviceSecdistState s;
|
||||
converFromDriverTable(s,driver);
|
||||
return buildSecdistStateToJson(s);
|
||||
};
|
||||
|
||||
bool parseMsg(const std::string &strJson,DriverTable &driver){
|
||||
DeviceSecdistState s;
|
||||
if(!parseSecdistStateFromJson(s,strJson)){
|
||||
LOG_F(WARNING, "parseSecdistStateFromJson failed");
|
||||
return false;
|
||||
}
|
||||
converToDriverTable(s,driver);
|
||||
return true;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,81 @@
|
||||
#ifndef U_POWER_CURRENTSTATE_ST_H
|
||||
#define U_POWER_CURRENTSTATE_ST_H
|
||||
#include "../driver.h"
|
||||
#include "string"
|
||||
#include "json/json.h"
|
||||
#include <bitset>
|
||||
|
||||
class uPower_currentStateMsg
|
||||
{
|
||||
private:
|
||||
/* data */
|
||||
public:
|
||||
uPower_currentStateMsg() {
|
||||
memset(&state, 0, sizeof(state));
|
||||
};
|
||||
~uPower_currentStateMsg() {};
|
||||
std::string key = "uPower_currentState_st";
|
||||
|
||||
pmState state;
|
||||
std::string buildMsg(pmState state)
|
||||
{
|
||||
// 状态赋值
|
||||
Json::Value currentBusState;
|
||||
currentBusState["HVBpowerBusVol_uint16"] = state.bus1State.powerBusVoltage;
|
||||
currentBusState["HVBdcDc5Cur_uint16"] = state.bus1State.dcDc5ModuleCurrent;
|
||||
currentBusState["HVBpowerBusCur_uint16"] = state.bus1State.powerBusCurrent;
|
||||
currentBusState["HVBbusAVol_uint16"] = state.bus1State.busbarAVoltage;
|
||||
currentBusState["HVBmotorCur_uint16"] = state.bus1State.propulsionMotorControlBoxCurrent;
|
||||
currentBusState["HVBbusACur_uint16"] = state.bus1State.busbarACurrent;
|
||||
currentBusState["HVBbatGroupCur_uint16"] = state.bus1State.lithiumBatteryGroupMeterCurrent;
|
||||
currentBusState["HVBbowHVolDisBoxCur_uint16"] = state.bus1State.bowHighVoltageDistributionBoxCurrent;
|
||||
currentBusState["HVBFTDev45Cur_uint16"] = state.bus1State.sternFTDevice45Current;
|
||||
currentBusState["HVBtyzCur_uint16"] = state.bus1State.tyzReservedSwitchCurrent;
|
||||
currentBusState["HVBsternRud1Cur_uint16"] = state.bus1State.sternRudderSwitch1Current;
|
||||
currentBusState["HVBreservedCur1_uint16"] = state.bus1State.reservedCurrent1;
|
||||
currentBusState["HVBsternRud2Cur_uint16"] = state.bus1State.sternRudderSwitch2Current;
|
||||
currentBusState["HVBreservedCur2_uint16"] = state.bus1State.reservedCurrent2;
|
||||
currentBusState["HVBfbCur_uint16"] = state.bus1State.fbReservedSwitchCurrent;
|
||||
currentBusState["HVBreservedCur3_uint16"] = state.bus1State.reservedCurrent3;
|
||||
|
||||
currentBusState["HVABbusBVol_uint16"] = state.bus2State.busbarBVoltage;
|
||||
currentBusState["HVABbusBCur_uint16"] = state.bus2State.busbarBCurrent;
|
||||
currentBusState["HVABFTDev123Cur_uint16"] = state.bus2State.bowFTDevice123Current;
|
||||
currentBusState["HVABactCur_uint16"] = state.bus2State.actuatorCurrent;
|
||||
currentBusState["HVABmastSteGeaCur_uint16"] = state.bus2State.mastSteeringGearControlBoxCurrent;
|
||||
currentBusState["HVABxczCur_uint16"] = state.bus2State.xczCurrent;
|
||||
currentBusState["HVABbowRudCur_uint16"] = state.bus2State.bowRudderControlBoxCurrent;
|
||||
currentBusState["HVABopenWaterCur_uint16"] = state.bus2State.openWaterCoverStartCylinderCurrent;
|
||||
|
||||
currentBusState["HVBBinsBusVol_uint16"] = state.bus3State.instrumentBusbarVoltage;
|
||||
currentBusState["HVBBbowLowVolDisBoxCur_uint16"] = state.bus3State.bowLowVoltageDistributionBoxCurrent;
|
||||
currentBusState["HVBBdcC1InsCur_uint16"] = state.bus3State.dcC1InstrumentDC48VCurrent;
|
||||
currentBusState["HVBBreservedCur1_uint16"] = state.bus3State.reservedCurrent1;
|
||||
currentBusState["HVBBemerBatCur_uint16"] = state.bus3State.emergencyLithiumBatteryGroup2Current;
|
||||
currentBusState["HVBBbatInsCur_uint16"] = state.bus3State.lithiumBatteryGroupInstrumentCurrent;
|
||||
currentBusState["HVBBunit4Cur_uint16"] = state.bus3State.unit4InstrumentDC48VCurrent;
|
||||
currentBusState["HVBBreservedCur2_uint16"] = state.bus3State.reservedCurrent2;
|
||||
currentBusState["HVBBemer2BusVol_uint16"] = state.bus3State.emergency2BusbarVoltage;
|
||||
currentBusState["HVBBCCUCur_uint16"] = state.bus3State.compositeEnergyManagementSystemEmergencyDC48VCurrent;
|
||||
currentBusState["HVBBFCSSecurSysCur_uint16"] = state.bus3State.fuelCellSecuritySystemEmergencyDC48VCurrent;
|
||||
currentBusState["HVBBplcCur_uint16"] = state.bus3State.plcControlPowerCurrent;
|
||||
|
||||
currentBusState["LVBinsBusVol_uint16"] = state.bus4State.instrumentBusbarVoltage;
|
||||
currentBusState["LVBBinsBusCur_uint16"] = state.bus4State.instrumentBusbarCurrent;
|
||||
currentBusState["LVBBunit1Cur_uint16"] = state.bus4State.unit1Current;
|
||||
currentBusState["LVBBunit2Cur_uint16"] = state.bus4State.unit2Current;
|
||||
currentBusState["LVBBunit3Cur_uint16"] = state.bus4State.unit3Current;
|
||||
currentBusState["LVBBunit5Cur_uint16"] = state.bus4State.unit5Current;
|
||||
currentBusState["LVBBbowPZDevCur_uint16"] = state.bus4State.bowPZDeviceCurrent;
|
||||
currentBusState["LVBBemerBatCur_uint16"] = state.bus4State.emergencyLithiumBatteryGroup1Current;
|
||||
currentBusState["LVBBemerBusVol_uint16"] = state.bus4State.emergency1BusbarVoltage;
|
||||
|
||||
// 转化为json格式
|
||||
|
||||
Json::StreamWriterBuilder writerBuilder;
|
||||
writerBuilder.settings_["indentation"] = "";
|
||||
return Json::writeString(writerBuilder, currentBusState);
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,55 @@
|
||||
#ifndef U_POWER_DISSYSSTATE_ST_H
|
||||
#define U_POWER_DISSYSSTATE_ST_H
|
||||
#include "../driver.h"
|
||||
#include "string"
|
||||
#include "json/json.h"
|
||||
#include <bitset>
|
||||
#include "../pmSysvariable.h"
|
||||
|
||||
class uPower_disSysStateMsg
|
||||
{
|
||||
private:
|
||||
/* data */
|
||||
public:
|
||||
uPower_disSysStateMsg() {
|
||||
};
|
||||
~uPower_disSysStateMsg() {};
|
||||
std::string key = "uPower_disSysState_st";
|
||||
|
||||
disSysBreakerList currentDisBreakerState;
|
||||
|
||||
std::string buildMsg(disSysBreakerList currentDisBreakerState)
|
||||
{
|
||||
//构建配电系统状态报告
|
||||
Json::Value dis;
|
||||
disBus1Breaker* pdis1=new disBus1Breaker;
|
||||
disBus2Breaker* pdis2=new disBus2Breaker;
|
||||
disBus3Breaker* pdis3=new disBus3Breaker;
|
||||
disBus4Breaker* pdis4=new disBus4Breaker;
|
||||
|
||||
*pdis1 = currentDisBreakerState.bus1Breaker;
|
||||
*pdis2 = currentDisBreakerState.bus2Breaker;
|
||||
*pdis3 = currentDisBreakerState.bus3Breaker;
|
||||
*pdis4 = currentDisBreakerState.bus4Breaker;
|
||||
|
||||
dis["HVolBusBreaker_uint16"] = *(unsigned short*)pdis1;
|
||||
dis["HVolABusBreaker_unit16"] = *(unsigned short*)pdis2;
|
||||
dis["HVolBBusBreaker_unit16"] = *(unsigned short*)pdis3;
|
||||
dis["LVolBusBreaker_uint16"] = *(unsigned short*)pdis4;
|
||||
|
||||
//TODO: 构建配电系统故障码
|
||||
// Json::Value faultCodeDis_array;
|
||||
// for(auto val : m_pm->faultCode)
|
||||
// {
|
||||
// faultCodeDis_array.append(val);
|
||||
// }
|
||||
// dis[VAR_TO_STR(faultCode_array)] = faultCodeDis_array;
|
||||
// 转化为json格式
|
||||
|
||||
Json::StreamWriterBuilder writerBuilder;
|
||||
writerBuilder.settings_["indentation"] = "";
|
||||
return Json::writeString(writerBuilder, dis);
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,220 @@
|
||||
#ifndef U_POWER_EQUINSSTATE_H
|
||||
#define U_POWER_EQUINSSTATE_H
|
||||
#include "../driver.h"
|
||||
#include "string"
|
||||
#include "json/json.h"
|
||||
#include <bitset>
|
||||
class uPower_equInsStateMsg
|
||||
{
|
||||
private:
|
||||
/* data */
|
||||
public:
|
||||
uPower_equInsStateMsg() {
|
||||
// 初始化成员变量
|
||||
//state全部初始化为0
|
||||
memset(&state, 0, sizeof(state));
|
||||
}; // 添加默认构造函数实现
|
||||
~uPower_equInsStateMsg() {}; // 添加析构函数实现
|
||||
std::string key = "uPower_equInsState_fb";
|
||||
|
||||
struct SensorState
|
||||
{
|
||||
unsigned int singleBeamSonar1 : 1; // 单波束声呐1
|
||||
unsigned int singleBeamSonar2 : 1; // 单波束声呐2
|
||||
unsigned int singleBeamSonar3 : 1; // 单波束声呐3
|
||||
unsigned int singleBeamSonar4 : 1; // 单波束声呐4
|
||||
unsigned int singleBeamSonar5 : 1; // 单波束声呐5
|
||||
unsigned int singleBeamSonar6 : 1; // 单波束声呐6
|
||||
unsigned int singleBeamSonar7 : 1; // 单波束声呐7
|
||||
unsigned int singleBeamSonar8 : 1; // 单波束声呐8
|
||||
unsigned int forwardSonar : 1; // 前视声呐
|
||||
unsigned int ctd1 : 1; // CTD1
|
||||
unsigned int ctd2 : 1; // CTD2
|
||||
unsigned int soundVelocityMeter : 1; // 声速仪
|
||||
unsigned int ntp : 1; // 深度计
|
||||
unsigned int depthMeter1 : 1; // 深度计1
|
||||
unsigned int depthMeter2 : 1; // 深度计2
|
||||
unsigned int depthMeter3 : 1; // 深度计3
|
||||
};
|
||||
struct ActuatorState
|
||||
{
|
||||
unsigned int openCloseMechanism1 : 1; // bit 0 启闭机构1
|
||||
unsigned int openCloseMechanism2 : 1; // bit 1 启闭机构2
|
||||
unsigned int openCloseMechanism3 : 1; // bit 2 启闭机构3
|
||||
unsigned int openCloseMechanism4 : 1; // bit 3 启闭机构4
|
||||
unsigned int openCloseMechanism5 : 1; // bit 4 启闭机构5
|
||||
unsigned int openCloseMechanism6 : 1; // bit 5 启闭机构6
|
||||
unsigned int reserved1 : 2; // bit 6-7 保留
|
||||
unsigned int openWaterMechanism1 : 1; // bit 8 敞水机构1
|
||||
unsigned int openWaterMechanism2 : 1; // bit 9 敞水机构2
|
||||
unsigned int openWaterMechanism3 : 1; // bit 10 敞水机构3
|
||||
unsigned int openWaterMechanism4 : 1; // bit 11 敞水机构4
|
||||
unsigned int openWaterMechanism5 : 1; // bit 12 敞水机构5
|
||||
unsigned int openWaterMechanism6 : 1; // bit 13 敞水机构6
|
||||
unsigned int openWaterMechanism7 : 1; // bit 14 敞水机构7
|
||||
unsigned int openWaterMechanism8 : 1; // bit 15 敞水机构8
|
||||
};
|
||||
|
||||
struct MotionState
|
||||
{
|
||||
unsigned int sternRudder1 : 1; // bit 0 艉部舵机1
|
||||
unsigned int sternRudder2 : 1; // bit 1 艉部舵机2
|
||||
unsigned int sternRudder3 : 1; // bit 2 艉部舵机3
|
||||
unsigned int sternRudder4 : 1; // bit 3 艉部舵机4
|
||||
unsigned int bowRudder : 1; // bit 4 艏舵电缸
|
||||
unsigned int waterInjection : 1; // bit 5 注水机构
|
||||
unsigned int propulsionMotor : 1; // bit 6 推进电机
|
||||
unsigned int buoyancyAdjust1 : 1; // bit 7 浮调机构(艏部)1
|
||||
unsigned int buoyancyAdjust2 : 1; // bit 8 浮调机构(艏部)2
|
||||
unsigned int buoyancyAdjust3 : 1; // bit 9 浮调机构(艏部)3
|
||||
unsigned int buoyancyAdjust4 : 1; // bit 10 浮调机构(艉部)4
|
||||
unsigned int buoyancyAdjust5 : 1; // bit 11 浮调机构(艉部)5
|
||||
unsigned int DVL : 1; // bit 12 DVL
|
||||
unsigned int INS : 1; // bit 13 惯导系统
|
||||
unsigned int bowRudderLeft : 1; // bit 14 艏舵左舵机
|
||||
unsigned int bowRudderRight : 1; // bit 15 艏右舵舵机
|
||||
};
|
||||
struct LoadcommState
|
||||
{
|
||||
unsigned int payloadControl : 1; // bit 0 载荷发控
|
||||
unsigned int optMast : 1; // bit 1 光电桅杆
|
||||
unsigned int emMast : 1; // bit 2 电磁桅杆
|
||||
unsigned int reserved1 : 1; // bit 3 保留
|
||||
unsigned int sideSonar : 1; // bit 4 舷侧声纳
|
||||
unsigned int towedSonar : 1; // bit 5 拖曳声纳
|
||||
unsigned int reserved2 : 2; // bit 6-7 保留
|
||||
unsigned int commMast : 1; // bit 8 通信桅杆
|
||||
unsigned int midLowFreqSonar : 1; // bit 9 中低频声呐
|
||||
unsigned int highFreqComm : 1; // bit 10 高频声通机
|
||||
unsigned int buoySystem : 1; // bit 11 浮标系统
|
||||
unsigned int commMastRudder : 1; // bit 12 通信桅杆舵机
|
||||
unsigned int optMastRudder : 1; // bit 13 光电桅杆舵机
|
||||
unsigned int emMastRudder : 1; // bit 14 电磁桅杆舵机
|
||||
unsigned int reserved3 : 1; // bit 15 保留
|
||||
};
|
||||
struct ThrowPowerState
|
||||
{
|
||||
unsigned int bowThrow : 1; // bit 0 艏部抛载
|
||||
unsigned int reserved1 : 7; // bit 1-7 保留
|
||||
unsigned int fuelCellController : 1; // bit 8 燃料电池控制器
|
||||
unsigned int instrumentPanel : 1; // bit 9 仪表配电板
|
||||
unsigned int powerPanel : 1; // bit 10 动力配电板
|
||||
unsigned int instrumentBattery : 1; // bit 11 仪表锂电池
|
||||
unsigned int powerBattery : 1; // bit 12 动力锂电
|
||||
unsigned int sternThrow : 1; // bit 13 艉部抛载
|
||||
unsigned int reserved2 : 2; // bit 14-15 保留
|
||||
};
|
||||
struct uPower_equInsState
|
||||
{
|
||||
SensorState sensorState;
|
||||
ActuatorState actuatorState;
|
||||
MotionState motionState;
|
||||
LoadcommState loadcommState;
|
||||
ThrowPowerState throwPowerState;
|
||||
} state;
|
||||
std::string buildMsg(DriverTable s)
|
||||
{
|
||||
// 按照协议格式填充数据
|
||||
|
||||
// 传感器状态赋值
|
||||
state.sensorState.singleBeamSonar1 = s.singleBeamSonar1;
|
||||
state.sensorState.singleBeamSonar2 = s.singleBeamSonar2;
|
||||
state.sensorState.singleBeamSonar3 = s.singleBeamSonar3;
|
||||
state.sensorState.singleBeamSonar4 = s.singleBeamSonar4;
|
||||
state.sensorState.singleBeamSonar5 = s.singleBeamSonar5;
|
||||
state.sensorState.singleBeamSonar6 = s.singleBeamSonar6;
|
||||
state.sensorState.singleBeamSonar7 = s.singleBeamSonar7;
|
||||
state.sensorState.singleBeamSonar8 = s.singleBeamSonar8;
|
||||
state.sensorState.forwardSonar = s.forwardSonar;
|
||||
state.sensorState.ctd1 = s.ctd1;
|
||||
state.sensorState.ctd2 = s.ctd2;
|
||||
state.sensorState.soundVelocityMeter = s.soundVeloc;
|
||||
state.sensorState.ntp = s.ntp;
|
||||
state.sensorState.depthMeter1 = s.depth1;
|
||||
state.sensorState.depthMeter2 = s.depth2;
|
||||
state.sensorState.depthMeter3 = s.depth3;
|
||||
|
||||
// 执行机构状态赋值
|
||||
state.actuatorState.openCloseMechanism1 = s.bowCover1;
|
||||
state.actuatorState.openCloseMechanism2 = s.bowCover2;
|
||||
state.actuatorState.openCloseMechanism3 = s.bowCover3;
|
||||
state.actuatorState.openCloseMechanism4 = s.bowCover4;
|
||||
state.actuatorState.openCloseMechanism5 = s.bowCover5;
|
||||
state.actuatorState.openCloseMechanism6 = s.bowCover6;
|
||||
state.actuatorState.openWaterMechanism1 = s.bowWaterlnet1;
|
||||
state.actuatorState.openWaterMechanism2 = s.bowWaterlnet2;
|
||||
state.actuatorState.openWaterMechanism3 = s.bowWaterlnet3;
|
||||
state.actuatorState.openWaterMechanism4 = s.bowWaterlnet4;
|
||||
state.actuatorState.openWaterMechanism5 = s.bowWaterlnet5;
|
||||
state.actuatorState.openWaterMechanism6 = s.bowWaterlnet6;
|
||||
state.actuatorState.openWaterMechanism7 = s.bowWaterlnet7;
|
||||
state.actuatorState.openWaterMechanism8 = s.bowWaterlnet8;
|
||||
|
||||
// 运动状态赋值
|
||||
state.motionState.sternRudder1 = s.sternRudderServo1;
|
||||
state.motionState.sternRudder2 = s.sternRudderServo2;
|
||||
state.motionState.sternRudder3 = s.sternRudderServo3;
|
||||
state.motionState.sternRudder4 = s.sternRudderServo4;
|
||||
|
||||
state.motionState.bowRudder = s.bowRudderDeploy;
|
||||
|
||||
state.motionState.waterInjection = s.waterInject;
|
||||
|
||||
state.motionState.propulsionMotor = s.thruster;
|
||||
state.motionState.buoyancyAdjust1 = s.buoyancyAdjust1;
|
||||
state.motionState.buoyancyAdjust2 = s.buoyancyAdjust2;
|
||||
state.motionState.buoyancyAdjust3 = s.buoyancyAdjust3;
|
||||
state.motionState.buoyancyAdjust4 = s.buoyancyAdjust4;
|
||||
state.motionState.buoyancyAdjust5 = s.buoyancyAdjust5;
|
||||
state.motionState.DVL = s.DVL;
|
||||
state.motionState.INS = s.ins;
|
||||
|
||||
state.motionState.bowRudderLeft = s.bowRudderServo1;
|
||||
state.motionState.bowRudderRight = s.bowRudderServo2;
|
||||
|
||||
// 负载通信状态赋值
|
||||
state.loadcommState.payloadControl = s.launchControler;
|
||||
state.loadcommState.sideSonar = s.sideSonar;
|
||||
state.loadcommState.optMast = s.photoSensor;
|
||||
state.loadcommState.emMast = s.electSensor;
|
||||
state.loadcommState.buoySystem = s.buoyage;
|
||||
state.loadcommState.commMastRudder = s.mastLiftingServo;
|
||||
state.loadcommState.optMastRudder = s.mastLiftingServo;
|
||||
state.loadcommState.emMastRudder = s.mastLiftingServo;
|
||||
state.loadcommState.highFreqComm = s.USBL;
|
||||
state.loadcommState.midLowFreqSonar = s.lowFreqSonar;
|
||||
state.loadcommState.commMast = s.commMast;
|
||||
state.loadcommState.towedSonar = 0; //拖曳声纳未安装,默认为0
|
||||
|
||||
// 抛载和电源状态赋值
|
||||
state.throwPowerState.bowThrow = s.bowThrow; // 艏部抛载
|
||||
state.throwPowerState.sternThrow = s.sternThrow; // 艉部抛载
|
||||
state.throwPowerState.fuelCellController = 1; // 燃料电池控制器 默认开启
|
||||
state.throwPowerState.instrumentPanel = 1; // 仪表配电板 默认开启
|
||||
state.throwPowerState.powerPanel = 1; // 动力配电板 默认开启
|
||||
state.throwPowerState.instrumentBattery = 1; // 仪表锂电池 默认开启
|
||||
state.throwPowerState.powerBattery = 1; // 动力锂电 默认开启
|
||||
|
||||
// 转化为json格式
|
||||
Json::Value root;
|
||||
root["sensor_int16"] = *reinterpret_cast<uint16_t*>(&state.sensorState);
|
||||
root["actuator_int16"] = *reinterpret_cast<uint16_t*>(&state.actuatorState);
|
||||
root["motion_int16"] = *reinterpret_cast<uint16_t*>(&state.motionState);
|
||||
root["loadcomm_int16"] = *reinterpret_cast<uint16_t*>(&state.loadcommState);
|
||||
root["throwpower_int16"] = *reinterpret_cast<uint16_t*>(&state.throwPowerState);
|
||||
|
||||
//以二进制形式打印
|
||||
// std::cout << "sensor_int16: " << std::bitset<16>(*reinterpret_cast<uint16_t*>(&state.sensorState)) << std::endl;
|
||||
// std::cout << "actuator_int16: " << std::bitset<16>(*reinterpret_cast<uint16_t*>(&state.actuatorState)) << std::endl;
|
||||
// std::cout << "motion_int16: " << std::bitset<16>(*reinterpret_cast<uint16_t*>(&state.motionState)) << std::endl;
|
||||
// std::cout << "loadcomm_int16: " << std::bitset<16>(*reinterpret_cast<uint16_t*>(&state.loadcommState)) << std::endl;
|
||||
// std::cout << "throwpower_int16: " << std::bitset<16>(*reinterpret_cast<uint16_t*>(&state.throwPowerState)) << std::endl;
|
||||
|
||||
// 返回json字符串
|
||||
Json::StreamWriterBuilder writerBuilder;
|
||||
writerBuilder.settings_["indentation"] = ""; // 紧凑格式,无缩进
|
||||
return Json::writeString(writerBuilder, root);
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,26 @@
|
||||
#ifndef U_POWER_EQUSTATE_FB_H
|
||||
#define U_POWER_EQUSTATE_FB_H
|
||||
#include "../driver.h"
|
||||
#include "string"
|
||||
#include "json/json.h"
|
||||
#include <bitset>
|
||||
|
||||
class uPower_equStateMsg
|
||||
{
|
||||
private:
|
||||
/* data */
|
||||
public:
|
||||
uPower_equStateMsg() {
|
||||
};
|
||||
~uPower_equStateMsg() {};
|
||||
std::string key = "uPower_equState_fb";
|
||||
|
||||
Driver driver;
|
||||
|
||||
std::string buildMsg(DriverTable s)
|
||||
{
|
||||
return driver.saveDriverTableToJson(&s);
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,133 @@
|
||||
#ifndef U_POWER_FCSSTATE_ST_H
|
||||
#define U_POWER_FCSSTATE_ST_H
|
||||
#include "../driver.h"
|
||||
#include "string"
|
||||
#include "json/json.h"
|
||||
#include <bitset>
|
||||
|
||||
class uPower_fcsStateMsg
|
||||
{
|
||||
private:
|
||||
/* data */
|
||||
public:
|
||||
uPower_fcsStateMsg() {
|
||||
memset(&state, 0, sizeof(state));
|
||||
};
|
||||
~uPower_fcsStateMsg() {};
|
||||
std::string key = "uPower_fcsState_st";
|
||||
|
||||
struct uPower_fcsState
|
||||
{
|
||||
unsigned int fcsStatus : 4; // 燃料电池状态
|
||||
unsigned int outputPower : 12; // 输出功率 (0-4095)
|
||||
unsigned int temperature : 8; // 温度 (0-255)
|
||||
unsigned int errorCode : 8; // 错误代码
|
||||
} state;
|
||||
|
||||
std::string buildMsg(ccuState ccustate)
|
||||
{
|
||||
//TODO:根据最新协议修改
|
||||
Json::Value fcs;
|
||||
// suffix = getTypeName(typeid(ccustate.fcuState).name());
|
||||
// fcs["fcuState"] = ccustate.fcuState;
|
||||
|
||||
// suffix = getTypeName(typeid(ccustate.fcuFaultLeve).name());
|
||||
// fcs["fcuFaultLeve"] = ccustate.fcuFaultLeve;
|
||||
|
||||
// suffix = getTypeName(typeid(ccustate.powerLimit).name());
|
||||
// fcs[VAR_TO_STR(powLimit)+suffix] = ccustate.powerLimit;
|
||||
|
||||
// suffix = getTypeName(typeid(ccustate.totalPowerGeneration).name());
|
||||
// fcs[VAR_TO_STR(powerGen)+suffix] = ccustate.totalPowerGeneration;
|
||||
|
||||
// suffix = getTypeName(typeid(ccustate.ch4o).name());
|
||||
// fcs[VAR_TO_STR(ch4o)+suffix] = ccustate.ch4o;
|
||||
|
||||
// suffix = getTypeName(typeid(ccustate.o2).name());
|
||||
// fcs[VAR_TO_STR(o2)+suffix] = ccustate.o2;
|
||||
|
||||
// suffix = getTypeName(typeid(ccustate.fcuVoltage).name());
|
||||
// fcs[VAR_TO_STR(fcuVol)+suffix] = ccustate.fcuVoltage;
|
||||
|
||||
// suffix = getTypeName(typeid(ccustate.fcuCurrent).name());
|
||||
// fcs[VAR_TO_STR(fcuCur)+suffix] = ccustate.fcuCurrent;
|
||||
|
||||
// suffix = getTypeName(typeid(ccustate.o2Level).name());
|
||||
// fcs[VAR_TO_STR(o2Level)+suffix] = ccustate.o2Level;
|
||||
|
||||
// suffix = getTypeName(typeid(ccustate.exchangerTemperature).name());
|
||||
// fcs[VAR_TO_STR(excTemp)+suffix] = ccustate.exchangerTemperature;
|
||||
|
||||
// suffix = getTypeName(typeid(ccustate.fcuOutPower).name());
|
||||
// fcs[VAR_TO_STR(fcuOutPower)+suffix] = ccustate.fcuOutPower;
|
||||
|
||||
// suffix = getTypeName(typeid(ccustate.fcuOutIns).name());
|
||||
// fcs[VAR_TO_STR(fcuOutIns)+suffix] = ccustate.fcuOutIns;
|
||||
|
||||
// suffix = getTypeName(typeid(ccustate.fcuVoltageIns).name());
|
||||
// fcs[VAR_TO_STR(fcuVolIns)+suffix] = ccustate.fcuVoltageIns;
|
||||
|
||||
// suffix = getTypeName(typeid(ccustate.fcuVoltagePower).name());
|
||||
// fcs[VAR_TO_STR(fcuVolPower)+suffix] = ccustate.fcuVoltagePower;
|
||||
|
||||
// suffix = getTypeName(typeid(ccustate.fcuCurrentIns).name());
|
||||
// fcs[VAR_TO_STR(fcuCurIns)+suffix] = ccustate.fcuCurrentIns;
|
||||
|
||||
// suffix = getTypeName(typeid(ccustate.fcuCurrentPower).name());
|
||||
// fcs[VAR_TO_STR(fcuCurPower)+suffix] = ccustate.fcuCurrentPower;
|
||||
|
||||
// suffix = getTypeName(typeid(ccustate.h2Concentration1).name());
|
||||
// fcs[VAR_TO_STR(h2Concent1)+suffix] = ccustate.h2Concentration1;
|
||||
|
||||
// suffix = getTypeName(typeid(ccustate.h2Concentration2).name());
|
||||
// fcs[VAR_TO_STR(h2Concent2)+suffix] = ccustate.h2Concentration2;
|
||||
|
||||
// suffix = getTypeName(typeid(ccustate.o2Concentration1).name());
|
||||
// fcs[VAR_TO_STR(o2Concent1)+suffix] = ccustate.o2Concentration1;
|
||||
|
||||
// suffix = getTypeName(typeid(ccustate.o2Concentration2).name());
|
||||
// fcs[VAR_TO_STR(o2Concent2)+suffix] = ccustate.o2Concentration2;
|
||||
|
||||
// suffix = getTypeName(typeid(ccustate.ch4oConcentration1).name());
|
||||
// fcs[VAR_TO_STR(ch4oConcent1)+suffix] = ccustate.ch4oConcentration1;
|
||||
|
||||
// suffix = getTypeName(typeid(ccustate.ch4oConcentration2).name());
|
||||
// fcs[VAR_TO_STR(ch4oConcent2)+suffix] = ccustate.ch4oConcentration2;
|
||||
|
||||
// suffix = getTypeName(typeid(ccustate.backpressure1).name());
|
||||
// fcs[VAR_TO_STR(backpressure1)+suffix] = ccustate.backpressure1;
|
||||
|
||||
// suffix = getTypeName(typeid(ccustate.backpressure2).name());
|
||||
// fcs[VAR_TO_STR(backpressure2)+suffix] = ccustate.backpressure2;
|
||||
|
||||
// suffix = getTypeName(typeid(ccustate.flameDetection).name());
|
||||
// fcs[VAR_TO_STR(flameDet)+suffix] = ccustate.flameDetection;
|
||||
|
||||
// unsigned short faultCode1;
|
||||
// unsigned short faultCode2;
|
||||
// unsigned short faultCode3;
|
||||
// faultCode1 = (ccustate.fcuGZ_1H << 8) | ccustate.fcuGZ_1L;
|
||||
// faultCode2 = (ccustate.fcuGZ_2H << 8) | ccustate.fcuGZ_2L;
|
||||
// faultCode3 = (ccustate.fcuGZ_3H << 8) | ccustate.fcuGZ_3L;
|
||||
|
||||
// suffix = getTypeName(typeid(faultCode1).name());
|
||||
// fcs[VAR_TO_STR(faultCode1)+suffix] = faultCode1;
|
||||
// suffix = getTypeName(typeid(faultCode2).name());
|
||||
// fcs[VAR_TO_STR(faultCode2)+suffix] = faultCode2;
|
||||
// suffix = getTypeName(typeid(faultCode3).name());
|
||||
// fcs[VAR_TO_STR(faultCode3)+suffix] = faultCode3;
|
||||
|
||||
// // 转化为json格式
|
||||
// Json::Value root;
|
||||
// root["fcsStatus"] = state.fcsStatus;
|
||||
// root["outputPower"] = state.outputPower;
|
||||
// root["temperature"] = state.temperature;
|
||||
// root["errorCode"] = state.errorCode;
|
||||
|
||||
Json::StreamWriterBuilder writerBuilder;
|
||||
writerBuilder.settings_["indentation"] = "";
|
||||
return Json::writeString(writerBuilder, fcs);
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,137 @@
|
||||
#ifndef U_POWER_LIBATSTATE_ST_H
|
||||
#define U_POWER_LIBATSTATE_ST_H
|
||||
#include "../driver.h"
|
||||
#include "string"
|
||||
#include "json/json.h"
|
||||
#include <bitset>
|
||||
|
||||
class uPower_liBatStateMsg
|
||||
{
|
||||
private:
|
||||
/* data */
|
||||
public:
|
||||
uPower_liBatStateMsg() {
|
||||
};
|
||||
~uPower_liBatStateMsg() {};
|
||||
std::string key = "uPower_liBatState_st";
|
||||
|
||||
|
||||
std::string buildMsg(ccuState ccustate)
|
||||
{
|
||||
//TODO:根据最新协议修改
|
||||
Json::Value lbs;
|
||||
//构建动力锂电池状态报告
|
||||
// suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.insPosRelayState).name());
|
||||
// lbs[VAR_TO_STR(insPosRelayState)+suffix] = m_pm->m_pmCurrentState.ccustate.insPosRelayState;
|
||||
|
||||
// suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.insNegRelayState).name());
|
||||
// lbs[VAR_TO_STR(insNegRelayState)+suffix] = m_pm->m_pmCurrentState.ccustate.insNegRelayState;
|
||||
|
||||
// suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.powerPosRelayState).name());
|
||||
// lbs[VAR_TO_STR(powPosRelayState)+suffix] = m_pm->m_pmCurrentState.ccustate.powerPosRelayState;
|
||||
|
||||
// suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.powerNegRelayState).name());
|
||||
// lbs[VAR_TO_STR(powNegRelayState)+suffix] = m_pm->m_pmCurrentState.ccustate.powerNegRelayState;
|
||||
|
||||
// suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.insBatLimit).name());
|
||||
// lbs[VAR_TO_STR(insBatLimit)+suffix] = m_pm->m_pmCurrentState.ccustate.insBatLimit;
|
||||
|
||||
// suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.powerBatLimit).name());
|
||||
// lbs[VAR_TO_STR(powerBatLimit)+suffix] = m_pm->m_pmCurrentState.ccustate.powerBatLimit;
|
||||
|
||||
// suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.insBatSoc).name());
|
||||
// lbs[VAR_TO_STR(insBatSoc)+suffix] = m_pm->m_pmCurrentState.ccustate.insBatSoc;
|
||||
|
||||
// suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.powerBatSoc).name());
|
||||
// lbs[VAR_TO_STR(powBatSoc)+suffix] = m_pm->m_pmCurrentState.ccustate.powerBatSoc;
|
||||
|
||||
// suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.insBatTotalElectricity).name());
|
||||
// lbs[VAR_TO_STR(insBatTotalElect)+suffix] = m_pm->m_pmCurrentState.ccustate.insBatTotalElectricity;
|
||||
|
||||
// suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.powerBatTotalElectricity).name());
|
||||
// lbs[VAR_TO_STR(powBatTotalElect)+suffix] = m_pm->m_pmCurrentState.ccustate.powerBatTotalElectricity;
|
||||
|
||||
// suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.insBatCurrentElectricity).name());
|
||||
// lbs[VAR_TO_STR(insBatCurElect)+suffix] = m_pm->m_pmCurrentState.ccustate.insBatCurrentElectricity;
|
||||
|
||||
// suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.powerBatCurrentElectricity).name());
|
||||
// lbs[VAR_TO_STR(powBatCurElect)+suffix] = m_pm->m_pmCurrentState.ccustate.powerBatCurrentElectricity;
|
||||
|
||||
// suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.insChargeState).name());
|
||||
// lbs[VAR_TO_STR(insChargeState)+suffix] = m_pm->m_pmCurrentState.ccustate.insChargeState;
|
||||
|
||||
// suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.powerChargeState).name());
|
||||
// lbs[VAR_TO_STR(powChargeState)+suffix] = m_pm->m_pmCurrentState.ccustate.powerChargeState;
|
||||
|
||||
// suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.insLinkVoltage).name());
|
||||
// lbs[VAR_TO_STR(insLinkVol)+suffix] = m_pm->m_pmCurrentState.ccustate.insLinkVoltage;
|
||||
|
||||
// suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.insPackVoltage).name());
|
||||
// lbs[VAR_TO_STR(insPackVol)+suffix] = m_pm->m_pmCurrentState.ccustate.insPackVoltage;
|
||||
|
||||
// suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.insCurrent).name());
|
||||
// lbs[VAR_TO_STR(insCurrent)+suffix] = m_pm->m_pmCurrentState.ccustate.insCurrent;
|
||||
|
||||
// suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.insPosInsulationResistance).name());
|
||||
// lbs[VAR_TO_STR(insPosRes)+suffix] = m_pm->m_pmCurrentState.ccustate.insPosInsulationResistance;
|
||||
|
||||
// suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.insNegInsulationResistance).name());
|
||||
// lbs[VAR_TO_STR(insNegRes)+suffix] = m_pm->m_pmCurrentState.ccustate.insNegInsulationResistance;
|
||||
|
||||
// suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.powerLinkVoltage).name());
|
||||
// lbs[VAR_TO_STR(powLinkVol)+suffix] = m_pm->m_pmCurrentState.ccustate.powerLinkVoltage;
|
||||
|
||||
// suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.powerPackVoltage).name());
|
||||
// lbs[VAR_TO_STR(powerPackVol)+suffix] = m_pm->m_pmCurrentState.ccustate.powerPackVoltage;
|
||||
|
||||
// suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.powerCurrent).name());
|
||||
// lbs[VAR_TO_STR(powCur)+suffix] = m_pm->m_pmCurrentState.ccustate.powerCurrent;
|
||||
|
||||
// suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.powerPosInsulationResistance).name());
|
||||
// lbs[VAR_TO_STR(powPosRes)+suffix] = m_pm->m_pmCurrentState.ccustate.powerPosInsulationResistance;
|
||||
|
||||
// suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.powerNegInsulationResistance).name());
|
||||
// lbs[VAR_TO_STR(powNegRes)+suffix] = m_pm->m_pmCurrentState.ccustate.powerNegInsulationResistance;
|
||||
|
||||
// suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.insCurrentSocHold1).name());
|
||||
// lbs[VAR_TO_STR(insCurSocHold1)+suffix] = m_pm->m_pmCurrentState.ccustate.insCurrentSocHold1;
|
||||
|
||||
// suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.insCurrentSocHold2).name());
|
||||
// lbs[VAR_TO_STR(insCurSocHold2)+suffix] = m_pm->m_pmCurrentState.ccustate.insCurrentSocHold2;
|
||||
|
||||
// suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.insCurrentSocHold3).name());
|
||||
// lbs[VAR_TO_STR(insCurSocHold3)+suffix] = m_pm->m_pmCurrentState.ccustate.insCurrentSocHold3;
|
||||
|
||||
// suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.fcuCurrentToInsLimit1).name());
|
||||
// lbs[VAR_TO_STR(fcuCurToInsLimit1)+suffix] = m_pm->m_pmCurrentState.ccustate.fcuCurrentToInsLimit1;
|
||||
|
||||
// suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.fcuCurrentToinsLimit2).name());
|
||||
// lbs[VAR_TO_STR(fcuCurToinsLimit2)+suffix] = m_pm->m_pmCurrentState.ccustate.fcuCurrentToinsLimit2;
|
||||
|
||||
// suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.powerCurrentSocHold1).name());
|
||||
// lbs[VAR_TO_STR(powCurSocHold1)+suffix] = m_pm->m_pmCurrentState.ccustate.powerCurrentSocHold1;
|
||||
|
||||
// suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.powerCurrentSocHold2).name());
|
||||
// lbs[VAR_TO_STR(powCurSocHold2)+suffix] = m_pm->m_pmCurrentState.ccustate.powerCurrentSocHold2;
|
||||
|
||||
// suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.powerCurrentSocHold3).name());
|
||||
// lbs[VAR_TO_STR(powCurSocHold3)+suffix] = m_pm->m_pmCurrentState.ccustate.powerCurrentSocHold3;
|
||||
|
||||
// suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.powerCurrentToInsLimit1).name());
|
||||
// lbs[VAR_TO_STR(powCurToInsLimit1)+suffix] = m_pm->m_pmCurrentState.ccustate.powerCurrentToInsLimit1;
|
||||
|
||||
// suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.powerCurrentToinsLimit2).name());
|
||||
// lbs[VAR_TO_STR(powCurToinsLimit2)+suffix] = m_pm->m_pmCurrentState.ccustate.powerCurrentToinsLimit2;
|
||||
|
||||
// suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.insAlarmIdentificationWord).name());
|
||||
// lbs[VAR_TO_STR(insfaultCode)+suffix] = m_pm->m_pmCurrentState.ccustate.insAlarmIdentificationWord;
|
||||
// suffix = getTypeName(typeid(m_pm->m_pmCurrentState.ccustate.powerAlarmIdentificationWord).name());
|
||||
// lbs[VAR_TO_STR(powfaultCode)+suffix] = m_pm->m_pmCurrentState.ccustate.powerAlarmIdentificationWord;
|
||||
|
||||
Json::StreamWriterBuilder writerBuilder;
|
||||
writerBuilder.settings_["indentation"] = "";
|
||||
return Json::writeString(writerBuilder, lbs);
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,63 @@
|
||||
#ifndef U_POWER_PMSTATE_FB_H
|
||||
#define U_POWER_PMSTATE_FB_H
|
||||
#include "../driver.h"
|
||||
#include "string"
|
||||
#include "json/json.h"
|
||||
#include <bitset>
|
||||
|
||||
class uPower_pmStateMsg
|
||||
{
|
||||
private:
|
||||
/* data */
|
||||
public:
|
||||
uPower_pmStateMsg() {
|
||||
memset(&state, 0, sizeof(state));
|
||||
};
|
||||
~uPower_pmStateMsg() {};
|
||||
std::string key = "uPower_pmState_fb";
|
||||
|
||||
struct uPower_pmState
|
||||
{
|
||||
unsigned char workCondition;
|
||||
unsigned char currentMod;
|
||||
unsigned char powerState;
|
||||
unsigned char faultLevel;
|
||||
vector<unsigned int> faultCode;
|
||||
unsigned int soc;
|
||||
unsigned int sustainableTime;
|
||||
unsigned int m_faultNum;
|
||||
unsigned char m_leakage;
|
||||
} state;
|
||||
|
||||
std::string buildMsg()
|
||||
{
|
||||
// 状态赋值
|
||||
//1.构建系统状态报告
|
||||
Json::Value pms;
|
||||
|
||||
pms["workCondition_uint"] = state.workCondition;
|
||||
pms["currentMod_uint8"] = state.currentMod;
|
||||
pms["powerState_uint8"] = state.powerState;
|
||||
pms["faultLevel_uint8"] = state.faultLevel;
|
||||
|
||||
Json::Value faultCode_array;
|
||||
for(auto val : state.faultCode)
|
||||
{
|
||||
faultCode_array.append(val);
|
||||
}
|
||||
pms["faultCode_array"] = faultCode_array;
|
||||
|
||||
pms["soc_uint16"] = state.soc;
|
||||
|
||||
pms["sustainableTime_int64"] = state.sustainableTime;
|
||||
|
||||
pms["leakage_uint8"] = state.m_leakage;
|
||||
|
||||
// 转化为json格式
|
||||
Json::StreamWriterBuilder writerBuilder;
|
||||
writerBuilder.settings_["indentation"] = "";
|
||||
return Json::writeString(writerBuilder, pms);
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
+140
-118
@@ -10,87 +10,106 @@
|
||||
#define BREAK_ON 0x55
|
||||
#define BREAK_FALSE 0x5A
|
||||
|
||||
|
||||
|
||||
//消息结构体变量定义
|
||||
#pragma pack (1)
|
||||
typedef struct ccuState
|
||||
{
|
||||
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;
|
||||
uint8_t fc_mode; // 燃料电池系统运行模式:00H-无效, 01H-调试, 02H-自动, 03H-补给
|
||||
uint8_t fc_status; // 燃料电池状态:00H-无效, 01H-初始化, ..., 0DH-维护完成(详见协议)
|
||||
uint8_t fc_fault_level; // 燃料电池故障等级:00H-无故障, 10H-一级, 20H-二级, 30H-三级, 40H-四级
|
||||
|
||||
uint16_t output_power_limit; // 系统输出功率限制值,单位:W,范围:0~30000W
|
||||
uint16_t total_generation_time; // 系统累计发电时间,单位:0.1小时,最大值6553.5小时
|
||||
uint16_t total_generation_power; // 系统累计发电总功率,单位:W
|
||||
uint16_t fault_level_1; // 一级故障位,按位表示不同的故障项
|
||||
uint16_t fault_level_2; // 二级故障位
|
||||
uint16_t fault_level_3; // 三级故障位
|
||||
uint16_t fault_level_4; // 四级故障位
|
||||
|
||||
uint8_t hydrogen_capacity; // 储氢罐剩余容量百分比,单位:%,范围:0~100
|
||||
uint8_t liquid_oxygen_capacity; // 液氧罐剩余容量百分比,单位:%,范围:0~100
|
||||
|
||||
uint16_t palladium_temp; // 钯膜最高温度,单位:℃
|
||||
uint16_t main_pipe_pressure; // 主水路压力,单位:0.01kPa
|
||||
uint16_t aux_pipe_pressure; // 辅水路压力,单位:0.01kPa
|
||||
|
||||
uint16_t cabin_pressure1; // 舱室1压力,单位:0.01kPa
|
||||
uint16_t cabin_pressure2; // 舱室2压力,单位:0.01kPa
|
||||
uint16_t cabin_temp1; // 舱室1温度,单位:0.01℃
|
||||
uint16_t cabin_temp2; // 舱室2温度,单位:0.01℃
|
||||
uint16_t cabin_humidity1; // 舱室1湿度,单位:0.01%RH
|
||||
uint16_t cabin_humidity2; // 舱室2湿度,单位:0.01%RH
|
||||
|
||||
uint8_t flame_detector1; // 火焰探测器1状态:00H-无效, 01H-报警, 02H-故障
|
||||
uint8_t flame_detector2; // 火焰探测器2状态:00H-无效, 01H-报警, 02H-故障
|
||||
|
||||
uint16_t h2_concentration1; // 舱室H2浓度1,单位:0.01% LEL(爆炸下限)
|
||||
uint16_t h2_concentration2; // 舱室H2浓度2,单位:0.01% LEL
|
||||
uint16_t h2_concentration3; // 舱室H2浓度3,单位:0.01% LEL
|
||||
uint16_t o2_concentration1; // 舱室O2浓度1,单位:0.01% LEL
|
||||
uint16_t o2_concentration2; // 舱室O2浓度2,单位:0.01% LEL
|
||||
uint16_t ch3oh_concentration1; // 舱室甲醇气体浓度1,单位:0.01% LEL
|
||||
uint16_t ch3oh_concentration2; // 舱室甲醇气体浓度2,单位:0.01% LEL
|
||||
|
||||
uint16_t reserved1[18]; // 保留字段,地址范围35~52,共18个uint16_t,协议预留
|
||||
|
||||
uint8_t dyn_alarm_flag[6]; // 动力锂电池报警标志字数组,共6字节,按位表示各类报警
|
||||
uint8_t ins_alarm_flag[6]; // 仪表锂电池报警标志字数组,共6字节,按位表示各类报警
|
||||
|
||||
uint8_t ins_relay_status1; // 仪表电池继电器状态,高4位表示正极继电器,低4位表示充电继电器
|
||||
uint8_t ins_relay_status2; // 仪表电池预充继电器和负极继电器状态
|
||||
uint8_t dyn_relay_status1; // 动力电池正极与充电继电器状态
|
||||
uint8_t dyn_relay_status2; // 动力电池预充与负极继电器状态
|
||||
|
||||
uint16_t ins_max_discharge_power; // 仪表电池最大允许放电功率,单位:kW,精度0.05kW
|
||||
uint16_t dyn_max_discharge_power; // 动力电池最大允许放电功率,单位:kW,精度0.05kW
|
||||
|
||||
uint8_t ins_soc; // 仪表锂电池荷电状态SOC,范围:0~100
|
||||
uint8_t dyn_soc; // 动力锂电池荷电状态SOC,范围:0~100
|
||||
|
||||
uint16_t ins_total_energy; // 仪表电池总能量,单位:kWh
|
||||
uint16_t dyn_total_energy; // 动力电池总能量,单位:kWh
|
||||
|
||||
uint16_t ins_power_input; // 仪表电池输入功率,单位:kW
|
||||
uint16_t dyn_power_input; // 动力电池输入功率,单位:kW
|
||||
|
||||
uint8_t ins_charge_status; // 仪表电池充放电状态:00H-无效,10H-充电,20H-放电
|
||||
uint8_t dyn_charge_status; // 动力电池充放电状态:00H-无效,10H-充电,20H-放电
|
||||
|
||||
uint16_t ins_voltage_link; // 仪表电池LINK端电压,单位:0.01V
|
||||
uint16_t ins_voltage_pack; // 仪表电池PACK端电压,单位:0.01V
|
||||
uint16_t ins_current; // 仪表电池电流,单位:0.01A(正值放电)
|
||||
uint16_t ins_resistance_pos; // 仪表电池正极绝缘电阻,单位:kΩ
|
||||
uint16_t ins_resistance_neg; // 仪表电池负极绝缘电阻,单位:kΩ
|
||||
|
||||
uint16_t dyn_voltage_link; // 动力电池LINK端电压,单位:0.01V
|
||||
uint16_t dyn_voltage_pack; // 动力电池PACK端电压,单位:0.01V
|
||||
uint16_t dyn_current; // 动力电池电流,单位:0.01A(正值放电)
|
||||
uint16_t dyn_resistance_pos; // 动力电池正极绝缘电阻,单位:kΩ
|
||||
uint16_t dyn_resistance_neg; // 动力电池负极绝缘电阻,单位:kΩ
|
||||
|
||||
uint8_t ins_emergency_status; // 仪表电池紧急状态字,按位表示异常或告警状态
|
||||
uint8_t dyn_emergency_status; // 动力电池紧急状态字,按位表示异常或告警状态
|
||||
|
||||
uint8_t reserved2[2]; // 保留字节,协议预留
|
||||
|
||||
uint8_t ins_soc_threshold1; // 仪表电池1 SOC门限,范围:0~100
|
||||
uint8_t ins_soc_threshold2; // 仪表电池2 SOC门限,范围:0~100
|
||||
uint8_t ins_soc_threshold3; // 仪表电池3 SOC门限,范围:0~100
|
||||
uint8_t dyn_soc_threshold1; // 动力电池1 SOC门限,范围:0~100
|
||||
uint8_t dyn_soc_threshold2; // 动力电池2 SOC门限,范围:0~100
|
||||
uint8_t dyn_soc_threshold3; // 动力电池3 SOC门限,范围:0~100
|
||||
|
||||
uint8_t ins_power_limit1; // 仪表电池1功率限制值,单位:%
|
||||
uint8_t ins_power_limit2; // 仪表电池2功率限制值,单位:%
|
||||
uint8_t dyn_power_limit1; // 动力电池1功率限制值,单位:%
|
||||
uint8_t dyn_power_limit2; // 动力电池2功率限制值,单位:%
|
||||
|
||||
uint32_t device_online_flag1; // 设备在线状态标志1,byte0:低压配电板在线标志位 byte1:复合管控主机在线标志位 byte2:复合管控备机在线标志位
|
||||
uint32_t device_online_flag2; // 设备在线状态标志2,byte0:仪表锂电在线标志位 byte1:动力锂电在线标志位 byte2:燃电锂电在线标志位 byte3:高压配电板在线标志位
|
||||
|
||||
uint32_t reserved3; // 保留字段,协议预留
|
||||
uint32_t heartbeat; // 主机心跳计数器或标志值
|
||||
} ccuState;
|
||||
|
||||
typedef struct {
|
||||
@@ -116,6 +135,8 @@ typedef struct {
|
||||
unsigned char powerBatEfficiency;
|
||||
unsigned char heartbeat;
|
||||
unsigned char masterState;
|
||||
unsigned int paceholder1;
|
||||
unsigned int paceholder2;
|
||||
}ccuColCmd;
|
||||
|
||||
typedef struct disHighVolBusState
|
||||
@@ -551,7 +572,8 @@ enum class FcuState : unsigned char {
|
||||
namespace BatteryCommand {
|
||||
enum Type : unsigned char {
|
||||
Start = 0x10,
|
||||
Stop = 0x20
|
||||
Stop = 0x20,
|
||||
Hold = 0x00
|
||||
};
|
||||
};
|
||||
|
||||
@@ -733,53 +755,53 @@ namespace DeviceId {
|
||||
|
||||
namespace FaultEnable {
|
||||
enum Type : bool {
|
||||
BasicNavigationFault_1 = true, // 使能故障
|
||||
BasicNavigationFault_2 = true,
|
||||
BasicNavigationFault_3 = true,
|
||||
BasicNavigationFault_4 = true,
|
||||
BasicNavigationFault_5 = true,
|
||||
BasicNavigationFault_6 = true,
|
||||
BasicNavigationFault_7 = true,
|
||||
BasicNavigationFault_8 = true,
|
||||
BasicNavigationFault_9 = true,
|
||||
BasicNavigationFault_10 = true,
|
||||
BasicNavigationFault_1 = false, // 使能故障
|
||||
BasicNavigationFault_2 = false,
|
||||
BasicNavigationFault_3 = false,
|
||||
BasicNavigationFault_4 = false,
|
||||
BasicNavigationFault_5 = false,
|
||||
BasicNavigationFault_6 = false,
|
||||
BasicNavigationFault_7 = false,
|
||||
BasicNavigationFault_8 = false,
|
||||
BasicNavigationFault_9 = false,
|
||||
BasicNavigationFault_10 = false,
|
||||
|
||||
ExtendedNavigationFault_1 = true, // 使能故障
|
||||
ExtendedNavigationFault_2 = true,
|
||||
ExtendedNavigationFault_3 = true,
|
||||
ExtendedNavigationFault_4 = true,
|
||||
ExtendedNavigationFault_1 = false, // 使能故障
|
||||
ExtendedNavigationFault_2 = false,
|
||||
ExtendedNavigationFault_3 = false,
|
||||
ExtendedNavigationFault_4 = false,
|
||||
|
||||
ObstacleAvoidanceFault_1 = true, // 使能故障
|
||||
ObstacleAvoidanceFault_2 = true,
|
||||
ObstacleAvoidanceFault_3 = true,
|
||||
ObstacleAvoidanceFault_1 = false, // 使能故障
|
||||
ObstacleAvoidanceFault_2 = false,
|
||||
ObstacleAvoidanceFault_3 = false,
|
||||
|
||||
BuoyancyControlFault_1 = true, // 使能故障
|
||||
BuoyancyControlFault_2 = true,
|
||||
BuoyancyControlFault_3 = true,
|
||||
BuoyancyControlFault_4 = true,
|
||||
BuoyancyControlFault_1 = false, // 使能故障
|
||||
BuoyancyControlFault_2 = false,
|
||||
BuoyancyControlFault_3 = false,
|
||||
BuoyancyControlFault_4 = false,
|
||||
|
||||
CommunicationSystemFault_1 = true, // 使能故障
|
||||
CommunicationSystemFault_2 = true,
|
||||
CommunicationSystemFault_3 = true,
|
||||
CommunicationSystemFault_1 = false, // 使能故障
|
||||
CommunicationSystemFault_2 = false,
|
||||
CommunicationSystemFault_3 = false,
|
||||
|
||||
PayloadSystemFault_1 = true, // 使能故障
|
||||
PayloadSystemFault_2 = true,
|
||||
PayloadSystemFault_3 = true,
|
||||
PayloadSystemFault_4 = true,
|
||||
PayloadSystemFault_5 = true,
|
||||
PayloadSystemFault_6 = true,
|
||||
PayloadSystemFault_7 = true,
|
||||
PayloadSystemFault_1 = false, // 使能故障
|
||||
PayloadSystemFault_2 = false,
|
||||
PayloadSystemFault_3 = false,
|
||||
PayloadSystemFault_4 = false,
|
||||
PayloadSystemFault_5 = false,
|
||||
PayloadSystemFault_6 = false,
|
||||
PayloadSystemFault_7 = false,
|
||||
|
||||
EmergencySystemFault_1 = true, // 使能故障
|
||||
EmergencySystemFault_2 = true,
|
||||
EmergencySystemFault_3 = true,
|
||||
EmergencySystemFault_4 = true,
|
||||
EmergencySystemFault_5 = true,
|
||||
EmergencySystemFault_6 = true,
|
||||
EmergencySystemFault_1 = false, // 使能故障
|
||||
EmergencySystemFault_2 = false,
|
||||
EmergencySystemFault_3 = false,
|
||||
EmergencySystemFault_4 = false,
|
||||
EmergencySystemFault_5 = false,
|
||||
EmergencySystemFault_6 = false,
|
||||
|
||||
SensorSystemFault_1 = true, // 使能故障
|
||||
SensorSystemFault_2 = true,
|
||||
SensorSystemFault_3 = true,
|
||||
SensorSystemFault_1 = false, // 使能故障
|
||||
SensorSystemFault_2 = false,
|
||||
SensorSystemFault_3 = false,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Binary file not shown.
+232
-117
@@ -4,6 +4,7 @@ import socket
|
||||
import threading
|
||||
import time
|
||||
from db import DB
|
||||
import os
|
||||
from udpMsg import (
|
||||
msg_disHighVolBusFbMsg,
|
||||
msg_disHighAVolBusFbMsg,
|
||||
@@ -36,12 +37,12 @@ class PowerManagerApp:
|
||||
|
||||
self.disSysPortC1 = 6000
|
||||
self.disSysHostC1 = '192.168.1.154'
|
||||
# self.disSysHostC1 = '192.168.0.140'
|
||||
self.disSysPortC2 = 6000
|
||||
self.disSysHostC2 = '192.168.1.158'
|
||||
|
||||
# 数据库配置
|
||||
self.db = DB('/home/zjk/project/H100/H100PowerManger/test/disSysTest/test.db')
|
||||
# self.db = DB('/home/zjk/project/H100/H100PowerManger/test/disSysTest/test.db')
|
||||
self.db = DB(os.path.join(os.path.dirname(__file__), 'test.db'))
|
||||
self.db.connect()
|
||||
|
||||
# 状态数据 - 完全匹配udpMsg.py中的定义
|
||||
@@ -167,7 +168,8 @@ class PowerManagerApp:
|
||||
"应急锂电池组1断路器": 0
|
||||
},
|
||||
"alarms": {
|
||||
"电源故障信号": 0,
|
||||
"仪表电源故障": 0,
|
||||
"应急电源故障": 0,
|
||||
"进水报警": 0
|
||||
},
|
||||
"voltage": {
|
||||
@@ -373,7 +375,7 @@ class PowerManagerApp:
|
||||
|
||||
def send_hvb_cmd(self, breaker_name, state):
|
||||
"""发送动力母线配电指令"""
|
||||
print(breaker_name,state)
|
||||
# print(breaker_name,state)
|
||||
cmd = msg_disHVBCmdMsg()
|
||||
if breaker_name == "燃料电池断路器":
|
||||
cmd.fuelCellCircuitBreaker = state
|
||||
@@ -498,11 +500,11 @@ class PowerManagerApp:
|
||||
def udp_receive_loop(self):
|
||||
"""UDP接收消息循环"""
|
||||
while self.running:
|
||||
print('接收中')
|
||||
# print('接收中')
|
||||
try:
|
||||
data, addr = self.sock.recvfrom(1024)
|
||||
self.process_udp_message(data)
|
||||
print('接收成功')
|
||||
# print('接收成功')
|
||||
except Exception as e:
|
||||
self.log_message(f"接收错误: {str(e)}")
|
||||
|
||||
@@ -552,7 +554,7 @@ class PowerManagerApp:
|
||||
|
||||
# 故障状态 - 扩展显示所有故障位
|
||||
fault_labels1 = ["过温关机", "输出过流", "输出过压", "输出欠压", "输入过压", "输入欠压", "输出短路保护", "内部故障"]
|
||||
fault_labels2 = ["通信故障", "工作状态", "冷却泵1故障", "冷却泵2故障", "冷却水泄漏", "保留", "保留", "保留"]
|
||||
fault_labels2 = ["通信故障", "工作状态", "冷却泵1故障", "冷却泵2故障", "冷却水泄漏", "冷却泵1运行状态", "冷却泵2运行状态", "保留"]
|
||||
|
||||
# DC/DC故障显示
|
||||
fault_frame = ttk.Frame(frame)
|
||||
@@ -574,26 +576,29 @@ class PowerManagerApp:
|
||||
|
||||
# 绝缘状态 - 详细显示
|
||||
ttk.Label(frame, text="动力母线绝缘:").grid(row=16, column=0, sticky=tk.W)
|
||||
self.high_vol_power_insulation = ttk.Label(frame, text="正常(0.0MΩ)")
|
||||
self.high_vol_power_insulation = ttk.Label(frame, text="正常")
|
||||
self.high_vol_power_insulation.grid(row=16, column=1, sticky=tk.W)
|
||||
|
||||
ttk.Label(frame, text="A母线绝缘:").grid(row=16, column=2, sticky=tk.W)
|
||||
self.high_vol_a_insulation = ttk.Label(frame, text="正常(0.0MΩ)")
|
||||
self.high_vol_a_insulation = ttk.Label(frame, text="正常")
|
||||
self.high_vol_a_insulation.grid(row=16, column=3, sticky=tk.W)
|
||||
|
||||
# 电流值显示
|
||||
current_labels = [
|
||||
("动力母线电流(A):", "powerBusCurrent"),
|
||||
("A母线电流(A):", "busbarACurrent"),
|
||||
("A汇流排电流(A):", "busbarACurrent"),
|
||||
("DC/DC5模块电流(A):", "dcDc5ModuleCurrent"),
|
||||
("推进电机控制箱电流(A):", "propulsionMotorControlBoxCurrent"),
|
||||
("锂电池组表电流(A):", "lithiumBatteryGroupMeterCurrent"),
|
||||
("艏高压配电箱电流(A):", "bowHighVoltageDistributionBoxCurrent"),
|
||||
("艉FT设备45电流(A):", "sternFTDevice45Current"),
|
||||
("TYZ备用开关电流(A):", "tyzReservedSwitchCurrent"),
|
||||
("艉舵机开关1电流(A):", "sternRudderSwitch1Current"),
|
||||
("艉舵机开关2电流(A):", "sternRudderSwitch2Current"),
|
||||
("FB备用开关电流(A):", "fbReservedSwitchCurrent")
|
||||
("锂电池组(仪表)电流(A):", "lithiumBatteryGroupMeterCurrent"),
|
||||
("艏部高压配电箱电流(A):", "bowHighVoltageDistributionBoxCurrent"),
|
||||
("艉部FT装置4/5电流(A):", "sternFTDevice45Current"),
|
||||
("TYZ预留开关电流(A):", "tyzReservedSwitchCurrent"),
|
||||
("艉舵开关1电流(A):", "sternRudderSwitch1Current"),
|
||||
("艉舵开关2电流(A):", "sternRudderSwitch2Current"),
|
||||
("FB预留开关电流(A):", "fbReservedSwitchCurrent"),
|
||||
("备用电流1(A):", "reservedCurrent1"),
|
||||
("备用电流2(A):", "reservedCurrent2"),
|
||||
("备用电流3(A):", "reservedCurrent3")
|
||||
]
|
||||
|
||||
for i, (label, _) in enumerate(current_labels):
|
||||
@@ -603,14 +608,22 @@ class PowerManagerApp:
|
||||
setattr(self, f"high_vol_{current_labels[i][1]}", label_var)
|
||||
|
||||
# 冷却水压力
|
||||
ttk.Label(frame, text="冷却水压力(MPa):").grid(row=23, column=0, sticky=tk.W)
|
||||
ttk.Label(frame, text="冷却水压力(MPa):").grid(row=24, column=0, sticky=tk.W)
|
||||
self.high_vol_cool_water_pressure = ttk.Label(frame, text="0.00KPa")
|
||||
self.high_vol_cool_water_pressure.grid(row=23, column=1, sticky=tk.W)
|
||||
self.high_vol_cool_water_pressure.grid(row=24, column=1, sticky=tk.W)
|
||||
|
||||
# 冷却水压力
|
||||
ttk.Label(frame, text="DC/DC温度:").grid(row=24, column=0, sticky=tk.W)
|
||||
ttk.Label(frame, text="DC/DC温度:").grid(row=24, column=3, sticky=tk.W)
|
||||
self.high_vol_dcdc_temp = ttk.Label(frame, text="0.00摄氏度")
|
||||
self.high_vol_dcdc_temp.grid(row=24, column=1, sticky=tk.W)
|
||||
self.high_vol_dcdc_temp.grid(row=24, column=4, sticky=tk.W)
|
||||
|
||||
ttk.Label(frame, text="仪表失电信号:").grid(row=25, column=0, sticky=tk.W)
|
||||
self.high_vol_losspower_insulation = ttk.Label(frame, text="正常")
|
||||
self.high_vol_losspower_insulation.grid(row=25, column=1, sticky=tk.W)
|
||||
|
||||
ttk.Label(frame, text="应急失电信号").grid(row=25, column=2, sticky=tk.W)
|
||||
self.high_vol_loss_emerpower_insulation = ttk.Label(frame, text="正常")
|
||||
self.high_vol_loss_emerpower_insulation.grid(row=25, column=3, sticky=tk.W)
|
||||
|
||||
def setup_high_a_vol_ui(self, parent):
|
||||
"""设置高压A母线状态界面"""
|
||||
@@ -623,46 +636,63 @@ class PowerManagerApp:
|
||||
frame.grid_columnconfigure(2, weight=1)
|
||||
|
||||
# 电压显示 - 添加详细说明
|
||||
ttk.Label(frame, text="高压B母线电压(V):").grid(row=0, column=0, sticky=tk.W)
|
||||
self.high_a_vol_voltage = ttk.Label(frame, text="0.0")
|
||||
ttk.Label(frame, text="汇流排B电压(V):").grid(row=0, column=0, sticky=tk.W)
|
||||
self.high_a_vol_voltage = ttk.Label(frame, text="0.0 V")
|
||||
self.high_a_vol_voltage.grid(row=0, column=1, sticky=tk.W)
|
||||
|
||||
# 电流显示 - 统一格式
|
||||
ttk.Label(frame, text="高压B母线电流(A):").grid(row=1, column=0, sticky=tk.W)
|
||||
self.high_a_vol_current = ttk.Label(frame, text="0.0")
|
||||
ttk.Label(frame, text="汇流排B电流(A):").grid(row=1, column=0, sticky=tk.W)
|
||||
self.high_a_vol_current = ttk.Label(frame, text="0.0 A")
|
||||
self.high_a_vol_current.grid(row=1, column=1, sticky=tk.W)
|
||||
|
||||
ttk.Label(frame, text="艏部FT设备123电流(A):").grid(row=2, column=0, sticky=tk.W)
|
||||
self.high_a_vol_bow_ft_current = ttk.Label(frame, text="0.0")
|
||||
self.high_a_vol_bow_ft_current = ttk.Label(frame, text="0.0 A")
|
||||
self.high_a_vol_bow_ft_current.grid(row=2, column=1, sticky=tk.W)
|
||||
|
||||
ttk.Label(frame, text="执行机构工作电流(A):").grid(row=3, column=0, sticky=tk.W)
|
||||
self.high_a_vol_actuator_current = ttk.Label(frame, text="0.0")
|
||||
ttk.Label(frame, text="启闭机构电流(A):").grid(row=3, column=0, sticky=tk.W)
|
||||
self.high_a_vol_actuator_current = ttk.Label(frame, text="0.0 A")
|
||||
self.high_a_vol_actuator_current.grid(row=3, column=1, sticky=tk.W)
|
||||
|
||||
# 补充缺失的电流显示项
|
||||
ttk.Label(frame, text="桅杆舵机控制箱电流(A):").grid(row=4, column=0, sticky=tk.W)
|
||||
self.high_a_vol_mast_steering_current = ttk.Label(frame, text="0.0 A")
|
||||
self.high_a_vol_mast_steering_current.grid(row=4, column=1, sticky=tk.W)
|
||||
|
||||
ttk.Label(frame, text="XCZ电流(A):").grid(row=4, column=2, sticky=tk.W)
|
||||
self.high_a_vol_xcz_current = ttk.Label(frame, text="0.0 A")
|
||||
self.high_a_vol_xcz_current.grid(row=4, column=3, sticky=tk.W)
|
||||
|
||||
ttk.Label(frame, text="艏舵控制箱电流(A):").grid(row=5, column=0, sticky=tk.W)
|
||||
self.high_a_vol_bow_rudder_current = ttk.Label(frame, text="0.0 A")
|
||||
self.high_a_vol_bow_rudder_current.grid(row=5, column=1, sticky=tk.W)
|
||||
|
||||
ttk.Label(frame, text="敞水盖启动电缸电流(A):").grid(row=5, column=2, sticky=tk.W)
|
||||
self.high_a_vol_open_cover_current = ttk.Label(frame, text="0.0 A")
|
||||
self.high_a_vol_open_cover_current.grid(row=5, column=3, sticky=tk.W)
|
||||
|
||||
# 断路器状态 - 添加详细说明
|
||||
ttk.Label(frame, text="高压A母线断路器状态:").grid(row=4, column=0, columnspan=4, sticky=tk.W)
|
||||
ttk.Label(frame, text="高压A母线断路器状态:").grid(row=10, column=0, columnspan=4, sticky=tk.W)
|
||||
self.high_a_vol_breakers = {}
|
||||
breaker_names = list(self.status_data["high_a_vol_bus"]["breakers"].keys())
|
||||
|
||||
for i, name in enumerate(breaker_names):
|
||||
ttk.Label(frame, text=f"{name}状态:").grid(row=5+i//2, column=(i%2)*2, sticky=tk.W)
|
||||
ttk.Label(frame, text=f"{name}状态:").grid(row=8+i//2, column=(i%2)*2, sticky=tk.W)
|
||||
canvas = tk.Canvas(frame, width=20, height=20, bg="white")
|
||||
canvas.grid(row=5+i//2, column=(i%2)*2+1, sticky=tk.W)
|
||||
canvas.grid(row=8+i//2, column=(i%2)*2+1, sticky=tk.W)
|
||||
self.high_a_vol_breakers[name] = canvas
|
||||
|
||||
# 报警状态 - 更详细描述
|
||||
ttk.Label(frame, text="仪表电源故障状态:").grid(row=8, column=0, sticky=tk.W)
|
||||
ttk.Label(frame, text="仪表电源失电信号:").grid(row=11, column=0, sticky=tk.W)
|
||||
self.high_a_vol_instrument_power_fault = ttk.Label(frame, text="正常")
|
||||
self.high_a_vol_instrument_power_fault.grid(row=8, column=1, sticky=tk.W)
|
||||
self.high_a_vol_instrument_power_fault.grid(row=11, column=1, sticky=tk.W)
|
||||
|
||||
ttk.Label(frame, text="应急电源故障状态:").grid(row=8, column=2, sticky=tk.W)
|
||||
ttk.Label(frame, text="应急电源失电信号:").grid(row=11, column=2, sticky=tk.W)
|
||||
self.high_a_vol_emergency_power_fault = ttk.Label(frame, text="正常")
|
||||
self.high_a_vol_emergency_power_fault.grid(row=8, column=3, sticky=tk.W)
|
||||
self.high_a_vol_emergency_power_fault.grid(row=11, column=3, sticky=tk.W)
|
||||
|
||||
ttk.Label(frame, text="进水报警:").grid(row=9, column=0, sticky=tk.W)
|
||||
ttk.Label(frame, text="进水报警:").grid(row=12, column=0, sticky=tk.W)
|
||||
self.high_a_vol_water_alarm = ttk.Label(frame, text="无")
|
||||
self.high_a_vol_water_alarm.grid(row=9, column=1, sticky=tk.W)
|
||||
self.high_a_vol_water_alarm.grid(row=12, column=1, sticky=tk.W)
|
||||
|
||||
def process_udp_message(self, data):
|
||||
"""处理接收到的UDP消息"""
|
||||
@@ -733,15 +763,16 @@ class PowerManagerApp:
|
||||
else:
|
||||
bus["insulation"]["A母线绝缘状态"] = 1
|
||||
|
||||
if msg.meterPowerLossSignal == 0x55:
|
||||
bus["alarms"]["仪表电源丢失信号"] = 0
|
||||
else:
|
||||
bus["alarms"]["仪表电源丢失信号"] = 1
|
||||
# bus["alarms"]["应急电源丢失信号"] = msg.emergencyPowerLossSignal
|
||||
if msg.emergencyPowerLossSignal == 0x55:
|
||||
bus["alarms"]["应急电源丢失信号"] = 0
|
||||
else:
|
||||
bus["alarms"]["应急电源丢失信号"] = 1
|
||||
# if msg.meterPowerLossSignal == 0x55:
|
||||
# bus["alarms"]["仪表电源丢失信号"] = 0
|
||||
# else:
|
||||
# bus["alarms"]["仪表电源丢失信号"] = 1
|
||||
bus["alarms"]["应急电源丢失信号"] = msg.emergencyPowerLossSignal
|
||||
bus["alarms"]["仪表电源丢失信号"] = msg.meterPowerLossSignal
|
||||
# if msg.emergencyPowerLossSignal == 0x55:
|
||||
# bus["alarms"]["应急电源丢失信号"] = 0
|
||||
# else:
|
||||
# bus["alarms"]["应急电源丢失信号"] = 1
|
||||
bus["cool_water_pressure"] = msg.coolWaterPressure / 10.0
|
||||
bus["dcdc_temp"] = msg.dcdcTemperature-40
|
||||
|
||||
@@ -778,8 +809,8 @@ class PowerManagerApp:
|
||||
bus["breakers"]["开盖启动气缸断路器"] = msg.openWaterCoverStartCylinderCircuitBreaker
|
||||
|
||||
|
||||
bus["alarms"]["仪表电源丢失信号"] = msg.instrumentPowerFailureSignal
|
||||
bus["alarms"]["应急电源丢失信号"] = msg.emergencyPowerFailureSignal
|
||||
bus["alarms"]["仪表电源故障"] = msg.instrumentPowerFailureSignal
|
||||
bus["alarms"]["应急电源故障"] = msg.emergencyPowerFailureSignal
|
||||
bus["alarms"]["进水报警"] = msg.waterIngressionAlarm
|
||||
|
||||
self.log_message("收到高压A母线状态更新")
|
||||
@@ -818,16 +849,16 @@ class PowerManagerApp:
|
||||
|
||||
# 0x55 正常
|
||||
# 0xaa 故障
|
||||
if msg.instrumentPowerFailureSignal == 0x55:
|
||||
bus["alarms"]["仪表电源故障"] = 0
|
||||
else:
|
||||
bus["alarms"]["仪表电源故障"] = 1
|
||||
# bus["alarms"]["仪表电源故障"] = msg.instrumentPowerFailureSignal
|
||||
if msg.emergencyPowerFailureSignal == 0x55:
|
||||
bus["alarms"]["应急电源故障"] = 0
|
||||
else:
|
||||
bus["alarms"]["应急电源故障"] = 1
|
||||
# bus["alarms"]["应急电源故障"] = msg.emergencyPowerFailureSignal
|
||||
# if msg.instrumentPowerFailureSignal == 0x55:
|
||||
# bus["alarms"]["仪表电源故障"] = 0
|
||||
# else:
|
||||
# bus["alarms"]["仪表电源故障"] = 1
|
||||
bus["alarms"]["仪表电源故障"] = msg.instrumentPowerFailureSignal
|
||||
# if msg.emergencyPowerFailureSignal == 0x55:
|
||||
# bus["alarms"]["应急电源故障"] = 0
|
||||
# else:
|
||||
# bus["alarms"]["应急电源故障"] = 1
|
||||
bus["alarms"]["应急电源故障"] = msg.emergencyPowerFailureSignal
|
||||
# bus["insulation"] = msg.instrumentBusbarInsulationLow
|
||||
if msg.instrumentBusbarInsulationLow == 0x55:
|
||||
bus["insulation"] = 0
|
||||
@@ -835,6 +866,8 @@ class PowerManagerApp:
|
||||
bus["insulation"] = 1
|
||||
|
||||
self.log_message("收到仪表主母线状态更新")
|
||||
else:
|
||||
print("仪表主母线状态","解析失败")
|
||||
|
||||
elif msg_id == 0x0008: # 仪表母线状态
|
||||
msg = msg_disLowBusFbMsg()
|
||||
@@ -864,22 +897,17 @@ class PowerManagerApp:
|
||||
bus["breakers"]["单元2断路器"] = msg.unit2CircuitBreaker
|
||||
bus["breakers"]["单元3断路器"] = msg.unit3CircuitBreaker
|
||||
bus["breakers"]["单元5断路器"] = msg.unit5CircuitBreaker
|
||||
bus["breakers"]["艏PZ设备断路器"] = msg.bowPZDeviceCircuitBreake
|
||||
bus["breakers"]["艏PZ设备断路器"] = msg.bowPZDeviceCircuitBreaker
|
||||
bus["breakers"]["备用断路器1"] = msg.reservedCircuitBreaker1
|
||||
bus["breakers"]["备用断路器2"] = msg.reservedCircuitBreaker2
|
||||
bus["breakers"]["应急锂电池组1断路器"] = msg.emergencyLithiumBatteryGroup1CircuitBreaker
|
||||
|
||||
# bus["alarms"]["电源故障信号"] = msg.powerFailureSignal
|
||||
if msg.powerFailureSignal == 0x55:
|
||||
bus["alarms"]["电源故障信号"] = 0
|
||||
else:
|
||||
bus["alarms"]["电源故障信号"] = 1
|
||||
# bus["alarms"]["进水报警"] = msg.waterIngressionAlarm
|
||||
if msg.waterIngressionAlarm == 0x55:
|
||||
bus["alarms"]["进水报警"] = 0
|
||||
else:
|
||||
bus["alarms"]["进水报警"] = 1
|
||||
bus["alarms"]["仪表电源故障"] = msg.instrumentPowerFailureSignal
|
||||
bus["alarms"]["应急电源故障"] = msg.emergencyPowerFailureSignal
|
||||
bus["alarms"]["进水报警"] = msg.waterIngressionAlarm
|
||||
self.log_message("收到仪表母线状态更新")
|
||||
else:
|
||||
print("仪表母线状态","解析失败")
|
||||
|
||||
else:
|
||||
self.log_message("消息解析失败")
|
||||
@@ -904,54 +932,81 @@ class PowerManagerApp:
|
||||
self.low_main_instrument_voltage = ttk.Label(frame, text="0.0")
|
||||
self.low_main_instrument_voltage.grid(row=0, column=1, sticky=tk.W)
|
||||
|
||||
ttk.Label(frame, text="应急2母线电压(V):").grid(row=0, column=2, sticky=tk.W)
|
||||
ttk.Label(frame, text="应急2汇流排电压(V):").grid(row=0, column=2, sticky=tk.W)
|
||||
self.low_main_emergency2_voltage = ttk.Label(frame, text="0.0")
|
||||
self.low_main_emergency2_voltage.grid(row=0, column=3, sticky=tk.W)
|
||||
|
||||
# 电流显示
|
||||
ttk.Label(frame, text="艏低压配电盒电流(A):").grid(row=1, column=0, sticky=tk.W)
|
||||
ttk.Label(frame, text="艏部低压配电箱电流(A):").grid(row=1, column=0, sticky=tk.W)
|
||||
self.low_main_bow_current = ttk.Label(frame, text="0.0")
|
||||
self.low_main_bow_current.grid(row=1, column=1, sticky=tk.W)
|
||||
|
||||
ttk.Label(frame, text="锂电池组仪表电流(A):").grid(row=1, column=2, sticky=tk.W)
|
||||
ttk.Label(frame, text="锂电池组(仪表)电流(A):").grid(row=1, column=2, sticky=tk.W)
|
||||
self.low_main_battery_current = ttk.Label(frame, text="0.0")
|
||||
self.low_main_battery_current.grid(row=1, column=3, sticky=tk.W)
|
||||
|
||||
# 补充其他电流显示项
|
||||
ttk.Label(frame, text="DC-C1(直流配电板1)仪表DC48V电流(A):").grid(row=2, column=0, sticky=tk.W)
|
||||
self.low_main_dcc1_current = ttk.Label(frame, text="0.0")
|
||||
self.low_main_dcc1_current.grid(row=2, column=1, sticky=tk.W)
|
||||
|
||||
ttk.Label(frame, text="应急锂电池组2电流(A):").grid(row=2, column=2, sticky=tk.W)
|
||||
self.low_main_emergency2_current = ttk.Label(frame, text="0.0")
|
||||
self.low_main_emergency2_current.grid(row=2, column=3, sticky=tk.W)
|
||||
|
||||
ttk.Label(frame, text="单元4仪表48V电流(A):").grid(row=3, column=0, sticky=tk.W)
|
||||
self.low_main_unit4_current = ttk.Label(frame, text="0.0")
|
||||
self.low_main_unit4_current.grid(row=3, column=1, sticky=tk.W)
|
||||
|
||||
ttk.Label(frame, text="复合能源管控系统应急DC48V电流(A):").grid(row=3, column=2, sticky=tk.W)
|
||||
self.low_main_energy_current = ttk.Label(frame, text="0.0")
|
||||
self.low_main_energy_current.grid(row=3, column=3, sticky=tk.W)
|
||||
|
||||
ttk.Label(frame, text="燃料电池安保系统应急DC48V电流(A):").grid(row=4, column=0, sticky=tk.W)
|
||||
self.low_main_fuelcell_current = ttk.Label(frame, text="0.0")
|
||||
self.low_main_fuelcell_current.grid(row=4, column=1, sticky=tk.W)
|
||||
|
||||
ttk.Label(frame, text="PLC控制电源电流(A):").grid(row=4, column=2, sticky=tk.W)
|
||||
self.low_main_plc_current = ttk.Label(frame, text="0.0")
|
||||
self.low_main_plc_current.grid(row=4, column=3, sticky=tk.W)
|
||||
|
||||
# 断路器状态
|
||||
ttk.Label(frame, text="断路器状态:").grid(row=2, column=0, columnspan=4, sticky=tk.W)
|
||||
ttk.Label(frame, text="断路器状态:").grid(row=5, column=0, columnspan=4, sticky=tk.W)
|
||||
self.low_main_breakers = {}
|
||||
breaker_names = list(self.status_data["low_main_bus"]["breakers"].keys())
|
||||
|
||||
# 断路器状态 - 调整为每行3个断路器,从行6开始
|
||||
for i, name in enumerate(breaker_names):
|
||||
row = 3 + i//2
|
||||
col = (i%2)*2
|
||||
row = 6 + i//3
|
||||
col = (i%3)*2
|
||||
ttk.Label(frame, text=name).grid(row=row, column=col, sticky=tk.W)
|
||||
canvas = tk.Canvas(frame, width=20, height=20, bg="white")
|
||||
canvas.grid(row=row, column=col+1, sticky=tk.W)
|
||||
self.low_main_breakers[name] = canvas
|
||||
|
||||
# 报警状态
|
||||
ttk.Label(frame, text="仪表电源故障:").grid(row=8, column=0, sticky=tk.W)
|
||||
ttk.Label(frame, text="仪表电源失电信号 :").grid(row=9, column=0, sticky=tk.W)
|
||||
self.low_main_instrument_fault = ttk.Label(frame, text="无")
|
||||
self.low_main_instrument_fault.grid(row=8, column=1, sticky=tk.W)
|
||||
self.low_main_instrument_fault.grid(row=9, column=1, sticky=tk.W)
|
||||
|
||||
ttk.Label(frame, text="应急电源故障:").grid(row=8, column=2, sticky=tk.W)
|
||||
ttk.Label(frame, text="应急电源失电信号 :").grid(row=9, column=2, sticky=tk.W)
|
||||
self.low_main_emergency_fault = ttk.Label(frame, text="无")
|
||||
self.low_main_emergency_fault.grid(row=8, column=3, sticky=tk.W)
|
||||
|
||||
# 报警状态
|
||||
ttk.Label(frame, text="仪表电源故障:").grid(row=8, column=0, sticky=tk.W)
|
||||
self.low_main_instrument_fault = ttk.Label(frame, text="无")
|
||||
self.low_main_instrument_fault.grid(row=8, column=1, sticky=tk.W)
|
||||
|
||||
ttk.Label(frame, text="应急电源故障:").grid(row=8, column=2, sticky=tk.W)
|
||||
self.low_main_emergency_fault = ttk.Label(frame, text="无")
|
||||
self.low_main_emergency_fault.grid(row=8, column=3, sticky=tk.W)
|
||||
self.low_main_emergency_fault.grid(row=9, column=3, sticky=tk.W)
|
||||
|
||||
# 绝缘状态
|
||||
ttk.Label(frame, text="绝缘状态:").grid(row=9, column=0, sticky=tk.W)
|
||||
ttk.Label(frame, text="仪表汇流排绝缘低 :").grid(row=10, column=0, sticky=tk.W)
|
||||
self.low_main_insulation = ttk.Label(frame, text="正常")
|
||||
self.low_main_insulation.grid(row=9, column=1, sticky=tk.W)
|
||||
self.low_main_insulation.grid(row=10, column=1, sticky=tk.W)
|
||||
|
||||
# 备用电流
|
||||
ttk.Label(frame, text="备用电流1 :").grid(row=11, column=0, sticky=tk.W)
|
||||
self.low_main_reserved1 = ttk.Label(frame, text="0.0")
|
||||
self.low_main_reserved1.grid(row=11, column=1, sticky=tk.W)
|
||||
|
||||
ttk.Label(frame, text="备用电流2 :").grid(row=11, column=2, sticky=tk.W)
|
||||
self.low_main_reserved2 = ttk.Label(frame, text="0.0")
|
||||
self.low_main_reserved2.grid(row=11, column=3, sticky=tk.W)
|
||||
|
||||
|
||||
return frame
|
||||
|
||||
@@ -967,7 +1022,7 @@ class PowerManagerApp:
|
||||
frame.grid_columnconfigure(3, weight=1)
|
||||
|
||||
# 电压显示
|
||||
ttk.Label(frame, text="仪表母线电压(V):").grid(row=0, column=0, sticky=tk.W)
|
||||
ttk.Label(frame, text="仪表母排电压(V):").grid(row=0, column=0, sticky=tk.W)
|
||||
self.low_bus_instrument_voltage = ttk.Label(frame, text="0.0")
|
||||
self.low_bus_instrument_voltage.grid(row=0, column=1, sticky=tk.W)
|
||||
|
||||
@@ -984,13 +1039,33 @@ class PowerManagerApp:
|
||||
self.low_bus_unit2_current = ttk.Label(frame, text="0.0")
|
||||
self.low_bus_unit2_current.grid(row=1, column=3, sticky=tk.W)
|
||||
|
||||
ttk.Label(frame, text="仪表母排电流(A):").grid(row=2, column=0, sticky=tk.W)
|
||||
self.low_bus_main_current = ttk.Label(frame, text="0.0")
|
||||
self.low_bus_main_current.grid(row=2, column=1, sticky=tk.W)
|
||||
|
||||
ttk.Label(frame, text="单元3电流(A):").grid(row=2, column=2, sticky=tk.W)
|
||||
self.low_bus_unit3_current = ttk.Label(frame, text="0.0")
|
||||
self.low_bus_unit3_current.grid(row=2, column=3, sticky=tk.W)
|
||||
|
||||
ttk.Label(frame, text="单元5电流(A):").grid(row=3, column=0, sticky=tk.W)
|
||||
self.low_bus_unit5_current = ttk.Label(frame, text="0.0")
|
||||
self.low_bus_unit5_current.grid(row=3, column=1, sticky=tk.W)
|
||||
|
||||
ttk.Label(frame, text="艏PZ设备电流(A):").grid(row=3, column=2, sticky=tk.W)
|
||||
self.low_bus_bow_pz_current = ttk.Label(frame, text="0.0")
|
||||
self.low_bus_bow_pz_current.grid(row=3, column=3, sticky=tk.W)
|
||||
|
||||
ttk.Label(frame, text="应急锂电池组1电流(A):").grid(row=4, column=0, sticky=tk.W)
|
||||
self.low_bus_emergency1_current = ttk.Label(frame, text="0.0")
|
||||
self.low_bus_emergency1_current.grid(row=4, column=1, sticky=tk.W)
|
||||
|
||||
# 断路器状态
|
||||
ttk.Label(frame, text="断路器状态:").grid(row=2, column=0, columnspan=4, sticky=tk.W)
|
||||
ttk.Label(frame, text="断路器状态:").grid(row=5, column=0, columnspan=4, sticky=tk.W)
|
||||
self.low_bus_breakers = {}
|
||||
breaker_names = list(self.status_data["low_bus"]["breakers"].keys())
|
||||
|
||||
for i, name in enumerate(breaker_names):
|
||||
row = 3 + i//2
|
||||
row = 6 + i//2
|
||||
col = (i%2)*2
|
||||
ttk.Label(frame, text=name).grid(row=row, column=col, sticky=tk.W)
|
||||
canvas = tk.Canvas(frame, width=20, height=20, bg="white")
|
||||
@@ -998,19 +1073,17 @@ class PowerManagerApp:
|
||||
self.low_bus_breakers[name] = canvas
|
||||
|
||||
# 报警状态
|
||||
ttk.Label(frame, text="电源故障信号:").grid(row=8, column=0, sticky=tk.W)
|
||||
ttk.Label(frame, text="仪表电失电信号 :").grid(row=10, column=0, sticky=tk.W)
|
||||
self.low_bus_power_fault = ttk.Label(frame, text="无")
|
||||
self.low_bus_power_fault.grid(row=8, column=1, sticky=tk.W)
|
||||
self.low_bus_power_fault.grid(row=10, column=1, sticky=tk.W)
|
||||
|
||||
ttk.Label(frame, text="进水报警:").grid(row=8, column=2, sticky=tk.W)
|
||||
ttk.Label(frame, text="应急电失电信号 :").grid(row=11, column=0, sticky=tk.W)
|
||||
self.low_bus_emgpower_fault = ttk.Label(frame, text="无")
|
||||
self.low_bus_emgpower_fault.grid(row=11, column=1, sticky=tk.W)
|
||||
|
||||
ttk.Label(frame, text="浸水报警 :").grid(row=10, column=2, sticky=tk.W)
|
||||
self.low_bus_water_alarm = ttk.Label(frame, text="无")
|
||||
self.low_bus_water_alarm.grid(row=8, column=3, sticky=tk.W)
|
||||
|
||||
self.low_bus_power_fault.grid(row=8, column=1, sticky=tk.W)
|
||||
|
||||
ttk.Label(frame, text="进水报警:").grid(row=8, column=2, sticky=tk.W)
|
||||
self.low_bus_water_alarm = ttk.Label(frame, text="无")
|
||||
self.low_bus_water_alarm.grid(row=8, column=3, sticky=tk.W)
|
||||
self.low_bus_water_alarm.grid(row=10, column=3, sticky=tk.W)
|
||||
|
||||
return frame
|
||||
|
||||
@@ -1045,7 +1118,10 @@ class PowerManagerApp:
|
||||
('tyzReservedSwitchCurrent', 'TYZ备用开关电流'),
|
||||
('sternRudderSwitch1Current', '艉舵机开关1电流'),
|
||||
('sternRudderSwitch2Current', '艉舵机开关2电流'),
|
||||
('fbReservedSwitchCurrent', 'FB备用开关电流')
|
||||
('fbReservedSwitchCurrent', 'FB备用开关电流'),
|
||||
('reservedCurrent1', '备用电流1'),
|
||||
('reservedCurrent2', '备用电流2'),
|
||||
('reservedCurrent3', '备用电流3')
|
||||
]
|
||||
|
||||
for var_name, data_key in current_vars:
|
||||
@@ -1057,7 +1133,7 @@ class PowerManagerApp:
|
||||
if name in self.high_vol_breakers:
|
||||
canvas = self.high_vol_breakers[name]
|
||||
# color = 'green' if state else 'red'
|
||||
print(name, hex(state))
|
||||
# print(name, hex(state))
|
||||
if state == 0x55:
|
||||
color = "green"
|
||||
elif state == 0xAA:
|
||||
@@ -1094,6 +1170,11 @@ class PowerManagerApp:
|
||||
|
||||
# # 更新温度状态
|
||||
self.high_vol_dcdc_temp.config(text=f"{status['dcdc_temp']} 摄氏度")
|
||||
# "仪表电源丢失信号": 0,
|
||||
# "应急电源丢失信号": 0
|
||||
# 更新失电故障显示
|
||||
self.high_vol_losspower_insulation.config(text="正常" if status['alarms']['仪表电源丢失信号'] == 0x55 else "故障")
|
||||
self.high_vol_loss_emerpower_insulation.config(text="正常" if status['alarms']['应急电源丢失信号'] == 0x55 else "故障")
|
||||
|
||||
def update_ui(self):
|
||||
"""更新界面状态"""
|
||||
@@ -1107,6 +1188,12 @@ class PowerManagerApp:
|
||||
self.high_a_vol_bow_ft_current.config(text=f"{high_a_vol['current']['艏FT设备123电流']:.1f} A")
|
||||
self.high_a_vol_actuator_current.config(text=f"{high_a_vol['current']['执行机构电流']:.1f} A")
|
||||
|
||||
# 更新新增的电流显示项
|
||||
self.high_a_vol_mast_steering_current.config(text=f"{high_a_vol['current']['桅舵机控制箱电流']:.1f} A")
|
||||
self.high_a_vol_xcz_current.config(text=f"{high_a_vol['current']['XCZ电流']:.1f} A")
|
||||
self.high_a_vol_bow_rudder_current.config(text=f"{high_a_vol['current']['艏舵控制箱电流']:.1f} A")
|
||||
self.high_a_vol_open_cover_current.config(text=f"{high_a_vol['current']['开盖启动气缸电流']:.1f} A")
|
||||
|
||||
for name, canvas in self.high_a_vol_breakers.items():
|
||||
state = high_a_vol["breakers"].get(name, 0)
|
||||
if state == 0x55:
|
||||
@@ -1151,22 +1238,32 @@ class PowerManagerApp:
|
||||
canvas.create_oval(2, 2, 18, 18, fill=color, outline="black")
|
||||
|
||||
self.high_a_vol_instrument_power_fault.config(
|
||||
text="正常" if not high_a_vol["alarms"]["仪表电源故障"] else "故障"
|
||||
text="正常" if high_a_vol["alarms"]["仪表电源故障"]==0x55 else "故障"
|
||||
)
|
||||
self.high_a_vol_emergency_power_fault.config(
|
||||
text="正常" if not high_a_vol["alarms"]["应急电源故障"] else "故障"
|
||||
text="正常" if high_a_vol["alarms"]["应急电源故障"]==0x55 else "故障"
|
||||
)
|
||||
self.high_a_vol_water_alarm.config(
|
||||
text="正常" if not high_a_vol["alarms"]["进水报警"] else "故障"
|
||||
text="正常" if high_a_vol["alarms"]["进水报警"]==0x55 else "故障"
|
||||
)
|
||||
|
||||
# 更新仪表主母线状态
|
||||
low_main = self.status_data["low_main_bus"]
|
||||
self.low_main_instrument_voltage.config(text=f"{low_main['voltage']['仪表母线电压']:.1f} V")
|
||||
self.low_main_emergency2_voltage.config(text=f"{low_main['voltage']['应急2母线电压']:.1f} V")
|
||||
self.low_main_bow_current.config(text=f"{low_main['current']['艏低压配电盒电流']:.1f}")
|
||||
self.low_main_battery_current.config(text=f"{low_main['current']['锂电池组仪表电流']:.1f} A")
|
||||
self.low_main_bow_current.config(text=f"{low_main['current']['艏低压配电盒电流']:.1f} A")
|
||||
self.low_main_battery_current.config(text=f"{low_main['current']['锂电池组仪表电流']:.1f} A")
|
||||
|
||||
# 更新新增的电流显示项
|
||||
self.low_main_dcc1_current.config(text=f"{low_main['current']['DC/C1仪表48V电流']:.1f} A")
|
||||
self.low_main_emergency2_current.config(text=f"{low_main['current']['应急锂电池组2电流']:.1f} A")
|
||||
self.low_main_unit4_current.config(text=f"{low_main['current']['单元4仪表48V电流']:.1f} A")
|
||||
self.low_main_energy_current.config(text=f"{low_main['current']['综合能量管理系统应急DC48V电流']:.1f} A")
|
||||
self.low_main_fuelcell_current.config(text=f"{low_main['current']['燃料电池安全系统应急DC48V电流']:.1f} A")
|
||||
self.low_main_plc_current.config(text=f"{low_main['current']['PLC控制电源电流']:.1f} A")
|
||||
# 新增加备用电流
|
||||
self.low_main_reserved1.config(text=f"{low_main['current']['备用电流1']:.1f} A")
|
||||
self.low_main_reserved2.config(text=f"{low_main['current']['备用电流2']:.1f} A")
|
||||
|
||||
for name, canvas in self.low_main_breakers.items():
|
||||
state = low_main["breakers"].get(name, 0)
|
||||
@@ -1182,21 +1279,29 @@ class PowerManagerApp:
|
||||
canvas.create_oval(2, 2, 18, 18, fill=color, outline="black")
|
||||
|
||||
self.low_main_instrument_fault.config(
|
||||
text="正常" if not low_main["alarms"]["仪表电源故障"] else "故障"
|
||||
text="正常" if low_main["alarms"]["仪表电源故障"]==0x55 else "故障"
|
||||
)
|
||||
self.low_main_emergency_fault.config(
|
||||
text="正常" if not low_main["alarms"]["应急电源故障"] else "故障"
|
||||
text="正常" if low_main["alarms"]["应急电源故障"]==0x55 else "故障"
|
||||
)
|
||||
self.low_main_insulation.config(
|
||||
text="正常" if not low_main["insulation"] else "故障"
|
||||
text="正常" if low_main["insulation"]==0x55 else "故障"
|
||||
)
|
||||
|
||||
# 更新仪表母线状态
|
||||
low_bus = self.status_data["low_bus"]
|
||||
self.low_bus_instrument_voltage.config(text=f"{low_bus['voltage']['仪表母线电压']:.1f} V")
|
||||
self.low_bus_emergency1_voltage.config(text=f"{low_bus['voltage']['应急1母线电压']:.1f} V")
|
||||
self.low_bus_unit1_current.config(text=f"{low_bus['current']['单元1电流']:.1f}")
|
||||
self.low_bus_unit2_current.config(text=f"{low_bus['current']['单元2电流']:.1f}")
|
||||
self.low_bus_unit1_current.config(text=f"{low_bus['current']['单元1电流']:.1f} A")
|
||||
self.low_bus_unit2_current.config(text=f"{low_bus['current']['单元2电流']:.1f} A")
|
||||
|
||||
# 更新新增的电流显示项
|
||||
self.low_bus_main_current.config(text=f"{low_bus['current']['仪表母线电流']:.1f} A")
|
||||
self.low_bus_unit3_current.config(text=f"{low_bus['current']['单元3电流']:.1f} A")
|
||||
self.low_bus_unit5_current.config(text=f"{low_bus['current']['单元5电流']:.1f} A")
|
||||
self.low_bus_bow_pz_current.config(text=f"{low_bus['current']['艏PZ设备电流']:.1f} A")
|
||||
self.low_bus_emergency1_current.config(text=f"{low_bus['current']['应急锂电池组1电流']:.1f} A")
|
||||
|
||||
|
||||
for name, canvas in self.low_bus_breakers.items():
|
||||
state = low_bus["breakers"].get(name, 0)
|
||||
@@ -1212,10 +1317,13 @@ class PowerManagerApp:
|
||||
canvas.create_oval(2, 2, 18, 18, fill=color, outline="black")
|
||||
|
||||
self.low_bus_power_fault.config(
|
||||
text="正常" if not low_bus["alarms"]["电源故障信号"] else "故障"
|
||||
text="正常" if low_bus["alarms"]["仪表电源故障"]==0x55 else "故障"
|
||||
)
|
||||
self.low_bus_emgpower_fault.config(
|
||||
text="正常" if low_bus["alarms"]["应急电源故障"]==0x55 else "故障"
|
||||
)
|
||||
self.low_bus_water_alarm.config(
|
||||
text="正常" if not low_bus["alarms"]["进水报警"] else "故障"
|
||||
text="正常" if low_bus["alarms"]["进水报警"]==0x55 else "故障"
|
||||
)
|
||||
# print('update_ui')
|
||||
# 每500ms更新一次
|
||||
@@ -1226,6 +1334,13 @@ class PowerManagerApp:
|
||||
timestamp = time.strftime("%Y-%m-%d %H:%M:%S")
|
||||
self.log_text.config(state=tk.NORMAL)
|
||||
self.log_text.insert(tk.END, f"[{timestamp}] {message}\n")
|
||||
|
||||
# 获取当前所有行数
|
||||
line_count = int(self.log_text.index('end-1c').split('.')[0])
|
||||
# 如果超过50行,删除最旧的行
|
||||
if line_count > 50:
|
||||
self.log_text.delete(1.0, 2.0)
|
||||
|
||||
self.log_text.config(state=tk.DISABLED)
|
||||
self.log_text.see(tk.END)
|
||||
|
||||
|
||||
@@ -143,7 +143,8 @@ class DB:
|
||||
reservedCircuitBreaker1 INTEGER,
|
||||
reservedCircuitBreaker2 INTEGER,
|
||||
emergencyLithiumBatteryGroup1CircuitBreaker INTEGER,
|
||||
powerFailureSignal INTEGER,
|
||||
instrumentPowerFailureSignal INTEGER,
|
||||
emergencyPowerFailureSignal INTEGER,
|
||||
waterIngressionAlarm INTEGER,
|
||||
instrumentBusbarVoltage INTEGER,
|
||||
instrumentBusbarCurrent INTEGER,
|
||||
@@ -369,7 +370,9 @@ class DB:
|
||||
'reservedCircuitBreaker1': data.reservedCircuitBreaker1,
|
||||
'reservedCircuitBreaker2': data.reservedCircuitBreaker2,
|
||||
'emergencyLithiumBatteryGroup1CircuitBreaker': data.emergencyLithiumBatteryGroup1CircuitBreaker,
|
||||
'powerFailureSignal': data.powerFailureSignal,
|
||||
# 'powerFailureSignal': data.powerFailureSignal,
|
||||
'instrumentPowerFailureSignal': data.instrumentPowerFailureSignal,
|
||||
'emergencyPowerFailureSignal': data.emergencyPowerFailureSignal,
|
||||
'waterIngressionAlarm': data.waterIngressionAlarm,
|
||||
'instrumentBusbarVoltage': data.instrumentBusbarVoltage,
|
||||
'instrumentBusbarCurrent': data.instrumentBusbarCurrent,
|
||||
@@ -556,7 +559,9 @@ if __name__ == "__main__":
|
||||
fb4.reservedCircuitBreaker1 = 0
|
||||
fb4.reservedCircuitBreaker2 = 0
|
||||
fb4.emergencyLithiumBatteryGroup1CircuitBreaker = 1
|
||||
fb4.powerFailureSignal = 0
|
||||
# fb4.powerFailureSignal = 0
|
||||
fb4.instrumentPowerFailureSignal = 0
|
||||
fb4.emergencyPowerFailureSignal = 0
|
||||
fb4.waterIngressionAlarm = 0
|
||||
fb4.instrumentBusbarVoltage = 48
|
||||
fb4.instrumentBusbarCurrent = 10
|
||||
|
||||
+28
-27
@@ -14,7 +14,7 @@ from udpMsg import (
|
||||
)
|
||||
|
||||
class PowerManagerSimulator:
|
||||
def __init__(self, host='127.0.0.1', port=5001):
|
||||
def __init__(self, host='127.0.0.1', port=6000):
|
||||
self.host = host
|
||||
self.port = port
|
||||
self.running = False
|
||||
@@ -63,19 +63,19 @@ class PowerManagerSimulator:
|
||||
self.high_vol_fb.sternFTDevice45Current = 15
|
||||
self.high_vol_fb.tyzReservedSwitchCurrent = 0
|
||||
self.high_vol_fb.sternRudderSwitch1Current = 10
|
||||
self.high_vol_fb.reservedCurrent1 = 0
|
||||
self.high_vol_fb.reservedCurrent1 = 100
|
||||
self.high_vol_fb.sternRudderSwitch2Current = 10
|
||||
self.high_vol_fb.reservedCurrent2 = 0
|
||||
self.high_vol_fb.fbReservedSwitchCurrent = 0
|
||||
self.high_vol_fb.reservedCurrent3 = 0
|
||||
self.high_vol_fb.reservedCurrent2 = 100
|
||||
self.high_vol_fb.fbReservedSwitchCurrent = 1000
|
||||
self.high_vol_fb.reservedCurrent3 = 100
|
||||
self.high_vol_fb.coolWaterPressure = 100
|
||||
|
||||
# 高压A母线反馈数据 - 测试所有成员
|
||||
self.high_a_vol_fb.bowFTDevice123CircuitBreaker = 0x55
|
||||
self.high_a_vol_fb.actuatorCircuitBreaker = 0x55
|
||||
self.high_a_vol_fb.mastSteeringGearControlBoxCircuitBreaker = 0x55
|
||||
self.high_a_vol_fb.xczCircuitBreaker = 0x55
|
||||
self.high_a_vol_fb.bowRudderControlBoxCircuitBreaker = 0x55
|
||||
self.high_a_vol_fb.bowFTDevice123CircuitBreaker = 0x5A
|
||||
self.high_a_vol_fb.actuatorCircuitBreaker = 0x5A
|
||||
self.high_a_vol_fb.mastSteeringGearControlBoxCircuitBreaker = 0x5A
|
||||
self.high_a_vol_fb.xczCircuitBreaker = 0x5A
|
||||
self.high_a_vol_fb.bowRudderControlBoxCircuitBreaker = 0x5A
|
||||
self.high_a_vol_fb.openWaterCoverStartCylinderCircuitBreaker = 0x55
|
||||
self.high_a_vol_fb.instrumentPowerFailureSignal = 0x55
|
||||
self.high_a_vol_fb.emergencyPowerFailureSignal = 0x55
|
||||
@@ -90,40 +90,41 @@ class PowerManagerSimulator:
|
||||
self.high_a_vol_fb.openWaterCoverStartCylinderCurrent = 0
|
||||
|
||||
# 仪表主母线反馈数据 - 测试所有成员
|
||||
self.low_main_fb.lithiumBatteryGroupInstrumentCircuitBreaker = 0x55
|
||||
self.low_main_fb.lithiumBatteryGroupInstrumentCircuitBreaker = 0x5A
|
||||
self.low_main_fb.bowLowVoltageDistributionBoxCircuitBreaker = 0x55
|
||||
self.low_main_fb.unit4InstrumentDC48VCircuitBreaker = 0x55
|
||||
self.low_main_fb.dcC1DCDistributionPanelCircuitBreaker = 0x55
|
||||
self.low_main_fb.dcC1DCDistributionPanelCircuitBreaker = 0x5A
|
||||
self.low_main_fb.reservedCircuitBreaker1 = 0x55
|
||||
self.low_main_fb.reservedCircuitBreaker2 = 0x55
|
||||
self.low_main_fb.emergencyLithiumBatteryGroup2CircuitBreaker = 0x55
|
||||
self.low_main_fb.emergencyLithiumBatteryGroup2CircuitBreaker = 0x5A
|
||||
self.low_main_fb.instrumentPowerFailureSignal = 0x55
|
||||
self.low_main_fb.emergencyPowerFailureSignal = 0x55
|
||||
self.low_main_fb.instrumentBusbarInsulationLow = 0x55
|
||||
self.low_main_fb.instrumentBusbarVoltage = 48
|
||||
self.low_main_fb.bowLowVoltageDistributionBoxCurrent = 10
|
||||
self.low_main_fb.dcC1InstrumentDC48VCurrent = 5
|
||||
self.low_main_fb.reservedCurrent1 = 0
|
||||
self.low_main_fb.emergencyLithiumBatteryGroup2Current = 0
|
||||
self.low_main_fb.reservedCurrent1 = 110
|
||||
self.low_main_fb.emergencyLithiumBatteryGroup2Current = 100
|
||||
self.low_main_fb.lithiumBatteryGroupInstrumentCurrent = 20
|
||||
self.low_main_fb.unit4InstrumentDC48VCurrent = 5
|
||||
self.low_main_fb.reservedCurrent2 = 0
|
||||
self.low_main_fb.reservedCurrent2 = 100
|
||||
self.low_main_fb.emergency2BusbarVoltage = 48
|
||||
self.low_main_fb.compositeEnergyManagementSystemEmergencyDC48VCurrent = 2
|
||||
self.low_main_fb.fuelCellSecuritySystemEmergencyDC48VCurrent = 2
|
||||
self.low_main_fb.plcControlPowerCurrent = 1
|
||||
|
||||
# 仪表汇流排反馈数据 - 测试所有成员
|
||||
self.low_bus_fb.unit1CircuitBreaker = 1
|
||||
self.low_bus_fb.unit2CircuitBreaker = 1
|
||||
self.low_bus_fb.unit3CircuitBreaker = 1
|
||||
self.low_bus_fb.unit5CircuitBreaker = 1
|
||||
self.low_bus_fb.bowPZDeviceCircuitBreaker = 1
|
||||
self.low_bus_fb.reservedCircuitBreaker1 = 0
|
||||
self.low_bus_fb.reservedCircuitBreaker2 = 0
|
||||
self.low_bus_fb.emergencyLithiumBatteryGroup1CircuitBreaker = 0
|
||||
self.low_bus_fb.powerFailureSignal = 0
|
||||
self.low_bus_fb.waterIngressionAlarm = 0
|
||||
self.low_bus_fb.unit1CircuitBreaker = 0x55
|
||||
self.low_bus_fb.unit2CircuitBreaker = 0x55
|
||||
self.low_bus_fb.unit3CircuitBreaker = 0x55
|
||||
self.low_bus_fb.unit5CircuitBreaker = 0x55
|
||||
self.low_bus_fb.bowPZDeviceCircuitBreaker = 0x55
|
||||
self.low_bus_fb.reservedCircuitBreaker1 = 0x55
|
||||
self.low_bus_fb.reservedCircuitBreaker2 = 0x55
|
||||
self.low_bus_fb.emergencyLithiumBatteryGroup1CircuitBreaker = 0x55
|
||||
self.low_bus_fb.instrumentPowerFailureSignal = 0x5A
|
||||
self.low_bus_fb.emergencyPowerFailureSignal = 0x5A
|
||||
self.low_bus_fb.waterIngressionAlarm = 0x55
|
||||
self.low_bus_fb.instrumentBusbarVoltage = 48
|
||||
self.low_bus_fb.instrumentBusbarCurrent = 500
|
||||
self.low_bus_fb.unit1Current = 100
|
||||
@@ -131,7 +132,7 @@ class PowerManagerSimulator:
|
||||
self.low_bus_fb.unit3Current = 100
|
||||
self.low_bus_fb.unit5Current = 100
|
||||
self.low_bus_fb.bowPZDeviceCurrent = 50
|
||||
self.low_bus_fb.emergencyLithiumBatteryGroup1Current = 0
|
||||
self.low_bus_fb.emergencyLithiumBatteryGroup1Current = 100
|
||||
self.low_bus_fb.emergency1BusbarVoltage = 48
|
||||
|
||||
def start(self):
|
||||
|
||||
@@ -366,7 +366,7 @@ class msg_disLowBusFbMsg:
|
||||
self.start1 = 0x40
|
||||
self.start2 = 0x40
|
||||
self.id = 0x0008
|
||||
self.length = 24 # disLowBusState结构体大小
|
||||
self.length = 25 # disLowBusState结构体大小
|
||||
self.checkCode = 0x00
|
||||
|
||||
# disLowBusState成员
|
||||
@@ -378,7 +378,8 @@ class msg_disLowBusFbMsg:
|
||||
self.reservedCircuitBreaker1 = 0x00
|
||||
self.reservedCircuitBreaker2 = 0x00
|
||||
self.emergencyLithiumBatteryGroup1CircuitBreaker = 0x00
|
||||
self.powerFailureSignal = 0x00
|
||||
self.instrumentPowerFailureSignal = 0x00
|
||||
self.emergencyPowerFailureSignal = 0x00
|
||||
self.waterIngressionAlarm = 0x00
|
||||
self.instrumentBusbarVoltage = 0
|
||||
self.instrumentBusbarCurrent = 0
|
||||
@@ -406,7 +407,8 @@ class msg_disLowBusFbMsg:
|
||||
data += struct.pack('<B', self.reservedCircuitBreaker1)
|
||||
data += struct.pack('<B', self.reservedCircuitBreaker2)
|
||||
data += struct.pack('<B', self.emergencyLithiumBatteryGroup1CircuitBreaker)
|
||||
data += struct.pack('<B', self.powerFailureSignal)
|
||||
data += struct.pack('<B', self.instrumentPowerFailureSignal)
|
||||
data += struct.pack('<B', self.emergencyPowerFailureSignal)
|
||||
data += struct.pack('<B', self.waterIngressionAlarm)
|
||||
data += struct.pack('<H', self.instrumentBusbarVoltage)
|
||||
data += struct.pack('<H', self.instrumentBusbarCurrent)
|
||||
@@ -426,8 +428,8 @@ class msg_disLowBusFbMsg:
|
||||
return data
|
||||
|
||||
def unpack(self, data):
|
||||
if len(data) < 4 + self.length + 1: # 头部4字节+数据长度+校验码1字节
|
||||
return False
|
||||
# if len(data) < 4 + self.length + 1: # 头部4字节+数据长度+校验码1字节
|
||||
# return False
|
||||
|
||||
self.start1 = data[0]
|
||||
self.start2 = data[1]
|
||||
@@ -443,7 +445,9 @@ class msg_disLowBusFbMsg:
|
||||
self.reservedCircuitBreaker1 = data[offset]; offset +=1
|
||||
self.reservedCircuitBreaker2 = data[offset]; offset +=1
|
||||
self.emergencyLithiumBatteryGroup1CircuitBreaker = data[offset]; offset +=1
|
||||
self.powerFailureSignal = data[offset]; offset +=1
|
||||
# self.powerFailureSignal = data[offset]; offset +=1
|
||||
self.instrumentPowerFailureSignal = data[offset]; offset +=1
|
||||
self.emergencyPowerFailureSignal = data[offset]; offset +=1
|
||||
self.waterIngressionAlarm = data[offset]; offset +=1
|
||||
self.instrumentBusbarVoltage = struct.unpack_from('<H', data, offset)[0]; offset +=2
|
||||
self.instrumentBusbarCurrent = struct.unpack_from('<H', data, offset)[0]; offset +=2
|
||||
|
||||
Reference in New Issue
Block a user