添加QT的webengineview开发者调试功能

This commit is contained in:
lixiaoyuan
2025-09-13 17:28:35 +08:00
parent 7f23138d9c
commit d1a8fb0665
18 changed files with 653 additions and 218 deletions

View File

@@ -28,7 +28,7 @@ void MqttClient::loadDataStruct(std::string filename)
for (auto& jsonitem : json.items())
{
std::string name = jsonitem.key();
auto jsonnodeItem = jsonitem.value();
auto& jsonnodeItem = jsonitem.value();
//int count = jsonnodeItem["count"];
auto jsonaddrs = jsonnodeItem["addr"];
@@ -56,25 +56,34 @@ void MqttClient::loadDataStruct(std::string filename)
int MqttClient::init(string addr, string clientId, string username, string password)
{
if (isConnected)
{
return MQTTASYNC_SUCCESS;
}
if (addr.empty())
{
return MQTTASYNC_FAILURE;
}
this->addr = addr;
this->clientId = clientId;
//this->mapTopicInfo["EMS_YX"] = TopicInfo("EMS_YX", 101);
//this->mapTopicInfo["EMS_YC"] = TopicInfo("EMS_YC", 101);
//this->mapTopicInfo["EMS_YT"] = TopicInfo("EMS_YT", 101);
//this->mapTopicInfo["PCS_YX"] = TopicInfo("PCS_YX", 102, 1);
this->mapTopicInfo["EMS_YX"] = TopicInfo("EMS_YX", 101);
this->mapTopicInfo["EMS_YC"] = TopicInfo("EMS_YC", 101);
this->mapTopicInfo["EMS_YT"] = TopicInfo("EMS_YT", 101);
this->mapTopicInfo["PCS_YX"] = TopicInfo("PCS_YX", 102, 1);
this->mapTopicInfo["PCS_YC"] = TopicInfo("PCS_YC", 102, 1);
//this->mapTopicInfo["PCU_YX"] = TopicInfo("PCU_YX", 103);
//this->mapTopicInfo["PCU_YC"] = TopicInfo("PCU_YC", 103);
//this->mapTopicInfo["BMS_YX"] = TopicInfo("BMS_YX", 104);
//this->mapTopicInfo["BMS_YC"] = TopicInfo("BMS_YC", 104);
//this->mapTopicInfo["BCU_YX"] = TopicInfo("BCU_YX", 105, 1);
//this->mapTopicInfo["BCU_YC"] = TopicInfo("BCU_YC", 105, 1);
//this->mapTopicInfo["MEM_YC"] = TopicInfo("MEM_YC", 3);
//this->mapTopicInfo["Cooling_YC"] = TopicInfo("Cooling_YC", 110);
//this->mapTopicInfo["TH_YC"] = TopicInfo("TH_YC", 111);
//this->mapTopicInfo["Gateway_YX"] = TopicInfo("Gateway_YX", 112);
//this->mapTopicInfo["Charger_YC"] = TopicInfo("Charger_YC", 113);
this->mapTopicInfo["PCU_YX"] = TopicInfo("PCU_YX", 103);
this->mapTopicInfo["PCU_YC"] = TopicInfo("PCU_YC", 103);
this->mapTopicInfo["BMS_YX"] = TopicInfo("BMS_YX", 104);
this->mapTopicInfo["BMS_YC"] = TopicInfo("BMS_YC", 104);
this->mapTopicInfo["BCU_YX"] = TopicInfo("BCU_YX", 105, 1);
this->mapTopicInfo["BCU_YC"] = TopicInfo("BCU_YC", 105, 1);
this->mapTopicInfo["MEM_YC"] = TopicInfo("MEM_YC", 3);
this->mapTopicInfo["Cooling_YC"] = TopicInfo("Cooling_YC", 110);
this->mapTopicInfo["TH_YC"] = TopicInfo("TH_YC", 111);
this->mapTopicInfo["Gateway_YX"] = TopicInfo("Gateway_YX", 112);
this->mapTopicInfo["Charger_YC"] = TopicInfo("Charger_YC", 113);
MQTTAsync_connectOptions option = MQTTAsync_connectOptions_initializer;
MQTTAsync_message pubmsg = MQTTAsync_message_initializer;
@@ -176,6 +185,10 @@ void MqttClient::subscribe()
{
spdlog::error("[mqtt] subscribe [{},{}] failed, err={}", topic, qos, rc);
}
else
{
spdlog::info("[mqtt] subscribe [{},{}] ", topic, qos);
}
}
}
@@ -332,8 +345,8 @@ int MqttClient::onMessageArrived(char* topic, int topicLen, MQTTAsync_message* m
if (iter != mapRegInfo.end())
{
auto addr = iter->first;
std::string val = JSON::toStr(data[i]);
spdlog::info("[mqtt] read register addr: [{}]={}, {}", addr, val, iter->second.remark);
auto& val = data[i];
//spdlog::info("[mqtt] read register addr: [{}]={}, {}", addr, val, iter->second.remark);
device->setParam(addr, val);
++iter;
}
@@ -341,11 +354,11 @@ int MqttClient::onMessageArrived(char* topic, int topicLen, MQTTAsync_message* m
}
else if (data.is_number())
{
device->setParam(key, Utils::toStr(data.get<int>()));
device->setParam(key, data.get<int>());
}
else if (data.is_string())
{
device->setParam(key, Utils::toStr(data.get<int>()));
device->setParam(key, Utils::toInt(data.get<std::string>()));
}
}
}