mirror of
https://gitee.com/js-yhsec/energy_storage.git
synced 2026-05-27 18:59:26 +08:00
实现启动splash画面,实现天历史数据的处理和数据库存贮
This commit is contained in:
@@ -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));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user