mirror of
https://gitee.com/js-yhsec/energy_storage.git
synced 2026-05-27 18:59:26 +08:00
修改设备显示信息的寄存器地址配置文件,修改服务端界面
This commit is contained in:
@@ -218,6 +218,8 @@ static std::map<std::string, HandlerOptions> g_mapHttpHandlerPost
|
||||
|
||||
{"/insertServiceApi", HandlerOptions(&HttpEntity::insertServiceApi, {})},
|
||||
{"/updateServiceApi", HandlerOptions(&HttpEntity::updateServiceApi, {"api_id"})},
|
||||
|
||||
{"/updateGatewayParams", HandlerOptions(&HttpEntity::updateGatewayParams, {DMStation::STATION_ID})},
|
||||
};
|
||||
|
||||
bool CheckHttpToken(const httplib::Request& req)
|
||||
@@ -935,6 +937,14 @@ Errcode HttpEntity::queryDevicByCategory(const httplib::Request& req, njson& jso
|
||||
jsongateway["workmode"] = station->getGatewayMode();
|
||||
jsongateway["emu"] = station->emuStatus == 1 ? "在线" : (station->emuStatus == 0 ? "离线" : "--");
|
||||
jsongateway["cdz"] = station->cdzStatus == 1 ? "在线" : (station->cdzStatus == 0 ? "离线" : "--");
|
||||
jsongateway["soc_min"] = station->gatewayParam.socMin;
|
||||
jsongateway["soc_max"] = station->gatewayParam.socMax;
|
||||
jsongateway["capacity"] = station->gatewayParam.capacity;
|
||||
jsongateway["power_safe"] = station->gatewayParam.powerSafe;
|
||||
jsongateway["power_discharge"] = station->gatewayParam.powerDischarge;
|
||||
jsongateway["power_charge"] = station->gatewayParam.powerCharge;
|
||||
jsongateway["backflow"] = station->gatewayParam.backflow;
|
||||
jsongateway["overload"] = station->gatewayParam.overload;
|
||||
}
|
||||
json["gateway"] = jsongateway;
|
||||
return Errcode::OK;
|
||||
@@ -981,7 +991,7 @@ Errcode HttpEntity::queryDeviceBCUDetail(const httplib::Request& req, njson& jso
|
||||
auto& row = device->vecBCUUnit[i];
|
||||
std::string soc = Utils::toStr(row[0], 1);
|
||||
std::string soh = Utils::toStr(row[1], 1);
|
||||
std::string u = Utils::toStr(row[2], 0);
|
||||
std::string u = Utils::toStr(row[2], 3);
|
||||
std::string t = Utils::toStr(row[3], 2);
|
||||
std::string r_i = Utils::toStr(row[4], 0);
|
||||
jsondata.push_back({{"SOC", soc}, {"SOH", soh}, {"V", u}, {"T", t}, {"R_i", r_i}});
|
||||
@@ -1011,8 +1021,18 @@ Errcode HttpEntity::insertPolicy(const httplib::Request& req, njson& json, std::
|
||||
Errcode HttpEntity::updatePolicy(const httplib::Request& req, njson& json, std::string& errmsg)
|
||||
{
|
||||
Fields params;
|
||||
GetRequestParams(req, {"policy_id", "type", "describe", "value", "is_open"}, params);
|
||||
return DAO::updatePolicyById(params);
|
||||
GetRequestParams(req, {"policy_id", "type", "name", "describe", "value", "is_open"}, params);
|
||||
auto err = DAO::updatePolicyById(params);
|
||||
if (err == Errcode::OK)
|
||||
{
|
||||
int policyId = params.get<int>("policy_id");
|
||||
auto policy = Application::data().getPolicyById(policyId);
|
||||
if (policy)
|
||||
{
|
||||
policy->setFields(params);
|
||||
}
|
||||
}
|
||||
return err;
|
||||
};
|
||||
Errcode HttpEntity::deletePolicy(const httplib::Request& req, njson& json, std::string& errmsg)
|
||||
{
|
||||
@@ -1625,4 +1645,40 @@ Errcode HttpEntity::deleteServiceApi(const httplib::Request& req, njson& json, s
|
||||
Fields params;
|
||||
GetRequestParams(req, {"api_id"}, params);
|
||||
return DAO::remove(NULL, "serviceapi", "api_id", params.value("api_id"));
|
||||
}
|
||||
|
||||
Errcode HttpEntity::updateGatewayParams(const httplib::Request& req, njson& json, std::string& errmsg)
|
||||
{
|
||||
//上下限SOC,安全输入功率,储能最大充放电功率,防逆流防过载回差。
|
||||
Fields params;
|
||||
GetRequestParams(req, {"station_id", "work_mode", "soc_min", "soc_max", "capacity", "power_safe", "power_discharge", "power_charge", "backflow", "overload"}, params);
|
||||
|
||||
int stationId = params.get<int>("station_id");
|
||||
auto station = Application::data().getStation(stationId);
|
||||
|
||||
if (params.contains("work_mode"))
|
||||
{
|
||||
int workMode = params.get<int>("work_mode");
|
||||
Fields fields;
|
||||
fields.set("station_id", params.value("station_id"));
|
||||
fields.set("work_mode", workMode);
|
||||
Errcode err = DAO::updateStationById(params);
|
||||
}
|
||||
|
||||
if (station)
|
||||
{
|
||||
params.get("work_mode", station->workMode);
|
||||
params.get("soc_min", station->gatewayParam.socMin); // 储能放电下限值 SOC 40038 (%, 0-99)
|
||||
params.get("soc_max", station->gatewayParam.socMax); // 储能充电上限值 SOC 40039 (%:1-100)
|
||||
params.get("capacity", station->gatewayParam.capacity); // 台区变压器容量 40040 (KVA 160-1600)
|
||||
params.get("power_safe", station->gatewayParam.powerSafe); // 安全输入功率 40041 (KW 0-400)
|
||||
params.get("power_discharge", station->gatewayParam.powerDischarge); // 储能最大放电功率 40042 (1KW 0-150)
|
||||
params.get("power_charge", station->gatewayParam.powerCharge); // 储能最大充电功率 40043 (1KW 0-150)
|
||||
params.get("backflow", station->gatewayParam.backflow); // 防逆流回差 40058(1KW 10-300)
|
||||
params.get("overload", station->gatewayParam.overload); // 防过载回差 40059(1KW 10-300)
|
||||
|
||||
station->setGarewayWorkMode();
|
||||
return Errcode::OK;
|
||||
}
|
||||
return Errcode::ERR_PARAM;
|
||||
}
|
||||
Reference in New Issue
Block a user