mirror of
https://gitee.com/js-yhsec/energy_storage.git
synced 2026-05-27 18:59:26 +08:00
新增台区电表(新设备类型)数据解析
This commit is contained in:
@@ -248,10 +248,11 @@ static map<int, string> mapPeriodOper =
|
||||
string Station::getGatewayParam()
|
||||
{
|
||||
stringstream ss;
|
||||
std::string str1 = std::format("运行模式:{}<br>储能EMY状态:{}<br>充电桩状态:{}<br><br>",
|
||||
std::string str1 = std::format("运行模式:{}<br>储能EMU状态:{}<br>充电桩状态:{}<br>台区电表状态:{}<br><br>",
|
||||
getGatewayMode(),
|
||||
this->emuStatus == 1 ? "在线" : (this->emuStatus == 0 ? "离线" : "--"),
|
||||
this->cdzStatus == 1 ? "在线" : (this->cdzStatus == 0 ? "离线" : "--"));
|
||||
this->cdzStatus == 1 ? "在线" : (this->cdzStatus == 0 ? "离线" : "--"),
|
||||
this->tamStatus == 1 ? "在线" : (this->tamStatus == 0 ? "离线" : "--"));
|
||||
str1 += "峰谷套利时段:<br>";
|
||||
{
|
||||
njson json;
|
||||
@@ -354,6 +355,7 @@ void Station::readAlert(std::shared_ptr<Device> device, std::string addr, int v,
|
||||
fields.set("log_id", Snowflake::instance().getIdStr());
|
||||
if (device) { fields.set("device_id", device->deviceId); }
|
||||
fields.set("type", int(EAlertType::DEVICE));
|
||||
fields.set("errcode", addr);
|
||||
fields.set("content", text + ":故障(" + std::to_string(v) + ")");
|
||||
fields.set("status", 0);
|
||||
auto dao = DaoEntity::create("log_alert");
|
||||
@@ -542,7 +544,7 @@ void Station::readGatewayMode(int deviceNo, int mode, string p1, string p2, stri
|
||||
}
|
||||
}
|
||||
|
||||
void Station::readGatewayStatus(int deviceNo, int cdzStatus, int emuStatus)
|
||||
void Station::readGatewayStatus(int deviceNo, int cdzStatus, int emuStatus, int tamStatus)
|
||||
{
|
||||
auto device = this->getDeviceByType(int(EDeviceType::GATEWAY), Utils::toStr(deviceNo));
|
||||
if (device)
|
||||
@@ -553,6 +555,7 @@ void Station::readGatewayStatus(int deviceNo, int cdzStatus, int emuStatus)
|
||||
|
||||
if (cdzStatus == 0) charge.status = 0;
|
||||
else if (charge.status == 0) charge.status = 1;
|
||||
|
||||
if (emuStatus == 0) storage.status = 0;
|
||||
else if (storage.status == 0) storage.status = 1;
|
||||
|
||||
@@ -578,6 +581,52 @@ void Station::readGatewayStatus(int deviceNo, int cdzStatus, int emuStatus)
|
||||
this->emuStatus = emuStatus;
|
||||
}
|
||||
}
|
||||
|
||||
//台区电表 1:在线,0:离线
|
||||
if (tamStatus >= 0)
|
||||
{
|
||||
if (tamStatus != this->tamStatus)
|
||||
{
|
||||
std::string text = "场站[" + name + "(" + std::to_string(stationId) + ")]台区电表状态变化:" + (tamStatus > 0 ? "在线" : "离线");
|
||||
if (this->tamStatus < 0) { text = "系统启动," + text; }
|
||||
DAO::insertSystemLogDevice(stationId, 0, text, tamStatus);
|
||||
this->tamStatus = tamStatus;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void DeviceReadJsonArray(std::shared_ptr<Device> device, njson& json, string key)
|
||||
{
|
||||
if (json.contains(key))
|
||||
{
|
||||
vector<int> vecd = json[key].get<std::vector<int>>();
|
||||
for (int i = 0; i <= vecd.size(); ++i)
|
||||
{
|
||||
device->setParam(key + std::to_string(i+1), vecd[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Station::readTDData(int deviceNo, string str)
|
||||
{
|
||||
njson json;
|
||||
bool ret = JSON::parse(str, json);
|
||||
if (!ret)
|
||||
{
|
||||
spdlog::error("TD_YC parse error: json={}", str);
|
||||
return;
|
||||
}
|
||||
auto device = this->getDeviceByType(int(EDeviceType::E_METER_TD), Utils::toStr(deviceNo));
|
||||
if (!device)
|
||||
{
|
||||
spdlog::error("TD_YC parse error, get device failed, deviceNo={}, json={}", deviceNo, str);
|
||||
return;
|
||||
}
|
||||
DeviceReadJsonArray(device, json, "U");
|
||||
DeviceReadJsonArray(device, json, "I");
|
||||
DeviceReadJsonArray(device, json, "P");
|
||||
DeviceReadJsonArray(device, json, "Ep");
|
||||
DeviceReadJsonArray(device, json, "En");
|
||||
}
|
||||
|
||||
static std::string MapValueToJson(int npos, std::map<int, float>& mapV)
|
||||
|
||||
Reference in New Issue
Block a user