增加控制功能
This commit is contained in:
@@ -79,7 +79,7 @@ void LowerCommManager::processPeriodicTasks() {
|
||||
sendCcuCommand(m_pm->m_CcuColCmd);
|
||||
//延时5ms
|
||||
usleep(5000);
|
||||
sendDisSysCommand(m_pm->m_targetDisBreakerState);
|
||||
// sendDisSysCommand(m_pm->m_targetDisBreakerState);
|
||||
m_udpComm->clearMsgQueue();
|
||||
|
||||
}
|
||||
|
||||
@@ -135,15 +135,24 @@ bool PowerManger::Iterate()
|
||||
CycleTriggeredEvent cycleEvent;
|
||||
PowerManagerFsm::dispatch(cycleEvent);
|
||||
faultLevel = getFaultLevel();
|
||||
|
||||
// 更新系统数据
|
||||
m_systemData->updateSystemData(m_pmCurrentState.ccustate);
|
||||
m_systemData->updateSystemData(m_pmCurrentState.bus1State);
|
||||
m_systemData->updateSystemData(m_pmCurrentState.bus2State);
|
||||
m_systemData->updateSystemData(m_pmCurrentState.bus3State);
|
||||
m_systemData->updateSystemData(m_pmCurrentState.bus4State);
|
||||
m_systemData->device_common_status.ccu_status.lastUpdateTime = m_lowerCommManager->msg_CcuStateFbMsg_Update_time;
|
||||
m_systemData->device_common_status.dis_hv_c1.lastUpdateTime = m_lowerCommManager->msg_disHighVolBusFbMsg_Update_time;
|
||||
m_systemData->device_common_status.dis_hv_c2.lastUpdateTime = m_lowerCommManager->msg_disHighAVolBusFbMsg_Update_time;
|
||||
m_systemData->device_common_status.dis_lv_c1.lastUpdateTime = m_lowerCommManager->msg_disHighBVolBusFbMsg_Update_time;
|
||||
m_systemData->device_common_status.dis_lv_c2.lastUpdateTime = m_lowerCommManager->msg_disLowBusFbMsg_Update_time;
|
||||
m_systemData->updateCommonStatus();
|
||||
|
||||
if (m_ticker++ % 5 == 0)
|
||||
{
|
||||
m_CcuColCmd.heartbeat++;
|
||||
// m_lowerCommManager->processPeriodicTasks();
|
||||
m_lowerCommManager->processPeriodicTasks();
|
||||
m_upperCommManager->processPeriodicTasks();
|
||||
}
|
||||
return(true);
|
||||
|
||||
@@ -0,0 +1,406 @@
|
||||
|
||||
#ifndef HTTP_SERVER_DASHBOARD_H
|
||||
#define HTTP_SERVER_DASHBOARD_H
|
||||
|
||||
#include <string>
|
||||
|
||||
const std::string DASHBOARD_HTML = R"row(
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>断路器控制面板</title>
|
||||
<style>
|
||||
body {
|
||||
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
||||
margin: 0;
|
||||
padding: 20px;
|
||||
background-color: #f8f9fa;
|
||||
}
|
||||
.container {
|
||||
display: flex;
|
||||
gap: 25px;
|
||||
max-width: 1400px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
.column {
|
||||
flex: 1;
|
||||
background: white;
|
||||
padding: 20px;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
|
||||
transition: transform 0.2s;
|
||||
}
|
||||
.column:hover {
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 4px 12px rgba(0,0,0,0.15);
|
||||
}
|
||||
.column-title {
|
||||
font-weight: 600;
|
||||
margin-bottom: 20px;
|
||||
text-align: center;
|
||||
font-size: 20px;
|
||||
color: #2c3e50;
|
||||
padding-bottom: 10px;
|
||||
border-bottom: 2px solid #eee;
|
||||
}
|
||||
.breaker {
|
||||
margin-bottom: 12px;
|
||||
padding: 10px 15px;
|
||||
background: #f8f9fa;
|
||||
border-radius: 6px;
|
||||
border-left: 4px solid #3498db;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
}
|
||||
.breaker-name {
|
||||
font-weight: 600;
|
||||
font-size: 18px;
|
||||
color: #2c3e50;
|
||||
padding: 6px 10px;
|
||||
background-color: rgba(46, 204, 113, 0.1);
|
||||
border-radius: 4px;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
width: fit-content;
|
||||
}
|
||||
.breaker-controls {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
align-items: center;
|
||||
}
|
||||
button {
|
||||
padding: 8px 16px;
|
||||
min-width: 70px;
|
||||
cursor: pointer;
|
||||
border: none;
|
||||
border-radius: 4px;
|
||||
font-weight: 500;
|
||||
font-size: 14px;
|
||||
transition: all 0.2s;
|
||||
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
||||
}
|
||||
button:hover {
|
||||
opacity: 0.9;
|
||||
transform: translateY(-1px);
|
||||
}
|
||||
button:first-of-type {
|
||||
background-color: #2ecc71;
|
||||
color: white;
|
||||
}
|
||||
button:last-of-type {
|
||||
background-color: #e74c3c;
|
||||
color: white;
|
||||
}
|
||||
.status-message {
|
||||
margin-top: 8px;
|
||||
padding: 6px;
|
||||
font-size: 13px;
|
||||
border-radius: 3px;
|
||||
}
|
||||
.status-success {
|
||||
background-color: rgba(46, 204, 113, 0.1);
|
||||
color: #27ae60;
|
||||
}
|
||||
.status-error {
|
||||
background-color: rgba(231, 76, 60, 0.1);
|
||||
color: #c0392b;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="column">
|
||||
<div class="column-title">高压母线设备</div>
|
||||
<!-- 高压母线断路器列表 -->
|
||||
<div class="breaker">
|
||||
<div class="breaker-name">燃料电池断路器</div>
|
||||
<div class="breaker-controls">
|
||||
<button onclick="sendCommand('high_vol_bus', 'fuel_cell', 'close')">闭合</button>
|
||||
<button onclick="sendCommand('high_vol_bus', 'fuel_cell', 'open')">断开</button>
|
||||
</div>
|
||||
<div id="high_vol_bus-status-message" class="status-message"></div>
|
||||
</div>
|
||||
<div class="breaker">
|
||||
<div class="breaker-name">动力锂电池断路器</div>
|
||||
<div class="breaker-controls">
|
||||
<button onclick="sendCommand('high_vol_bus', 'power_battery', 'close')">闭合</button>
|
||||
<button onclick="sendCommand('high_vol_bus', 'power_battery', 'open')">断开</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="breaker">
|
||||
<div class="breaker-name">推进电机断路器</div>
|
||||
<div class="breaker-controls">
|
||||
<button onclick="sendCommand('high_vol_bus', 'propulsion_motor', 'close')">闭合</button>
|
||||
<button onclick="sendCommand('high_vol_bus', 'propulsion_motor', 'open')">断开</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="breaker">
|
||||
<div class="breaker-name">锂电池组仪表断路器</div>
|
||||
<div class="breaker-controls">
|
||||
<button onclick="sendCommand('high_vol_bus', 'battery_meter', 'close')">闭合</button>
|
||||
<button onclick="sendCommand('high_vol_bus', 'battery_meter', 'open')">断开</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="breaker">
|
||||
<div class="breaker-name">DC/DC5模块断路器</div>
|
||||
<div class="breaker-controls">
|
||||
<button onclick="sendCommand('high_vol_bus', 'dcdc5', 'close')">闭合</button>
|
||||
<button onclick="sendCommand('high_vol_bus', 'dcdc5', 'open')">断开</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="breaker">
|
||||
<div class="breaker-name">艏部高压配电箱断路器</div>
|
||||
<div class="breaker-controls">
|
||||
<button onclick="sendCommand('high_vol_bus', 'bow_distribution', 'close')">闭合</button>
|
||||
<button onclick="sendCommand('high_vol_bus', 'bow_distribution', 'open')">断开</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="breaker">
|
||||
<div class="breaker-name">艉部FT装置4/5断路器</div>
|
||||
<div class="breaker-controls">
|
||||
<button onclick="sendCommand('high_vol_bus', 'stern_ft45', 'close')">闭合</button>
|
||||
<button onclick="sendCommand('high_vol_bus', 'stern_ft45', 'open')">断开</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="breaker">
|
||||
<div class="breaker-name">艉舵开关1断路器</div>
|
||||
<div class="breaker-controls">
|
||||
<button onclick="sendCommand('high_vol_bus', 'stern_rudder1', 'close')">闭合</button>
|
||||
<button onclick="sendCommand('high_vol_bus', 'stern_rudder1', 'open')">断开</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="breaker">
|
||||
<div class="breaker-name">艉舵开关2断路器</div>
|
||||
<div class="breaker-controls">
|
||||
<button onclick="sendCommand('high_vol_bus', 'stern_rudder2', 'close')">闭合</button>
|
||||
<button onclick="sendCommand('high_vol_bus', 'stern_rudder2', 'open')">断开</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="breaker">
|
||||
<div class="breaker-name">FB预留断路器</div>
|
||||
<div class="breaker-controls">
|
||||
<button onclick="sendCommand('high_vol_bus', 'fb_reserve', 'close')">闭合</button>
|
||||
<button onclick="sendCommand('high_vol_bus', 'fb_reserve', 'open')">断开</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="breaker">
|
||||
<div class="breaker-name">TYZ预留断路器</div>
|
||||
<div class="breaker-controls">
|
||||
<button onclick="sendCommand('high_vol_bus', 'tyz_reserve', 'close')">闭合</button>
|
||||
<button onclick="sendCommand('high_vol_bus', 'tyz_reserve', 'open')">断开</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="breaker">
|
||||
<div class="breaker-name">预留断路器</div>
|
||||
<div class="breaker-controls">
|
||||
<button onclick="sendCommand('high_vol_bus', 'reserve', 'close')">闭合</button>
|
||||
<button onclick="sendCommand('high_vol_bus', 'reserve', 'open')">断开</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="breaker">
|
||||
<div class="breaker-name">DC/DC5模块启动</div>
|
||||
<div class="breaker-controls">
|
||||
<button onclick="sendCommand('high_vol_bus', 'dcdc5_start', 'close')">启动</button>
|
||||
<button onclick="sendCommand('high_vol_bus', 'dcdc5_start', 'open')">停止</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="breaker">
|
||||
<div class="breaker-name">冷却系统启动</div>
|
||||
<div class="breaker-controls">
|
||||
<button onclick="sendCommand('high_vol_bus', 'cooling_system', 'close')">启动</button>
|
||||
<button onclick="sendCommand('high_vol_bus', 'cooling_system', 'open')">停止</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="column">
|
||||
<div class="column-title">艏高压设备</div>
|
||||
<!-- 艏高压断路器列表 -->
|
||||
<div class="breaker">
|
||||
<div class="breaker-name">艏部FT装置1-3断路器</div>
|
||||
<div class="breaker-controls">
|
||||
<button onclick="sendCommand('bow_high_vol', 'bow_ft1_3', 'close')">闭合</button>
|
||||
<button onclick="sendCommand('bow_high_vol', 'bow_ft1_3', 'open')">断开</button>
|
||||
</div>
|
||||
<div id="bow_high_vol-status-message" class="status-message"></div>
|
||||
</div>
|
||||
<div class="breaker">
|
||||
<div class="breaker-name">启闭机构断路器</div>
|
||||
<div class="breaker-controls">
|
||||
<button onclick="sendCommand('bow_high_vol', 'opening_mechanism', 'close')">闭合</button>
|
||||
<button onclick="sendCommand('bow_high_vol', 'opening_mechanism', 'open')">断开</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="breaker">
|
||||
<div class="breaker-name">桅杆舵机控制箱断路器</div>
|
||||
<div class="breaker-controls">
|
||||
<button onclick="sendCommand('bow_high_vol', 'mast_steering', 'close')">闭合</button>
|
||||
<button onclick="sendCommand('bow_high_vol', 'mast_steering', 'open')">断开</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="breaker">
|
||||
<div class="breaker-name">XCZ断路器</div>
|
||||
<div class="breaker-controls">
|
||||
<button onclick="sendCommand('bow_high_vol', 'xcz', 'close')">闭合</button>
|
||||
<button onclick="sendCommand('bow_high_vol', 'xcz', 'open')">断开</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="breaker">
|
||||
<div class="breaker-name">艏舵控制箱断路器</div>
|
||||
<div class="breaker-controls">
|
||||
<button onclick="sendCommand('bow_high_vol', 'bow_rudder', 'close')">闭合</button>
|
||||
<button onclick="sendCommand('bow_high_vol', 'bow_rudder', 'open')">断开</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="breaker">
|
||||
<div class="breaker-name">敞水盖启动电缸断路器</div>
|
||||
<div class="breaker-controls">
|
||||
<button onclick="sendCommand('bow_high_vol', 'water_cover', 'close')">闭合</button>
|
||||
<button onclick="sendCommand('bow_high_vol', 'water_cover', 'open')">断开</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="column">
|
||||
<div class="column-title">仪表母线设备</div>
|
||||
<!-- 仪表母线断路器列表 -->
|
||||
<div class="breaker">
|
||||
<div class="breaker-name">锂电池组(仪表)断路器</div>
|
||||
<div class="breaker-controls">
|
||||
<button onclick="sendCommand('meter_bus', 'battery_meter', 'close')">闭合</button>
|
||||
<button onclick="sendCommand('meter_bus', 'battery_meter', 'open')">断开</button>
|
||||
</div>
|
||||
<div id="meter_bus-status-message" class="status-message"></div>
|
||||
</div>
|
||||
<div class="breaker">
|
||||
<div class="breaker-name">艏部低压配电箱断路器</div>
|
||||
<div class="breaker-controls">
|
||||
<button onclick="sendCommand('meter_bus', 'bow_low_dist', 'close')">闭合</button>
|
||||
<button onclick="sendCommand('meter_bus', 'bow_low_dist', 'open')">断开</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="breaker">
|
||||
<div class="breaker-name">UNIT4仪表DC48V断路器</div>
|
||||
<div class="breaker-controls">
|
||||
<button onclick="sendCommand('meter_bus', 'unit4_dc48v', 'close')">闭合</button>
|
||||
<button onclick="sendCommand('meter_bus', 'unit4_dc48v', 'open')">断开</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="breaker">
|
||||
<div class="breaker-name">DC-C1直流配电板断路器</div>
|
||||
<div class="breaker-controls">
|
||||
<button onclick="sendCommand('meter_bus', 'dc_c1', 'close')">闭合</button>
|
||||
<button onclick="sendCommand('meter_bus', 'dc_c1', 'open')">断开</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="breaker">
|
||||
<div class="breaker-name">预留断路器1</div>
|
||||
<div class="breaker-controls">
|
||||
<button onclick="sendCommand('meter_bus', 'reserve1', 'close')">闭合</button>
|
||||
<button onclick="sendCommand('meter_bus', 'reserve1', 'open')">断开</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="breaker">
|
||||
<div class="breaker-name">预留断路器2</div>
|
||||
<div class="breaker-controls">
|
||||
<button onclick="sendCommand('meter_bus', 'reserve2', 'close')">闭合</button>
|
||||
<button onclick="sendCommand('meter_bus', 'reserve2', 'open')">断开</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="breaker">
|
||||
<div class="breaker-name">应急锂电池组2断路器</div>
|
||||
<div class="breaker-controls">
|
||||
<button onclick="sendCommand('meter_bus', 'emergency_battery2', 'close')">闭合</button>
|
||||
<button onclick="sendCommand('meter_bus', 'emergency_battery2', 'open')">断开</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="column">
|
||||
<div class="column-title">艏低压设备</div>
|
||||
<!-- 艏低压断路器列表 -->
|
||||
<div class="breaker">
|
||||
<div class="breaker-name">UNIT1断路器</div>
|
||||
<div class="breaker-controls">
|
||||
<button onclick="sendCommand('bow_low_vol', 'unit1', 'close')">闭合</button>
|
||||
<button onclick="sendCommand('bow_low_vol', 'unit1', 'open')">断开</button>
|
||||
</div>
|
||||
<div id="bow_low_vol-status-message" class="status-message"></div>
|
||||
</div>
|
||||
<div class="breaker">
|
||||
<div class="breaker-name">UNIT2断路器</div>
|
||||
<div class="breaker-controls">
|
||||
<button onclick="sendCommand('bow_low_vol', 'unit2', 'close')">闭合</button>
|
||||
<button onclick="sendCommand('bow_low_vol', 'unit2', 'open')">断开</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="breaker">
|
||||
<div class="breaker-name">UNIT3断路器</div>
|
||||
<div class="breaker-controls">
|
||||
<button onclick="sendCommand('bow_low_vol', 'unit3', 'close')">闭合</button>
|
||||
<button onclick="sendCommand('bow_low_vol', 'unit3', 'open')">断开</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="breaker">
|
||||
<div class="breaker-name">UNIT5断路器</div>
|
||||
<div class="breaker-controls">
|
||||
<button onclick="sendCommand('bow_low_vol', 'unit5', 'close')">闭合</button>
|
||||
<button onclick="sendCommand('bow_low_vol', 'unit5', 'open')">断开</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="breaker">
|
||||
<div class="breaker-name">艏部PZ装置断路器</div>
|
||||
<div class="breaker-controls">
|
||||
<button onclick="sendCommand('bow_low_vol', 'bow_pz', 'close')">闭合</button>
|
||||
<button onclick="sendCommand('bow_low_vol', 'bow_pz', 'open')">断开</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="breaker">
|
||||
<div class="breaker-name">预留断路器1</div>
|
||||
<div class="breaker-controls">
|
||||
<button onclick="sendCommand('bow_low_vol', 'reserve1', 'close')">闭合</button>
|
||||
<button onclick="sendCommand('bow_low_vol', 'reserve1', 'open')">断开</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="breaker">
|
||||
<div class="breaker-name">预留断路器2</div>
|
||||
<div class="breaker-controls">
|
||||
<button onclick="sendCommand('bow_low_vol', 'reserve2', 'close')">闭合</button>
|
||||
<button onclick="sendCommand('bow_low_vol', 'reserve2', 'open')">断开</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="breaker">
|
||||
<div class="breaker-name">应急锂电池组1断路器</div>
|
||||
<div class="breaker-controls">
|
||||
<button onclick="sendCommand('bow_low_vol', 'emergency_battery1', 'close')">闭合</button>
|
||||
<button onclick="sendCommand('bow_low_vol', 'emergency_battery1', 'open')">断开</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function sendCommand(type, id, action, value) {
|
||||
fetch('/control', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ device_type: type, device_id: id, action: action, value: value })
|
||||
})
|
||||
.then(res => res.json())
|
||||
.then(data => {
|
||||
const el = document.getElementById(type + '-status-message');
|
||||
if (data.success) {
|
||||
el.textContent = data.message || '操作成功';
|
||||
el.className = 'status-message status-success';
|
||||
} else {
|
||||
el.textContent = data.message || '操作失败';
|
||||
el.className = 'status-message status-error';
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
)row";
|
||||
#endif // HTTP_SERVER_DASHBOARD_H
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "httpserver.h"
|
||||
#include "index.h"
|
||||
#include "dashboard.h"
|
||||
#include "../PowerManger.h"
|
||||
#include "mongoose.h"
|
||||
#include <iostream>
|
||||
@@ -59,6 +60,40 @@ void HttpServer::handleWebSocketEvent(struct mg_connection* c, int ev, void* ev_
|
||||
LOG_F(INFO, "Upgrading to WebSocket: id=%lu fd=%d", c->id, c->fd);
|
||||
mg_ws_upgrade(c, hm, nullptr);
|
||||
LOG_F(INFO, "WebSocket upgrade completed: id=%lu fd=%d", c->id, 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());
|
||||
} else if (mg_match(hm->uri, mg_str("/control"), NULL)) {
|
||||
// 处理断路器控制请求
|
||||
if (mg_strcmp(hm->method, mg_str("POST")) == 0) {
|
||||
// 解析JSON请求
|
||||
char *device_type = mg_json_get_str(hm->body, "$.device_type");
|
||||
char *device_id = mg_json_get_str(hm->body, "$.device_id");
|
||||
char *action = mg_json_get_str(hm->body, "$.action");
|
||||
|
||||
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);
|
||||
|
||||
// 模拟随机成功或失败 (70%成功率)
|
||||
bool success = (rand() % 10) < 7;
|
||||
const char *message = success ? "操作成功" : "操作失败";
|
||||
|
||||
// 返回JSON响应
|
||||
mg_http_reply(c, 200, "Content-Type: application/json\r\n",
|
||||
"{\"success\": %s, \"message\": \"%s\"}",
|
||||
success ? "true" : "false", message);
|
||||
} else {
|
||||
mg_http_reply(c, 400, "Content-Type: text/plain\r\n", "Invalid request");
|
||||
}
|
||||
// 释放分配的内存
|
||||
if (device_type) free(device_type);
|
||||
if (device_id) free(device_id);
|
||||
if (action) free(action);
|
||||
} else {
|
||||
mg_http_reply(c, 405, "Content-Type: text/plain\r\n", "Method Not Allowed");
|
||||
}
|
||||
} else {
|
||||
// 返回主页HTML
|
||||
mg_http_reply(c, 200, "Content-Type: text/html; charset=utf-8\r\n", INDEX_HTML.c_str());
|
||||
@@ -225,8 +260,33 @@ void HttpServer::pushSystemData() {
|
||||
j["dyn_power_limit2"] = Json::Value(m_systemData->dyn_power_limit2); // 动力电池2功率限制值
|
||||
|
||||
//设备在线状态
|
||||
j["device_online_flag1"] = Json::Value(m_systemData->device_online_flag1);
|
||||
j["device_online_flag2"] = Json::Value(m_systemData->device_online_flag2);
|
||||
j["device_onile"]["device_online_flag1"] = Json::Value(m_systemData->device_online_flag1);
|
||||
j["device_onile"]["device_online_flag2"] = Json::Value(m_systemData->device_online_flag2);
|
||||
|
||||
j["device_onile"]["ins_online_state"] = Json::Value(m_systemData->device_online_status.ins_online_state); // 仪表锂电在线标志位
|
||||
j["device_onile"]["dyn_online_state"] = Json::Value(m_systemData->device_online_status.dyn_online_state); // 动力锂电在线标志位
|
||||
j["device_onile"]["fuel_online_state"] = Json::Value(m_systemData->device_online_status.fuel_online_state); // 燃电锂电在线标志位
|
||||
j["device_onile"]["high_voltage_online_state"] = Json::Value(m_systemData->device_online_status.high_voltage_online_state); // 高压配电板在线标志位
|
||||
j["device_onile"]["low_voltage_online_state"] = Json::Value(m_systemData->device_online_status.low_voltage_online_state); // 低压配电板在线标志位
|
||||
j["device_onile"]["composite_online_state"] = Json::Value(m_systemData->device_online_status.composite_online_state); // 复合管控主机在线标志位
|
||||
j["device_onile"]["composite_backup_online_state"] = Json::Value(m_systemData->device_online_status.composite_backup_online_state); // 复合管控备机在线标志位
|
||||
|
||||
//通信状态
|
||||
//ccu状态
|
||||
j["comm_state"]["ccu_status"]["isTimeout"] = Json::Value(m_systemData->device_common_status.ccu_status.isTimeout);
|
||||
j["comm_state"]["ccu_status"]["lastUpdateTime"] = Json::Value(m_systemData->device_common_status.ccu_status.lastUpdateTime);
|
||||
|
||||
//高压配电状态
|
||||
j["comm_state"]["dis_hv_c1"]["isTimeout"] = Json::Value(m_systemData->device_common_status.dis_hv_c1.isTimeout);
|
||||
j["comm_state"]["dis_hv_c1"]["lastUpdateTime"] = Json::Value(m_systemData->device_common_status.dis_hv_c1.lastUpdateTime);
|
||||
j["comm_state"]["dis_hv_c2"]["isTimeout"] = Json::Value(m_systemData->device_common_status.dis_hv_c2.isTimeout);
|
||||
j["comm_state"]["dis_hv_c2"]["lastUpdateTime"] = Json::Value(m_systemData->device_common_status.dis_hv_c2.lastUpdateTime);
|
||||
|
||||
//低压配电状态
|
||||
j["comm_state"]["dis_lv_c1"]["isTimeout"] = Json::Value(m_systemData->device_common_status.dis_lv_c1.isTimeout);
|
||||
j["comm_state"]["dis_lv_c1"]["lastUpdateTime"] = Json::Value(m_systemData->device_common_status.dis_lv_c1.lastUpdateTime);
|
||||
j["comm_state"]["dis_lv_c2"]["isTimeout"] = Json::Value(m_systemData->device_common_status.dis_lv_c2.isTimeout);
|
||||
j["comm_state"]["dis_lv_c2"]["lastUpdateTime"] = Json::Value(m_systemData->device_common_status.dis_lv_c2.lastUpdateTime);
|
||||
|
||||
//复合管控器心跳计算器
|
||||
j["heartbeat"] = Json::Value(m_systemData->heartbeat);
|
||||
|
||||
@@ -346,6 +346,38 @@ public:
|
||||
float emergency1BusbarVoltage;
|
||||
} instrument_bus_status;
|
||||
|
||||
struct COMMON_STATUS
|
||||
{
|
||||
//超时状态
|
||||
bool isTimeout;
|
||||
//最后更新时间
|
||||
double lastUpdateTime;
|
||||
};
|
||||
|
||||
struct DeviceCommonStatus
|
||||
{
|
||||
COMMON_STATUS ccu_status;
|
||||
COMMON_STATUS dis_hv_c1;
|
||||
COMMON_STATUS dis_hv_c2;
|
||||
COMMON_STATUS dis_lv_c1;
|
||||
COMMON_STATUS dis_lv_c2;
|
||||
} device_common_status;
|
||||
|
||||
struct DeviceOnlineStatus
|
||||
{
|
||||
//在线状态
|
||||
//0x00: 未上线
|
||||
//0x01: 在线
|
||||
//0x02: 上线后掉线
|
||||
uint8_t ins_online_state; //仪表锂电在线标志位
|
||||
uint8_t dyn_online_state; //动力锂电在线标志位
|
||||
uint8_t fuel_online_state; //燃电锂电在线标志位
|
||||
uint8_t high_voltage_online_state; //高压配电板在线标志位
|
||||
uint8_t low_voltage_online_state; //低压配电板在线标志位
|
||||
uint8_t composite_online_state; //复合管控主机在线标志位
|
||||
uint8_t composite_backup_online_state; //复合管控备机在线标志位
|
||||
} device_online_status;
|
||||
|
||||
public:
|
||||
SystemData(){
|
||||
//初始化变量全部为0
|
||||
@@ -353,6 +385,17 @@ public:
|
||||
};
|
||||
~SystemData();
|
||||
|
||||
void updateCommonStatus(double time_out=3){
|
||||
//更新时间
|
||||
double currentTime = MOOSTime();
|
||||
//判断是否超时
|
||||
device_common_status.ccu_status.isTimeout = (currentTime - device_common_status.ccu_status.lastUpdateTime) > time_out;
|
||||
device_common_status.dis_hv_c1.isTimeout = (currentTime - device_common_status.dis_hv_c1.lastUpdateTime) > time_out;
|
||||
device_common_status.dis_hv_c2.isTimeout = (currentTime - device_common_status.dis_hv_c2.lastUpdateTime) > time_out;
|
||||
device_common_status.dis_lv_c1.isTimeout = (currentTime - device_common_status.dis_lv_c1.lastUpdateTime) > time_out;
|
||||
device_common_status.dis_lv_c2.isTimeout = (currentTime - device_common_status.dis_lv_c2.lastUpdateTime) > time_out;
|
||||
};
|
||||
|
||||
void updateSystemData(ccuState data){
|
||||
fc_mode = data.fc_mode;
|
||||
fc_status = data.fc_status;
|
||||
@@ -481,6 +524,16 @@ public:
|
||||
//设备在线状态
|
||||
device_online_flag1 = data.device_online_flag1;
|
||||
device_online_flag2 = data.device_online_flag2;
|
||||
|
||||
//更新设备在线状态
|
||||
device_online_status.ins_online_state = (data.device_online_flag1 >> 0) & 0xFF; // byte0:仪表锂电在线标志位
|
||||
device_online_status.dyn_online_state = (data.device_online_flag1 >> 8) & 0xFF; // byte1:动力锂电在线标志位
|
||||
device_online_status.fuel_online_state = (data.device_online_flag1 >> 16) & 0xFF; // byte2:燃电锂电在线标志位
|
||||
device_online_status.high_voltage_online_state = (data.device_online_flag1 >> 24) & 0xFF; // byte3:高压配电板在线标志位
|
||||
|
||||
device_online_status.low_voltage_online_state = (data.device_online_flag2 >> 0) & 0xFF; // byte0:低压配电板在线标志位
|
||||
device_online_status.composite_online_state = (data.device_online_flag2 >> 8) & 0xFF; // byte1:复合管控主机在线标志位
|
||||
device_online_status.composite_backup_online_state = (data.device_online_flag2 >> 16) & 0xFF; // byte2:复合管控备机在线标志位
|
||||
|
||||
//心跳计数器
|
||||
heartbeat = data.heartbeat;
|
||||
|
||||
Reference in New Issue
Block a user