0712提交

This commit is contained in:
zjk
2025-07-12 15:39:28 +08:00
parent 4116397f3e
commit 2ef5fd92ac
32 changed files with 3601 additions and 458 deletions
+39 -4
View File
@@ -291,7 +291,7 @@ public:
state.forwardSonar = driver.forwardSonar;
state.depth3 = driver.depth3;
state.soundVeloc = driver.soundVeloc;
state.bowRudderServo = driver.bowRudderServo1 | driver.bowRudderServo2;
state.bowRudderServo = driver.bowRudderServo1;
state.bowRudderDeploy = driver.bowRudderDeploy;
state.ctd1 = driver.ctd1;
state.waterInject = driver.waterInject;
@@ -320,8 +320,10 @@ public:
state.mastLiftingServo = driver.mastLiftingServo;
state.DVL = driver.DVL;
state.ADCP = driver.DVL; // Assuming ADCP is same as DVL
//出入水传感器1、2共用一个继电器
state.inOutLetWater1 = driver.inputWaterSensor1;
state.inOutLetWater2 = driver.inputWaterSensor2;
state.inOutLetWater2 = driver.inputWaterSensor1;
// state.inOutLetWater2 = driver.inputWaterSensor2;
// UNIT4
state.singleBeamSonar7 = driver.singleBeamSonar7;
@@ -490,7 +492,40 @@ public:
// std::cout << buildSecdistStateToJson(s) << std::endl;
return buildSecdistStateToJson(s);
};
static DriverTable fault_state;
std::string buildMsg(DriverTable driver, DriverTable driver_state, DriverTable &driver_fault_state){
static size_t f_callCount = 0; // 静态变量,记录函数调用次数
unsigned int nCheck = 10;
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;
unsigned char* faultStatePtr = reinterpret_cast<unsigned char*>(&driver_fault_state) + i;
unsigned char* faultState = reinterpret_cast<unsigned char*>(&fault_state) + i;
if (*driverCopyPtr == *statePtr)
{
*driverCopyPtr = 2;
*faultStatePtr = 0;
*faultState = 0;
}
else
{
*faultState = *faultState + 1;
if(*faultState >= 5)
{
//只有开启失败才计入故障
if(*driverCopyPtr == 1)
*faultStatePtr = 1;
*faultState = 5;
}
}
}
f_callCount ++;
converFromDriverTable(s, driverCopy);
return buildSecdistStateToJson(s);
};
};
#endif
+2 -2
View File
@@ -2,13 +2,13 @@
#define UPLAN_PLANSTOP_CMD_H
#include <string>
#include "../logc/loguru.hpp"
#define DB_TO_PM_TASKSTOP "uPlan_planStop_cmd"
#define DB_TO_PM_TASKSTOP "uPlan_planStop_st"
class uPlan_planStopMsg
{
private:
/* data */
public:
std::string key = "uPlan_planStop_cmd";
std::string key = "uPlan_planStop_st";
uPlan_planStopMsg(/* args */){};
~uPlan_planStopMsg(){};
bool getTaskStop(const std::string& key, const std::string& msg) {
+1 -1
View File
@@ -26,7 +26,7 @@ public:
const DriverTable getEquipmentCmd(const std::string& key, const std::string& msg)
{
DriverTable cmd;
if (driver.loadDriverTableFromJson(msg, cmd) < 0)
if (driver.loadDriverTableFromJson(msg, cmd) < 0)
{
LOG_F(WARNING, "get equipment cmd error:%s", msg.c_str());
}
+8 -5
View File
@@ -4,7 +4,7 @@
#include "string"
#include "json/json.h"
#include <bitset>
#include "../systemData.h"
class uPower_pmStateMsg
{
private:
@@ -37,7 +37,7 @@ public:
unsigned char m_leakage;
} state;
std::string buildMsg()
std::string buildMsg(const SystemData& data)
{
// 状态赋值
Json::Value pms;
@@ -45,13 +45,16 @@ public:
pms["workCondition_uint8"] = state.workCondition;
pms["currentMod_uint8"] = state.currentMod;
pms["powerState_uint8"] = state.powerState;
pms["faultLevel_uint8"] = state.faultLevel;
// pms["faultLevel_uint8"] = state.faultLevel;
pms["faultLevel_uint8"] = data.getFaultCodeLevel();
Json::Value faultCode_array = Json::Value(Json::arrayValue);
for(auto val : state.faultCode)
//TODO:屏蔽所有故障
for(auto faultCode : data.getFaultCode())
{
faultCode_array.append(val);
faultCode_array.append(faultCode);
}
pms["faultCode_array"] = faultCode_array;
pms["soc_uint16"] = state.soc;