修改场站策略解析及网关指令下发

This commit is contained in:
lixiaoyuan
2025-09-14 16:00:30 +08:00
parent d1a8fb0665
commit 6418335d9d
14 changed files with 252 additions and 68 deletions

View File

@@ -40,6 +40,9 @@ void Station::setFields(Fields& fields)
this->workModeId = fields.get<int>(DMStation::WORK_MODE);
this->code = fields.value(DMStation::CODE);
this->status = fields.get<int>(DMStation::STATUS);
this->operationDate = fields.value(DMStation::OPERATION_DATE);
this->policy.setFields(fields);
}
void Station::addDevice(int deviceId, std::shared_ptr<Device> device)
@@ -210,7 +213,19 @@ void Station::setGarewayWorkMode()
json["ts"] = Utils::time();
json["no"] = 1; // 设备编号
json["40001"] = this->workModeId;
if (policy.type == 1)
{
json["40002"] = njson::array(); // 峰谷套利
policy.getGatewayJsonPeriods(json["40002"]);
}
else if (policy.type == 5)
{
json["40021"] = njson::array(); // 自定时段
policy.getGatewayJsonPeriods(json["40021"]);
}
std::string text = json.dump();
spdlog::info(text);
mqttCli->publish("Gateway_YT", text);
}
}