实现启动splash画面,实现天历史数据的处理和数据库存贮

This commit is contained in:
lixiaoyuan
2025-09-09 19:26:05 +08:00
parent 5c94e2098a
commit b2338f21b0
29 changed files with 426 additions and 71 deletions

View File

@@ -49,6 +49,9 @@ void Application::init()
// 创建主业务循环线程
std::thread([=]() { runThreadMain(); }).detach();
// 统计分析
std::thread([=]() { runThreadStat(); }).detach();
}
@@ -56,7 +59,7 @@ void Application::runThreadDevice()
{
while (!isQuit)
{
std::this_thread::sleep_for(std::chrono::milliseconds(10));
std::this_thread::sleep_for(std::chrono::milliseconds(100));
}
}
@@ -101,4 +104,32 @@ void Application::runThreadMain()
std::this_thread::sleep_for(std::chrono::milliseconds(10));
}
}
void Application::runThreadStat()
{
int nCachePos = 0;
while (!isQuit)
{
int64_t tTime = Utils::time();
int64_t tDate = Utils::date();
int64_t delta = tTime-tDate;
int n = delta / 600;
int offset = delta % 600;
if (delta >=0 && delta < 86400 && offset <= 10 && n != nCachePos)
{
nCachePos = n;
std::string dt = Utils::dateStr(tDate);
for (auto item: appdata.mapStation)
{
item.second->writeRuntimeData(dt, nCachePos);
}
}
else
{
spdlog::info("保存历史数据倒计时: {}", 600 - offset);
}
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
}
}