解析bms信息吧

This commit is contained in:
ZZ 2022-04-11 11:47:34 +08:00
parent aa1c7f7a9f
commit fc96f14e99

View File

@ -6,6 +6,7 @@ import com.xhpc.pp.mapper.XhpcDeviceMessageMapper;
import com.xhpc.pp.tx.ServiceParameter; import com.xhpc.pp.tx.ServiceParameter;
import com.xhpc.pp.tx.ServiceResult; import com.xhpc.pp.tx.ServiceResult;
import com.xhpc.pp.tx.logic.ServiceLogic; import com.xhpc.pp.tx.logic.ServiceLogic;
import com.xhpc.pp.utils.HexUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Lazy; import org.springframework.context.annotation.Lazy;
@ -26,7 +27,41 @@ public class BmsChargingDataLogic implements ServiceLogic {
public ServiceResult service(ServiceParameter sp) throws Exception { public ServiceResult service(ServiceParameter sp) throws Exception {
Map<String, Object> req = sp.getParameters(); Map<String, Object> 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(); XhpcDeviceMessage deviceMessage = new XhpcDeviceMessage();
deviceMessage.setType(StationDeviceEnum.PILE.getCode()); deviceMessage.setType(StationDeviceEnum.PILE.getCode());
deviceMessage.setSerialNumber(sp.getPileNo()); deviceMessage.setSerialNumber(sp.getPileNo());