From 5c8dd51e5733127a9f0abb760dbf1dbb570fa491 Mon Sep 17 00:00:00 2001 From: ZZ Date: Mon, 11 Apr 2022 15:31:51 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E6=9E=90bms=E4=BF=A1=E6=81=AF..?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xhpc/pp/logic/BmsChargingDataLogic.java | 28 +++--- .../com/xhpc/pp/logic/BmsErrorDataLogic.java | 85 +++++++++++++++++++ 2 files changed, 102 insertions(+), 11 deletions(-) diff --git a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/BmsChargingDataLogic.java b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/BmsChargingDataLogic.java index ca449034..6ce9cfa6 100644 --- a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/BmsChargingDataLogic.java +++ b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/BmsChargingDataLogic.java @@ -43,22 +43,28 @@ public class BmsChargingDataLogic implements ServiceLogic { idxStart = 2 + idxStart; String flags2 = HexUtils.toBinaryString(hex.substring(idxStart, 2 + idxStart));//后4检测标识位 idxStart = 0; - String flag = flags1.substring(idxStart, 2 * (++idxStart)); + String flag = flags1.substring(idxStart, 2 + idxStart); + idxStart = 2 + idxStart; String sb = flag.equals("00") ? "正常" : (flag.equals("01") ? "过高" : "正常");//BMS 单体动力蓄电池电压过高/过低 - flag = flags1.substring(idxStart, 2 * (++idxStart)); + flag = flags1.substring(idxStart, 2 + idxStart); + idxStart = 2 + idxStart; String wb = flag.equals("00") ? "正常" : (flag.equals("01") ? "过高" : "正常");//BMS 整车动力蓄电池荷电状态SOC 过高/过低 - flag = flags1.substring(idxStart, 2 * (++idxStart)); + flag = flags1.substring(idxStart, 2 + idxStart); + idxStart = 2 + idxStart; String pbovcurrency = flag.equals("00") ? "正常" : (flag.equals("01") ? "过流" : "不可信状态");//BMS 动力蓄电池充电过电流 - flag = flags1.substring(idxStart, 2 * (++idxStart)); - String pbtemphi = flag.equals("00") ? "正常" : (flag.equals("01") ? "过流" : "不可信状态");//BMS 动力蓄电池温度过高 + flag = flags1.substring(idxStart, 2 + idxStart); + String pbtemphi = flag.equals("00") ? "正常" : (flag.equals("01") ? "过高" : "不可信状态");//BMS 动力蓄电池温度过高 idxStart = 0; - flag = flags1.substring(idxStart, 2 * (++idxStart)); - String pbinsulation = flag.equals("00") ? "正常" : (flag.equals("01") ? "过流" : "不可信状态");//BMS 动力蓄电池绝缘状态 - flag = flags2.substring(idxStart, 2 * (++idxStart)); - String pboconn = flag.equals("00") ? "正常" : (flag.equals("01") ? "过流" : "不可信状态");//BMS 动力蓄电池组输出连接器连接状态 - flag = flags2.substring(idxStart, 2 * (++idxStart)); + flag = flags1.substring(idxStart, 2 + idxStart); + idxStart = 2 + idxStart; + String pbinsulation = flag.equals("00") ? "正常" : (flag.equals("01") ? "不正常" : "不可信状态");//BMS 动力蓄电池绝缘状态 + flag = flags2.substring(idxStart, 2 + idxStart); + idxStart = 2 + idxStart; + String pboconn = flag.equals("00") ? "正常" : (flag.equals("01") ? "不正常" : "不可信状态");//BMS 动力蓄电池组输出连接器连接状态 + flag = flags2.substring(idxStart, 2 + idxStart); + idxStart = 2 + idxStart; String chargingForbidden = flag.equals("00") ? "禁止" : "允许";//充电禁止 - flag = flags2.substring(idxStart, 2 * (++idxStart)); + flag = flags2.substring(idxStart, 2 + idxStart); String reserved = flag;//预留位 //682382A90025808360000100100122041109221317998083600001001001FF57FF56FF85F14D05 diff --git a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/BmsErrorDataLogic.java b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/BmsErrorDataLogic.java index 5895bad2..fded20e8 100644 --- a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/BmsErrorDataLogic.java +++ b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/BmsErrorDataLogic.java @@ -6,6 +6,7 @@ import com.xhpc.pp.mapper.XhpcDeviceMessageMapper; import com.xhpc.pp.tx.ServiceParameter; import com.xhpc.pp.tx.ServiceResult; import com.xhpc.pp.tx.logic.ServiceLogic; +import com.xhpc.pp.utils.HexUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.context.annotation.Lazy; @@ -25,9 +26,93 @@ public class BmsErrorDataLogic implements ServiceLogic { @Override public ServiceResult service(ServiceParameter sp) throws Exception { + String remark = "充电桩与 BMS 充电错误报文"; Map req = sp.getParameters(); + String hex = (String) req.get("hex"); + int idxStart = 60; + String flags1 = HexUtils.toBinaryString(hex.substring(idxStart, 2 + idxStart));//每字节若干检测标识位 + idxStart = 2 + idxStart; + String flags2 = HexUtils.toBinaryString(hex.substring(idxStart, 2 + idxStart)); + idxStart = 2 + idxStart; + String flags3 = HexUtils.toBinaryString(hex.substring(idxStart, 2 + idxStart)); + idxStart = 2 + idxStart; + String flags4 = HexUtils.toBinaryString(hex.substring(idxStart, 2 + idxStart)); + idxStart = 2 + idxStart; + String flags5 = HexUtils.toBinaryString(hex.substring(idxStart, 2 + idxStart)); + idxStart = 2 + idxStart; + String flags6 = HexUtils.toBinaryString(hex.substring(idxStart, 2 + idxStart)); + idxStart = 2 + idxStart; + String flags7 = HexUtils.toBinaryString(hex.substring(idxStart, 2 + idxStart)); + idxStart = 2 + idxStart; + String flags8 = HexUtils.toBinaryString(hex.substring(idxStart, 2 + idxStart)); + idxStart = 0;//1 + String flag = flags1.substring(idxStart, 2 + idxStart); + String spn2560x00 = flag.equals("00") ? "正常" : (flag.equals("01") ? "超时" : "不可信状态");//接收 SPN2560=0x00 的充电机辨识报文超时 + idxStart = 2 + idxStart; + flag = flags1.substring(idxStart, 2 + idxStart); + String spn2560xAA = flag.equals("00") ? "正常" : (flag.equals("01") ? "超时" : "不可信状态");//接收 SPN2560=0xAA 的充电机辨识报文超时 + idxStart = 2 + idxStart; + flag = flags1.substring(idxStart, 4 + idxStart); + String reserved1 = flag;//预留位 + idxStart = 0;//2 + String rectsyncmax = flag.equals("00") ? "正常" : (flag.equals("01") ? "超时" : "不可信状态");//接收充电机的时间同步和充电机最大输出能力报文超时 + idxStart = 2 + idxStart; + flag = flags2.substring(idxStart, 2 + idxStart); + String recchgprepcompl = flag.equals("00") ? "正常" : (flag.equals("01") ? "超时" : "不可信状态");//接收充电机完成充电准备报文超时 + idxStart = 2 + idxStart; + flag = flags2.substring(idxStart, 4 + idxStart); + String reserved2 = flag;//预留位 + idxStart = 0;//3 + flag = flags3.substring(idxStart, 2 + idxStart); + String recchgst = flag.equals("00") ? "正常" : (flag.equals("01") ? "超时" : "不可信状态");//接收充电机充电状态报文超时 + idxStart = 2 + idxStart; + flag = flags3.substring(idxStart, 2 + idxStart); + String recchgstop = flag.equals("00") ? "正常" : (flag.equals("01") ? "超时" : "不可信状态");//接收充电机中止充电报文超时 + idxStart = 2 + idxStart; + flag = flags3.substring(idxStart, 4 + idxStart); + String reserved3 = flag;//预留位 + idxStart = 0; // 4 + flag = flags4.substring(idxStart, 2 + idxStart); + String recchgsum = flag.equals("00") ? "正常" : (flag.equals("01") ? "超时" : "不可信状态");//接收充电机充电统计报文超时 + idxStart = 2 + idxStart; + flag = flags4.substring(idxStart, 6 + idxStart); + String reserved4 = flag;//BMS 其他 + idxStart = 0; // 5 + flag = flags5.substring(idxStart, 2 + idxStart); + String recbmsvid = flag.equals("00") ? "正常" : (flag.equals("01") ? "超时" : "不可信状态");//接收 BMS 和车辆的辨识报文超时 + idxStart = 2 + idxStart; + flag = flags5.substring(idxStart, 6 + idxStart); + String reserved5 = flag;//BMS 其他 + idxStart = 0;//6 + flag = flags6.substring(idxStart, 2 + idxStart); + String recbatarg = flag.equals("00") ? "正常" : (flag.equals("01") ? "超时" : "不可信状态");//接收电池充电参数报文超时 + idxStart = 2 + idxStart; + flag = flags6.substring(idxStart, 2 + idxStart); + String recbmsprecompl = flag.equals("00") ? "正常" : (flag.equals("01") ? "超时" : "不可信状态");//接收 BMS 完成充电准备报文超时 + idxStart = 2 + idxStart; + flag = flags3.substring(idxStart, 4 + idxStart); + String reserved6 = flag;//预留位 + idxStart = 0;//7 + flag = flags7.substring(idxStart, 2 + idxStart); + String recbatsumsts = flag.equals("00") ? "正常" : (flag.equals("01") ? "超时" : "不可信状态");//接收电池充电总状态报文超时 + idxStart = 2 + idxStart; + flag = flags7.substring(idxStart, 2 + idxStart); + String recbmschgreq = flag.equals("00") ? "正常" : (flag.equals("01") ? "超时" : "不可信状态");//接收电池充电要求报文超时 + idxStart = 2 + idxStart; + flag = flags7.substring(idxStart, 2 + idxStart); + String recbmsstopchg = flag.equals("00") ? "正常" : (flag.equals("01") ? "超时" : "不可信状态");//接收 BMS 中止充电报文超时 + idxStart = 2 + idxStart; + flag = flags3.substring(idxStart, 2 + idxStart); + String reserved7 = flag;//预留位 + idxStart = 0;//8 + flag = flags8.substring(idxStart, 2 + idxStart); + String recbumssum = flag.equals("00") ? "正常" : (flag.equals("01") ? "超时" : "不可信状态");//接收 BMS 充电统计报文超时 + idxStart = 2 + idxStart; + flag = flags3.substring(idxStart, 6 + idxStart); + String reserved8 = flag;//预留位 + XhpcDeviceMessage deviceMessage = new XhpcDeviceMessage(); deviceMessage.setType(StationDeviceEnum.PILE.getCode()); deviceMessage.setSerialNumber(sp.getPileNo());