update 预约充电

This commit is contained in:
Guoqs
2024-07-30 15:26:11 +08:00
parent 8d3fbda9a2
commit b58c272121
11 changed files with 110 additions and 32 deletions

View File

@@ -46,19 +46,25 @@ public abstract class AbstractHandler implements InitializingBean {
protected byte[] getResult(YKCDataProtocol ykcDataProtocol, byte[] messageBody) {
// 起始标志
byte[] head = ykcDataProtocol.getHead();
// 序列号域
byte[] serialNumber = ykcDataProtocol.getSerialNumber();
// 加密标志
byte[] encryptFlag = ykcDataProtocol.getEncryptFlag();
// 请求帧类型
byte[] requestFrameType = ykcDataProtocol.getFrameType();
// 应答帧类型
byte[] responseFrameType = YKCFrameTypeCode.PlatformAnswersRelation.getResponseFrameTypeBytes(requestFrameType);
// 数据域 值为“序列号域+加密标志+帧类型标志+消息体”字节数之和
byte[] dataFields = Bytes.concat(serialNumber, encryptFlag, responseFrameType, messageBody);
// 计算crc 从序列号域到数据域的 CRC 校验
int crc16 = CRC16Util.calcCrc16(dataFields);
return Bytes.concat(head, BytesUtil.intToBytes(dataFields.length, 1), dataFields, BytesUtil.intToBytes(crc16));
}

View File

@@ -16,7 +16,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* 预约充电启动结果上送
* 0x65预约充电启动结果上送
*/
@Slf4j
@Component
@@ -66,7 +66,7 @@ public class ReservationChargingStartupResultHandler extends AbstractHandler{
byte[] vinCodeByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
String vinCode = BytesUtil.bcd2Str(vinCodeByteArr);
// 启动结果
// 启动结果 0x00失败 0x01成功
startIndex += length;
length = 1;
byte[] startupResultByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);