完善了次级配电的功能

This commit is contained in:
zjk
2025-07-04 09:53:56 +08:00
parent ba8cd0383a
commit 4116397f3e
10 changed files with 538 additions and 1783 deletions
+44 -3
View File
@@ -4,6 +4,7 @@
#include <json/json.h>
#include "../driver.h"
#include "../logc/loguru.hpp"
#include <cstring>
class uDevice_secdistStateMsg
{
@@ -329,7 +330,7 @@ public:
state.bowThrow = driver.bowThrow;
state.depth2 = driver.depth2;
state.thruster = driver.thruster;
state.haulingMachine = 0; // No corresponding field in DriverTable
state.haulingMachine = 2; // No corresponding field in DriverTable
state.buoyancyAdjust4 = driver.buoyancyAdjust4;
state.buoyancyAdjust5 = driver.buoyancyAdjust5;
state.sternRudderServo1 = driver.sternRudderServo1;
@@ -337,7 +338,7 @@ public:
state.sternRudderServo3 = driver.sternRudderServo3;
state.sternRudderServo4 = driver.sternRudderServo4;
state.ctd2 = driver.ctd2;
state.commDevStern = 0; // No corresponding field in DriverTable
state.commDevStern = 2; // No corresponding field in DriverTable
state.inOutLetWater3 = driver.inputWaterSensor3;
// UNIT5
@@ -350,7 +351,7 @@ public:
// driver.overDeep1
// driver.overDeep2
// driver.ntp
state.dragSonar = 0; // Assuming dragSonar is same as lowFreqSonar
state.dragSonar = 2; // Assuming dragSonar is same as lowFreqSonar
return true;
@@ -449,6 +450,46 @@ public:
converToDriverTable(s,driver);
return true;
};
std::string buildMsg(DriverTable driver, DriverTable driver_state){
DeviceSecdistState s;
DriverTable driverCopy = driver;
for (size_t i = 0; i < sizeof(DriverTable); ++i) {
unsigned char* driverCopyPtr = reinterpret_cast<unsigned char*>(&driverCopy) + i;
unsigned char* statePtr = reinterpret_cast<unsigned char*>(&driver_state) + i;
if (*driverCopyPtr == *statePtr) {
*driverCopyPtr = 2;
}
}
converFromDriverTable(s, driverCopy);
// std::cout << (int)s.depth1 << std::endl;
// std::cout << buildSecdistStateToJson(s) << std::endl;
return buildSecdistStateToJson(s);
};
std::string buildMsg(DriverTable driver, DriverTable driver_state, unsigned int nCheck){
static size_t callCount = 0; // 静态变量,记录函数调用次数
DeviceSecdistState s;
DriverTable driverCopy = driver;
if (nCheck > 0 && callCount % nCheck == 0)
{
for (size_t i = 0; i < sizeof(DriverTable); ++i) {
unsigned char* driverCopyPtr = reinterpret_cast<unsigned char*>(&driverCopy) + i;
unsigned char* statePtr = reinterpret_cast<unsigned char*>(&driver_state) + i;
if (*driverCopyPtr == *statePtr) {
*driverCopyPtr = 2;
}
}
}
else {
memset(&driverCopy, 2, sizeof(DriverTable));
}
callCount ++;
converFromDriverTable(s, driverCopy);
// std::cout << (int)s.depth1 << std::endl;
// std::cout << buildSecdistStateToJson(s) << std::endl;
return buildSecdistStateToJson(s);
};
};
+2 -2
View File
@@ -4,14 +4,14 @@
#include "../pmSysvariable.h"
#include "../logc/loguru.hpp"
//决策消息
#define DB_TO_PM_MISSION "uPlan_taskStart_cmd"
#define DB_TO_PM_MISSION "uPlan_taskStart_st"
class uPlan_taskStartMsg
{
private:
/* data */
public:
std::string key = "uPlan_taskStart_cmd";
std::string key = "uPlan_taskStart_st";
uPlan_taskStartMsg(/* args */){};
~uPlan_taskStartMsg(){};
+9 -5
View File
@@ -133,8 +133,9 @@ public:
}
}
}m_state_of_bus_lv_a;
std::string buildMsg(SystemData data,disSysBreakerList currentDisBreakerState)
// std::string buildMsg(SystemData data,disSysBreakerList currentDisBreakerState)
std::string buildMsg(const SystemData& data,disSysBreakerList currentDisBreakerState)
{
//构建配电系统状态报告
Json::Value dis;
@@ -182,11 +183,14 @@ public:
m_state_of_bus_lv_a.set_emergency_lithium_battery_group_1_breaker((data.instrument_bus_status.emergencyLithiumBatteryGroup1CircuitBreaker == 1));
dis["LVolBusBreaker_uint16"] = m_state_of_bus_lv.relay_states.to_ulong();
//TODO: 构建配电系统故障码
//构建配电系统故障码
Json::Value faultCodeDis_array = Json::Value(Json::arrayValue);
for(auto val : data.disSysFaultCode)
{
faultCodeDis_array.append(val);
std::lock_guard<std::mutex> lock(data.faultCodeMutex);
for(auto val : data.disSysFaultCode)
{
faultCodeDis_array.append(val);
}
}
dis["faultCode_array"] = faultCodeDis_array;
+2 -1
View File
@@ -24,7 +24,8 @@ public:
unsigned int errorCode : 8; // 错误代码
} state;
std::string buildMsg(SystemData data)
// std::string buildMsg(SystemData data)
std::string buildMsg(const SystemData& data)
{
//TODO:根据最新协议修改
Json::Value fcs;
+2 -2
View File
@@ -15,8 +15,8 @@ public:
~uPower_liBatStateMsg() {};
std::string key = "uPower_liBatState_st";
std::string buildMsg(SystemData data)
// std::string buildMsg(SystemData data)
std::string buildMsg(const SystemData& data)
{
//TODO:根据最新协议修改
Json::Value lbs;