#ifndef UPPERCOMMMANAGER_H #define UPPERCOMMMANAGER_H #include #include "../pmSysvariable.h" #include "../logc/loguru.hpp" //决策消息 #define DB_TO_PM_MISSION "uPlan_taskStart_st" class uPlan_taskStartMsg { private: /* data */ public: std::string key = "uPlan_taskStart_st"; uPlan_taskStartMsg(/* args */){}; ~uPlan_taskStartMsg(){}; MissionState getMission(const std::string& key, const std::string& msg) { MissionState mission{}; Json::Value root; Json::CharReaderBuilder builder; JSONCPP_STRING errs; // 解析JSON字符串 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 mission; } // 提取taskType_str if (root.isMember("taskType_str") && root["taskType_str"].isString()) { mission.type = TaskType::fromString(root["taskType_str"].asString()); LOG_F(INFO, "taskType: %d", mission.type, root["taskType_str"].asString()); } // 提取balanceEnabled_bool if (root.isMember("balanceEnabled_bool") && root["balanceEnabled_bool"].isBool()) { mission.enableBuoyancyAdjustment = root["balanceEnabled_bool"].asBool(); LOG_F(INFO, "balanceEnabled_bool: %d", mission.enableBuoyancyAdjustment); } // 提取bowRudderUnfold_bool if (root.isMember("bowRudderUnfold_bool") && root["bowRudderUnfold_bool"].isBool()) { mission.enableBowRudder = root["bowRudderUnfold_bool"].asBool(); LOG_F(INFO, "bowRudderUnfold_bool: %d", mission.enableBowRudder); } return mission; }; }; #endif