- 修复 LOG_F 格式串与参数类型/数量不匹配(udpComm.h、uPlan_taskStart.h、httpserver.cpp、PowerManagerFsm.cpp、WaterBasedReady.cpp、LowerCommManager.cpp) - httpserver.cpp 中 mg_connection::fd 为 void*,打印时强转为 int - uExternComm_setOpCondition.h / uPower_sysState.h 补齐返回值,消除 -Wreturn-type - driver.cpp 移除结构化绑定(C++17),保持 -std=c++11 - PowerManagerFsm.hpp 为 class Lifting 补充 react(DevCmdExt) 声明,消除死代码编译错误
43 lines
1.2 KiB
C++
43 lines
1.2 KiB
C++
#ifndef UEXTERCOMM_SETOPCONDITION_CMD_H
|
|
#define UEXTERCOMM_SETOPCONDITION_CMD_H
|
|
#include <string>
|
|
#include "../logc/loguru.hpp"
|
|
#include "json/json.h"
|
|
//外部通信消息
|
|
#define DB_TO_PM_SETOPCONDITION "uExternComm_setOpCondition_cmd"
|
|
|
|
class uExternComm_setOpConditionMsg
|
|
{
|
|
private:
|
|
/* data */
|
|
public:
|
|
std::string key = "uExternComm_setOpCondition_cmd";
|
|
uExternComm_setOpConditionMsg(/* args */){};
|
|
~uExternComm_setOpConditionMsg(){};
|
|
|
|
int getSetOpCondition(const std::string& key, const std::string& msg)
|
|
{
|
|
Json::Value root;
|
|
Json::CharReaderBuilder builder;
|
|
JSONCPP_STRING errs;
|
|
|
|
// 解析JSON字符串
|
|
std::istringstream stream(msg);
|
|
if (!Json::parseFromStream(builder, stream, &root, &errs)) {
|
|
LOG_F(WARNING, "JSON解析失败: %s", errs.c_str());
|
|
return -1;
|
|
}
|
|
|
|
// 检查并读取操作条件
|
|
if (root.isMember("state_uint8") && root["state_uint8"].isUInt()) {
|
|
LOG_F(INFO, "上位机指令:opCondition: %d", root["state_uint8"].asUInt());
|
|
return root["state_uint8"].asUInt();
|
|
} else {
|
|
LOG_F(WARNING, "缺少或类型不匹配: opCondition");
|
|
return -1;
|
|
}
|
|
}
|
|
|
|
};
|
|
|
|
#endif |