mirror of
https://gitee.com/js-yhsec/energy_storage.git
synced 2026-05-27 18:59:26 +08:00
完成系统管理web端功能,实现系统管理服务端接口,实现登录功能
This commit is contained in:
@@ -2,20 +2,68 @@
|
||||
|
||||
#include "common/Utils.h"
|
||||
|
||||
#include "Config.h"
|
||||
#include "app/Dao.h"
|
||||
#include "app/Device.h"
|
||||
|
||||
void Application::init()
|
||||
{
|
||||
std::thread([=]()
|
||||
{
|
||||
while (!isQuit()) { runThreadMain(); }
|
||||
}).detach();
|
||||
Config::init("assets/config/app.json");
|
||||
|
||||
// 设置数据库配置
|
||||
DaoEntity::setOption(Config::option.database.host,
|
||||
Config::option.database.port,
|
||||
Config::option.database.user,
|
||||
Config::option.database.passwd,
|
||||
Config::option.database.dbname);
|
||||
XLOGI() << "[APP] set database option: host=" << Config::option.database.host
|
||||
<< ", port=" << Config::option.database.port
|
||||
<< ", user=" << Config::option.database.user
|
||||
<< ", dbname=" << Config::option.database.dbname;
|
||||
|
||||
// 连接数据库,读取基础信息
|
||||
|
||||
|
||||
// 读取设备信息,连接设备
|
||||
this->initDevice();
|
||||
std::thread([=]() { runThreadDevice(); }).detach();
|
||||
|
||||
// 创建主业务循环线程
|
||||
std::thread([=]() { runThreadMain(); }).detach();
|
||||
}
|
||||
|
||||
void Application::initDevice()
|
||||
{
|
||||
DaoEntity dao("");
|
||||
std::string sql = "select * from device;";
|
||||
vector<DataFields> result;
|
||||
dao.exec(sql, result);
|
||||
for (auto& fields: result)
|
||||
{
|
||||
Device::add(fields);
|
||||
}
|
||||
}
|
||||
|
||||
void Application::runThreadMain()
|
||||
{
|
||||
static TimeTick tt;
|
||||
tt.elapse(1000);
|
||||
while (!isQuit())
|
||||
{
|
||||
|
||||
//XLOGD() << "HelloWorld";
|
||||
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(1));
|
||||
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(10));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Application::runThreadDevice()
|
||||
{
|
||||
while (!isQuit())
|
||||
{
|
||||
|
||||
|
||||
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(10));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user