1.新增服务端UI界面,显示服务基础信息。2.修改设备显示配置。3.监控页面储能系统显示储能模式,模式设置新增'手动'

This commit is contained in:
lixiaoyuan
2025-09-25 19:20:25 +08:00
parent d7888c2be4
commit 8aba56f47d
39 changed files with 2954 additions and 408 deletions

View File

@@ -25,8 +25,7 @@ bool MqttClient::load(std::string filename)
std::map<std::string, TopicInfo> MqttClient::s_mapTopicInfo;
int MqttClient::init(string addr, string clientId, string username, string password)
{
if (addr.empty())
{ if (addr.empty())
{
return MQTTASYNC_FAILURE;
}
@@ -43,7 +42,7 @@ int MqttClient::init(string addr, string clientId, string username, string passw
int rc {0};
// "tcp://localhost:1883"
std::string str = "ESS-" + std::to_string(Utils::random(1000, 9999)) + "-" +clientId;
std::string str = "ESS-" + clientId + "-" + std::to_string(Utils::time());
rc = MQTTAsync_create(&client, addr.c_str(), str.c_str(), MQTTCLIENT_PERSISTENCE_NONE, NULL);
if (rc != MQTTASYNC_SUCCESS)
{
@@ -303,7 +302,10 @@ int MqttClient::onMessageArrived(char* topic, int topicLen, MQTTAsync_message* m
{
std::string key = item.key();
auto& val = item.value();
if (key == "40001") { station->readGatewayMode(val.get<int>()); }
if (key == "40001")
{
station->readGatewayMode(val.get<int>());
}
//else if (key == "40002") { spdlog::info("[mqtt] read register addr: [{}]={}, {}", key, val.dump(), "峰谷时间段"); }
//else if (key == "40021") { spdlog::info("[mqtt] read register addr: [{}]={}, {}", key, val.dump(), "自定时间段"); }
//else if (key == "40038") { spdlog::info("[mqtt] read register addr: [{}]={}, {}", key, val.dump(), "其他参数"); }
@@ -314,7 +316,7 @@ int MqttClient::onMessageArrived(char* topic, int topicLen, MQTTAsync_message* m
int cdzStatus = -1;
int emuStatus = -1;
JSON::read(json, "cdz", cdzStatus);
JSON::read(json, "emu", cdzStatus);
JSON::read(json, "emu", emuStatus);
station->readGatewayStatus(cdzStatus, emuStatus);
}
else
@@ -391,7 +393,11 @@ void MqttClient::ParseArrivedMessage(njson& json, string command, std::shared_pt
auto addr = iter->first;
auto& regUnit = iter->second;
spdlog::debug("[mqtt] read [{}]={}, {}{}", addr, val, regUnit.name, regUnit.remark);
if (command == "BCU_YC" || command == "BCU_YX")
{
//spdlog::info("[mqtt] read [{}]={}, {}{}", addr, val, regUnit.name, regUnit.remark);
}
if (regUnit.alert && val > 0)
{
station->readAlert(device, addr, val, "[" + command + "]" + regUnit.name + "(" + addr + ")");