mirror of
https://gitee.com/san-bing/JChargePointProtocol
synced 2026-05-04 09:59:55 +08:00
!11 命令码:0x17 (参数配置帧上行命令)
* BMS 0x17 (参数配置帧上行命令) = 更新BmsParamConfigReport * BMS 0x17 (参数配置帧上行命令) = additionalInfo里塞了一遍,固定字段里也塞了一遍,改成只塞一遍固定字段 * BMS 0x17 (参数配置帧上行命令) = 删除ParamConfigRequest * BMS 0x17 (参数配置帧上行命令) = 修改模型命名BmsParamConfigReport和相关的类重新命名 * BMS 0x17 (参数配置帧上行命令) = 修改cmd paramConfigProto = 33 * BMS 0x17 (参数配置帧上行命令) = 修改protocol.proto、数值类型改成BigDecimal * BMS 0x17 (参数配置帧上行命令) + 上行BMS参数配置报文 * BMS 0x17 (参数配置帧上行命令) * 0x17 (参数配置帧上行命令) * 命令码:0x17 (参数配置帧上行命令) * 命令码:0x17 (参数配置帧上行命令) * Revert "命令码:0x17 (参数配置帧上行命令)" * 命令码:0x17 (参数配置帧上行命令)
This commit is contained in:
@@ -78,4 +78,9 @@ public interface PileProtocolService {
|
||||
* 下发计费
|
||||
*/
|
||||
void setPricing(String pileCode, SetPricingRequest setPricingRequest);
|
||||
|
||||
/**
|
||||
* 充电桩与 BMS 参数配置阶段报文
|
||||
*/
|
||||
void onBmsParamConfigReport(UplinkQueueMessage uplinkQueueMsg, Callback callback);
|
||||
}
|
||||
@@ -314,6 +314,7 @@ public class DefaultPileProtocolService implements PileProtocolService {
|
||||
downlinkCallService.sendDownlinkMessage(downlinkRequestMessageBuilder, pileCode);
|
||||
}
|
||||
|
||||
|
||||
private static Period createPeriod(int sn, LocalTime beginTime, LocalTime endTime, PricingModelFlag flag) {
|
||||
Period period = new Period();
|
||||
period.setSn(sn);
|
||||
@@ -337,4 +338,9 @@ public class DefaultPileProtocolService implements PileProtocolService {
|
||||
builder.setRequestData(uplinkQueueMessage.getRequestData());
|
||||
return builder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBmsParamConfigReport(UplinkQueueMessage uplinkQueueMsg, Callback callback) {
|
||||
log.info("充电桩与 BMS 参数配置阶段报文 {}", uplinkQueueMsg);
|
||||
}
|
||||
}
|
||||
@@ -192,6 +192,10 @@ public class ProtocolUplinkConsumerService extends AbstractConsumerService imple
|
||||
|
||||
pileProtocolService.onTransactionRecord(uplinkQueueMsg, callback);
|
||||
|
||||
} else if (uplinkQueueMsg.hasBmsParamConfigReport()) {
|
||||
|
||||
pileProtocolService.onBmsParamConfigReport(uplinkQueueMsg, callback);
|
||||
|
||||
} else {
|
||||
|
||||
callback.onSuccess();
|
||||
|
||||
@@ -66,6 +66,7 @@ message UplinkQueueMessage {
|
||||
RemoteStartChargingResponse remoteStartChargingResponse = 28;
|
||||
RemoteStopChargingResponse remoteStopChargingResponse = 29;
|
||||
TransactionRecord transactionRecord = 30;
|
||||
BmsParamConfigReport bmsParamConfigReport = 33;
|
||||
}
|
||||
|
||||
message DownlinkRequestMessage {
|
||||
@@ -288,4 +289,22 @@ message TransactionRecord {
|
||||
message TransactionRecordAck {
|
||||
string tradeNo = 6;
|
||||
bool success = 7;
|
||||
}
|
||||
|
||||
message BmsParamConfigReport {
|
||||
int64 ts = 1; // 时间戳
|
||||
string pileCode = 2; // 桩编码
|
||||
string gunCode = 3; // 枪编码
|
||||
string tradeNo = 4; // 交易号
|
||||
string maxSingleCellVoltage = 5; // BMS单体最高允许充电电压 (V)
|
||||
string maxChargeCurrent = 6; // BMS最高允许充电电流 (A)
|
||||
string ratedEnergy = 7; // BMS动力蓄电池标称总能量 (kWh)
|
||||
string maxTotalChargeVoltage = 8; // BMS最高允许充电总电压 (V)
|
||||
string maxTemperature = 9; // BMS最高允许温度 (℃)
|
||||
string soc = 10; // BMS荷电状态SOC (%)
|
||||
string currentBatteryVoltage = 11; // BMS当前电池电压 (V)
|
||||
string pileMaxOutputVoltage = 12; // 电桩最高输出电压 (V)
|
||||
string pileMinOutputVoltage = 13; // 电桩最低输出电压 (V)
|
||||
string pileMaxOutputCurrent = 14; // 电桩最大输出电流 (A)
|
||||
string pileMinOutputCurrent = 15; // 电桩最小输出电流 (A)
|
||||
}
|
||||
@@ -49,4 +49,11 @@
|
||||
#### 上行交易记录
|
||||
`68 a2 00 46 00 3b 20 23 12 12 00 00 10 32 32 39 00 00 00 00 00 00 20 23 12 12 00 00 10 01 b0 36 04 11 6d 0c 17 a0 8c 09 11 6d 0c 17 f0 49 02 00 00 00 00 00 00 00 00 00 00 00 00 00 d0 fb 01 00 00 00 00 00 00 00 00 00 00 00 00 00 b0 ad 01 00 00 00 00 00 00 00 00 00 00 00 00 00 90 5f 01 00 72 06 00 00 72 06 00 00 78 05 00 00 00 00 00 00 00 00 00 00 00 00 72 06 00 00 72 06 00 00 78 05 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 a0 8c 09 11 6d 0c 17 40 00 00 00 00 00 00 00 00 03 E0`
|
||||
#### 下行交易就应答
|
||||
`68 15 00 46 00 06 20 23 12 12 00 00 10 32 32 39 00 00 00 00 00 00 00 C6 2D `
|
||||
`68 15 00 46 00 06 20 23 12 12 00 00 10 32 32 39 00 00 00 00 00 00 00 C6 2D `
|
||||
|
||||
---
|
||||
|
||||
### 7.4上行BMS参数配置
|
||||
`68 31 00 16 00 17 32 01 02 00 00 00 00 11 15 11 16 15 55 35 02 60 20 23 12 12 00 00 10 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 78 BB`
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,185 @@
|
||||
/**
|
||||
* 开源代码,仅供学习和交流研究使用,商用请联系三丙
|
||||
* 微信:mohan_88888
|
||||
* 抖音:程序员三丙
|
||||
* 付费课程知识星球:https://t.zsxq.com/aKtXo
|
||||
*/
|
||||
package sanbing.jcpp.protocol.yunkuaichong.v150.cmd;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import sanbing.jcpp.protocol.ProtocolContext;
|
||||
import sanbing.jcpp.protocol.listener.tcp.TcpSession;
|
||||
import sanbing.jcpp.protocol.yunkuaichong.YunKuaiChongUplinkCmdExe;
|
||||
import sanbing.jcpp.protocol.yunkuaichong.YunKuaiChongUplinkMessage;
|
||||
import sanbing.jcpp.protocol.yunkuaichong.annotation.YunKuaiChongCmd;
|
||||
import sanbing.jcpp.proto.gen.ProtocolProto.UplinkQueueMessage;
|
||||
import sanbing.jcpp.infrastructure.util.trace.TracerContextUtil;
|
||||
import sanbing.jcpp.proto.gen.ProtocolProto.BmsParamConfigReport;
|
||||
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import sanbing.jcpp.infrastructure.util.codec.BCDUtil;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 云快充协议上行命令处理类 - 参数配置帧解析 (V1.5.0版本)
|
||||
* 命令码:0x17 (参数配置帧上行命令)
|
||||
*/
|
||||
@Slf4j
|
||||
@YunKuaiChongCmd(0x17)
|
||||
public class YunKuaiChongV150BmsParamConfigULCmd extends YunKuaiChongUplinkCmdExe {
|
||||
// 电流值偏移量常量(单位:安培)
|
||||
private static final BigDecimal CURRENT_OFFSET = new BigDecimal("-400.0");
|
||||
// 温度值偏移量常量(单位:摄氏度)
|
||||
private static final BigDecimal TEMP_OFFSET = new BigDecimal("-50.0");
|
||||
|
||||
/**
|
||||
* 执行命令解析
|
||||
* @param tcpSession TCP会话对象
|
||||
* @param yunKuaiChongUplinkMessage 上行消息对象
|
||||
* @param ctx 协议上下文
|
||||
*/
|
||||
@Override
|
||||
public void execute(TcpSession tcpSession, YunKuaiChongUplinkMessage yunKuaiChongUplinkMessage, ProtocolContext ctx) {
|
||||
log.info("{} 云快充1.5.0充电桩参数配置帧请求", tcpSession);
|
||||
// 将消息体包装为ByteBuf以便读取
|
||||
ByteBuf byteBuf = Unpooled.wrappedBuffer(yunKuaiChongUplinkMessage.getMsgBody());
|
||||
// 从Tracer总获取当前时间
|
||||
long ts = TracerContextUtil.getCurrentTracer().getTracerTs();
|
||||
|
||||
/* 按协议顺序解析消息体 */
|
||||
|
||||
// 1. 交易流水号:16字节BCD编码字符串
|
||||
String tradeNo = readBcdString(byteBuf, 16);
|
||||
|
||||
// 2. 桩编号:7字节BCD编码字符串
|
||||
String pileCode = readBcdString(byteBuf, 7);
|
||||
|
||||
// 3. 枪号:1字节BCD编码字符串
|
||||
String gunCode = readBcdString(byteBuf, 1);
|
||||
|
||||
// 4. BMS单体最高允许充电电压:2字节无符号整数,单位0.01V
|
||||
BigDecimal maxSingleCellVoltage = readVoltage(byteBuf, 100);
|
||||
|
||||
// 5. BMS最高允许充电电流:2字节无符号整数,单位0.1A(需加-400A偏移量)
|
||||
BigDecimal maxChargeCurrent = readCurrent(byteBuf);
|
||||
|
||||
// 6. BMS动力蓄电池标称总能量:2字节无符号整数,单位0.1kWh
|
||||
BigDecimal ratedEnergy = readEnergy(byteBuf); // 单位0.1kWh
|
||||
|
||||
// 7. BMS最高允许充电总电压:2字节无符号整数,单位0.1V
|
||||
BigDecimal maxTotalChargeVoltage = readVoltage(byteBuf, 10);
|
||||
|
||||
// 8. BMS最高允许温度:1字节无符号整数,单位1℃(需加-50℃偏移量)
|
||||
BigDecimal maxTemperature = readTemperature(byteBuf);
|
||||
|
||||
// 9. BMS荷电状态SOC:2字节无符号整数,单位0.1%
|
||||
BigDecimal soc = readPercentage(byteBuf);
|
||||
|
||||
// 10. BMS当前电池电压:2字节无符号整数,单位0.1V
|
||||
BigDecimal currentBatteryVoltage = readVoltage(byteBuf, 10);
|
||||
|
||||
// 11. 电桩最高输出电压:2字节无符号整数,单位0.1V
|
||||
BigDecimal pileMaxOutputVoltage = readVoltage(byteBuf, 10);
|
||||
|
||||
// 12. 电桩最低输出电压:2字节无符号整数,单位0.1V
|
||||
BigDecimal pileMinOutputVoltage = readVoltage(byteBuf, 10);
|
||||
|
||||
// 13. 电桩最大输出电流:2字节无符号整数,单位0.1A(需加-400A偏移量)
|
||||
BigDecimal pileMaxOutputCurrent = readCurrent(byteBuf);
|
||||
|
||||
// 14. 电桩最小输出电流:2字节无符号整数,单位0.1A(需加-400A偏移量)
|
||||
BigDecimal pileMinOutputCurrent = readCurrent(byteBuf);
|
||||
|
||||
// 转发到后端
|
||||
BmsParamConfigReport bmsParamConfigReport = BmsParamConfigReport.newBuilder()
|
||||
.setTs(ts)
|
||||
.setPileCode(pileCode)
|
||||
.setTradeNo(tradeNo)
|
||||
.setGunCode(gunCode)
|
||||
.setMaxSingleCellVoltage(maxSingleCellVoltage.toPlainString())
|
||||
.setMaxChargeCurrent(maxChargeCurrent.toPlainString())
|
||||
.setRatedEnergy(ratedEnergy.toPlainString())
|
||||
.setMaxTotalChargeVoltage(maxTotalChargeVoltage.toPlainString())
|
||||
.setMaxTemperature(maxTemperature.toPlainString())
|
||||
.setSoc(soc.toPlainString())
|
||||
.setCurrentBatteryVoltage(currentBatteryVoltage.toPlainString())
|
||||
.setPileMaxOutputVoltage(pileMaxOutputVoltage.toPlainString())
|
||||
.setPileMinOutputVoltage(pileMinOutputVoltage.toPlainString())
|
||||
.setPileMaxOutputCurrent(pileMaxOutputCurrent.toPlainString())
|
||||
.setPileMinOutputCurrent(pileMinOutputCurrent.toPlainString())
|
||||
.build();
|
||||
UplinkQueueMessage uplinkQueueMessage = uplinkMessageBuilder(bmsParamConfigReport.getPileCode(), tcpSession, yunKuaiChongUplinkMessage)
|
||||
.setBmsParamConfigReport(bmsParamConfigReport)
|
||||
.build();
|
||||
tcpSession.getForwarder().sendMessage(uplinkQueueMessage);
|
||||
|
||||
}
|
||||
|
||||
//=== 协议数据解析辅助方法 ===//
|
||||
|
||||
/**
|
||||
* 读取BCD编码字符串
|
||||
* @param buf 字节缓冲区
|
||||
* @param length 读取字节长度
|
||||
* @return 解析后的字符串
|
||||
*/
|
||||
private String readBcdString(ByteBuf buf, int length) {
|
||||
byte[] bytes = new byte[length];
|
||||
buf.readBytes(bytes);
|
||||
return BCDUtil.toString(bytes); // 调用BCD工具类转换
|
||||
}
|
||||
/**
|
||||
* 读取电压值(返回BigDecimal)
|
||||
* @param buf 字节缓冲区
|
||||
* @param magnification 放大倍数(如100表示原始值需除以100)
|
||||
* @return 电压值(BigDecimal)
|
||||
*/
|
||||
public BigDecimal readVoltage(ByteBuf buf, int magnification) {
|
||||
long value = buf.readUnsignedShortLE();
|
||||
return reduceMagnification(value, magnification, 4);
|
||||
}
|
||||
/**
|
||||
* 读取电流值(返回BigDecimal)
|
||||
* @param buf 字节缓冲区
|
||||
* @return 电流值(BigDecimal),已应用偏移量
|
||||
*/
|
||||
public BigDecimal readCurrent(ByteBuf buf) {
|
||||
long value = buf.readUnsignedShortLE();
|
||||
BigDecimal current = reduceMagnification(value, 10, 4); // 0.1倍率
|
||||
return current.add(CURRENT_OFFSET); // 应用电流偏移
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取能量值(返回BigDecimal)
|
||||
* @param buf 字节缓冲区
|
||||
* @return 能量值(BigDecimal)
|
||||
*/
|
||||
private BigDecimal readEnergy(ByteBuf buf) {
|
||||
long value = buf.readUnsignedShortLE();
|
||||
return reduceMagnification(value, 10, 4); // 0.1倍率
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取温度值(返回BigDecimal)
|
||||
* @param buf 字节缓冲区
|
||||
* @return 温度值(BigDecimal),已应用偏移量
|
||||
*/
|
||||
public BigDecimal readTemperature(ByteBuf buf) {
|
||||
long value = buf.readUnsignedByte();
|
||||
BigDecimal temp = reduceMagnification(value, 1, 4); // 原始值
|
||||
return temp.add(TEMP_OFFSET); // 应用温度偏移
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取百分比值(返回BigDecimal)
|
||||
* @param buf 字节缓冲区
|
||||
* @return 百分比值(BigDecimal)
|
||||
*/
|
||||
public BigDecimal readPercentage(ByteBuf buf) {
|
||||
long value = buf.readUnsignedShortLE();
|
||||
return reduceMagnification(value, 10, 4); // 0.1倍率
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user