mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-20 11:05:18 +08:00
新增 0x17、0x23报文解析
This commit is contained in:
@@ -2,11 +2,15 @@ package com.jsowell.netty.handler.yunkuaichong;
|
||||
|
||||
import com.jsowell.common.core.domain.ykc.YKCDataProtocol;
|
||||
import com.jsowell.common.core.domain.ykc.YKCFrameTypeCode;
|
||||
import com.jsowell.common.core.redis.RedisCache;
|
||||
import com.jsowell.common.util.BytesUtil;
|
||||
import com.jsowell.common.util.YKCUtils;
|
||||
import com.jsowell.netty.factory.YKCOperateFactory;
|
||||
import com.jsowell.common.core.domain.ykc.BMSDemandAndChargerOutputData;
|
||||
import com.jsowell.pile.service.PileBasicInfoService;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
@@ -19,6 +23,13 @@ import org.springframework.stereotype.Component;
|
||||
@Slf4j
|
||||
@Component
|
||||
public class BMSDemandAndChargerOutputHandler extends AbstractYkcHandler {
|
||||
|
||||
@Autowired
|
||||
private RedisCache redisCache;
|
||||
|
||||
@Autowired
|
||||
private PileBasicInfoService pileBasicInfoService;
|
||||
|
||||
private final String type = YKCUtils.frameType2Str(YKCFrameTypeCode.CHARGING_PROCESS_BMS_DEMAND_AND_CHARGER_OUTPUT_CODE.getBytes());
|
||||
|
||||
@Override
|
||||
@@ -26,6 +37,94 @@ public class BMSDemandAndChargerOutputHandler extends AbstractYkcHandler {
|
||||
YKCOperateFactory.register(type, this);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
String msg = "8823000000259602241208235501743088230000002596023c10ed1202d70d40037201175500e10de3120000";
|
||||
// 获取消息体
|
||||
byte[] msgBody = BytesUtil.str2Bcd(msg);
|
||||
|
||||
int startIndex = 0;
|
||||
int length = 16;
|
||||
|
||||
// 交易流水号
|
||||
byte[] serialNumByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||
String transactionCode = BytesUtil.bcd2Str(serialNumByteArr);
|
||||
|
||||
// 桩编码
|
||||
startIndex += length;
|
||||
length = 7;
|
||||
byte[] pileSnByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||
String pileSn = BytesUtil.bcd2Str(pileSnByteArr);
|
||||
|
||||
// 枪号
|
||||
startIndex += length;
|
||||
length = 1;
|
||||
byte[] pileConnectorNumByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||
String connectorCode = BytesUtil.bcd2Str(pileConnectorNumByteArr);
|
||||
|
||||
// BMS 电压需求 0.1 V/位, 0 V 偏移量
|
||||
startIndex += length;
|
||||
length = 2;
|
||||
byte[] bmsVoltageDemandByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||
String bmsVoltageDemand = String.valueOf(BytesUtil.bytesToIntLittle(bmsVoltageDemandByteArr) * 0.1);
|
||||
|
||||
// BMS 电流需求 0.1 A/位, -400 A 偏移量
|
||||
startIndex += length;
|
||||
byte[] bmsCurrentDemandByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||
String bmsCurrentDemand = String.valueOf(BytesUtil.bytesToIntLittle(bmsCurrentDemandByteArr) * 0.1 - 400);
|
||||
|
||||
// BMS 充电模式 0x01:恒压充电; 0x02:恒流充电
|
||||
startIndex += length;
|
||||
length = 1;
|
||||
byte[] bmsChargingModelByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||
String bmsChargingModel = BytesUtil.bcd2Str(bmsChargingModelByteArr);
|
||||
|
||||
// BMS 充电电压测量值 0.1 V/位, 0 V 偏移量
|
||||
startIndex += length;
|
||||
length = 2;
|
||||
byte[] bmsChargingVoltageByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||
String bmsChargingVoltage = String.valueOf(BytesUtil.bytesToIntLittle(bmsChargingVoltageByteArr) * 0.1);
|
||||
|
||||
// BMS 充电电流测量值 0.1 A/位, -400 A 偏移量
|
||||
startIndex += length;
|
||||
byte[] bmsChargingCurrentByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||
String bmsChargingCurrent = String.valueOf(BytesUtil.bytesToIntLittle(bmsChargingCurrentByteArr) * 0.1 - 400);
|
||||
|
||||
// BMS 最高单体动力蓄电池电压及组号 1-12 位:最高单体动力蓄电池电压, 数据分辨率: 0.01 V/位, 0 V 偏移量;数据范围: 0~24 V; 13-16 位: 最高单体动力蓄电池电 压所在组号,数据分辨率: 1/位, 0 偏移量;数据范围: 0~15
|
||||
startIndex += length;
|
||||
byte[] bmsMaxVoltageAndGroupNum = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||
String bmsMaxVoltageAndGroup = String.valueOf(BytesUtil.bytesToIntLittle(bmsMaxVoltageAndGroupNum) * 0.01);
|
||||
|
||||
// BMS 当前荷电状态 SOC( %) 1%/位, 0%偏移量; 数据范围: 0~100%
|
||||
startIndex += length;
|
||||
length = 1;
|
||||
byte[] socByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||
String soc = BytesUtil.bcd2Str(socByteArr);
|
||||
|
||||
// BMS 估算剩余充电时间 1 min/位, 0 min 偏移量; 数据范围: 0~600 min
|
||||
startIndex += length;
|
||||
length = 2;
|
||||
byte[] bmsTheRestChargingTimeByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||
String bmsTheRestChargingTime = String.valueOf(BytesUtil.bytesToIntLittle(bmsTheRestChargingTimeByteArr));
|
||||
|
||||
// 电桩电压输出值 0.1 V/位, 0 V 偏移量
|
||||
startIndex += length;
|
||||
byte[] pileVoltageOutputByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||
String pileVoltageOutput = String.valueOf(BytesUtil.bytesToIntLittle(pileVoltageOutputByteArr) * 0.1);
|
||||
|
||||
// 电桩电流输出值 0.1 A/位, -400 A 偏移量
|
||||
startIndex += length;
|
||||
byte[] pileCurrentOutputByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||
String pileCurrentOutput = String.valueOf(BytesUtil.bytesToIntLittle(pileCurrentOutputByteArr) * 0.1 - 400);
|
||||
|
||||
// 累计充电时间 1 min/位, 0 min 偏移量; 数据范围: 0~600 min
|
||||
startIndex += length;
|
||||
byte[] chargingTimeByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||
String chargingTime = String.valueOf(BytesUtil.bytesToIntLittle(chargingTimeByteArr));
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] supplyProcess(YKCDataProtocol ykcDataProtocol, ChannelHandlerContext channel) {
|
||||
// log.info("[===充电过程 BMS 需求与充电机输出===] param:{}, channel:{}", JSON.toJSONString(ykcDataProtocol), channel.toString());
|
||||
@@ -37,6 +136,7 @@ public class BMSDemandAndChargerOutputHandler extends AbstractYkcHandler {
|
||||
|
||||
// 交易流水号
|
||||
byte[] serialNumByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||
String transactionCode = BytesUtil.bcd2Str(serialNumByteArr);
|
||||
|
||||
// 桩编码
|
||||
startIndex += length;
|
||||
@@ -51,56 +151,89 @@ public class BMSDemandAndChargerOutputHandler extends AbstractYkcHandler {
|
||||
startIndex += length;
|
||||
length = 1;
|
||||
byte[] pileConnectorNumByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||
String connectorCode = BytesUtil.bcd2Str(pileConnectorNumByteArr);
|
||||
|
||||
// BMS 电压需求 0.1 V/位, 0 V 偏移量
|
||||
startIndex += length;
|
||||
length = 2;
|
||||
byte[] bmsVoltageDemandByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||
String bmsVoltageDemand = String.valueOf(BytesUtil.bytesToIntLittle(bmsVoltageDemandByteArr) * 0.1);
|
||||
|
||||
// BMS 电流需求 0.1 A/位, -400 A 偏移量
|
||||
startIndex += length;
|
||||
byte[] bmsCurrentDemandByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||
String bmsCurrentDemand = String.valueOf(BytesUtil.bytesToIntLittle(bmsCurrentDemandByteArr) * 0.1 - 400);
|
||||
|
||||
// BMS 充电模式 0x01:恒压充电; 0x02:恒流充电
|
||||
startIndex += length;
|
||||
length = 1;
|
||||
byte[] bmsChargingModelByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||
String bmsChargingModel = BytesUtil.bcd2Str(bmsChargingModelByteArr);
|
||||
|
||||
// BMS 充电电压测量值 0.1 V/位, 0 V 偏移量
|
||||
startIndex += length;
|
||||
length = 2;
|
||||
byte[] bmsChargingVoltageByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||
String bmsChargingVoltage = String.valueOf(BytesUtil.bytesToIntLittle(bmsChargingVoltageByteArr) * 0.1);
|
||||
|
||||
// BMS 充电电流测量值 0.1 A/位, -400 A 偏移量
|
||||
startIndex += length;
|
||||
byte[] bmsChargingCurrentByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||
String bmsChargingCurrent = String.valueOf(BytesUtil.bytesToIntLittle(bmsChargingCurrentByteArr) * 0.1 - 400);
|
||||
|
||||
// BMS 最高单体动力蓄电池电压及组号 1-12 位:最高单体动力蓄电池电压, 数据分辨率: 0.01 V/位, 0 V 偏移量;数据范围: 0~24 V; 13-16 位: 最高单体动力蓄电池电 压所在组号,数据分辨率: 1/位, 0 偏移量;数据范围: 0~15
|
||||
startIndex += length;
|
||||
byte[] bmsMaxVoltageAndGroupNum = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||
String bmsMaxVoltageAndGroup = String.valueOf(BytesUtil.bytesToIntLittle(bmsMaxVoltageAndGroupNum) * 0.01);
|
||||
|
||||
// BMS 当前荷电状态 SOC( %) 1%/位, 0%偏移量; 数据范围: 0~100%
|
||||
startIndex += length;
|
||||
length = 1;
|
||||
byte[] socByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||
String soc = BytesUtil.bcd2Str(socByteArr);
|
||||
|
||||
// BMS 估算剩余充电时间 1 min/位, 0 min 偏移量; 数据范围: 0~600 min
|
||||
startIndex += length;
|
||||
length = 2;
|
||||
byte[] bmsTheRestChargingTimeByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||
String bmsTheRestChargingTime = String.valueOf(BytesUtil.bytesToIntLittle(bmsTheRestChargingTimeByteArr));
|
||||
|
||||
// 电桩电压输出值 0.1 V/位, 0 V 偏移量
|
||||
startIndex += length;
|
||||
byte[] pileVoltageOutputByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||
String pileVoltageOutput = String.valueOf(BytesUtil.bytesToIntLittle(pileVoltageOutputByteArr) * 0.1);
|
||||
|
||||
// 电桩电流输出值 0.1 A/位, -400 A 偏移量
|
||||
startIndex += length;
|
||||
byte[] pileCurrentOutputByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||
String pileCurrentOutput = String.valueOf(BytesUtil.bytesToIntLittle(pileCurrentOutputByteArr) * 0.1 - 400);
|
||||
|
||||
// 累计充电时间 1 min/位, 0 min 偏移量; 数据范围: 0~600 min
|
||||
startIndex += length;
|
||||
byte[] chargingTimeByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||
String chargingTime = String.valueOf(BytesUtil.bytesToIntLittle(chargingTimeByteArr));
|
||||
|
||||
// 存入缓存(过期时间 3 天)
|
||||
BMSDemandAndChargerOutputData bmsDemandAndChargerOutputData = BMSDemandAndChargerOutputData.builder()
|
||||
.transactionCode(transactionCode)
|
||||
.pileSn(pileSn)
|
||||
.connectorCode(connectorCode)
|
||||
.bmsVoltageDemand(bmsVoltageDemand)
|
||||
.bmsCurrentDemand(bmsCurrentDemand)
|
||||
.bmsChargingModel(bmsChargingModel)
|
||||
.bmsChargingVoltage(bmsChargingVoltage)
|
||||
.bmsChargingCurrent(bmsChargingCurrent)
|
||||
.bmsMaxVoltageAndGroup(bmsMaxVoltageAndGroup)
|
||||
.soc(soc)
|
||||
.bmsTheRestChargingTime(bmsTheRestChargingTime)
|
||||
.pileVoltageOutput(pileVoltageOutput)
|
||||
.pileCurrentOutput(pileCurrentOutput)
|
||||
.chargingTime(chargingTime)
|
||||
|
||||
.build();
|
||||
|
||||
// 调用方法存入缓存
|
||||
pileBasicInfoService.saveBMSDemandAndChargerOutputInfo2Redis(bmsDemandAndChargerOutputData);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -26,6 +26,113 @@ public class BMSInformationHandler extends AbstractYkcHandler {
|
||||
YKCOperateFactory.register(type, this);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
String msg = "8823000000104502241209160539911188230000001045027c45043e080010";
|
||||
|
||||
byte[] msgBody = BytesUtil.str2Bcd(msg);
|
||||
|
||||
int startIndex = 0;
|
||||
int length = 16;
|
||||
|
||||
// 交易流水号
|
||||
byte[] serialNumByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||
String transactionCode = BytesUtil.bcd2Str(serialNumByteArr);
|
||||
|
||||
// 桩编码
|
||||
startIndex += length;
|
||||
length = 7;
|
||||
byte[] pileSnByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||
String pileSn = BytesUtil.bcd2Str(pileSnByteArr);
|
||||
|
||||
// 枪号
|
||||
startIndex += length;
|
||||
length = 1;
|
||||
byte[] pileConnectorNumByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||
String connectorCode = BytesUtil.bcd2Str(pileConnectorNumByteArr);
|
||||
|
||||
// BMS 最高单体动力蓄电池电压所在编号 1/位, 1 偏移量; 数据范围: 1~256
|
||||
startIndex += length;
|
||||
byte[] BMSMaxVoltageNumByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||
String bmsMaxVoltageNum = String.valueOf(BytesUtil.bytesToIntLittle(BMSMaxVoltageNumByteArr));
|
||||
|
||||
// BMS 最高动力蓄电池温度 1ºC/位, -50 ºC 偏移量;数据范 围: -50 ºC ~+200 ºC
|
||||
startIndex += length;
|
||||
byte[] BMSMaxBatteryTemperatureByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||
String bmsMaxBatteryTemperature = String.valueOf(BytesUtil.bytesToIntLittle(BMSMaxBatteryTemperatureByteArr) - 50);
|
||||
|
||||
// 最高温度检测点编号 1/位, 1 偏移量; 数据范围: 1~128
|
||||
startIndex += length;
|
||||
byte[] maxTemperatureDetectionNumByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||
String maxTemperatureDetectionNum = String.valueOf(BytesUtil.bytesToIntLittle(maxTemperatureDetectionNumByteArr) + 1);
|
||||
|
||||
// 最低动力蓄电池温度 1ºC/位, -50 ºC 偏移量;数据范 围: -50 ºC ~+200 ºC
|
||||
startIndex += length;
|
||||
byte[] minBatteryTemperatureByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||
String minBatteryTemperature = String.valueOf(BytesUtil.bytesToIntLittle(minBatteryTemperatureByteArr) - 50);
|
||||
|
||||
// 最低动力蓄电池温度检测点编号 1/位, 1 偏移量; 数据范围: 1~128
|
||||
startIndex += length;
|
||||
byte[] minTemperatureDetectionNumByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||
String minTemperatureDetectionNum = String.valueOf(BytesUtil.bytesToIntLittle(minTemperatureDetectionNumByteArr) + 1);
|
||||
|
||||
/**
|
||||
* BMS 单体动力蓄电池电压过高 /过低 (<00> :=正常 ; <01> :=过高 ; <10>: =过低)
|
||||
*/
|
||||
startIndex += length;
|
||||
length = 2;
|
||||
byte[] singleBMSVoltageStatusByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||
String singleBMSVoltageStatus = BytesUtil.bcd2Str(singleBMSVoltageStatusByteArr);
|
||||
|
||||
/**
|
||||
* BMS 整车动力蓄电池荷电状态 SOC 过高/过低 (<00> :=正常 ; <01> :=过高 ; <10>: =过低)
|
||||
*/
|
||||
startIndex += length;
|
||||
byte[] carBMSSocStatusByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||
String carBMSSocStatus = BytesUtil.bcd2Str(carBMSSocStatusByteArr);
|
||||
|
||||
/**
|
||||
* BMS 动力蓄电池充电过电流 (<00> :=正常 ; <01> :=过流 ; <10>: =不可信状态)
|
||||
*/
|
||||
startIndex += length;
|
||||
byte[] BMSBatteryChargeCurrentStatusByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||
String bmsBatteryChargeCurrentStatus = BytesUtil.bcd2Str(BMSBatteryChargeCurrentStatusByteArr);
|
||||
|
||||
/**
|
||||
* BMS 动力蓄电池温度过高 (<00> :=正常 ; <01> :=过流 ; <10>: =不可信状态)
|
||||
*/
|
||||
startIndex += length;
|
||||
byte[] BMSBatteryTemperatureByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||
String bmsBatteryTemperature = BytesUtil.bcd2Str(BMSBatteryTemperatureByteArr);
|
||||
|
||||
/**
|
||||
* BMS 动力蓄电池绝缘状态 (<00> :=正常 ; <01> :=过流 ; <10>: =不可信状态)
|
||||
*/
|
||||
startIndex += length;
|
||||
byte[] BMSBatteryInsulationStatusByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||
String bmsBatteryInsulationStatus = BytesUtil.bcd2Str(BMSBatteryInsulationStatusByteArr);
|
||||
|
||||
|
||||
/**
|
||||
* BMS 动力蓄电池组输出连接器连接状态 (<00> :=正常 ; <01> :=过流 ; <10>: =不可信状态)
|
||||
*/
|
||||
startIndex += length;
|
||||
byte[] BMSBatteryOutputStatusByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||
String bmsBatteryOutputStatus = BytesUtil.bcd2Str(BMSBatteryOutputStatusByteArr);
|
||||
|
||||
/**
|
||||
* 充电禁止 (<00>: =禁止; <01>: =允许)
|
||||
*/
|
||||
startIndex += length;
|
||||
byte[] chargeProhibitByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||
String chargeProhibit = BytesUtil.bcd2Str(chargeProhibitByteArr);
|
||||
|
||||
/**
|
||||
* 预留位
|
||||
*/
|
||||
startIndex += length;
|
||||
byte[] noMeanPositionByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] supplyProcess(YKCDataProtocol ykcDataProtocol, ChannelHandlerContext channel) {
|
||||
// log.info("[===充电过程 BMS 信息===] param:{}, channel:{}", JSON.toJSONString(ykcDataProtocol), channel.toString());
|
||||
@@ -37,6 +144,7 @@ public class BMSInformationHandler extends AbstractYkcHandler {
|
||||
|
||||
// 交易流水号
|
||||
byte[] serialNumByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||
String transactionCode = BytesUtil.bcd2Str(serialNumByteArr);
|
||||
|
||||
// 桩编码
|
||||
startIndex += length;
|
||||
@@ -51,46 +159,88 @@ public class BMSInformationHandler extends AbstractYkcHandler {
|
||||
startIndex += length;
|
||||
length = 1;
|
||||
byte[] pileConnectorNumByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||
String connectorCode = BytesUtil.bcd2Str(pileConnectorNumByteArr);
|
||||
|
||||
// BMS 最高单体动力蓄电池电压所在编号 1/位, 1 偏移量; 数据范围: 1~256
|
||||
startIndex += length;
|
||||
byte[] BMSMaxVoltageNumByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||
String bmsMaxVoltageNum = String.valueOf(BytesUtil.bytesToIntLittle(BMSMaxVoltageNumByteArr));
|
||||
|
||||
// BMS 最高动力蓄电池温度 1ºC/位, -50 ºC 偏移量;数据范 围: -50 ºC ~+200 ºC
|
||||
startIndex += length;
|
||||
byte[] BMSMaxBatteryTemperatureByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||
String bmsMaxBatteryTemperature = String.valueOf(BytesUtil.bytesToIntLittle(BMSMaxBatteryTemperatureByteArr) - 50);
|
||||
|
||||
// 最高温度检测点编号 1/位, 1 偏移量; 数据范围: 1~128
|
||||
startIndex += length;
|
||||
byte[] maxTemperatureDetectionNumByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||
String maxTemperatureDetectionNum = String.valueOf(BytesUtil.bytesToIntLittle(maxTemperatureDetectionNumByteArr) + 1);
|
||||
|
||||
// 最低动力蓄电池温度 1ºC/位, -50 ºC 偏移量;数据范 围: -50 ºC ~+200 ºC
|
||||
startIndex += length;
|
||||
byte[] minBatteryTemperature = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||
byte[] minBatteryTemperatureByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||
String minBatteryTemperature = String.valueOf(BytesUtil.bytesToIntLittle(minBatteryTemperatureByteArr) - 50);
|
||||
|
||||
// 最低动力蓄电池温度检测点编号 1/位, 1 偏移量; 数据范围: 1~128
|
||||
startIndex += length;
|
||||
byte[] minTemperatureDetectionNumByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||
String minTemperatureDetectionNum = String.valueOf(BytesUtil.bytesToIntLittle(minTemperatureDetectionNumByteArr) + 1);
|
||||
|
||||
/**
|
||||
* 9-12
|
||||
* 9: BMS 单体动力蓄电池电压过高 /过低 (<00> :=正常 ; <01> :=过高 ; <10>: =过低)
|
||||
* 10: BMS 整车动力蓄电池荷电状态 SOC 过高/过低 (<00> :=正常 ; <01> :=过高 ; <10>: =过低)
|
||||
* 11: BMS 动力蓄电池充电过电流 (<00> :=正常 ; <01> :=过流 ; <10>: =不可信状态)
|
||||
* 12: BMS 动力蓄电池温度过高 (<00> :=正常 ; <01> :=过流 ; <10>: =不可信状态)
|
||||
* BMS 单体动力蓄电池电压过高 /过低 (<00> :=正常 ; <01> :=过高 ; <10>: =过低)
|
||||
*/
|
||||
startIndex += length;
|
||||
byte[] numNineToTwelve = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||
length = 2;
|
||||
byte[] singleBMSVoltageStatusByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||
String singleBMSVoltageStatus = BytesUtil.bcd2Str(singleBMSVoltageStatusByteArr);
|
||||
|
||||
/**
|
||||
* 13-16
|
||||
* 13: BMS 动力蓄电池绝缘状态 (<00> :=正常 ; <01> :=过流 ; <10>: =不可信状态)
|
||||
* 14: BMS 动力蓄电池组输出连接器连接状态 (<00> :=正常 ; <01> :=过流 ; <10>: =不可信状态)
|
||||
* 15: 充电禁止 (<00>: =禁止; <01>: =允许)
|
||||
* 16: 预留位 00
|
||||
* BMS 整车动力蓄电池荷电状态 SOC 过高/过低 (<00> :=正常 ; <01> :=过高 ; <10>: =过低)
|
||||
*/
|
||||
startIndex += length;
|
||||
byte[] numThirteenToSixteen = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||
byte[] carBMSSocStatusByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||
String carBMSSocStatus = BytesUtil.bcd2Str(carBMSSocStatusByteArr);
|
||||
|
||||
/**
|
||||
* BMS 动力蓄电池充电过电流 (<00> :=正常 ; <01> :=过流 ; <10>: =不可信状态)
|
||||
*/
|
||||
startIndex += length;
|
||||
byte[] BMSBatteryChargeCurrentStatusByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||
String bmsBatteryChargeCurrentStatus = BytesUtil.bcd2Str(BMSBatteryChargeCurrentStatusByteArr);
|
||||
|
||||
/**
|
||||
* BMS 动力蓄电池温度过高 (<00> :=正常 ; <01> :=过流 ; <10>: =不可信状态)
|
||||
*/
|
||||
startIndex += length;
|
||||
byte[] BMSBatteryTemperatureByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||
String bmsBatteryTemperature = BytesUtil.bcd2Str(BMSBatteryTemperatureByteArr);
|
||||
|
||||
/**
|
||||
* BMS 动力蓄电池绝缘状态 (<00> :=正常 ; <01> :=过流 ; <10>: =不可信状态)
|
||||
*/
|
||||
startIndex += length;
|
||||
byte[] BMSBatteryInsulationStatusByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||
String bmsBatteryInsulationStatus = BytesUtil.bcd2Str(BMSBatteryInsulationStatusByteArr);
|
||||
|
||||
/**
|
||||
* BMS 动力蓄电池组输出连接器连接状态 (<00> :=正常 ; <01> :=过流 ; <10>: =不可信状态)
|
||||
*/
|
||||
startIndex += length;
|
||||
byte[] BMSBatteryOutputStatusByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||
String bmsBatteryOutputStatus = BytesUtil.bcd2Str(BMSBatteryOutputStatusByteArr);
|
||||
|
||||
/**
|
||||
* 充电禁止 (<00>: =禁止; <01>: =允许)
|
||||
*/
|
||||
startIndex += length;
|
||||
byte[] chargeProhibitByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||
String chargeProhibit = BytesUtil.bcd2Str(chargeProhibitByteArr);
|
||||
|
||||
/**
|
||||
* 预留位
|
||||
*/
|
||||
startIndex += length;
|
||||
byte[] noMeanPositionByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||
|
||||
|
||||
return null;
|
||||
|
||||
@@ -2,11 +2,13 @@ package com.jsowell.netty.handler.yunkuaichong;
|
||||
|
||||
import com.jsowell.common.core.domain.ykc.YKCDataProtocol;
|
||||
import com.jsowell.common.core.domain.ykc.YKCFrameTypeCode;
|
||||
import com.jsowell.common.core.redis.RedisCache;
|
||||
import com.jsowell.common.util.BytesUtil;
|
||||
import com.jsowell.common.util.YKCUtils;
|
||||
import com.jsowell.netty.factory.YKCOperateFactory;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
@@ -19,6 +21,9 @@ import org.springframework.stereotype.Component;
|
||||
@Slf4j
|
||||
@Component
|
||||
public class ChargingHandshakeHandler extends AbstractYkcHandler {
|
||||
@Autowired
|
||||
private RedisCache redisCache;
|
||||
|
||||
private final String type = YKCUtils.frameType2Str(YKCFrameTypeCode.CHARGING_HANDSHAKE_CODE.getBytes());
|
||||
|
||||
@Override
|
||||
@@ -37,6 +42,7 @@ public class ChargingHandshakeHandler extends AbstractYkcHandler {
|
||||
|
||||
// 交易流水号
|
||||
byte[] serialNumByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||
String transactionCode = BytesUtil.bcd2Str(serialNumByteArr);
|
||||
|
||||
// 桩编码
|
||||
startIndex += length;
|
||||
@@ -57,48 +63,57 @@ public class ChargingHandshakeHandler extends AbstractYkcHandler {
|
||||
startIndex += length;
|
||||
length = 3;
|
||||
byte[] BMSCommunicationProtocolVersionByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||
|
||||
String bmsCommunicationVersion = "V1.1";
|
||||
|
||||
// BMS 电池类型 01H:铅酸电池;02H:氢 电池;03H:磷酸铁锂电池;04H:锰 酸锂电池;05H:钴酸锂电池 ;06H: 三元材料电池;07H:聚合物锂离子 电池;08H:钛酸锂电池;FFH:其他
|
||||
startIndex += length;
|
||||
length = 1;
|
||||
byte[] BMSBatteryTypeByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||
String bmsBatteryType = BytesUtil.bcd2Str(BMSBatteryTypeByteArr); // 03
|
||||
|
||||
// BMS 整车动力蓄电池系统额定容量 0.1 Ah /位, 0 Ah 偏移量
|
||||
startIndex += length;
|
||||
length = 2;
|
||||
byte[] BMSBatteryCapacityByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||
String bmsBatteryCapacity = String.valueOf(BytesUtil.bytesToIntLittle(BMSBatteryCapacityByteArr) * 0.1); // 171.0
|
||||
|
||||
// BMS 整车动力蓄电池系统额定总电压 0.1V/位, 0V 偏移量
|
||||
startIndex += length;
|
||||
byte[] BMSBatteryVoltageByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||
String bmsBatteryVoltage = String.valueOf(BytesUtil.bytesToIntLittle(BMSBatteryVoltageByteArr) * 0.1); // 347.8
|
||||
|
||||
// BMS 电池生产厂商名称
|
||||
startIndex += length;
|
||||
length = 4;
|
||||
byte[] BMSBatteryFactoryByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||
String bmsBatteryFactory = BytesUtil.ascii2Str(BMSBatteryFactoryByteArr); // CATL
|
||||
|
||||
// BMS 电池组序号
|
||||
startIndex += length;
|
||||
byte[] BMSBatteryNumByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||
String bmsBatteryNum = BytesUtil.bin2HexStr(BMSBatteryNumByteArr);
|
||||
|
||||
// BMS 电池组生产日期年 1985 年偏移量, 数据范围: 1985~ 2235 年
|
||||
startIndex += length;
|
||||
length = 1;
|
||||
byte[] BMSProductionDateYearByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||
String bmsProductionDateYear = BytesUtil.bin2HexStr(BMSProductionDateYearByteArr);
|
||||
|
||||
// BMS 电池组生产日期月 0 月偏移量, 数据范围: 1~12 月
|
||||
startIndex += length;
|
||||
byte[] BMSProductionDateMonthByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||
String bmsProductionDateMonth = BytesUtil.bin2HexStr(BMSProductionDateMonthByteArr);
|
||||
|
||||
// BMS 电池组生产日期日 0 日偏移量, 数据范围: 1~31 日
|
||||
startIndex += length;
|
||||
byte[] BMSProductionDateDayByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||
String bmsProductionDateDay = BytesUtil.bin2HexStr(BMSProductionDateDayByteArr);
|
||||
|
||||
// BMS 电池组充电次数 1 次/位, 0 次偏移量, 以 BMS 统 计为准
|
||||
startIndex += length;
|
||||
length = 3;
|
||||
byte[] BMSChargingTimesByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||
String bmsChargingTimes = BytesUtil.bin2HexStr(BMSChargingTimesByteArr);
|
||||
|
||||
// BMS 电池组产权标识 (<0>: =租赁; <1>: =车自有)
|
||||
startIndex += length;
|
||||
@@ -112,14 +127,16 @@ public class ChargingHandshakeHandler extends AbstractYkcHandler {
|
||||
// BMS 车辆识别码
|
||||
startIndex += length;
|
||||
length = 17;
|
||||
byte[] BMSCarIdentifyCodeByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||
byte[] vinByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||
String vinCode = YKCUtils.parseVin(vinByteArr);
|
||||
|
||||
// BMS 软件版本号
|
||||
startIndex += length;
|
||||
length = 8;
|
||||
byte[] BMSSoftwareVersionByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||
|
||||
|
||||
// 保存数据到redis
|
||||
// redisCache.setCacheObject();
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user