mirror of
https://gitee.com/js-yhsec/energy_storage.git
synced 2026-05-27 18:59:26 +08:00
实现QT6启动器,QT版本有qt5升级到qt6
This commit is contained in:
@@ -33,8 +33,6 @@ std::string ElectPeriod::dump()
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void AppData::initFromDB()
|
||||
{
|
||||
auto dao = DaoEntity::create("");
|
||||
@@ -250,10 +248,16 @@ void AppData::init()
|
||||
for (auto& item : mapStation)
|
||||
{
|
||||
auto& station = item.second;
|
||||
// "tcp://localhost:1883"
|
||||
station->mqttCli->init(optionMqtt.host, station->code, optionMqtt.username, optionMqtt.password);
|
||||
|
||||
if (station->status == 1)
|
||||
{
|
||||
// "tcp://localhost:1883"
|
||||
station->mqttCli->init(optionMqtt.host, station->code, optionMqtt.username, optionMqtt.password);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this->launchDate = Config::option.lunchDate;
|
||||
}
|
||||
|
||||
std::shared_ptr<Station> AppData::getStation(int stationId)
|
||||
|
||||
@@ -109,7 +109,7 @@ public:
|
||||
public:
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// === 系统 ===
|
||||
int64_t sysActivationTime {};
|
||||
std::string launchDate;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// === 数据库 ===
|
||||
|
||||
@@ -117,7 +117,8 @@ void Application::runThreadStat()
|
||||
int64_t delta = tTime-tDate;
|
||||
int n = delta / 600;
|
||||
int offset = delta % 600;
|
||||
if (delta >=0 && delta < 86400 && offset <= 10 && n != nCachePos)
|
||||
bool flagStore = (delta >=0 && delta < 86400 && offset <= 10 && n != nCachePos);
|
||||
if (flagStore)
|
||||
{
|
||||
nCachePos = n;
|
||||
std::string dt = Utils::dateStr(tDate);
|
||||
@@ -128,7 +129,7 @@ void Application::runThreadStat()
|
||||
}
|
||||
else
|
||||
{
|
||||
spdlog::info("保存历史数据倒计时: {}", 600 - offset);
|
||||
//spdlog::info("保存历史数据倒计时: {}", 600 - offset);
|
||||
}
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
|
||||
}
|
||||
|
||||
@@ -22,11 +22,11 @@ bool Config::init(std::string filename)
|
||||
if (jsonroot.contains("database"))
|
||||
{
|
||||
njson json = jsonroot.at("database");
|
||||
option.database.host = json.contains("host") ? json.at("host") : "";
|
||||
option.database.port = json.contains("port") ? json.at("port") : 0;
|
||||
option.database.user = json.contains("user") ? json.at("user") : "";
|
||||
option.database.passwd = json.contains("passwd") ? json.at("passwd") : "";
|
||||
option.database.dbname = json.contains("dbname") ? json.at("dbname") : "";
|
||||
JSON::read(json, "host", option.database.host);
|
||||
JSON::read(json, "port", option.database.port);
|
||||
JSON::read(json, "user", option.database.user);
|
||||
JSON::read(json, "passwd", option.database.passwd);
|
||||
JSON::read(json, "dbname", option.database.dbname);
|
||||
|
||||
spdlog::info("[config] parse database success. host={}", option.database.host);
|
||||
}
|
||||
@@ -60,10 +60,8 @@ bool Config::init(std::string filename)
|
||||
spdlog::info("[config] parse mqtt failed: not found.");
|
||||
}
|
||||
|
||||
if (jsonroot.contains("weburl"))
|
||||
{
|
||||
JSON::read(jsonroot, "weburl", option.webSrvUrl);
|
||||
}
|
||||
JSON::read(jsonroot, "weburl", option.webSrvUrl);
|
||||
JSON::read(jsonroot, "launchdate", option.lunchDate);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -27,6 +27,7 @@ struct AppOption
|
||||
} mqtt;
|
||||
|
||||
std::string webSrvUrl;
|
||||
std::string lunchDate;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -182,9 +182,49 @@ void Device::storeDB(int npos)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void Device::setParam(std::string k, std::string v)
|
||||
{
|
||||
mapParams[k] = v;
|
||||
|
||||
if (type == 3 ) // 电表
|
||||
{
|
||||
if (k == "") this->err = Utils::toInt(v);
|
||||
}
|
||||
else if (type == 101) // EMS
|
||||
{
|
||||
}
|
||||
else if (type == 102) // PCS
|
||||
{
|
||||
if (k == "0x1003") err = Utils::toInt(v); // 故障状态 R uint16 1故障,0正常 0 0x1003
|
||||
if (k == "0x1005") online = Utils::toInt(v); // 设备在线 R uint16 1在线,0无效 1 0x1005
|
||||
if (k == "0x1009") running = (v=="1" || v=="2"); //充放状态 R uint16 0:待机, 1:充电, 2:放电, 3:搁置 0 0x1009
|
||||
}
|
||||
else if (type == 103) // PCU
|
||||
{
|
||||
if (k == "0x1002") err = Utils::toInt(v); //故障状态 R uint16 1故障,0正常 0 0x1002
|
||||
if (k == "0x1004") online = Utils::toInt(v); //设备在线 R uint16 1在线,0无效 1 0x1004
|
||||
if (k == "0x1006") running = Utils::toInt(v); //启停状态 R uint16 1开机,0关机 1 0x1006
|
||||
}
|
||||
else if (type == 104) // BMS
|
||||
{
|
||||
if (k == "0x004A") { err = (v=="1"); online = 1; } //运行状态 R uint16 0 运行状态 0-正常 1-告警 2-保护 0x004A
|
||||
if (k == "0x004B") running = (v=="1" || v=="2"); //充放电状态 R uint16 0 0-待机 1-充电 2-放电 0x004B
|
||||
}
|
||||
else if (type == 105) // BCU
|
||||
{
|
||||
if (k == "0xA003") running = (v=="51" || v=="68"); //蓄电池充放电状态 R uint16 "0x11开路,0x22待机,0x33充电,0x44放电" 34 0xA003
|
||||
if (k == "0xA004") err = (v=="85"); online=1; //电池组运行状态 R uint16 "0x11跳机,0x22待机,0x33放空,0x44充满,0x55预警,0x66正常" 102 0xA004
|
||||
}
|
||||
else if (type == 106) // 充电桩
|
||||
{
|
||||
}
|
||||
else if (type == 109) // 光伏板
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
std::string Device::getParam(std::string k, std::string defaultVal)
|
||||
@@ -197,6 +237,7 @@ std::string Device::getParam(std::string k, std::string defaultVal)
|
||||
return defaultVal;
|
||||
}
|
||||
|
||||
|
||||
void Device::getRuntimeParams(std::vector<std::pair<std::string, std::string>>& params)
|
||||
{
|
||||
// 3 电表
|
||||
@@ -208,35 +249,70 @@ void Device::getRuntimeParams(std::vector<std::pair<std::string, std::string>>&
|
||||
// 106 充电桩
|
||||
// 109 光伏板
|
||||
|
||||
|
||||
if (this->type == 3)
|
||||
{
|
||||
params.push_back({"A相电压", getParam("0x000B", "0.0") + "V"});
|
||||
params.push_back({"B相电压", getParam("0x000D", "0.0") + "V"});
|
||||
params.push_back({"C相电压", getParam("0x000F", "0.0") + "V"});
|
||||
params.push_back({"A相电流", getParam("0x0011", "0.0") + "A"});
|
||||
params.push_back({"B相电流", getParam("0x0013", "0.0") + "A"});
|
||||
params.push_back({"C相电流", getParam("0x0015", "0.0") + "A"});
|
||||
params.push_back({"A相电压", getParam("0x000B", "0.0") + " V"});
|
||||
params.push_back({"A相电流", getParam("0x000D", "0.0") + " A"});
|
||||
params.push_back({"B相电压", getParam("0x000F", "0.0") + " V"});
|
||||
params.push_back({"B相电流", getParam("0x0011", "0.0") + " A"});
|
||||
params.push_back({"C相电压", getParam("0x0013", "0.0") + " V"});
|
||||
params.push_back({"C相电流", getParam("0x0015", "0.0") + " A"});
|
||||
}
|
||||
else if (this->type == 101)
|
||||
else if (this->type == 101) // EMS
|
||||
{
|
||||
params.push_back({"额定电压", getParam("0x0001", "0.0") + "V"});
|
||||
params.push_back({"实时电压", getParam("0x0001", "0.0") + "V"});
|
||||
params.push_back({"额定电流", getParam("0x0001", "0.0") + "A"});
|
||||
params.push_back({"实时电流", getParam("0x0001", "0.0") + "A"});
|
||||
params.push_back({"额定功率", getParam("0x0001", "0.0") + "kW"});
|
||||
params.push_back({"实时功率", getParam("0x0001", "0.0") + "A"});
|
||||
params.push_back({"A相电压", getParam("0x107E", "0.0") + " V"});
|
||||
params.push_back({"A相电流", getParam("0x1084", "0.0") + " A"});
|
||||
params.push_back({"B相电压", getParam("0x1080", "0.0") + " V"});
|
||||
params.push_back({"B相电流", getParam("0x1086", "0.0") + " A"});
|
||||
params.push_back({"C相电压", getParam("0x1082", "0.0") + " V"});
|
||||
params.push_back({"C相电流", getParam("0x1088", "0.0") + " A"});
|
||||
}
|
||||
else if (this->type == 102) // PCS
|
||||
{
|
||||
params.push_back({"A相电压", getParam("0x0010", "0.0") + " V"});
|
||||
params.push_back({"A相电流", getParam("0x0019", "0.0") + " A"});
|
||||
params.push_back({"B相电压", getParam("0x0011", "0.0") + " V"});
|
||||
params.push_back({"B相电流", getParam("0x001A", "0.0") + " A"});
|
||||
params.push_back({"C相电压", getParam("0x0011", "0.0") + " V"});
|
||||
params.push_back({"C相电流", getParam("0x001B", "0.0") + " A"});
|
||||
}
|
||||
else if (this->type == 103) // PCU
|
||||
{
|
||||
params.push_back({"A相电压", getParam("0x0013", "0.0") + " V"});
|
||||
params.push_back({"A相电流", getParam("0x001C", "0.0") + " A"});
|
||||
params.push_back({"B相电压", getParam("0x0014", "0.0") + " V"});
|
||||
params.push_back({"B相电流", getParam("0x001D", "0.0") + " A"});
|
||||
params.push_back({"C相电压", getParam("0x0015", "0.0") + " V"});
|
||||
params.push_back({"C相电流", getParam("0x001E", "0.0") + " A"});
|
||||
}
|
||||
else if (this->type == 104) // BMS
|
||||
{
|
||||
params.push_back({"SOC", getParam("0x0001", "0") + " %"});
|
||||
params.push_back({"SOH", getParam("0x0002", "0") + " %"});
|
||||
params.push_back({"电压", getParam("0x0003", "0.0") + " V"});
|
||||
params.push_back({"电流", getParam("0x0005", "0.0") + " A"});
|
||||
params.push_back({"单体最大电压", getParam("0x0021", "0.0") + " V"});
|
||||
params.push_back({"单体最小电压", getParam("0x0024", "0.0") + " V"});
|
||||
params.push_back({"单体最大温度", getParam("0x0029", "0.0") + " ℃"});
|
||||
params.push_back({"单体最小温度", getParam("0x002C", "0.0") + " ℃"});
|
||||
}
|
||||
else if (this->type == 105) // BCU
|
||||
{
|
||||
params.push_back({"簇电压", getParam("0x0003", "0.0") + " V"});
|
||||
params.push_back({"簇电流", getParam("0x0005", "0") + " A"});
|
||||
params.push_back({"簇温度", getParam("0x0007", "0.0") + " ℃"});
|
||||
params.push_back({"簇电阻", getParam("0x0009", "0.0") + " Ω"});
|
||||
params.push_back({"簇SOC", getParam("0x000B", "0") + " %"});
|
||||
params.push_back({"簇SOH", getParam("0x000C", "0") + " %"});
|
||||
}
|
||||
//else if (this->type == 101)
|
||||
//{
|
||||
|
||||
//}
|
||||
else
|
||||
{
|
||||
params.push_back({"额定电压", getParam("0x0001", "0.0") + "V"});
|
||||
params.push_back({"实时电压", getParam("0x0001", "0.0") + "V"});
|
||||
params.push_back({"额定电流", getParam("0x0001", "0.0") + "A"});
|
||||
params.push_back({"实时电流", getParam("0x0001", "0.0") + "A"});
|
||||
params.push_back({"额定功率", getParam("0x0001", "0.0") + "kW"});
|
||||
params.push_back({"实时功率", getParam("0x0001", "0.0") + "A"});
|
||||
params.push_back({"额定电压", getParam("0x0001", "0.0") + " V"});
|
||||
params.push_back({"实时电压", getParam("0x0001", "0.0") + " V"});
|
||||
params.push_back({"额定电流", getParam("0x0001", "0.0") + " A"});
|
||||
params.push_back({"实时电流", getParam("0x0001", "0.0") + " A"});
|
||||
params.push_back({"额定功率", getParam("0x0001", "0.0") + " W"});
|
||||
params.push_back({"实时功率", getParam("0x0001", "0.0") + " W"});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ void Station::setFields(Fields& fields)
|
||||
this->energyCapacity = fields.get<double>(DMStation::CAPACITY);
|
||||
this->workModeId = fields.get<int>(DMStation::WORK_MODE);
|
||||
this->code = fields.value(DMStation::CODE);
|
||||
this->status = fields.get<int>(DMStation::STATUS);
|
||||
}
|
||||
|
||||
void Station::addDevice(int deviceId, std::shared_ptr<Device> device)
|
||||
|
||||
@@ -113,6 +113,7 @@ public:
|
||||
int stationId {};
|
||||
std::string name;
|
||||
std::string code;
|
||||
int status {0};
|
||||
bool isConnected {false};
|
||||
|
||||
int workModeId {}; // 运行模式
|
||||
|
||||
Reference in New Issue
Block a user