!19 绿能模块

* 绿能模块
This commit is contained in:
三丙
2025-08-09 11:00:12 +00:00
parent 3d441d75a3
commit 199711026c
34 changed files with 1122 additions and 50 deletions

View File

@@ -71,7 +71,7 @@ public class AbstractYunKuaiChongCmdExe {
protected static byte[] encodePileCode(String pileCode) {
if (StringUtils.length(pileCode) > 32) {
throw new IllegalArgumentException("云快充1.5可接受最大桩编号为14位");
throw new IllegalArgumentException("云快充可接受最大桩编号为14位");
}
String pileCodeStr = StringUtils.leftPad(pileCode, 14, '0');
@@ -81,7 +81,7 @@ public class AbstractYunKuaiChongCmdExe {
protected static byte[] encodeGunCode(String gunCode) {
if (StringUtils.length(gunCode) > 2) {
throw new IllegalArgumentException("云快充1.5可接受最大枪编号为2位");
throw new IllegalArgumentException("云快充可接受最大枪编号为2位");
}
String gunCodeStr = StringUtils.leftPad(gunCode, 2, '0');

View File

@@ -8,6 +8,7 @@ package sanbing.jcpp.protocol.yunkuaichong;
import cn.hutool.core.util.ClassUtil;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufUtil;
import io.netty.buffer.Unpooled;
import lombok.extern.slf4j.Slf4j;
import sanbing.jcpp.infrastructure.util.JCPPPair;
@@ -100,6 +101,8 @@ public class YunKuaiChongProtocolMessageProcessor extends ProtocolMessageProcess
// ================== 校验和双模式处理 ==================
final int checkSumLE = in.getUnsignedShortLE(checksumPos);
final int checkSumBE = in.getUnsignedShort(checksumPos);
byte[] checkSumBytes = new byte[2];
in.getBytes(checksumPos, checkSumBytes);
// ================== 校验数据智能拷贝 ==================
final byte[] checkData = Arrays.copyOfRange(msg, 2, 2 + dataLength);
@@ -108,16 +111,16 @@ public class YunKuaiChongProtocolMessageProcessor extends ProtocolMessageProcess
JCPPPair<Boolean, Integer> checkResult = checkCrcSum(checkData, checkSumLE);
if (!checkResult.getFirst()) {
if (log.isDebugEnabled()) { // 日志惰性计算
log.debug("{} 云快充校验域一次校验失败 CMD:{} 校验和0x{} 期望校验和:0x{}",
session, frameType, Integer.toHexString(checkSumLE), Integer.toHexString(checkResult.getSecond()));
log.debug("{} 云快充校验域一次校验失败 CMD:{} 校验和0x{} 期望校验和:{}",
session, Integer.toHexString(frameType), ByteBufUtil.hexDump(checkSumBytes), checkResult.getSecond());
}
checkResult = checkCrcSum(checkData, checkSumBE);
}
// ================== 最终校验失败处理 ==================
if (!checkResult.getFirst()) {
log.info("{} 云快充校验域二次校验失败 CMD:{} 校验和0x{} 期望校验和:0x{}",
session, frameType, Integer.toHexString(checkSumBE), Integer.toHexString(checkResult.getSecond()));
log.info("{} 云快充校验域二次校验失败 CMD:{} 校验和0x{} 期望校验和:{}",
session, Integer.toHexString(frameType), ByteBufUtil.hexDump(checkSumBytes), checkResult.getSecond());
return;
}

View File

@@ -29,6 +29,7 @@ import java.util.concurrent.TimeUnit;
import static sanbing.jcpp.infrastructure.util.config.ThreadPoolConfiguration.PROTOCOL_SESSION_SCHEDULED;
import static sanbing.jcpp.protocol.domain.SessionCloseReason.MANUALLY;
import static sanbing.jcpp.protocol.listener.tcp.TcpSession.SCHEDULE_KEY_AUTO_SYNC_TIME;
import static sanbing.jcpp.protocol.yunkuaichong.YunKuaiChongDwonlinkMessage.FAILURE_BYTE;
import static sanbing.jcpp.protocol.yunkuaichong.YunKuaiChongDwonlinkMessage.SUCCESS_BYTE;
import static sanbing.jcpp.protocol.yunkuaichong.enums.YunKuaiChongDownlinkCmdEnum.LOGIN_ACK;
@@ -94,7 +95,7 @@ public class YunKuaiChongV150LoginAckDLCmd extends YunKuaiChongDownlinkCmdExe {
}
private void registerSyncTimeTask(TcpSession tcpSession, byte[] pileCodeBytes, YunKuaiChongUplinkMessage requestData) {
tcpSession.addSchedule("auto-sync-time", k -> {
tcpSession.addSchedule(SCHEDULE_KEY_AUTO_SYNC_TIME, k -> {
log.info("{} 云快充1.5.0开始注册定时对时任务", tcpSession);
return PROTOCOL_SESSION_SCHEDULED.scheduleAtFixedRate(() ->
syncTime(tcpSession, pileCodeBytes, requestData),