增加调试页面
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
#include "data.h"
|
||||
#include "logpage.h"
|
||||
#include "testpage.h"
|
||||
#include "degubpage.h"
|
||||
|
||||
using json = Json::Value;
|
||||
|
||||
@@ -86,6 +87,14 @@ void HttpServer::handleWebSocketEvent(struct mg_connection* c, int ev, void* ev_
|
||||
// 返回测试页面HTML
|
||||
mg_http_reply(c, 200, "Content-Type: text/html; charset=utf-8\r\n", TESTPAGE_HTML.c_str());
|
||||
}
|
||||
} else if (mg_match(hm->uri, mg_str("/debug"), NULL)) {
|
||||
// 返回调试页面HTML
|
||||
mg_http_reply(c, 200, "Content-Type: text/html; charset=utf-8\r\n", DEBUGPAGE_HTML.c_str());
|
||||
} 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);
|
||||
mg_ws_upgrade(c, hm, nullptr);
|
||||
LOG_F(INFO, "Debug WebSocket upgrade completed: id=%lu fd=%d", c->id, c->fd);
|
||||
} else if (mg_match(hm->uri, mg_str("/moosdb_test"), NULL)) {
|
||||
if (mg_strcmp(hm->method, mg_str("POST")) == 0) {
|
||||
// 解析JSON请求
|
||||
@@ -555,6 +564,65 @@ void HttpServer::pushSystemData() {
|
||||
j["moosdb"]["lastIterateCount"] = Json::Value(m_powerManger->GetPublicIterateCount());
|
||||
j["moosdb"]["serverHost"] = Json::Value(m_powerManger->GetServerHost());
|
||||
j["moosdb"]["serverPort"] = Json::Value(m_powerManger->GetServerPort());
|
||||
|
||||
// degub
|
||||
#ifdef _DEBUG
|
||||
//订阅消息
|
||||
j["debug"]["m_secdistStateMsg_fb_debug"]["name"] = Json::Value(m_powerManger->m_upperCommManager->m_secdistStateMsg_fb_debug.first);
|
||||
j["debug"]["m_secdistStateMsg_fb_debug"]["content"] = Json::Value(m_powerManger->m_upperCommManager->m_secdistStateMsg_fb_debug.second);
|
||||
|
||||
j["debug"]["m_equStateMsg_cmd_debug"]["name"] = Json::Value(m_powerManger->m_upperCommManager->m_equStateMsg_cmd_debug.first);
|
||||
j["debug"]["m_equStateMsg_cmd_debug"]["content"] = Json::Value(m_powerManger->m_upperCommManager->m_equStateMsg_cmd_debug.second);
|
||||
|
||||
j["debug"]["m_depthMsg_st_debug"]["name"] = Json::Value(m_powerManger->m_upperCommManager->m_depthMsg_st_debug.first);
|
||||
j["debug"]["m_depthMsg_st_debug"]["content"] = Json::Value(m_powerManger->m_upperCommManager->m_depthMsg_st_debug.second);
|
||||
|
||||
j["debug"]["m_setOpConditionMsg_st_debug"]["name"] = Json::Value(m_powerManger->m_upperCommManager->m_setOpConditionMsg_st_debug.first);
|
||||
j["debug"]["m_setOpConditionMsg_st_debug"]["content"] = Json::Value(m_powerManger->m_upperCommManager->m_setOpConditionMsg_st_debug.second);
|
||||
|
||||
j["debug"]["m_setOpModeMsg_st_debug"]["name"] = Json::Value(m_powerManger->m_upperCommManager->m_setOpModeMsg_st_debug.first);
|
||||
j["debug"]["m_setOpModeMsg_st_debug"]["content"] = Json::Value(m_powerManger->m_upperCommManager->m_setOpModeMsg_st_debug.second);
|
||||
|
||||
j["debug"]["m_taskStartMsg_st_debug"]["name"] = Json::Value(m_powerManger->m_upperCommManager->m_taskStartMsg_st_debug.first);
|
||||
j["debug"]["m_taskStartMsg_st_debug"]["content"] = Json::Value(m_powerManger->m_upperCommManager->m_taskStartMsg_st_debug.second);
|
||||
|
||||
j["debug"]["m_taskStopMsg_st_debug"]["name"] = Json::Value(m_powerManger->m_upperCommManager->m_taskStopMsg_st_debug.first);
|
||||
j["debug"]["m_taskStopMsg_st_debug"]["content"] = Json::Value(m_powerManger->m_upperCommManager->m_taskStopMsg_st_debug.second);
|
||||
|
||||
j["debug"]["m_setDevSwitchMsg_st_debug"]["name"] = Json::Value(m_powerManger->m_upperCommManager->m_setDevSwitchMsg_st_debug.first);
|
||||
j["debug"]["m_setDevSwitchMsg_st_debug"]["content"] = Json::Value(m_powerManger->m_upperCommManager->m_setDevSwitchMsg_st_debug.second);
|
||||
|
||||
j["debug"]["m_setPMSysMsg_st_debug"]["name"] = Json::Value(m_powerManger->m_upperCommManager->m_setPMSysMsg_st_debug.first);
|
||||
j["debug"]["m_setPMSysMsg_st_debug"]["content"] = Json::Value(m_powerManger->m_upperCommManager->m_setPMSysMsg_st_debug.second);
|
||||
|
||||
j["debug"]["m_sysStateMsg_st_debug"]["name"] = Json::Value(m_powerManger->m_upperCommManager->m_sysStateMsg_st_debug.first);
|
||||
j["debug"]["m_sysStateMsg_st_debug"]["content"] = Json::Value(m_powerManger->m_upperCommManager->m_sysStateMsg_st_debug.second);
|
||||
|
||||
//发布消息
|
||||
j["debug"]["m_equInsStateMsg_fb_degub"]["name"] = Json::Value(m_powerManger->m_upperCommManager->m_equInsStateMsg_fb_degub.first);
|
||||
j["debug"]["m_equInsStateMsg_fb_degub"]["content"] = Json::Value(m_powerManger->m_upperCommManager->m_equInsStateMsg_fb_degub.second);
|
||||
|
||||
j["debug"]["m_secdistStateMsg_cmd_debug"]["name"] = Json::Value(m_powerManger->m_upperCommManager->m_secdistStateMsg_cmd_debug.first);
|
||||
j["debug"]["m_secdistStateMsg_cmd_debug"]["content"] = Json::Value(m_powerManger->m_upperCommManager->m_secdistStateMsg_cmd_debug.second);
|
||||
|
||||
j["debug"]["m_equStateMsg_fb_debug"]["name"] = Json::Value(m_powerManger->m_upperCommManager->m_equStateMsg_fb_debug.first);
|
||||
j["debug"]["m_equStateMsg_fb_debug"]["content"] = Json::Value(m_powerManger->m_upperCommManager->m_equStateMsg_fb_debug.second);
|
||||
|
||||
j["debug"]["m_disSysStateMsg_st_debug"]["name"] = Json::Value(m_powerManger->m_upperCommManager->m_disSysStateMsg_st_debug.first);
|
||||
j["debug"]["m_disSysStateMsg_st_debug"]["content"] = Json::Value(m_powerManger->m_upperCommManager->m_disSysStateMsg_st_debug.second);
|
||||
|
||||
j["debug"]["m_currentStateMsg_st_debug"]["name"] = Json::Value(m_powerManger->m_upperCommManager->m_currentStateMsg_st_debug.first);
|
||||
j["debug"]["m_currentStateMsg_st_debug"]["content"] = Json::Value(m_powerManger->m_upperCommManager->m_currentStateMsg_st_debug.second);
|
||||
|
||||
j["debug"]["m_pmStateMsg_fb_debug"]["name"] = Json::Value(m_powerManger->m_upperCommManager->m_pmStateMsg_fb_debug.first);
|
||||
j["debug"]["m_pmStateMsg_fb_debug"]["content"] = Json::Value(m_powerManger->m_upperCommManager->m_pmStateMsg_fb_debug.second);
|
||||
|
||||
j["debug"]["m_fcsStateMsg_st_debug"]["name"] = Json::Value(m_powerManger->m_upperCommManager->m_fcsStateMsg_st_debug.first);
|
||||
j["debug"]["m_fcsStateMsg_st_debug"]["content"] = Json::Value(m_powerManger->m_upperCommManager->m_fcsStateMsg_st_debug.second);
|
||||
|
||||
j["debug"]["m_liBatStateMsg_st_debug"]["name"] = Json::Value(m_powerManger->m_upperCommManager->m_liBatStateMsg_st_debug.first);
|
||||
j["debug"]["m_liBatStateMsg_st_debug"]["content"] = Json::Value(m_powerManger->m_upperCommManager->m_liBatStateMsg_st_debug.second);
|
||||
#endif
|
||||
// 时间戳
|
||||
j["timestamp"] = Json::Value((Json::UInt64)(std::chrono::duration_cast<std::chrono::milliseconds>(
|
||||
std::chrono::system_clock::now().time_since_epoch()).count()));
|
||||
|
||||
Reference in New Issue
Block a user