实现服务端的QT应用界面

This commit is contained in:
lixiaoyuan
2025-09-24 19:06:31 +08:00
parent 0abb4e54f1
commit d7888c2be4
26 changed files with 435 additions and 173 deletions

View File

@@ -218,6 +218,7 @@ int MqttClient::polling()
}
}
}
tsPolling = Utils::time();
return 0;
}
@@ -256,6 +257,7 @@ void MqttClient::onConnectSuccess( MQTTAsync_successData* resp)
spdlog::info("[mqtt] connect to {} success, clientId={}.", addr, clientId);
this->isConnected = true;
this->subscribe();
this->polling();
}
void MqttClient::onConnectFaiure(MQTTAsync_failureData* resp)
@@ -302,9 +304,9 @@ 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>()); }
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(), "其他参数"); }
//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(), "其他参数"); }
}
}
else if (command == "Gateway_YX")
@@ -388,13 +390,13 @@ 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 (regUnit.alert && val > 0)
{
station->readAlert(device, addr, val, "[" + command + "]" + regUnit.name + "(" + addr + ")");
}
device->setParam(addr, val);
spdlog::debug("[mqtt] read [{}]={}, {}{}", addr, val, regUnit.name, regUnit.remark);
if (command == "MEM_YC") { station->readRuntimeData(deviceNo, addr, val); }
else if (command == "Fire40_YX") { station->readFire40Data(deviceNo, addr, val); }