mirror of
https://gitee.com/js-yhsec/energy_storage.git
synced 2026-05-27 18:59:26 +08:00
修改运行监控显示信息,提交electron代码
This commit is contained in:
@@ -207,15 +207,69 @@ void Station::setGarewayWorkMode()
|
||||
string Station::getGatewayMode()
|
||||
{
|
||||
// 0:手动,1:峰谷套利,2:增网配容,3:应急供电,4:并网保电,5:自定时段
|
||||
if (workModeGateway == 0) { return "手动"; }
|
||||
else if (workModeGateway == 1) { return "峰谷套利"; }
|
||||
else if (workModeGateway == 2) { return "增网配容"; }
|
||||
else if (workModeGateway == 3) { return "应急供电"; }
|
||||
else if (workModeGateway == 4) { return "并网保电"; }
|
||||
else if (workModeGateway == 5) { return "自定时段"; }
|
||||
if (gatewayParam.mode == 0) { return "手动"; }
|
||||
else if (gatewayParam.mode == 1) { return "峰谷套利"; }
|
||||
else if (gatewayParam.mode == 2) { return "增网配容"; }
|
||||
else if (gatewayParam.mode == 3) { return "应急供电"; }
|
||||
else if (gatewayParam.mode == 4) { return "并网保电"; }
|
||||
else if (gatewayParam.mode == 5) { return "自定时段"; }
|
||||
else { return "--"; };
|
||||
}
|
||||
|
||||
static map<int, string> mapPeriodType =
|
||||
{
|
||||
{1, "谷"}, {2, "平"}, {3, "峰"}, {4, "尖"}
|
||||
};
|
||||
static map<int, string> mapPeriodOper =
|
||||
{
|
||||
{0, "停"}, {1, "充"}, {2, "充"}, {3, "放"}, {4, "放"}
|
||||
};
|
||||
|
||||
string Station::getGatewayParam()
|
||||
{
|
||||
stringstream ss;
|
||||
std::string str1 = "峰谷套利时段:<br>";
|
||||
std::string str2 = "自定时段:<br>";
|
||||
{
|
||||
njson json;
|
||||
if (JSON::parse(gatewayParam.param1, json))
|
||||
{
|
||||
for (int i = 0; i<json.size(); ++i)
|
||||
{
|
||||
str1 += "    " + std::to_string(i+1) + "月: ";
|
||||
|
||||
ss.str("");
|
||||
for (auto& jsonitem : json[i])
|
||||
{
|
||||
ss << "(" << setw(2) << setfill('0') << jsonitem[0].get<int>();
|
||||
ss << ":" << setw(2) << setfill('0') << jsonitem[1].get<int>() << " ";
|
||||
ss << mapPeriodType[jsonitem[2].get<int>()] << ") ";
|
||||
}
|
||||
str1 += ss.str() + "<br>";
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
njson json;
|
||||
if (JSON::parse(gatewayParam.param2, json))
|
||||
{
|
||||
for (int i = 0; i<json.size(); ++i)
|
||||
{
|
||||
str2 += "    时段" + std::to_string(i+1) + ": ";
|
||||
ss.str("");
|
||||
for (auto& jsonitem : json[i])
|
||||
{
|
||||
ss << "(" << setw(2) << setfill('0') << jsonitem[0].get<int>();
|
||||
ss << ":" << setw(2) << setfill('0') << jsonitem[1].get<int>() << " ";
|
||||
ss << mapPeriodOper[jsonitem[2].get<int>()] << ") ";
|
||||
}
|
||||
str2 += ss.str() + "<br>";
|
||||
}
|
||||
}
|
||||
}
|
||||
return str1 + "<br/>" + str2;
|
||||
}
|
||||
|
||||
void Station::checkDevice()
|
||||
{
|
||||
for (auto& item: mapDevice)
|
||||
@@ -263,14 +317,37 @@ void Station::readRuntimeData(int deviceNo, string addr, int val)
|
||||
statData.ts = Utils::time();
|
||||
if (addr == "0x002F") { statData.dayElectIn = val; } //日充电电量 R uint32 1kWh 0x002F
|
||||
else if (addr == "0x0031") { statData.dayElectOut = val; } //日放电电量 R uint32 1kWh 0x0031
|
||||
else if (addr == "0x0033") { statData.dayFeeIn = val; } //日充电费用 R uint32 1RMB 0x0033
|
||||
else if (addr == "0x0033") { statData.dayFeeIn = val; } //日充电费用 R uint32 1RMB 0x0033
|
||||
else if (addr == "0x0035") { statData.dayFeeOut = val; } //日放电费用 R uint32 1RMB 0x0035
|
||||
else if (addr == "0x0037") { statData.dayIncome = val; } //日收益 R int32 1RMB 0x0037
|
||||
else if (addr == "0x004D") { statData.totalElectIn = val; } //总充电电量 R uint32 1kWh 0x004D
|
||||
else if (addr == "0x004F") { statData.totalElectOut = val; } //总放电电量 R uint32 1kWh 0x004F
|
||||
else if (addr == "0x0051") { statData.totalFeeIn = val; } //总充电费用 R uint32 1RMB 0x0051
|
||||
else if (addr == "0x0053") { statData.totalFeeOut = val; } //总放电费用 R uint32 1RMB 0x0053
|
||||
else if (addr == "0x0051") { statData.totalFeeIn = val; } //总充电费用 R uint32 1RMB 0x0051
|
||||
else if (addr == "0x0053") { statData.totalFeeOut = val; } //总放电费用 R uint32 1RMB 0x0053
|
||||
else if (addr == "0x0055") { statData.totalIncome = val; } //总收益 R int32 1RMB 0x0055
|
||||
|
||||
else if (addr == "0x0039") { statData.dayElectIn_J = val; } //日正向尖有功电能 R uint32 1kWh 0x0039
|
||||
else if (addr == "0x003B") { statData.dayElectIn_F = val; } //日正向峰有功电能 R uint32 1kWh 0x003B
|
||||
else if (addr == "0x003D") { statData.dayElectIn_P = val; } //日正向平有功电能 R uint32 1kWh 0x003D
|
||||
else if (addr == "0x003F") { statData.dayElectIn_G = val; } //日正向谷有功电能 R uint32 1kWh 0x003F
|
||||
else if (addr == "0x0041") { statData.dayElectIn_Total = val; } //日正向总有功电能 R uint32 1kWh 0x0041
|
||||
|
||||
else if (addr == "0x0043") { statData.dayElectOut_J = val; } //日反向尖有功电能 R uint32 1kWh 0x0043
|
||||
else if (addr == "0x0045") { statData.dayElectOut_F = val; } //日反向峰有功电能 R uint32 1kWh 0x0045
|
||||
else if (addr == "0x0047") { statData.dayElectOut_P = val; } //日反向平有功电能 R uint32 1kWh 0x0047
|
||||
else if (addr == "0x0049") { statData.dayElectOut_G = val; } //日反向谷有功电能 R uint32 1kWh 0x0049
|
||||
else if (addr == "0x004B") { statData.dayElectOut_Total = val; } //日反向总有功电能 R uint32 1kWh 0x004B
|
||||
|
||||
else if (addr == "0x0057") { statData.totalElectIn_J = val; } //总正向尖有功电能 R uint32 1kWh 0x0057
|
||||
else if (addr == "0x0059") { statData.totalElectIn_F = val; } //总正向峰有功电能 R uint32 1kWh 0x0059
|
||||
else if (addr == "0x005B") { statData.totalElectIn_P = val; } //总正向平有功电能 R uint32 1kWh 0x005B
|
||||
else if (addr == "0x005D") { statData.totalElectIn_G = val; } //总正向谷有功电能 R uint32 1kWh 0x005D
|
||||
else if (addr == "0x005F") { statData.totalElectIn_Total = val; } //总正向总有功电能 R uint32 1kWh 0x005F
|
||||
else if (addr == "0x0061") { statData.totalElectOut_J = val; } //总反向尖有功电能 R uint32 1kWh 0x0061
|
||||
else if (addr == "0x0063") { statData.totalElectOut_F = val; } //总反向峰有功电能 R uint32 1kWh 0x0063
|
||||
else if (addr == "0x0065") { statData.totalElectOut_P = val; } //总反向平有功电能 R uint32 1kWh 0x0065
|
||||
else if (addr == "0x0067") { statData.totalElectOut_G = val; } //总反向谷有功电能 R uint32 1kWh 0x0067
|
||||
else if (addr == "0x0069") { statData.totalElectOut_Total = val; } //总反向总有功电能 R uint32 1kWh 0x0069
|
||||
}
|
||||
}
|
||||
|
||||
@@ -342,9 +419,12 @@ void Station::readCoolingData(int deviceNo, string addr, int val)
|
||||
else if (addr == "0x100E") { ; }// 出水压力传感器 R uint16 0:正常,1:告警 0x100E
|
||||
}
|
||||
|
||||
void Station::readGatewayMode(int mode)
|
||||
void Station::readGatewayMode(int mode, string p1, string p2, string p3)
|
||||
{
|
||||
this->workModeGateway = mode;
|
||||
this->gatewayParam.mode = mode;
|
||||
this->gatewayParam.param1 = p1;
|
||||
this->gatewayParam.param2 = p2;
|
||||
this->gatewayParam.param3 = p3;
|
||||
if (mode != this->workMode)
|
||||
{
|
||||
//this->setGarewayWorkMode();
|
||||
@@ -464,34 +544,6 @@ void Station::writeStatistic()
|
||||
|
||||
if (statData.ts > 0)
|
||||
{
|
||||
Fields fields;
|
||||
fields.set("dt", Utils::dateStr(statData.ts));
|
||||
fields.set("station_id", this->stationId);
|
||||
fields.set("device_id", 0);
|
||||
fields.set("elect_in", statData.dayElectIn);
|
||||
fields.set("elect_out", statData.dayElectOut);
|
||||
fields.set("fee_in", statData.dayFeeIn);
|
||||
fields.set("fee_out", statData.dayFeeOut);
|
||||
fields.set("income", statData.dayIncome);
|
||||
//fields.set("num_in", "");
|
||||
//fields.set("num_out", "");
|
||||
//fields.set("num_err", "");
|
||||
//fields.set("t_in", "");
|
||||
//fields.set("t_out", "");
|
||||
//fields.set("usage_rate", "");
|
||||
fields.set("elect_in_total", statData.totalElectIn);
|
||||
fields.set("elect_out_total", statData.totalElectOut);
|
||||
fields.set("fee_in_total", statData.totalFeeIn);
|
||||
fields.set("fee_out_total", statData.totalFeeOut);
|
||||
fields.set("income_total", statData.totalIncome);
|
||||
|
||||
dao->setTableName("stat_storage");
|
||||
std::vector<std::string> vecKeys = {
|
||||
"elect_in", "elect_out", "num_in", "num_out", "num_err", "t_in", "t_out", "usage_rate", "fee_in", "fee_out",
|
||||
"elect_in_total", "elect_out_total", "fee_in_total", "fee_out_total", "income_total"
|
||||
};
|
||||
dao->duplicateUpdate(fields, vecKeys);
|
||||
|
||||
{ // stat_day
|
||||
Fields fields;
|
||||
fields.set("dt", Utils::dateStr(statData.ts));
|
||||
@@ -503,14 +555,54 @@ void Station::writeStatistic()
|
||||
}
|
||||
{
|
||||
Fields fields;
|
||||
fields.set("dt", Utils::dateStr(statData.ts));
|
||||
fields.set("station_id", this->stationId);
|
||||
fields.set("elect_in", statData.dayElectIn);
|
||||
fields.set("elect_out", statData.dayElectOut);
|
||||
fields.set("income", statData.dayIncome);
|
||||
fields.set("E_in", statData.totalElectIn);
|
||||
fields.set("E_in_J", statData.totalElectIn_J);
|
||||
fields.set("E_in_F", statData.totalElectIn_F);
|
||||
fields.set("E_in_P", statData.totalElectIn_P);
|
||||
fields.set("E_in_G", statData.totalElectIn_G);
|
||||
fields.set("E_out", statData.totalElectOut);
|
||||
fields.set("E_out_J", statData.totalElectOut_J);
|
||||
fields.set("E_out_F", statData.totalElectOut_F);
|
||||
fields.set("E_out_P", statData.totalElectOut_P);
|
||||
fields.set("E_out_G", statData.totalElectOut_G);
|
||||
fields.set("fee_in", statData.totalFeeIn);
|
||||
fields.set("fee_Out", statData.totalFeeOut);
|
||||
fields.set("income", statData.totalIncome);
|
||||
dao->setTableName("stat_total");
|
||||
dao->duplicateUpdate(fields, {"elect_in", "elect_out", "income"});
|
||||
}
|
||||
|
||||
dao->duplicateUpdate(fields, {
|
||||
"E_in", "E_in_J", "E_in_F", "E_in_P", "E_in_G",
|
||||
"E_out", "E_out_J", "E_out_F", "E_out_P", "E_out_G",
|
||||
"fee_in", "fee_Out", "income"
|
||||
});
|
||||
}
|
||||
{
|
||||
Fields fields;
|
||||
fields.set("dt", Utils::dateStr(statData.ts));
|
||||
fields.set("station_id", this->stationId);
|
||||
fields.set("E_in", statData.dayElectIn);
|
||||
fields.set("E_in_J", statData.dayElectIn_J);
|
||||
fields.set("E_in_F", statData.dayElectIn_F);
|
||||
fields.set("E_in_P", statData.dayElectIn_P);
|
||||
fields.set("E_in_G", statData.dayElectIn_G);
|
||||
fields.set("E_out", statData.dayElectOut);
|
||||
fields.set("E_out_J", statData.dayElectOut_J);
|
||||
fields.set("E_out_F", statData.dayElectOut_F);
|
||||
fields.set("E_out_P", statData.dayElectOut_P);
|
||||
fields.set("E_out_G", statData.dayElectOut_G);
|
||||
fields.set("fee_in", statData.dayFeeIn);
|
||||
fields.set("fee_Out", statData.dayFeeOut);
|
||||
fields.set("income", statData.dayIncome);
|
||||
dao->setTableName("stat_total_day");
|
||||
|
||||
dao->duplicateUpdate(fields, {
|
||||
"E_in", "E_in_J", "E_in_F", "E_in_P", "E_in_G",
|
||||
"E_out", "E_out_J", "E_out_F", "E_out_P", "E_out_G",
|
||||
"fee_in", "fee_Out", "income"
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
@@ -532,5 +624,4 @@ void Station::writeStatistic()
|
||||
fields.set("value", MapValueToJson(npos, mapCacheElectCharger));
|
||||
dao->duplicateUpdate(fields, {"value"});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user