From fc96f14e99883fa4bf127931b9871a0d55e7cfd5 Mon Sep 17 00:00:00 2001 From: ZZ Date: Mon, 11 Apr 2022 11:47:34 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E6=9E=90bms=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E5=90=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xhpc/pp/logic/BmsChargingDataLogic.java | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) 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 85a72517..ca449034 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 @@ -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; @@ -26,7 +27,41 @@ public class BmsChargingDataLogic implements ServiceLogic { public ServiceResult service(ServiceParameter sp) throws Exception { Map req = sp.getParameters(); + String hex = (String) req.get("hex"); + int idxStart = 60; + int hibsn = Integer.parseInt(hex.substring(idxStart, 2 + idxStart), 16);//BMS 最高单体动力蓄电池电压所在编号 + idxStart = 2 + idxStart; + int hibtemp = Integer.parseInt(hex.substring(idxStart, 2 + idxStart), 16) - 50;//BMS 最高动力蓄电池温度 + idxStart = 2 + idxStart; + int hibtempchkpt = Integer.parseInt(hex.substring(idxStart, 2 + idxStart), 16);//最高温度检测点编号 + idxStart = 2 + idxStart; + int lobtemp = Integer.parseInt(hex.substring(idxStart, 2 + idxStart), 16) - 50;//最低动力蓄电池温度 + idxStart = 2 + idxStart; + int lobtempchkpt = Integer.parseInt(hex.substring(idxStart, 2 + idxStart), 16);//最低动力蓄电池温度检测点编号 + idxStart = 2 + idxStart; + String flags1 = HexUtils.toBinaryString(hex.substring(idxStart, 2 + idxStart));//前4检测标识位 + idxStart = 2 + idxStart; + String flags2 = HexUtils.toBinaryString(hex.substring(idxStart, 2 + idxStart));//后4检测标识位 + idxStart = 0; + String flag = flags1.substring(idxStart, 2 * (++idxStart)); + String sb = flag.equals("00") ? "正常" : (flag.equals("01") ? "过高" : "正常");//BMS 单体动力蓄电池电压过高/过低 + flag = flags1.substring(idxStart, 2 * (++idxStart)); + String wb = flag.equals("00") ? "正常" : (flag.equals("01") ? "过高" : "正常");//BMS 整车动力蓄电池荷电状态SOC 过高/过低 + flag = flags1.substring(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 动力蓄电池温度过高 + 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)); + String chargingForbidden = flag.equals("00") ? "禁止" : "允许";//充电禁止 + flag = flags2.substring(idxStart, 2 * (++idxStart)); + String reserved = flag;//预留位 + //682382A90025808360000100100122041109221317998083600001001001FF57FF56FF85F14D05 XhpcDeviceMessage deviceMessage = new XhpcDeviceMessage(); deviceMessage.setType(StationDeviceEnum.PILE.getCode()); deviceMessage.setSerialNumber(sp.getPileNo());