为数据库插入增加保护

This commit is contained in:
zjk
2026-01-19 21:52:26 +08:00
parent 481171d9ea
commit b5ca051831
97 changed files with 363231 additions and 98 deletions
+15 -3
View File
@@ -157,6 +157,8 @@ bool UpperCommManager::processUpperMsg(const string& key, const string& strJson)
else if(key == uDetect_xcVoltage_cmd::key)
{
uDetect_xcVoltage_cmd xcCmd;
xcCmd.xcHighVoltageAdd_int32 = 0;
xcCmd.xcLowVoltageAdd_int32 = 0;
xcCmd.fromJsonString(strJson);
SideSonarCmd sideSonarCmd;
sideSonarCmd.xcHighVoltageAdd = xcCmd.xcHighVoltageAdd_int32;
@@ -175,6 +177,17 @@ bool UpperCommManager::processUpperMsg(const string& key, const string& strJson)
PowerManagerFsm::dispatch(devCmdExt);
LOG_F(INFO, "set dev switch success");
return true;
}
else if(key == uDevice_thruster_st::key)
{
uDevice_thruster_st thrusterSt;
thrusterSt.fromJsonString(strJson);
m_pm->m_thrustRpm = thrusterSt.rpm_int16;
if(thrusterSt.maxTorque_uint16 == 0)
m_pm->m_thrustEnable = 0;
else
m_pm->m_thrustEnable = 1;
return true;
};
LOG_F(WARNING, "Unknown key: %s", key.c_str());
return false;
@@ -184,8 +197,6 @@ void UpperCommManager::processPeriodicTasks() {
buildSystemReport();
std::string strJson;
//发送当前设备状态
//TODO: 修改设备状态
m_pm->m_currentDriverState.ins = 1;
strJson = m_equStateMsg.buildMsg(m_pm->m_currentDriverState);
m_pm->sendNotification(m_equStateMsg.key, strJson);
//发送次级配电指令 修改后的代码
@@ -211,7 +222,8 @@ void UpperCommManager::buildSystemReport() {
// cout << "m_pmStateMsg.state.faultCode.size():" << m_pmStateMsg.state.faultCode.size() << endl;
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_leakage = m_pm->m_leakage;
m_pmStateMsg.state.m_leakage = m_pm->m_systemData->generateLeakageCode();
m_pmStateMsg.state.m_faultNum = m_pm->m_faultNum;
m_pm->sendNotification(m_pmStateMsg.key, m_pmStateMsg.buildMsg(*(m_pm->m_systemData)));