mirror of
https://gitee.com/js-yhsec/energy_storage.git
synced 2026-05-27 18:59:26 +08:00
修改策略管理
This commit is contained in:
@@ -686,6 +686,7 @@ Errcode HttpEntity::updateStation(const httplib::Request& req, njson& json, std:
|
||||
}
|
||||
}
|
||||
}
|
||||
// 发送指令到网关
|
||||
if (params.contains("station_id") && params.contains("work_mode"))
|
||||
{
|
||||
int stationId = params.get<int>("station_id");
|
||||
@@ -694,6 +695,53 @@ Errcode HttpEntity::updateStation(const httplib::Request& req, njson& json, std:
|
||||
if (station)
|
||||
{
|
||||
station->setGarewayWorkMode();
|
||||
// 根据 work_mode 到数据库查询策略信息
|
||||
std::string sql = std::format("select * from policy where `type`='{}'", workmode);
|
||||
std::vector<Fields> result;
|
||||
int ret = DaoEntity::execOnce(sql, result);
|
||||
if (result.size() > 0)
|
||||
{
|
||||
auto& item = result[0];
|
||||
std::string valJson = item.value("value");
|
||||
|
||||
njson json = njson::parse(valJson);
|
||||
if (json.is_object())
|
||||
{
|
||||
// 设置 station 的网关参数,然后调用 setGarewayParams 向网关发送指令
|
||||
if (workmode == 6)
|
||||
{
|
||||
if (json.contains("soc_min")) { station->gatewayParam.socMin = Utils::toFloat(json["soc_min"])*100; }
|
||||
if (json.contains("soc_max")) { station->gatewayParam.socMax = Utils::toFloat(json["soc_max"])*100; }
|
||||
}
|
||||
else if (workmode == 7)
|
||||
{
|
||||
//if (json.contains("charge")) { station->gatewayParam.powerCharge = json["charge"].get<float>(); }
|
||||
//if (json.contains("discharge")) { station->gatewayParam.powerDischarge = json["discharge"].get<float>(); }
|
||||
}
|
||||
else if (workmode == 8)
|
||||
{
|
||||
if (json.contains("charge")) { station->gatewayParam.powerCharge = Utils::toInt(json["charge"]); }
|
||||
if (json.contains("discharge")) { station->gatewayParam.powerDischarge = Utils::toInt(json["discharge"]); }
|
||||
if (json.contains("power_reverse")) { station->gatewayParam.backflow = Utils::toInt(json["power_reverse"]); }
|
||||
}
|
||||
else if (workmode == 9)
|
||||
{
|
||||
if (json.contains("charge")) { station->gatewayParam.powerCharge = Utils::toInt(json["charge"]); }
|
||||
if (json.contains("discharge")) { station->gatewayParam.powerDischarge = Utils::toInt(json["discharge"]); }
|
||||
}
|
||||
}
|
||||
//station->setGarewayParams();
|
||||
}
|
||||
|
||||
////params.get("work_mode", station->workMode);
|
||||
//ps.get("soc_min", station->gatewayParam.socMin); // 储能放电下限值 SOC 40038 (%, 0-99)
|
||||
//ps.get("soc_max", station->gatewayParam.socMax); // 储能充电上限值 SOC 40039 (%:1-100)
|
||||
//ps.get("capacity", station->gatewayParam.capacity); // 台区变压器容量 40040 (KVA 160-1600)
|
||||
//ps.get("power_safe", station->gatewayParam.powerSafe); // 安全输入功率 40041 (KW 0-400)
|
||||
//ps.get("power_discharge", station->gatewayParam.powerDischarge); // 储能最大放电功率 40042 (1KW 0-150)
|
||||
//ps.get("power_charge", station->gatewayParam.powerCharge); // 储能最大充电功率 40043 (1KW 0-150)
|
||||
//ps.get("backflow", station->gatewayParam.backflow); // 防逆流回差 40058(1KW 10-300)
|
||||
//ps.get("overload", station->gatewayParam.overload); // 防过载回差 40059(1KW 10-300)
|
||||
}
|
||||
}
|
||||
return err;
|
||||
|
||||
@@ -51,6 +51,8 @@ public:
|
||||
|
||||
Errcode queryStationList(const httplib::Request& req, njson& json, std::string& errmsg);
|
||||
Errcode insertStation(const httplib::Request& req, njson& json, std::string& errmsg);
|
||||
|
||||
// 参数中有work_mode时,发送指令到网关
|
||||
Errcode updateStation(const httplib::Request& req, njson& json, std::string& errmsg);
|
||||
Errcode deleteStation(const httplib::Request& req, njson& json, std::string& errmsg);
|
||||
|
||||
@@ -125,6 +127,7 @@ public:
|
||||
Errcode updateServiceApi(const httplib::Request& req, njson& json, std::string& errmsg);
|
||||
Errcode deleteServiceApi(const httplib::Request& req, njson& json, std::string& errmsg);
|
||||
|
||||
// 更新网关参数
|
||||
Errcode updateGatewayParams(const httplib::Request& req, njson& json, std::string& errmsg);
|
||||
|
||||
/// ===========================================================================================
|
||||
|
||||
Reference in New Issue
Block a user