修复:编译告警(格式串不匹配、非 void 函数缺返回值、C++17 结构化绑定)
- 修复 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) 声明,消除死代码编译错误
This commit is contained in:
@@ -657,7 +657,7 @@ bool LowerCommManager::operate_HV_dcDc5_Breaker(char opt)
|
||||
disHighVolBusCmd cmd{}; // 默认全零
|
||||
double t0 = MOOSTime();
|
||||
bool ok = false;
|
||||
string name = "DCDC Module";
|
||||
const char* name = "DCDC Module";
|
||||
LOG_F(INFO, "operate %s: opt=%d", name, opt);
|
||||
|
||||
cmd.dcdc5Module = getBreakerOption(opt);
|
||||
@@ -709,7 +709,7 @@ bool LowerCommManager::operate_HV_coolingSystem_Breaker(char opt)
|
||||
disHighVolBusCmd cmd{}; // 默认全零
|
||||
double t0 = MOOSTime();
|
||||
bool ok = false;
|
||||
string name = "CoolingSystem";
|
||||
const char* name = "CoolingSystem";
|
||||
LOG_F(INFO, "operate %s: opt=%d", name, opt);
|
||||
|
||||
cmd.coolingSystem = getBreakerOption(opt);
|
||||
|
||||
@@ -929,7 +929,9 @@ vector<DriverCommand> Driver::loadDriverIdFromJson(const std::string &strJson) {
|
||||
{"launchControler_uint8", 37}, {"sideSonar_uint8", 35}, {"buoyage_uint8", 56}
|
||||
};
|
||||
|
||||
for (const auto& [field, id] : fieldToId) {
|
||||
for (const auto& entry : fieldToId) {
|
||||
const std::string& field = entry.first;
|
||||
int id = entry.second;
|
||||
if (root.isMember(field)) {
|
||||
unsigned char newValue = root[field].asUInt();
|
||||
DriverCommand cmd;
|
||||
|
||||
@@ -170,7 +170,7 @@ void PowerManagerFsm::handleNoPowerDeviceCmd(int id , int cmd){
|
||||
if(noPowerDevices.find(id) != noPowerDevices.end())
|
||||
{
|
||||
pm->m_driver.setDeviceState(pm->m_subDisSysCmd, (DeviceId::Type)id, (unsigned char)cmd);
|
||||
LOG_F(INFO, "无动力电设备操作: %d, %d", DeviceId::toString((DeviceId::Type)id),id, cmd);
|
||||
LOG_F(INFO, "无动力电设备操作: %s, %d, %d", DeviceId::toString((DeviceId::Type)id).c_str(), id, cmd);
|
||||
}
|
||||
}
|
||||
void PowerManagerFsm::handleHydroacousticDeviceCmd(int id , int cmd)
|
||||
@@ -198,7 +198,7 @@ void PowerManagerFsm::handleHydroacousticDeviceCmd(int id , int cmd)
|
||||
MOOSPause(10000);
|
||||
}
|
||||
}
|
||||
LOG_F(INFO, "水声设备操作: %d, %d", DeviceId::toString((DeviceId::Type)id), id, cmd);
|
||||
LOG_F(INFO, "水声设备操作: %s, %d, %d", DeviceId::toString((DeviceId::Type)id).c_str(), id, cmd);
|
||||
pm->m_driver.setDeviceState(pm->m_subDisSysCmd, (DeviceId::Type)id, (unsigned char)cmd);
|
||||
|
||||
}
|
||||
|
||||
@@ -295,6 +295,7 @@ class Lifting : public PowerManagerFsm {
|
||||
public:
|
||||
void entry() override;
|
||||
void react(MasterCommandEvent const &) override;
|
||||
void react(DevCmdExt const &e) override;
|
||||
};
|
||||
|
||||
#endif // POWER_MANAGER_FSM_HPP
|
||||
@@ -50,7 +50,7 @@ void WaterBasedReady::react(DevCmdExt const &e)
|
||||
MOOSPause(10000);
|
||||
}
|
||||
}
|
||||
LOG_F(INFO, "水声设备操作: %s,%d, %d", DeviceId::toString((DeviceId::Type)id), id, cmd);
|
||||
LOG_F(INFO, "水声设备操作: %s,%d, %d", DeviceId::toString((DeviceId::Type)id).c_str(), id, cmd);
|
||||
string info = "INFO:水声设备操作: " + DeviceId::toString((DeviceId::Type)id) + ", " + std::to_string(id) + ", " + std::to_string(cmd);
|
||||
pm->m_systemData->setSystemInfo(info);
|
||||
pm->m_driver.setDeviceState(pm->m_subDisSysCmd, (DeviceId::Type)id, (unsigned char)cmd);
|
||||
|
||||
@@ -22,7 +22,7 @@ void HttpServer::handleWebSocketEvent(struct mg_connection* c, int ev, void* ev_
|
||||
// WebSocket连接成功建立
|
||||
std::lock_guard<std::mutex> lock(server->ws_connections_mutex_);
|
||||
server->ws_connections_.push_back(c);
|
||||
LOG_F(INFO, "WebSocket connection established: id=%lu fd=%d", c->id, c->fd);
|
||||
LOG_F(INFO, "WebSocket connection established: id=%lu fd=%d", c->id, (int)(intptr_t)c->fd);
|
||||
} else if (ev == MG_EV_CLOSE || ev == MG_EV_ERROR) {
|
||||
// 连接关闭或错误
|
||||
std::lock_guard<std::mutex> lock(server->ws_connections_mutex_);
|
||||
@@ -32,17 +32,17 @@ void HttpServer::handleWebSocketEvent(struct mg_connection* c, int ev, void* ev_
|
||||
struct mg_http_message *hm = (struct mg_http_message *) ev_data;
|
||||
if (errno != 0) {
|
||||
LOG_F(ERROR, "WebSocket error: id=%lu fd=%d, errno=%d",
|
||||
c->id, c->fd, errno);
|
||||
c->id, (int)(intptr_t)c->fd, errno);
|
||||
// 打印socket错误信息
|
||||
char buf[256];
|
||||
strerror_r(errno, buf, sizeof(buf));
|
||||
LOG_F(ERROR, "Socket error: %s", buf);
|
||||
} else {
|
||||
LOG_F(ERROR, "WebSocket connection closed abnormally: id=%lu fd=%d",
|
||||
c->id, c->fd);
|
||||
c->id, (int)(intptr_t)c->fd);
|
||||
}
|
||||
} else {
|
||||
LOG_F(INFO, "WebSocket closed: id=%lu fd=%d", c->id, c->fd);
|
||||
LOG_F(INFO, "WebSocket closed: id=%lu fd=%d", c->id, (int)(intptr_t)c->fd);
|
||||
}
|
||||
server->ws_connections_.erase(it);
|
||||
|
||||
@@ -67,9 +67,9 @@ void HttpServer::handleWebSocketEvent(struct mg_connection* c, int ev, void* ev_
|
||||
struct mg_http_message *hm = (struct mg_http_message *) ev_data;
|
||||
if (mg_match(hm->uri, mg_str("/ws"), NULL)) {
|
||||
// 升级到WebSocket连接
|
||||
LOG_F(INFO, "Upgrading to WebSocket: id=%lu fd=%d", c->id, c->fd);
|
||||
LOG_F(INFO, "Upgrading to WebSocket: id=%lu fd=%d", c->id, (int)(intptr_t)c->fd);
|
||||
mg_ws_upgrade(c, hm, nullptr);
|
||||
LOG_F(INFO, "WebSocket upgrade completed: id=%lu fd=%d", c->id, c->fd);
|
||||
LOG_F(INFO, "WebSocket upgrade completed: id=%lu fd=%d", c->id, (int)(intptr_t)c->fd);
|
||||
} else if (mg_match(hm->uri, mg_str("/dashboard"), NULL)) {
|
||||
// 返回仪表盘HTML
|
||||
mg_http_reply(c, 200, "Content-Type: text/html; charset=utf-8\r\n", DASHBOARD_HTML.c_str());
|
||||
@@ -151,9 +151,9 @@ void HttpServer::handleWebSocketEvent(struct mg_connection* c, int ev, void* ev_
|
||||
}
|
||||
} else if (mg_match(hm->uri, mg_str("/ws/debug"), NULL)) {
|
||||
// 升级到调试WebSocket连接
|
||||
LOG_F(INFO, "Upgrading to Debug WebSocket: id=%lu fd=%d", c->id, c->fd);
|
||||
LOG_F(INFO, "Upgrading to Debug WebSocket: id=%lu fd=%d", c->id, (int)(intptr_t)c->fd);
|
||||
mg_ws_upgrade(c, hm, nullptr);
|
||||
LOG_F(INFO, "Debug WebSocket upgrade completed: id=%lu fd=%d", c->id, c->fd);
|
||||
LOG_F(INFO, "Debug WebSocket upgrade completed: id=%lu fd=%d", c->id, (int)(intptr_t)c->fd);
|
||||
} else if (mg_match(hm->uri, mg_str("/moosdb_test"), NULL)) {
|
||||
if (mg_strcmp(hm->method, mg_str("POST")) == 0) {
|
||||
// 解析JSON请求
|
||||
@@ -201,7 +201,7 @@ void HttpServer::handleWebSocketEvent(struct mg_connection* c, int ev, void* ev_
|
||||
if (device_type && device_id && action) {
|
||||
//TODO: 处理断路器控制逻辑
|
||||
LOG_F(INFO, "Received control request: device_type=%s, device_id=%s, action=%s ,from Net DashBoard id=%lu fd=%d",
|
||||
device_type, device_id, action, c->id, c->fd);
|
||||
device_type, device_id, action, c->id, (int)(intptr_t)c->fd);
|
||||
char opt = (action_str == "open") ? 0 : 1;
|
||||
if(device_type_str == "meter_bus")
|
||||
{
|
||||
|
||||
@@ -61,7 +61,7 @@ public:
|
||||
return false;
|
||||
}
|
||||
if (ccuHost.empty() || ccuPort <= 0) {
|
||||
LOG_F(ERROR, "Invalid CCU address: %s:%d", ccuHost.c_str(), ccuPort);
|
||||
LOG_F(ERROR, "Invalid CCU address: %s:%ld", ccuHost.c_str(), ccuPort);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -30,8 +30,8 @@ public:
|
||||
|
||||
// 检查并读取操作条件
|
||||
if (root.isMember("state_uint8") && root["state_uint8"].isUInt()) {
|
||||
return root["state_uint8"].asUInt();
|
||||
LOG_F(INFO, "上位机指令:opCondition: %d", root["state_uint8"].asUInt());
|
||||
return root["state_uint8"].asUInt();
|
||||
} else {
|
||||
LOG_F(WARNING, "缺少或类型不匹配: opCondition");
|
||||
return -1;
|
||||
|
||||
@@ -32,7 +32,7 @@ public:
|
||||
// 提取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());
|
||||
LOG_F(INFO, "taskType: %d (%s)", mission.type, root["taskType_str"].asString().c_str());
|
||||
}
|
||||
|
||||
// 提取balanceEnabled_bool
|
||||
|
||||
@@ -25,6 +25,7 @@ public:
|
||||
{
|
||||
LOG_F(WARNING, "get master control cmd error:%s", msg.c_str());
|
||||
}
|
||||
return cmd;
|
||||
};
|
||||
bool parseControlCmdFromJson(MSControlCmd &cmd, const std::string &strJson)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user