mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-22 12:05:05 +08:00
update 电单车协议
This commit is contained in:
@@ -72,96 +72,93 @@ public class EBikeMessageCmd82 extends AbsEBikeMessage {
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
public static class SpecificData {
|
||||
private String rateMode; // 费率模式 (1字节)
|
||||
private String balanceOrValidity; // 余额/有效期 (4字节)
|
||||
private String portNumber; // 端口号 (指实际端口号, 发指令的时候自动转换为桩能识别的byte字节)
|
||||
private String chargeCommand; // 充电命令 (1字节)
|
||||
private String chargeDurationOrPower; // 充电时长/电量 (2字节)
|
||||
private int rateMode; // 费率模式 (1字节)
|
||||
private int balanceOrValidity; // 余额/有效期 (4字节)
|
||||
private int portNumber; // 端口号 (指实际端口号, 发指令的时候自动转换为桩能识别的byte字节)
|
||||
private int chargeCommand; // 充电命令 (1字节)
|
||||
private int chargeDurationOrPower; // 充电时长/电量 (2字节)
|
||||
private String orderNumber; // 订单编号 (16字节)
|
||||
private String maxChargeDuration; // 最大充电时长 (2字节)
|
||||
private String overloadPower; // 过载功率 (2字节)
|
||||
private String qrCodeLight; // 二维码灯 (1字节)
|
||||
private String longChargeMode; // 长充模式 (1字节)
|
||||
private String extraFloatChargeTime; // 额外浮充时间 (2字节)
|
||||
private String skipShortCircuitDetection; // 是否跳过短路检测 (1字节)
|
||||
private String noUserPullOutCheck; // 不判断用户拔出 (1字节)
|
||||
private String forceAutoStopWhenFull; // 强制带充满自停 (1字节)
|
||||
private String fullChargePower; // 充满功率 (1字节)
|
||||
private String maxFullChargePowerCheckTime; // 充满功率最长判断时间 (1字节)
|
||||
private int maxChargeDuration; // 最大充电时长 (2字节)
|
||||
private int overloadPower; // 过载功率 (2字节)
|
||||
private int qrCodeLight; // 二维码灯 (1字节)
|
||||
private int longChargeMode; // 长充模式 (1字节)
|
||||
private int extraFloatChargeTime; // 额外浮充时间 (2字节)
|
||||
private int skipShortCircuitDetection; // 是否跳过短路检测 (1字节)
|
||||
private int noUserPullOutCheck; // 不判断用户拔出 (1字节)
|
||||
private int forceAutoStopWhenFull; // 强制带充满自停 (1字节)
|
||||
private int fullChargePower; // 充满功率 (1字节)
|
||||
private int maxFullChargePowerCheckTime; // 充满功率最长判断时间 (1字节)
|
||||
|
||||
public SpecificData(byte[] dataBytes) {
|
||||
byte rateModeBytes = dataBytes[0];
|
||||
this.rateMode = BytesUtil.bcd2StrLittle(new byte[]{rateModeBytes});
|
||||
this.rateMode = BytesUtil.bytesToIntLittle(new byte[]{rateModeBytes});
|
||||
|
||||
byte[] balanceOrValidityBytes = Arrays.copyOfRange(dataBytes, 1, 5);
|
||||
this.balanceOrValidity = BytesUtil.bcd2StrLittle(balanceOrValidityBytes);
|
||||
this.balanceOrValidity = BytesUtil.bytesToIntLittle(balanceOrValidityBytes);
|
||||
|
||||
byte portNumberBytes = dataBytes[5];
|
||||
this.portNumber = BytesUtil.bcd2StrLittle(new byte[]{portNumberBytes});
|
||||
this.portNumber = BytesUtil.bytesToIntLittle(new byte[]{portNumberBytes});
|
||||
|
||||
byte chargeCommandBytes = dataBytes[6];
|
||||
this.chargeCommand = BytesUtil.bcd2StrLittle(new byte[]{chargeCommandBytes});
|
||||
this.chargeCommand = BytesUtil.bytesToIntLittle(new byte[]{chargeCommandBytes});
|
||||
|
||||
byte[] chargeDurationOrPowerBytes = Arrays.copyOfRange(dataBytes, 7, 9);
|
||||
this.chargeDurationOrPower = BytesUtil.bcd2StrLittle(chargeDurationOrPowerBytes);
|
||||
this.chargeDurationOrPower = BytesUtil.bytesToIntLittle(chargeDurationOrPowerBytes);
|
||||
|
||||
byte[] orderNumberBytes = Arrays.copyOfRange(dataBytes, 9, 25);
|
||||
this.orderNumber = BytesUtil.bcd2StrLittle(orderNumberBytes);
|
||||
|
||||
byte[] maxChargeDurationBytes = Arrays.copyOfRange(dataBytes, 25, 27);
|
||||
this.maxChargeDuration = BytesUtil.bcd2StrLittle(maxChargeDurationBytes);
|
||||
this.maxChargeDuration = BytesUtil.bytesToIntLittle(maxChargeDurationBytes);
|
||||
|
||||
byte[] overloadPowerBytes = Arrays.copyOfRange(dataBytes, 27, 29);
|
||||
this.overloadPower = BytesUtil.bcd2StrLittle(overloadPowerBytes);
|
||||
this.overloadPower = BytesUtil.bytesToIntLittle(overloadPowerBytes);
|
||||
|
||||
byte qrCodeLightBytes = dataBytes[29];
|
||||
this.qrCodeLight = BytesUtil.bcd2StrLittle(new byte[]{qrCodeLightBytes});
|
||||
this.qrCodeLight = BytesUtil.bytesToIntLittle(new byte[]{qrCodeLightBytes});
|
||||
|
||||
byte longChargeModeBytes = dataBytes[30];
|
||||
this.longChargeMode = BytesUtil.bcd2StrLittle(new byte[]{longChargeModeBytes});
|
||||
this.longChargeMode = BytesUtil.bytesToIntLittle(new byte[]{longChargeModeBytes});
|
||||
|
||||
byte[] extraFloatChargeTimeBytes = Arrays.copyOfRange(dataBytes, 31, 33);
|
||||
this.extraFloatChargeTime = BytesUtil.bcd2StrLittle(extraFloatChargeTimeBytes);
|
||||
this.extraFloatChargeTime = BytesUtil.bytesToIntLittle(extraFloatChargeTimeBytes);
|
||||
|
||||
byte skipShortCircuitDetectionBytes = dataBytes[33];
|
||||
this.skipShortCircuitDetection = BytesUtil.bcd2StrLittle(new byte[]{skipShortCircuitDetectionBytes});
|
||||
this.skipShortCircuitDetection = BytesUtil.bytesToIntLittle(new byte[]{skipShortCircuitDetectionBytes});
|
||||
|
||||
byte noUserPullOutCheckBytes = dataBytes[34];
|
||||
this.noUserPullOutCheck = BytesUtil.bcd2StrLittle(new byte[]{noUserPullOutCheckBytes});
|
||||
this.noUserPullOutCheck = BytesUtil.bytesToIntLittle(new byte[]{noUserPullOutCheckBytes});
|
||||
|
||||
byte forceAutoStopWhenFullByte = dataBytes[35];
|
||||
this.forceAutoStopWhenFull = BytesUtil.bcd2StrLittle(new byte[]{forceAutoStopWhenFullByte});
|
||||
this.forceAutoStopWhenFull = BytesUtil.bytesToIntLittle(new byte[]{forceAutoStopWhenFullByte});
|
||||
|
||||
byte fullChargePowerBytes = dataBytes[36];
|
||||
this.fullChargePower = BytesUtil.bcd2StrLittle(new byte[]{fullChargePowerBytes});
|
||||
this.fullChargePower = BytesUtil.bytesToIntLittle(new byte[]{fullChargePowerBytes});
|
||||
|
||||
byte maxFullChargePowerCheckTimeBytes = dataBytes[37];
|
||||
this.maxFullChargePowerCheckTime = BytesUtil.bcd2StrLittle(new byte[]{maxFullChargePowerCheckTimeBytes});
|
||||
this.maxFullChargePowerCheckTime = BytesUtil.bytesToIntLittle(new byte[]{maxFullChargePowerCheckTimeBytes});
|
||||
}
|
||||
|
||||
// 获取字节数组
|
||||
public byte[] getBytes() {
|
||||
// 费率模式
|
||||
byte[] rateModeBytes = BytesUtil.intToBytesLittle(Integer.parseInt(rateMode), 1);
|
||||
byte[] rateModeBytes = BytesUtil.intToBytesLittle(rateMode, 1);
|
||||
// 余额/有效期
|
||||
byte[] balanceOrValidityBytes = BytesUtil.intToBytesLittle(Integer.parseInt(balanceOrValidity), 4);
|
||||
byte[] balanceOrValidityBytes = BytesUtil.intToBytesLittle(balanceOrValidity, 4);
|
||||
// 端口号
|
||||
byte[] portNumberBytes = YouDianUtils.convertPortNumberToBytes(portNumber);
|
||||
// 充电命令
|
||||
byte[] chargeCommandBytes = BytesUtil.intToBytesLittle(Integer.parseInt(chargeCommand), 1);
|
||||
byte[] chargeCommandBytes = BytesUtil.intToBytesLittle(chargeCommand, 1);
|
||||
// 充电时长/电量
|
||||
byte[] chargeDurationOrPowerBytes = BytesUtil.stringToHexBytes(chargeDurationOrPower, 2);
|
||||
byte[] chargeDurationOrPowerBytes = BytesUtil.intToBytesLittle(chargeDurationOrPower, 2);
|
||||
// 订单编号
|
||||
// byte[] orderNumberBytes = BytesUtil.stringToHexBytes(orderNumber, 16);
|
||||
byte[] orderNumberBytes = BytesUtil.ensureLength(BytesUtil.str2Bcd(orderNumber), 16);
|
||||
// 最大充电时长
|
||||
// byte[] maxChargeDurationBytes = BytesUtil.stringToHexBytes(maxChargeDuration, 2);
|
||||
byte[] maxChargeDurationBytes = BytesUtil.intToBytesLittle(Integer.parseInt(maxChargeDuration), 2);
|
||||
byte[] maxChargeDurationBytes = BytesUtil.intToBytesLittle(maxChargeDuration, 2);
|
||||
// 过载功率
|
||||
// byte[] overloadPowerBytes = BytesUtil.stringToHexBytes(overloadPower, 2);
|
||||
byte[] overloadPowerBytes = BytesUtil.intToBytesLittle(Integer.parseInt(overloadPower), 2);
|
||||
byte[] overloadPowerBytes = BytesUtil.intToBytesLittle(overloadPower, 2);
|
||||
// 二维码灯
|
||||
byte[] qrCodeLightBytes = BytesUtil.intToBytesLittle(Integer.parseInt(qrCodeLight), 1);
|
||||
byte[] qrCodeLightBytes = BytesUtil.intToBytesLittle(qrCodeLight, 1);
|
||||
// 长充模式
|
||||
// byte[] longChargeModeBytes = BytesUtil.stringToHexBytes(longChargeMode, 1);
|
||||
// 额外浮充时间
|
||||
|
||||
Reference in New Issue
Block a user