mirror of
https://gitee.com/san-bing/JChargePointProtocol
synced 2026-05-05 02:19:56 +08:00
增加充电BMS握手转发逻辑
This commit is contained in:
@@ -109,7 +109,7 @@ public class YunKuaiChongProtocolMessageProcessor extends ProtocolMessageProcess
|
||||
if (!checkResult.getFirst()) {
|
||||
if (log.isDebugEnabled()) { // 日志惰性计算
|
||||
log.debug("{} 云快充校验域一次校验失败 CMD:{} 校验和:0x{} 期望校验和:0x{}",
|
||||
session, frameType, Integer.toHexString(checkSumBE), Integer.toHexString(checkSumLE));
|
||||
session, frameType, Integer.toHexString(checkSumLE), Integer.toHexString(checkResult.getSecond()));
|
||||
}
|
||||
checkResult = checkCrcSum(checkData, checkSumBE);
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ import lombok.Getter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import sanbing.jcpp.infrastructure.util.codec.BCDUtil;
|
||||
import sanbing.jcpp.infrastructure.util.jackson.JacksonUtil;
|
||||
import sanbing.jcpp.infrastructure.util.trace.TracerContextUtil;
|
||||
import sanbing.jcpp.proto.gen.ProtocolProto.BmsAbortProto;
|
||||
import sanbing.jcpp.proto.gen.ProtocolProto.UplinkQueueMessage;
|
||||
import sanbing.jcpp.protocol.ProtocolContext;
|
||||
@@ -37,6 +38,9 @@ public class YunKuaiChongV150BmsAbortULCmd extends YunKuaiChongUplinkCmdExe {
|
||||
log.debug("{} 云快充1.5.0充电阶段BMS中止", tcpSession);
|
||||
ByteBuf byteBuf = Unpooled.wrappedBuffer(yunKuaiChongUplinkMessage.getMsgBody());
|
||||
|
||||
// 从Tracer总获取当前时间
|
||||
long ts = TracerContextUtil.getCurrentTracer().getTracerTs();
|
||||
|
||||
ObjectNode additionalInfo = JacksonUtil.newObjectNode();
|
||||
// 1.交易流水号
|
||||
byte[] tradeNoBytes = new byte[16];
|
||||
@@ -65,6 +69,7 @@ public class YunKuaiChongV150BmsAbortULCmd extends YunKuaiChongUplinkCmdExe {
|
||||
additionalInfo.put("BMS中止充电错误原因", parseErrorReasons(errorReasonByte));
|
||||
|
||||
BmsAbortProto proto = BmsAbortProto.newBuilder()
|
||||
.setTs(ts)
|
||||
.setPileCode(pileCode)
|
||||
.setGunCode(gunCode)
|
||||
.setTradeNo(tradeNo)
|
||||
|
||||
@@ -12,6 +12,7 @@ import io.netty.buffer.Unpooled;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import sanbing.jcpp.infrastructure.util.codec.BCDUtil;
|
||||
import sanbing.jcpp.infrastructure.util.jackson.JacksonUtil;
|
||||
import sanbing.jcpp.infrastructure.util.trace.TracerContextUtil;
|
||||
import sanbing.jcpp.proto.gen.ProtocolProto.BmsChargingInfoProto;
|
||||
import sanbing.jcpp.proto.gen.ProtocolProto.UplinkQueueMessage;
|
||||
import sanbing.jcpp.protocol.ProtocolContext;
|
||||
@@ -32,6 +33,9 @@ public class YunKuaiChongV150BmsChargingInfoULCmd extends YunKuaiChongUplinkCmdE
|
||||
public void execute(TcpSession tcpSession, YunKuaiChongUplinkMessage yunKuaiChongUplinkMessage, ProtocolContext ctx) {
|
||||
log.debug("{} 云快充1.5.0充电过程BMS信息", tcpSession);
|
||||
ByteBuf byteBuf = Unpooled.wrappedBuffer(yunKuaiChongUplinkMessage.getMsgBody());
|
||||
// 从Tracer总获取当前时间
|
||||
long ts = TracerContextUtil.getCurrentTracer().getTracerTs();
|
||||
|
||||
ObjectNode additionalInfo = JacksonUtil.newObjectNode();
|
||||
// 1.交易流水号
|
||||
byte[] tradeNoBytes = new byte[16];
|
||||
@@ -73,6 +77,7 @@ public class YunKuaiChongV150BmsChargingInfoULCmd extends YunKuaiChongUplinkCmdE
|
||||
byteBuf.skipBytes(2);
|
||||
|
||||
BmsChargingInfoProto bmsCharingInfoProto = BmsChargingInfoProto.newBuilder()
|
||||
.setTs(ts)
|
||||
.setPileCode(pileCode)
|
||||
.setTradeNo(tradeNo)
|
||||
.setGunCode(gunCode)
|
||||
|
||||
@@ -13,6 +13,9 @@ import io.netty.buffer.Unpooled;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import sanbing.jcpp.infrastructure.util.codec.BCDUtil;
|
||||
import sanbing.jcpp.infrastructure.util.jackson.JacksonUtil;
|
||||
import sanbing.jcpp.infrastructure.util.trace.TracerContextUtil;
|
||||
import sanbing.jcpp.proto.gen.ProtocolProto.BmsHandshakeProto;
|
||||
import sanbing.jcpp.proto.gen.ProtocolProto.UplinkQueueMessage;
|
||||
import sanbing.jcpp.protocol.ProtocolContext;
|
||||
import sanbing.jcpp.protocol.listener.tcp.TcpSession;
|
||||
import sanbing.jcpp.protocol.yunkuaichong.YunKuaiChongUplinkCmdExe;
|
||||
@@ -34,71 +37,60 @@ public class YunKuaiChongV150BmsHandshakeULCmd extends YunKuaiChongUplinkCmdExe
|
||||
log.debug("{} 云快充1.5.0充电握手", tcpSession);
|
||||
ByteBuf byteBuf = Unpooled.wrappedBuffer(yunKuaiChongUplinkMessage.getMsgBody());
|
||||
|
||||
// 从Tracer总获取当前时间
|
||||
long ts = TracerContextUtil.getCurrentTracer().getTracerTs();
|
||||
|
||||
ObjectNode additionalInfo = JacksonUtil.newObjectNode();
|
||||
|
||||
// 1.交易流水号
|
||||
byte[] tradeNoBytes = new byte[16];
|
||||
byteBuf.readBytes(tradeNoBytes);
|
||||
String tradeNo = BCDUtil.toString(tradeNoBytes);
|
||||
additionalInfo.put("交易流水号", tradeNo);
|
||||
|
||||
// 2.桩编号
|
||||
byte[] pileCodeBytes = new byte[7];
|
||||
byteBuf.readBytes(pileCodeBytes);
|
||||
String pileCode = BCDUtil.toString(pileCodeBytes);
|
||||
additionalInfo.put("桩编号", pileCode);
|
||||
|
||||
// 3.抢号
|
||||
byte gunCodeByte = byteBuf.readByte();
|
||||
String gunCode = BCDUtil.toString(gunCodeByte);
|
||||
additionalInfo.put("抢号", gunCode);
|
||||
|
||||
// 4.BMS 通信协议版本号
|
||||
byte[] bmsConnectVersionBytes = new byte[3];
|
||||
byteBuf.readBytes(bmsConnectVersionBytes);
|
||||
additionalInfo.put("BMS 通信协议版本号", HexUtil.encodeHexStr(bmsConnectVersionBytes));
|
||||
|
||||
// 5.BMS 电池类型
|
||||
int bmsBatteryType = byteBuf.readUnsignedByte();
|
||||
additionalInfo.put("BMS电池类型", bmsBatteryType);
|
||||
|
||||
// 6.BMS 整车动力蓄电池系统额定容量
|
||||
int bmsPowerCapacity = byteBuf.readUnsignedShortLE();
|
||||
additionalInfo.put("BMS整车动力蓄电池系统额定容量", bmsPowerCapacity);
|
||||
|
||||
// 7.BMS 整车动力蓄电池系统额定总电压
|
||||
int bmsPowerMaxVoltage = byteBuf.readUnsignedShortLE();
|
||||
additionalInfo.put("BMS整车动力蓄电池系统额定总电压", bmsPowerMaxVoltage);
|
||||
|
||||
// 8.BMS 电池生产厂商名称
|
||||
byte[] bmsFactoryBytes = new byte[4];
|
||||
byteBuf.readBytes(bmsFactoryBytes);
|
||||
String bmsFactory = new String(bmsFactoryBytes, StandardCharsets.US_ASCII);
|
||||
additionalInfo.put("BMS电池生产厂商名称", bmsFactory);
|
||||
|
||||
// 9.BMS 电池组序号
|
||||
int bmsSerialNo = byteBuf.readIntLE();
|
||||
additionalInfo.put("BMS 电池组序号", bmsSerialNo);
|
||||
|
||||
// 10.BMS 电池组生产日期年
|
||||
int bmsCreateYear = byteBuf.readUnsignedByte();
|
||||
additionalInfo.put("BMS 电池组生产日期年", bmsCreateYear);
|
||||
|
||||
// 11.BMS 电池组生产日期月
|
||||
int bmsCreateMonth = byteBuf.readUnsignedByte();
|
||||
additionalInfo.put("BMS 电池组生产日期月", bmsCreateMonth);
|
||||
|
||||
// 12.BMS 电池组生产日期日
|
||||
int bmsCreateDay = byteBuf.readUnsignedByte();
|
||||
additionalInfo.put("BMS 电池组生产日期日", bmsCreateDay);
|
||||
|
||||
// 13.BMS 电池组充电次数
|
||||
int bmsChargeCount = byteBuf.readUnsignedMedium();
|
||||
additionalInfo.put("BMS 电池组充电次数", bmsChargeCount);
|
||||
|
||||
// 14.BMS 电池组产权标识
|
||||
int bmsPropertyRightLabel = byteBuf.readUnsignedByte();
|
||||
additionalInfo.put("BMS 电池组产权标识", bmsPropertyRightLabel);
|
||||
|
||||
// 15.预留位
|
||||
byteBuf.skipBytes(1);
|
||||
@@ -107,14 +99,39 @@ public class YunKuaiChongV150BmsHandshakeULCmd extends YunKuaiChongUplinkCmdExe
|
||||
byte[] carVINBytes = new byte[17];
|
||||
byteBuf.readBytes(carVINBytes);
|
||||
String bmsVinCode = new String(carVINBytes, StandardCharsets.US_ASCII);
|
||||
additionalInfo.put("电动汽车唯一标识", bmsVinCode);
|
||||
|
||||
// 17.BMS 软件版本号
|
||||
byte[] bmsSoftVersionBytes = new byte[8];
|
||||
byteBuf.readBytes(bmsSoftVersionBytes);
|
||||
additionalInfo.put("BMS 软件版本号", HexUtil.encodeHexStr(bmsSoftVersionBytes));
|
||||
|
||||
// TODO 先打印日志,暂不转发
|
||||
log.debug("{} 云快充1.5.0充电握手信息解析完成:{}", tcpSession, additionalInfo);
|
||||
// 构建BmsHandshakeProto对象
|
||||
BmsHandshakeProto bmsHandshakeProto = BmsHandshakeProto.newBuilder()
|
||||
.setTs(ts)
|
||||
.setPileCode(pileCode)
|
||||
.setGunCode(gunCode)
|
||||
.setTradeNo(tradeNo)
|
||||
.setBmsProtocolVersion(HexUtil.encodeHexStr(bmsConnectVersionBytes))
|
||||
.setBmsBatteryType(bmsBatteryType)
|
||||
.setBmsPowerCapacity(bmsPowerCapacity)
|
||||
.setBmsPowerMaxVoltage(bmsPowerMaxVoltage)
|
||||
.setBmsFactory(bmsFactory)
|
||||
.setBmsSerialNo(bmsSerialNo)
|
||||
.setBmsCreateYear(bmsCreateYear)
|
||||
.setBmsCreateMonth(bmsCreateMonth)
|
||||
.setBmsCreateDay(bmsCreateDay)
|
||||
.setBmsChargeCount(bmsChargeCount)
|
||||
.setBmsPropertyRightLabel(bmsPropertyRightLabel)
|
||||
.setCarVinCode(bmsVinCode)
|
||||
.setBmsSoftwareVersion(HexUtil.encodeHexStr(bmsSoftVersionBytes))
|
||||
.setAdditionalInfo(additionalInfo.toString())
|
||||
.build();
|
||||
|
||||
// 构建上行队列消息
|
||||
UplinkQueueMessage uplinkQueueMessage = uplinkMessageBuilder(pileCode, tcpSession, yunKuaiChongUplinkMessage)
|
||||
.setBmsHandshakeProto(bmsHandshakeProto)
|
||||
.build();
|
||||
|
||||
// 转发到应用层
|
||||
tcpSession.getForwarder().sendMessage(uplinkQueueMessage);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user