From 9c51037aa184b81bfff23c2a8fa7ae2562d80163 Mon Sep 17 00:00:00 2001 From: lixiaoyuan Date: Mon, 25 May 2026 15:07:33 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9EMS=E8=BF=90=E8=A1=8C?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E6=A0=87=E8=AF=86=E5=88=A4=E6=96=AD=E6=96=B9?= =?UTF-8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/Device.cpp | 15 ++++++++++++++- src/app/Device.h | 4 +--- src/app/Station.cpp | 22 +++++++++++++++++++--- src/protocol/HttpEntity.cpp | 6 +++--- web/src/components/Home/Map.vue | 6 +++--- web/src/components/Home/TotalStation.vue | 2 +- 6 files changed, 41 insertions(+), 14 deletions(-) diff --git a/src/app/Device.cpp b/src/app/Device.cpp index 7c8acb6..0ba7c8d 100644 --- a/src/app/Device.cpp +++ b/src/app/Device.cpp @@ -236,13 +236,26 @@ void Device::setParam(std::string k, int v) } mapParams[k] = valStr; - if (type == 3 ) // 电表 + if (type == int(EDeviceType::E_METER)) // 电表 { running = 1; } else if (type == int(EDeviceType::EMS)) // 101 EMS { running = 1; + // EMS 没有总的故障状态标识,需要对多有的故障状态位进行判断 + err = (mapParams["0x2001"] != "0") || (mapParams["0x2002"] != "0") || + (mapParams["0x2006"] != "0") || (mapParams["0x2007"] != "0") || + (mapParams["0x200B"] != "0") || (mapParams["0x200C"] != "0") || + (mapParams["0x200E"] != "0") || (mapParams["0x200F"] != "0") || + (mapParams["0x2010"] != "0") || (mapParams["0x2011"] != "0") || + (mapParams["0x2013"] != "0") || (mapParams["0x2014"] != "0") || + (mapParams["0x2018"] != "0") || (mapParams["0x2019"] != "0") || + (mapParams["0x201A"] != "0") || (mapParams["0x201B"] != "0") || + (mapParams["0x201C"] != "0") || (mapParams["0x201D"] != "0") || + (mapParams["0x201E"] != "0") || (mapParams["0x201F"] != "0") || + (mapParams["0x2020"] != "0") || (mapParams["0x2021"] != "0") || + (mapParams["0x2022"] != "0"); } else if (type == int(EDeviceType::PCS)) // 102 PCS { diff --git a/src/app/Device.h b/src/app/Device.h index 5799a8e..eb47216 100644 --- a/src/app/Device.h +++ b/src/app/Device.h @@ -42,8 +42,6 @@ public: void setBCUUnit(std::string k, int pos, int v, int count); public: - - int stationId = {0}; int deviceId = {0}; int type = {0}; @@ -66,7 +64,7 @@ public: // 通讯entity std::shared_ptr commEntity; - int64_t tsDataDate {}; + //std::map mapCacheVoltage; //std::map mapCacheCurrent; //std::map mapCachePower; diff --git a/src/app/Station.cpp b/src/app/Station.cpp index e48ab28..62463ec 100644 --- a/src/app/Station.cpp +++ b/src/app/Station.cpp @@ -426,6 +426,12 @@ void Station::readBMSData(int deviceNo, string addr, int val) if (addr == "0x0003") { this->storage.voltage = val * 0.1; } // ["电压", "0x0003", "0.0", " V", "0.1"], else if (addr == "0x0005") { this->storage.current = val * 0.1; } // ["电流", "0x0005", "0.0", " A", "0.1"] , else if (addr == "0x000F") { this->storage.power = val; } // ["堆功率", "0x000F", "0.0", " kW"] , + else if (addr == "0x004A") // 0-待机 1-充电 2-放电 + { + if (val == 0) this->storage.status = 1; + else if (val == 1) this->storage.status = 2; + else if (val == 2) this->storage.status = 3; + } } // 充电桩 @@ -576,6 +582,8 @@ void Station::readGatewayMode(int deviceNo, int mode, string p1, string p2, stri } } +/// "CDZ": 1, //充电桩 1:在线,0:离线 +/// "EMU": 1, //储能 1:在线,0:离线 void Station::readGatewayStatus(int deviceNo, int cdzStatus, int emuStatus, int tamStatus) { auto device = this->getDeviceByType(int(EDeviceType::GATEWAY), Utils::toStr(deviceNo)); @@ -627,7 +635,7 @@ void Station::readGatewayStatus(int deviceNo, int cdzStatus, int emuStatus, int } } -static void DeviceReadJsonArray(std::shared_ptr device, njson& json, string key) +static bool DeviceReadJsonArray(std::shared_ptr device, njson& json, string key) { if (json.contains(key)) { @@ -636,7 +644,9 @@ static void DeviceReadJsonArray(std::shared_ptr device, njson& json, str { device->setParam(key + std::to_string(i+1), vecd[i]); } + return true; } + return false; } void Station::readTDData(int deviceNo, string str) @@ -659,8 +669,14 @@ void Station::readTDData(int deviceNo, string str) DeviceReadJsonArray(device, json, "P"); DeviceReadJsonArray(device, json, "Ep"); // 正向总、尖、峰、平、谷电能 DeviceReadJsonArray(device, json, "En"); // 反向总、尖、峰、平、谷电能 - DeviceReadJsonArray(device, json, "EpTo"); // 当日正向总、尖、峰、平、谷电能 - DeviceReadJsonArray(device, json, "EnTo"); // 当日反向总、尖、峰、平、谷电能 + if (!DeviceReadJsonArray(device, json, "EpTo")) // 当日正向总、尖、峰、平、谷电能 + { + for (int i = 0; i<5; i++) { device->setParam("EpTo" + std::to_string(i+1), 0); } + } + if (!DeviceReadJsonArray(device, json, "EnTo")) // 当日反向总、尖、峰、平、谷电能 + { + for (int i = 0; i<5; i++) { device->setParam("EnTo" + std::to_string(i+1), 0); } + } } static std::string MapValueToJson(int npos, std::map& mapV) diff --git a/src/protocol/HttpEntity.cpp b/src/protocol/HttpEntity.cpp index aa7131e..587f4d8 100644 --- a/src/protocol/HttpEntity.cpp +++ b/src/protocol/HttpEntity.cpp @@ -1344,7 +1344,7 @@ static string GetStationStatusStr(int status) { if (status == 1) return "空闲"; else if (status == 2) return "充电"; - else if (status == 2) return "放电"; + else if (status == 3) return "放电"; else if (status == 9) return "故障"; else return "离线"; } @@ -1845,9 +1845,9 @@ Errcode HttpEntity::queryEnvironment(const httplib::Request& req, njson& json, s nodearray.push_back({{"pos", "警铃是否使用"}, {"status", unit.usedAlarm == 0 ? "否" : "是"}}); nodearray.push_back({{"pos", "警铃状态"}, {"status", mapStatusDef[unit.statusAlarm]}}); // 0:无效 1:掉线 2:正常 3:启动 nodearray.push_back({{"pos", "瓶头阀是否使用"}, {"status", unit.usedValve == 0 ? "否" : "是"}}); - nodearray.push_back({{"pos", "瓶头阀状态"}, {"status", mapStatusDef[unit.statusAlarm]}}); // 0:无效 1:掉线 2:正常 3:启动 + nodearray.push_back({{"pos", "瓶头阀状态"}, {"status", mapStatusDef[unit.statusValve]}}); // 0:无效 1:掉线 2:正常 3:启动 nodearray.push_back({{"pos", "手报是否使用"}, {"status", unit.usedMCP == 0 ? "否" : "是"}}); - nodearray.push_back({{"pos", "手报状态"}, {"status", mapStatusDef[unit.statusAlarm]}}); // 0:无效 1:掉线 2:正常 3:启动 + nodearray.push_back({{"pos", "手报状态"}, {"status", mapStatusDef[unit.statusMCP]}}); // 0:无效 1:掉线 2:正常 3:启动 break; } jsondata["fire40"] = nodearray; diff --git a/web/src/components/Home/Map.vue b/web/src/components/Home/Map.vue index c27940b..3f058b0 100644 --- a/web/src/components/Home/Map.vue +++ b/web/src/components/Home/Map.vue @@ -97,9 +97,9 @@ export default { this.markers = res.data.map((item) => { return { ...item, - iconMap: (item.err === "1") - ? require('../../assets/home/homeIcon.png') - : require('../../assets/home/homeIcon1.png') + iconMap: (item.err === "0") + ? require('../../assets/home/homeIcon1.png') + : require('../../assets/home/homeIcon.png') } }) } else { diff --git a/web/src/components/Home/TotalStation.vue b/web/src/components/Home/TotalStation.vue index 7b3aaa6..da1ba0c 100644 --- a/web/src/components/Home/TotalStation.vue +++ b/web/src/components/Home/TotalStation.vue @@ -85,7 +85,7 @@ export default { item.value = newVal[item.key] || (item.d ? 0 : '') if (item.value === '离线' || item.value === '故障') item.color = '#f08080' else if (item.value === '空闲') item.color = '#f0f0a0' - else if (item.value === '充电' || item.value === '放电' || item.value === '发电') item.color = '#f0f0a0' + else if (item.value === '充电' || item.value === '放电' || item.value === '发电') item.color = '#a0f0a0' }) } },