增加mooos信息

This commit is contained in:
zjk
2025-05-19 01:02:33 +08:00
parent f1a422e0c3
commit d6e3d466b2
8 changed files with 2484 additions and 1565 deletions
@@ -6,6 +6,7 @@
#include <iostream>
#include "json/json.h"
#include <sys/resource.h>
#include "data.h"
using json = Json::Value;
@@ -63,6 +64,9 @@ void HttpServer::handleWebSocketEvent(struct mg_connection* c, int ev, void* ev_
} 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());
} else if (mg_match(hm->uri, mg_str("/data"), NULL)) {
// 返回数据页面HTML
mg_http_reply(c, 200, "Content-Type: text/html; charset=utf-8\r\n", DATA_HTML.c_str());
} else if (mg_match(hm->uri, mg_str("/control"), NULL)) {
// 处理断路器控制请求
if (mg_strcmp(hm->method, mg_str("POST")) == 0) {
@@ -485,6 +489,14 @@ void HttpServer::pushSystemData() {
j["instrument_bus_status"]["emergencyLithiumBatteryGroup1Current"] = Json::Value(m_systemData->instrument_bus_status.emergencyLithiumBatteryGroup1Current); // 应急锂电池组1电流
j["instrument_bus_status"]["emergency1BusbarVoltage"] = Json::Value(m_systemData->instrument_bus_status.emergency1BusbarVoltage); // 应急1汇流排电压
//MOOSDB数据
j["moosdb"]["appFreq"] = Json::Value(m_powerManger->GetPublicAppFreq());
j["moosdb"]["commFreq"] = Json::Value(m_powerManger->GetPublicCommsFreq());
j["moosdb"]["startTime"] = Json::Value(m_powerManger->GetPublicAppStartTime());
j["moosdb"]["cpuLoad"] = Json::Value(m_powerManger->GetPublicCPULoad());
j["moosdb"]["timeSinceIterate"] = Json::Value(m_powerManger->GetPublicTimeSinceIterate());
j["moosdb"]["lastIterateTime"] = Json::Value(m_powerManger->GetPublicLastIterateTime());
// 时间戳
j["timestamp"] = Json::Value((Json::UInt64)(std::chrono::duration_cast<std::chrono::milliseconds>(
std::chrono::system_clock::now().time_since_epoch()).count()));