添加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

@@ -18,6 +18,8 @@ void Application::init()
// MQTT 数据结构
MqttClient::loadDataStruct("assets/config/registeraddr.json");
// 设备读取寄存器的地址定义
Device::loadParamAddr("assets/config/monitoraddr.json");
// 设置数据库配置
DaoEntity::setOption(Config::option.database.host,
@@ -34,7 +36,7 @@ void Application::init()
// 连接数据库,读取基础信息
// 初始化系统基础数据
appdata.init();
this->isInit = appdata.init();
// 创建设备处理线程
std::thread([=]() { runThreadDevice(); }).detach();
@@ -47,11 +49,11 @@ void Application::init()
}
}).detach();
// 创建主业务循环线程
std::thread([=]() { runThreadMain(); }).detach();
// 统计分析
std::thread([=]() { runThreadStat(); }).detach();
// 创建主业务循环线程
std::thread([=]() { runThreadMain(); }).detach();
}
@@ -71,47 +73,37 @@ void Application::runThreadMain()
while (!isQuit)
{
//// 连接场站
//static TimeTick ttStation;
//if (ttStation.elapse(10000))
//{
// if (!mqttCli->isConnected)
// {
// }
// else
// {
// for (auto& item: appdata.mapStation)
// {
// auto station = item.second;
// if (station && !station->isConnected)
// {
// std::string stationCode = station->code;
// std::vector<std::string> vecTopics = {
// "up/json" + stationCode + "/EMS_YX",
// "up/json" + stationCode + "/EMS_YC",
// "up/json" + stationCode + "/PCU_YX",
// "up/json" + stationCode + "/PCU_YC",
// };
// mqttCli->subscribe(vecTopics, [=](int id)
// {
// station->isConnected = (id == 0);
// });
// }
// break;
// }
// }
//}
if (!this->isInit) // 初始化失败
{
std::this_thread::sleep_for(std::chrono::milliseconds(10000));
this->isInit = appdata.init();
if (!this->isInit) { continue; }
}
static TimeTick ttMqtt;
// 检查 场站的 MQTT 连接
if (ttMqtt.elapse(10))
{
auto& optionMqtt = Config::option.mqtt;
if (!optionMqtt.host.empty())
{
for (auto& item : appdata.mapStation)
{
if (item.second)
{
item.second->initMqtt();
//item.second->polling();
}
}
}
}
///////////////////////////////////////////////////////////////////////////////////////////
/// 召测
static TimeTick tt1;
if (tt1.elapse(10))
{
for (auto& item: appdata.mapStation)
{
auto& station = item.second;
station->polling();
}
}
std::this_thread::sleep_for(std::chrono::milliseconds(10));
}