mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-23 12:35:07 +08:00
update 电单车协议
This commit is contained in:
@@ -34,17 +34,17 @@ public abstract class AbsEBikeMessage {
|
||||
private static AbsEBikeMessage createMessageInstance(String command, String header, int length, int physicalId, int messageId, int checksum, byte[] dataBytes) {
|
||||
switch (command) {
|
||||
case "02":
|
||||
return new EBikeMessageCmd02(header, length, physicalId, messageId, command, null, checksum, new CreditCardInfo(dataBytes));
|
||||
return new EBikeMessageCmd02(header, length, physicalId, messageId, command, null, checksum, new EBikeMessageCmd02.CreditCardInfo(dataBytes));
|
||||
case "03":
|
||||
return new EBikeMessageCmd03(header, length, physicalId, messageId, command, null, checksum, new SettlementInfo(dataBytes));
|
||||
return new EBikeMessageCmd03(header, length, physicalId, messageId, command, null, checksum, new EBikeMessageCmd03.SettlementInfo(dataBytes));
|
||||
case "04":
|
||||
return new EBikeMessageCmd04(header, length, physicalId, messageId, command, null, checksum, new ConfirmOrder(dataBytes));
|
||||
return new EBikeMessageCmd04(header, length, physicalId, messageId, command, null, checksum, new EBikeMessageCmd04.ConfirmOrder(dataBytes));
|
||||
case "06":
|
||||
return new EBikeMessageCmd06(header, length, physicalId, messageId, command, null, checksum, new PowerHeartbeat(dataBytes));
|
||||
return new EBikeMessageCmd06(header, length, physicalId, messageId, command, null, checksum, new EBikeMessageCmd06.PowerHeartbeat(dataBytes));
|
||||
case "20":
|
||||
return new EBikeMessageCmd20(header, length, physicalId, messageId, command, null, checksum, new DeviceRegister(dataBytes));
|
||||
return new EBikeMessageCmd20(header, length, physicalId, messageId, command, null, checksum, new EBikeMessageCmd20.DeviceRegister(dataBytes));
|
||||
case "21":
|
||||
return new EBikeMessageCmd21(header, length, physicalId, messageId, command, null, checksum, new DeviceHeartbeat(dataBytes));
|
||||
return new EBikeMessageCmd21(header, length, physicalId, messageId, command, null, checksum, new EBikeMessageCmd21.DeviceHeartbeat(dataBytes));
|
||||
case "22":
|
||||
return new EBikeMessageCmd22(header, length, physicalId, messageId, command, null, checksum);
|
||||
default:
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
package com.jsowell.pile.domain.ebike.deviceupload;
|
||||
|
||||
import com.jsowell.common.util.BytesUtil;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
@Data
|
||||
public class ConfirmOrder {
|
||||
/**
|
||||
* 端口号
|
||||
*/
|
||||
private String portNumber;
|
||||
|
||||
/**
|
||||
* 在线/离线启动
|
||||
*/
|
||||
private String startMode;
|
||||
|
||||
/**
|
||||
* 卡片ID
|
||||
*/
|
||||
private String cardId;
|
||||
|
||||
/**
|
||||
* 充电时长
|
||||
*/
|
||||
private String chargingTime;
|
||||
|
||||
/**
|
||||
* 订单编号
|
||||
*/
|
||||
private String orderCode;
|
||||
|
||||
public ConfirmOrder(byte[] dataBytes) {
|
||||
this.portNumber = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, 0, 1)) + "";
|
||||
this.startMode = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, 1, 2)) + "";
|
||||
this.cardId = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, 2, 6)) + "";
|
||||
this.chargingTime = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, 6, 8)) + "";
|
||||
this.orderCode = BytesUtil.bcd2StrLittle(Arrays.copyOfRange(dataBytes, 8, 24));
|
||||
}
|
||||
}
|
||||
@@ -1,69 +0,0 @@
|
||||
package com.jsowell.pile.domain.ebike.deviceupload;
|
||||
|
||||
import com.jsowell.common.util.BytesUtil;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
@Data
|
||||
public class CreditCardInfo {
|
||||
/**
|
||||
* 卡片ID
|
||||
*/
|
||||
private String cardId;
|
||||
|
||||
/**
|
||||
* 卡片类型
|
||||
*/
|
||||
private String cardType;
|
||||
|
||||
/**
|
||||
* 端口号
|
||||
*/
|
||||
private String portNumber;
|
||||
|
||||
/**
|
||||
* 余额卡内金额
|
||||
*/
|
||||
private String cardBalance;
|
||||
|
||||
/**
|
||||
* 时间戳
|
||||
*/
|
||||
// private String timestamp;
|
||||
|
||||
/**
|
||||
* 卡号2字节数
|
||||
*/
|
||||
private int card2Length;
|
||||
|
||||
/**
|
||||
* 卡号2
|
||||
*/
|
||||
private String card2Code;
|
||||
|
||||
public CreditCardInfo(byte[] dataBytes) {
|
||||
int startIndex = 0;
|
||||
int length = 4;
|
||||
this.cardId = BytesUtil.bcd2Str(Arrays.copyOfRange(dataBytes, startIndex, startIndex = startIndex + length)) + "";
|
||||
|
||||
length = 1;
|
||||
this.cardType = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, startIndex, startIndex = startIndex + length)) + "";
|
||||
|
||||
length = 1;
|
||||
this.portNumber = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, startIndex, startIndex = startIndex + length)) + "";
|
||||
|
||||
length = 2;
|
||||
this.cardBalance = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, startIndex, startIndex = startIndex + length)) + "";
|
||||
|
||||
// length = 4;
|
||||
// this.timestamp = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, startIndex, startIndex = startIndex + length)) + "";
|
||||
|
||||
if (dataBytes.length > startIndex) {
|
||||
length = 1;
|
||||
card2Length = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, startIndex, startIndex = startIndex + length));
|
||||
|
||||
this.card2Code = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, startIndex, card2Length)) + "";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
package com.jsowell.pile.domain.ebike.deviceupload;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.jsowell.common.enums.ebike.PortStatusEnum;
|
||||
import com.jsowell.common.util.BytesUtil;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 此为心跳包,间隔时间默认为3分钟,方便服务器管理SocketIP
|
||||
* 设备如2次收不到服务器应答,则进入离线状态
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public class DeviceHeartbeat {
|
||||
/**
|
||||
* 电压:设备的当前电压(打包发送心跳包指令时的当前时间点的实时电压)
|
||||
*/
|
||||
private String voltage;
|
||||
|
||||
/**
|
||||
* 端口数量:表示设备总共有多少个端口,和后面的“端口状态”配套
|
||||
*/
|
||||
private int portNumber;
|
||||
|
||||
/**
|
||||
* 注4、各端口状态:一个字节表示一个端口,和“端口数量”匹配,
|
||||
* 如端口数量是16,则“各端口状态”为16字节;
|
||||
* 每个字节表示的意思,
|
||||
* 0=空闲,1=充电中,2=有充电器但未充电(用户未启动充电),3=有充电器但未充电(已充满电) 4=该路无法计量,5=浮充,6=存储器损坏,
|
||||
* 7=插座弹片卡住故障,8=接触不良或保险丝烧断故障,9=(算法-继电器粘连),0x0A=霍尔开关损坏(即插入检测传感器)。
|
||||
* 0x0B=(预检-继电器坏或保险丝断),0x0D=(预检-负载短路)。0x0E=(过滤性预检-继电器粘连),0x0F=(刷卡芯片损坏故障),0x10=(检测电路故障)
|
||||
*/
|
||||
private List<String> portStatus;
|
||||
|
||||
/**
|
||||
* 信号强度:指分机与主机之间的无线信号强度,如LORA信号。00则为有线组网或无信号强度功能
|
||||
*/
|
||||
private String rssi;
|
||||
|
||||
/**
|
||||
* 当前环境温度:表示当前设备内的温度,可能和真正的当前环境温度有一定的误差,如00则表示无此功能
|
||||
*/
|
||||
private String temperature;
|
||||
|
||||
|
||||
public DeviceHeartbeat(byte[] dataBytes) {
|
||||
this.voltage = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, 0, 2)) + "";
|
||||
this.portNumber = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, 2, 3));
|
||||
|
||||
byte[] statusBytes = Arrays.copyOfRange(dataBytes, 3, this.portNumber);
|
||||
List<String> statusList = Lists.newArrayList();
|
||||
for (byte statusByte : statusBytes) {
|
||||
int status = BytesUtil.bytesToIntLittle(new byte[]{statusByte});
|
||||
statusList.add(PortStatusEnum.getDescriptionByValue(status));
|
||||
}
|
||||
this.portStatus = statusList;
|
||||
this.rssi = BytesUtil.bcd2StrLittle(Arrays.copyOfRange(dataBytes, dataBytes.length - 2, dataBytes.length - 1));
|
||||
this.temperature = BytesUtil.bcd2StrLittle(Arrays.copyOfRange(dataBytes, dataBytes.length - 1, dataBytes.length));
|
||||
}
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
package com.jsowell.pile.domain.ebike.deviceupload;
|
||||
|
||||
import com.jsowell.common.util.BytesUtil;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
@Data
|
||||
public class DeviceRegister {
|
||||
/**
|
||||
* 固件版本,如100则表示V1.00版本
|
||||
*/
|
||||
private String firmwareVersion;
|
||||
|
||||
/**
|
||||
* 端口数量 表示设备总共有多少个端口
|
||||
*/
|
||||
private String portNumber;
|
||||
|
||||
/**
|
||||
* 虚拟ID:需要内部组网的设备的本地地址,如485、LORA系列,如不需组网的设备,默认为00
|
||||
*/
|
||||
private String virtualId;
|
||||
|
||||
/**
|
||||
* 设备类型: 见01指令中的设备类型表
|
||||
*/
|
||||
private String deviceType;
|
||||
|
||||
/**
|
||||
* 工作模式:第0位:0=联网,1=刷卡。第1位:0=RN8209,1=BL0939。第2位:0=无短路预检,1=有短路预检。第3位:0=光耦检测模式,1=带灯模式。
|
||||
*/
|
||||
private String workMode;
|
||||
|
||||
/**
|
||||
* 电源板版本号:电源板的固件版本号,如没有电源板的机型则为0
|
||||
*/
|
||||
private String powerBoardVersion;
|
||||
|
||||
public DeviceRegister(byte[] dataBytes) {
|
||||
this.firmwareVersion = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, 0, 2)) + "";
|
||||
this.portNumber = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, 2, 3)) + "";
|
||||
this.virtualId = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, 3, 4)) + "";
|
||||
this.deviceType = BytesUtil.bcd2StrLittle(Arrays.copyOfRange(dataBytes, 4, 5));
|
||||
this.workMode = BytesUtil.bcd2StrLittle(Arrays.copyOfRange(dataBytes, 5, 6));
|
||||
this.powerBoardVersion = BytesUtil.bcd2StrLittle(Arrays.copyOfRange(dataBytes, 6, 8));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +1,11 @@
|
||||
package com.jsowell.pile.domain.ebike.deviceupload;
|
||||
|
||||
import com.jsowell.common.util.BytesUtil;
|
||||
import com.jsowell.pile.domain.ebike.AbsEBikeMessage;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* 刷卡操作(02指令)
|
||||
@@ -24,4 +29,68 @@ public class EBikeMessageCmd02 extends AbsEBikeMessage {
|
||||
public CreditCardInfo getCreditCardInfo() {
|
||||
return creditCardInfo;
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public static class CreditCardInfo {
|
||||
/**
|
||||
* 卡片ID
|
||||
*/
|
||||
private String cardId;
|
||||
|
||||
/**
|
||||
* 卡片类型
|
||||
*/
|
||||
private String cardType;
|
||||
|
||||
/**
|
||||
* 端口号
|
||||
*/
|
||||
private String portNumber;
|
||||
|
||||
/**
|
||||
* 余额卡内金额
|
||||
*/
|
||||
private String cardBalance;
|
||||
|
||||
/**
|
||||
* 时间戳
|
||||
*/
|
||||
// private String timestamp;
|
||||
|
||||
/**
|
||||
* 卡号2字节数
|
||||
*/
|
||||
private int card2Length;
|
||||
|
||||
/**
|
||||
* 卡号2
|
||||
*/
|
||||
private String card2Code;
|
||||
|
||||
public CreditCardInfo(byte[] dataBytes) {
|
||||
int startIndex = 0;
|
||||
int length = 4;
|
||||
this.cardId = BytesUtil.bcd2Str(Arrays.copyOfRange(dataBytes, startIndex, startIndex = startIndex + length)) + "";
|
||||
|
||||
length = 1;
|
||||
this.cardType = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, startIndex, startIndex = startIndex + length)) + "";
|
||||
|
||||
length = 1;
|
||||
this.portNumber = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, startIndex, startIndex = startIndex + length)) + "";
|
||||
|
||||
length = 2;
|
||||
this.cardBalance = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, startIndex, startIndex = startIndex + length)) + "";
|
||||
|
||||
// length = 4;
|
||||
// this.timestamp = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, startIndex, startIndex = startIndex + length)) + "";
|
||||
|
||||
if (dataBytes.length > startIndex) {
|
||||
length = 1;
|
||||
card2Length = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, startIndex, startIndex = startIndex + length));
|
||||
|
||||
this.card2Code = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, startIndex, card2Length)) + "";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,10 @@
|
||||
package com.jsowell.pile.domain.ebike.deviceupload;
|
||||
|
||||
import com.jsowell.common.util.BytesUtil;
|
||||
import com.jsowell.pile.domain.ebike.AbsEBikeMessage;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class EBikeMessageCmd03 extends AbsEBikeMessage {
|
||||
|
||||
@@ -19,4 +23,34 @@ public class EBikeMessageCmd03 extends AbsEBikeMessage {
|
||||
public SettlementInfo getSettlementInfo() {
|
||||
return settlementInfo;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class SettlementInfo {
|
||||
private String chargingDuration; // 充电时长, 单位:"秒"
|
||||
private String maxPower; // 最大功率, 单位:"0.1W"
|
||||
private String consumedEnergy; // 耗电量, 单位:"0.01度"
|
||||
private String portNumber; // 端口号
|
||||
private String startMode; // 在线/离线启动/验证码
|
||||
private String cardNumberOrVerificationCode; // 卡号/验证码
|
||||
private String stopReason; // 停止原因
|
||||
private String orderNumber; // 订单编号
|
||||
private String secondMaxPower; // 第二最大功率
|
||||
// private String timestamp; // 时间戳 上发指令当时的时间,有时候不准确,该字段属于调试使用,服务器无需关心此字段
|
||||
// private String placeholderDuration; // 占位时长 充电柜专用,其他设备忽略此字段 表示充满后占用设备的时长,单位为分钟
|
||||
|
||||
public SettlementInfo(byte[] dataBytes) {
|
||||
this.chargingDuration = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, 0, 2)) + "";
|
||||
this.maxPower = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, 2, 4)) + "";
|
||||
this.consumedEnergy = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, 4, 6)) + "";
|
||||
this.portNumber = BytesUtil.bcd2StrLittle(new byte[]{dataBytes[6]});
|
||||
this.startMode = BytesUtil.bcd2StrLittle(new byte[]{dataBytes[7]});
|
||||
this.cardNumberOrVerificationCode = BytesUtil.bcd2StrLittle(Arrays.copyOfRange(dataBytes, 8, 12));
|
||||
this.stopReason = BytesUtil.bcd2StrLittle(new byte[]{dataBytes[12]});
|
||||
this.orderNumber = BytesUtil.bcd2StrLittle(Arrays.copyOfRange(dataBytes, 13, 29));
|
||||
this.secondMaxPower = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, 29, 31)) + "";
|
||||
// this.timestamp = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, 31, 35)) + "";
|
||||
// this.placeholderDuration = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, 35, 37)) + "";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,10 @@
|
||||
package com.jsowell.pile.domain.ebike.deviceupload;
|
||||
|
||||
import com.jsowell.common.util.BytesUtil;
|
||||
import com.jsowell.pile.domain.ebike.AbsEBikeMessage;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* 充电端口订单确认(04指令)
|
||||
@@ -23,4 +27,40 @@ public class EBikeMessageCmd04 extends AbsEBikeMessage {
|
||||
public ConfirmOrder getSettlementInfo() {
|
||||
return confirmOrder;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class ConfirmOrder {
|
||||
/**
|
||||
* 端口号
|
||||
*/
|
||||
private String portNumber;
|
||||
|
||||
/**
|
||||
* 在线/离线启动
|
||||
*/
|
||||
private String startMode;
|
||||
|
||||
/**
|
||||
* 卡片ID
|
||||
*/
|
||||
private String cardId;
|
||||
|
||||
/**
|
||||
* 充电时长
|
||||
*/
|
||||
private String chargingTime;
|
||||
|
||||
/**
|
||||
* 订单编号
|
||||
*/
|
||||
private String orderCode;
|
||||
|
||||
public ConfirmOrder(byte[] dataBytes) {
|
||||
this.portNumber = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, 0, 1)) + "";
|
||||
this.startMode = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, 1, 2)) + "";
|
||||
this.cardId = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, 2, 6)) + "";
|
||||
this.chargingTime = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, 6, 8)) + "";
|
||||
this.orderCode = BytesUtil.bcd2StrLittle(Arrays.copyOfRange(dataBytes, 8, 24));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,11 @@
|
||||
package com.jsowell.pile.domain.ebike.deviceupload;
|
||||
|
||||
import com.jsowell.common.util.BytesUtil;
|
||||
import com.jsowell.pile.domain.ebike.AbsEBikeMessage;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* 端口充电时功率心跳包(06指令)
|
||||
@@ -24,4 +29,157 @@ public class EBikeMessageCmd06 extends AbsEBikeMessage {
|
||||
public PowerHeartbeat getPowerHeartbeat() {
|
||||
return powerHeartbeat;
|
||||
}
|
||||
|
||||
/**
|
||||
* 功率心跳包
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public static class PowerHeartbeat {
|
||||
/**
|
||||
* 端口号:当前充电的端口号。注:00表示1号端口,01表示2号端口
|
||||
*/
|
||||
private String port;
|
||||
|
||||
/**
|
||||
* 各端口状态: 1=充电中, 2=已扫码,暂未检测到功率,等待插入充电器(充电柜专有,如单车桩出现此值为出错值请忽略),3=有充电器但未充电(已充满电),5=浮充,其他值=出错值请忽略
|
||||
*/
|
||||
private String portStatus;
|
||||
|
||||
/**
|
||||
* 充电时长:开始充电到当前为止,已经充电多长时间
|
||||
*/
|
||||
private String chargingTime;
|
||||
|
||||
/**
|
||||
* 当前订单累计电量:当前端口的订单,开始充电到当前为止,已经消耗的电量
|
||||
*/
|
||||
private String totalUsedElectricity;
|
||||
|
||||
/**
|
||||
* 在线/离线启动:=0表示启动时,处于离线状态 ;=1表示启动时,处于在线状态; 3=验证码启动(仅支持带按键和屏幕的机型)
|
||||
*/
|
||||
private String startMode;
|
||||
|
||||
/**
|
||||
* 实时功率:心跳包发送时的当前功率
|
||||
*/
|
||||
private String realTimePower;
|
||||
|
||||
/**
|
||||
* 心跳包期间最大功率:心跳包期间出现过的最大功率
|
||||
*/
|
||||
private String maxPower;
|
||||
|
||||
/**
|
||||
* 心跳包期间最小功率:心跳包期间出现过的最小功率
|
||||
*/
|
||||
private String minPower;
|
||||
|
||||
/**
|
||||
* 心跳包期间平均功率:心跳包期间出现过的平均功率
|
||||
*/
|
||||
private String avgPower;
|
||||
|
||||
/**
|
||||
* 订单编号:当前充电的订单编号
|
||||
*/
|
||||
private String orderCode;
|
||||
|
||||
/**
|
||||
* 该时间段内消耗电量:此数据需除以4800后才是真实的电量,该字段属于调试使用,服务器无需关心此字段
|
||||
*/
|
||||
// private String timePeriodElectricity;
|
||||
|
||||
/**
|
||||
* 峰值功率:整个充电过程中出现过的最大功率,有些版本无此字段
|
||||
*/
|
||||
private String peakPower;
|
||||
|
||||
/**
|
||||
* 设备的当前电压
|
||||
*/
|
||||
private String voltage;
|
||||
|
||||
/**
|
||||
* 设备的当前电流,可以计量芯片采集也可以通过计算得出,0.001A为单位,1000表示1A电流
|
||||
*/
|
||||
private String current;
|
||||
|
||||
/**
|
||||
* 设备的当前环境温度,仅针对有此功能的机型
|
||||
*/
|
||||
private String ambientTemperature;
|
||||
|
||||
/**
|
||||
* 端口温度,仅针对有此功能的机型
|
||||
*/
|
||||
private String portTemperature;
|
||||
|
||||
/**
|
||||
* 上发指令当时的时间,有时候不准确,该字段属于调试使用,服务器无需关心此字段
|
||||
*/
|
||||
// private String timestamp;
|
||||
|
||||
/**
|
||||
* 占位时长:(充电柜专用,其他设备忽略此字段)表示充满后占用设备的时长,单位为分钟
|
||||
*/
|
||||
private String occupancyTime;
|
||||
|
||||
|
||||
public PowerHeartbeat(byte[] dataBytes) {
|
||||
int startIndex = 0;
|
||||
int length = 1;
|
||||
this.port = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, startIndex, startIndex = startIndex + length)) + "";
|
||||
|
||||
length = 1;
|
||||
this.portStatus = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, startIndex, startIndex = startIndex + length)) + "";
|
||||
|
||||
length = 2;
|
||||
this.chargingTime = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, startIndex, startIndex = startIndex + length)) + "";
|
||||
|
||||
length = 2;
|
||||
this.totalUsedElectricity = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, startIndex, startIndex = startIndex + length)) * 0.01 + "";
|
||||
|
||||
length = 1;
|
||||
this.startMode = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, startIndex, startIndex = startIndex + length)) + "";
|
||||
|
||||
length = 2;
|
||||
this.realTimePower = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, startIndex, startIndex = startIndex + length)) * 0.1 + "";
|
||||
|
||||
length = 2;
|
||||
this.maxPower = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, startIndex, startIndex = startIndex + length)) * 0.1 + "";
|
||||
|
||||
length = 2;
|
||||
this.minPower = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, startIndex, startIndex = startIndex + length)) * 0.1 + "";
|
||||
|
||||
length = 2;
|
||||
this.avgPower = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, startIndex, startIndex = startIndex + length)) * 0.1 + "";
|
||||
|
||||
length = 16;
|
||||
this.orderCode = BytesUtil.bcd2StrLittle(Arrays.copyOfRange(dataBytes, startIndex, startIndex = startIndex + length));
|
||||
|
||||
length = 2;
|
||||
this.peakPower = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, startIndex, startIndex = startIndex + length)) + "";
|
||||
|
||||
length = 2;
|
||||
this.voltage = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, startIndex, startIndex = startIndex + length)) * 0.1 + "";
|
||||
|
||||
length = 2;
|
||||
this.current = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, startIndex, startIndex = startIndex + length)) * 0.0001 + "";
|
||||
|
||||
length = 1;
|
||||
this.ambientTemperature = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, startIndex, startIndex = startIndex + length)) + "";
|
||||
|
||||
length = 1;
|
||||
this.portTemperature = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, startIndex, startIndex = startIndex + length)) + "";
|
||||
|
||||
// length = 4;
|
||||
// this.timestamp = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, startIndex, startIndex = startIndex + length)) + "";
|
||||
|
||||
length = 2;
|
||||
this.occupancyTime = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, startIndex, startIndex = startIndex + length)) + "";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +1,10 @@
|
||||
package com.jsowell.pile.domain.ebike.deviceupload;
|
||||
|
||||
import com.jsowell.common.util.BytesUtil;
|
||||
import com.jsowell.pile.domain.ebike.AbsEBikeMessage;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* 设备注册包(20指令)
|
||||
@@ -22,4 +26,48 @@ public class EBikeMessageCmd20 extends AbsEBikeMessage {
|
||||
public DeviceRegister getDeviceRegister() {
|
||||
return deviceRegister;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class DeviceRegister {
|
||||
/**
|
||||
* 固件版本,如100则表示V1.00版本
|
||||
*/
|
||||
private String firmwareVersion;
|
||||
|
||||
/**
|
||||
* 端口数量 表示设备总共有多少个端口
|
||||
*/
|
||||
private String portNumber;
|
||||
|
||||
/**
|
||||
* 虚拟ID:需要内部组网的设备的本地地址,如485、LORA系列,如不需组网的设备,默认为00
|
||||
*/
|
||||
private String virtualId;
|
||||
|
||||
/**
|
||||
* 设备类型: 见01指令中的设备类型表
|
||||
*/
|
||||
private String deviceType;
|
||||
|
||||
/**
|
||||
* 工作模式:第0位:0=联网,1=刷卡。第1位:0=RN8209,1=BL0939。第2位:0=无短路预检,1=有短路预检。第3位:0=光耦检测模式,1=带灯模式。
|
||||
*/
|
||||
private String workMode;
|
||||
|
||||
/**
|
||||
* 电源板版本号:电源板的固件版本号,如没有电源板的机型则为0
|
||||
*/
|
||||
private String powerBoardVersion;
|
||||
|
||||
public DeviceRegister(byte[] dataBytes) {
|
||||
this.firmwareVersion = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, 0, 2)) + "";
|
||||
this.portNumber = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, 2, 3)) + "";
|
||||
this.virtualId = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, 3, 4)) + "";
|
||||
this.deviceType = BytesUtil.bcd2StrLittle(Arrays.copyOfRange(dataBytes, 4, 5));
|
||||
this.workMode = BytesUtil.bcd2StrLittle(Arrays.copyOfRange(dataBytes, 5, 6));
|
||||
this.powerBoardVersion = BytesUtil.bcd2StrLittle(Arrays.copyOfRange(dataBytes, 6, 8));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,9 +1,15 @@
|
||||
package com.jsowell.pile.domain.ebike.deviceupload;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.jsowell.common.enums.ebike.PortStatusEnum;
|
||||
import com.jsowell.common.util.BytesUtil;
|
||||
import com.jsowell.pile.domain.ebike.AbsEBikeMessage;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 设备注册包(20指令)
|
||||
*/
|
||||
@@ -23,4 +29,58 @@ public class EBikeMessageCmd21 extends AbsEBikeMessage {
|
||||
this.deviceHeartbeat = new DeviceHeartbeat(dataBytes);
|
||||
}
|
||||
|
||||
/**
|
||||
* 此为心跳包,间隔时间默认为3分钟,方便服务器管理SocketIP
|
||||
* 设备如2次收不到服务器应答,则进入离线状态
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public static class DeviceHeartbeat {
|
||||
/**
|
||||
* 电压:设备的当前电压(打包发送心跳包指令时的当前时间点的实时电压)
|
||||
*/
|
||||
private String voltage;
|
||||
|
||||
/**
|
||||
* 端口数量:表示设备总共有多少个端口,和后面的“端口状态”配套
|
||||
*/
|
||||
private int portNumber;
|
||||
|
||||
/**
|
||||
* 注4、各端口状态:一个字节表示一个端口,和“端口数量”匹配,
|
||||
* 如端口数量是16,则“各端口状态”为16字节;
|
||||
* 每个字节表示的意思,
|
||||
* 0=空闲,1=充电中,2=有充电器但未充电(用户未启动充电),3=有充电器但未充电(已充满电) 4=该路无法计量,5=浮充,6=存储器损坏,
|
||||
* 7=插座弹片卡住故障,8=接触不良或保险丝烧断故障,9=(算法-继电器粘连),0x0A=霍尔开关损坏(即插入检测传感器)。
|
||||
* 0x0B=(预检-继电器坏或保险丝断),0x0D=(预检-负载短路)。0x0E=(过滤性预检-继电器粘连),0x0F=(刷卡芯片损坏故障),0x10=(检测电路故障)
|
||||
*/
|
||||
private List<String> portStatus;
|
||||
|
||||
/**
|
||||
* 信号强度:指分机与主机之间的无线信号强度,如LORA信号。00则为有线组网或无信号强度功能
|
||||
*/
|
||||
private String rssi;
|
||||
|
||||
/**
|
||||
* 当前环境温度:表示当前设备内的温度,可能和真正的当前环境温度有一定的误差,如00则表示无此功能
|
||||
*/
|
||||
private String temperature;
|
||||
|
||||
|
||||
public DeviceHeartbeat(byte[] dataBytes) {
|
||||
this.voltage = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, 0, 2)) + "";
|
||||
this.portNumber = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, 2, 3));
|
||||
|
||||
byte[] statusBytes = Arrays.copyOfRange(dataBytes, 3, this.portNumber);
|
||||
List<String> statusList = Lists.newArrayList();
|
||||
for (byte statusByte : statusBytes) {
|
||||
int status = BytesUtil.bytesToIntLittle(new byte[]{statusByte});
|
||||
statusList.add(PortStatusEnum.getDescriptionByValue(status));
|
||||
}
|
||||
this.portStatus = statusList;
|
||||
this.rssi = BytesUtil.bcd2StrLittle(Arrays.copyOfRange(dataBytes, dataBytes.length - 2, dataBytes.length - 1));
|
||||
this.temperature = BytesUtil.bcd2StrLittle(Arrays.copyOfRange(dataBytes, dataBytes.length - 1, dataBytes.length));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,159 +0,0 @@
|
||||
package com.jsowell.pile.domain.ebike.deviceupload;
|
||||
|
||||
import com.jsowell.common.util.BytesUtil;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* 功率心跳包
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public class PowerHeartbeat {
|
||||
/**
|
||||
* 端口号:当前充电的端口号。注:00表示1号端口,01表示2号端口
|
||||
*/
|
||||
private String port;
|
||||
|
||||
/**
|
||||
* 各端口状态: 1=充电中, 2=已扫码,暂未检测到功率,等待插入充电器(充电柜专有,如单车桩出现此值为出错值请忽略),3=有充电器但未充电(已充满电),5=浮充,其他值=出错值请忽略
|
||||
*/
|
||||
private String portStatus;
|
||||
|
||||
/**
|
||||
* 充电时长:开始充电到当前为止,已经充电多长时间
|
||||
*/
|
||||
private String chargingTime;
|
||||
|
||||
/**
|
||||
* 当前订单累计电量:当前端口的订单,开始充电到当前为止,已经消耗的电量
|
||||
*/
|
||||
private String totalUsedElectricity;
|
||||
|
||||
/**
|
||||
* 在线/离线启动:=0表示启动时,处于离线状态 ;=1表示启动时,处于在线状态; 3=验证码启动(仅支持带按键和屏幕的机型)
|
||||
*/
|
||||
private String startMode;
|
||||
|
||||
/**
|
||||
* 实时功率:心跳包发送时的当前功率
|
||||
*/
|
||||
private String realTimePower;
|
||||
|
||||
/**
|
||||
* 心跳包期间最大功率:心跳包期间出现过的最大功率
|
||||
*/
|
||||
private String maxPower;
|
||||
|
||||
/**
|
||||
* 心跳包期间最小功率:心跳包期间出现过的最小功率
|
||||
*/
|
||||
private String minPower;
|
||||
|
||||
/**
|
||||
* 心跳包期间平均功率:心跳包期间出现过的平均功率
|
||||
*/
|
||||
private String avgPower;
|
||||
|
||||
/**
|
||||
* 订单编号:当前充电的订单编号
|
||||
*/
|
||||
private String orderCode;
|
||||
|
||||
/**
|
||||
* 该时间段内消耗电量:此数据需除以4800后才是真实的电量,该字段属于调试使用,服务器无需关心此字段
|
||||
*/
|
||||
// private String timePeriodElectricity;
|
||||
|
||||
/**
|
||||
* 峰值功率:整个充电过程中出现过的最大功率,有些版本无此字段
|
||||
*/
|
||||
private String peakPower;
|
||||
|
||||
/**
|
||||
* 设备的当前电压
|
||||
*/
|
||||
private String voltage;
|
||||
|
||||
/**
|
||||
* 设备的当前电流,可以计量芯片采集也可以通过计算得出,0.001A为单位,1000表示1A电流
|
||||
*/
|
||||
private String current;
|
||||
|
||||
/**
|
||||
* 设备的当前环境温度,仅针对有此功能的机型
|
||||
*/
|
||||
private String ambientTemperature;
|
||||
|
||||
/**
|
||||
* 端口温度,仅针对有此功能的机型
|
||||
*/
|
||||
private String portTemperature;
|
||||
|
||||
/**
|
||||
* 上发指令当时的时间,有时候不准确,该字段属于调试使用,服务器无需关心此字段
|
||||
*/
|
||||
// private String timestamp;
|
||||
|
||||
/**
|
||||
* 占位时长:(充电柜专用,其他设备忽略此字段)表示充满后占用设备的时长,单位为分钟
|
||||
*/
|
||||
private String occupancyTime;
|
||||
|
||||
|
||||
public PowerHeartbeat(byte[] dataBytes) {
|
||||
int startIndex = 0;
|
||||
int length = 1;
|
||||
this.port = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, startIndex, startIndex = startIndex + length)) + "";
|
||||
|
||||
length = 1;
|
||||
this.portStatus = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, startIndex, startIndex = startIndex + length)) + "";
|
||||
|
||||
length = 2;
|
||||
this.chargingTime = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, startIndex, startIndex = startIndex + length)) + "";
|
||||
|
||||
length = 2;
|
||||
this.totalUsedElectricity = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, startIndex, startIndex = startIndex + length)) * 0.01 + "";
|
||||
|
||||
length = 1;
|
||||
this.startMode = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, startIndex, startIndex = startIndex + length)) + "";
|
||||
|
||||
length = 2;
|
||||
this.realTimePower = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, startIndex, startIndex = startIndex + length)) * 0.1 + "";
|
||||
|
||||
length = 2;
|
||||
this.maxPower = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, startIndex, startIndex = startIndex + length)) * 0.1 + "";
|
||||
|
||||
length = 2;
|
||||
this.minPower = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, startIndex, startIndex = startIndex + length)) * 0.1 + "";
|
||||
|
||||
length = 2;
|
||||
this.avgPower = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, startIndex, startIndex = startIndex + length)) * 0.1 + "";
|
||||
|
||||
length = 16;
|
||||
this.orderCode = BytesUtil.bcd2StrLittle(Arrays.copyOfRange(dataBytes, startIndex, startIndex = startIndex + length));
|
||||
|
||||
length = 2;
|
||||
this.peakPower = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, startIndex, startIndex = startIndex + length)) + "";
|
||||
|
||||
length = 2;
|
||||
this.voltage = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, startIndex, startIndex = startIndex + length)) * 0.1 + "";
|
||||
|
||||
length = 2;
|
||||
this.current = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, startIndex, startIndex = startIndex + length)) * 0.0001 + "";
|
||||
|
||||
length = 1;
|
||||
this.ambientTemperature = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, startIndex, startIndex = startIndex + length)) + "";
|
||||
|
||||
length = 1;
|
||||
this.portTemperature = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, startIndex, startIndex = startIndex + length)) + "";
|
||||
|
||||
// length = 4;
|
||||
// this.timestamp = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, startIndex, startIndex = startIndex + length)) + "";
|
||||
|
||||
length = 2;
|
||||
this.occupancyTime = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, startIndex, startIndex = startIndex + length)) + "";
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
package com.jsowell.pile.domain.ebike.deviceupload;
|
||||
|
||||
import com.jsowell.common.util.BytesUtil;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
@Data
|
||||
public class SettlementInfo {
|
||||
private String chargingDuration; // 充电时长, 单位:"秒"
|
||||
private String maxPower; // 最大功率, 单位:"0.1W"
|
||||
private String consumedEnergy; // 耗电量, 单位:"0.01度"
|
||||
private String portNumber; // 端口号
|
||||
private String startMode; // 在线/离线启动/验证码
|
||||
private String cardNumberOrVerificationCode; // 卡号/验证码
|
||||
private String stopReason; // 停止原因
|
||||
private String orderNumber; // 订单编号
|
||||
private String secondMaxPower; // 第二最大功率
|
||||
// private String timestamp; // 时间戳 上发指令当时的时间,有时候不准确,该字段属于调试使用,服务器无需关心此字段
|
||||
// private String placeholderDuration; // 占位时长 充电柜专用,其他设备忽略此字段 表示充满后占用设备的时长,单位为分钟
|
||||
|
||||
public SettlementInfo(byte[] dataBytes) {
|
||||
this.chargingDuration = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, 0, 2)) + "";
|
||||
this.maxPower = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, 2, 4)) + "";
|
||||
this.consumedEnergy = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, 4, 6)) + "";
|
||||
this.portNumber = BytesUtil.bcd2StrLittle(new byte[]{dataBytes[6]});
|
||||
this.startMode = BytesUtil.bcd2StrLittle(new byte[]{dataBytes[7]});
|
||||
this.cardNumberOrVerificationCode = BytesUtil.bcd2StrLittle(Arrays.copyOfRange(dataBytes, 8, 12));
|
||||
this.stopReason = BytesUtil.bcd2StrLittle(new byte[]{dataBytes[12]});
|
||||
this.orderNumber = BytesUtil.bcd2StrLittle(Arrays.copyOfRange(dataBytes, 13, 29));
|
||||
this.secondMaxPower = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, 29, 31)) + "";
|
||||
// this.timestamp = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, 31, 35)) + "";
|
||||
// this.placeholderDuration = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, 35, 37)) + "";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +1,11 @@
|
||||
package com.jsowell.pile.domain.ebike.serversend;
|
||||
|
||||
import com.jsowell.common.util.BytesUtil;
|
||||
import com.jsowell.pile.domain.ebike.AbsEBikeMessage;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* 服务器开始、停止充电操作(82指令)
|
||||
@@ -22,4 +27,75 @@ public class EBikeMessageCmd82 extends AbsEBikeMessage {
|
||||
public SpecificData getSpecificData() {
|
||||
return specificData;
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public static class SpecificData {
|
||||
private String rateMode; // 费率模式 (1字节)
|
||||
private String balanceOrValidity; // 余额/有效期 (4字节)
|
||||
private String portNumber; // 端口号 (1字节)
|
||||
private String chargeCommand; // 充电命令 (1字节)
|
||||
private String 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字节)
|
||||
|
||||
public SpecificData(byte[] dataBytes) {
|
||||
byte rateModeBytes = dataBytes[0];
|
||||
this.rateMode = BytesUtil.bcd2StrLittle(new byte[]{rateModeBytes});
|
||||
|
||||
byte[] balanceOrValidityBytes = Arrays.copyOfRange(dataBytes, 1, 5);
|
||||
this.balanceOrValidity = BytesUtil.bcd2StrLittle(balanceOrValidityBytes);
|
||||
|
||||
byte portNumberBytes = dataBytes[5];
|
||||
this.portNumber = BytesUtil.bcd2StrLittle(new byte[]{portNumberBytes});
|
||||
|
||||
byte chargeCommandBytes = dataBytes[6];
|
||||
this.chargeCommand = BytesUtil.bcd2StrLittle(new byte[]{chargeCommandBytes});
|
||||
|
||||
byte[] chargeDurationOrPowerBytes = Arrays.copyOfRange(dataBytes, 7, 9);
|
||||
this.chargeDurationOrPower = BytesUtil.bcd2StrLittle(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);
|
||||
|
||||
byte[] overloadPowerBytes = Arrays.copyOfRange(dataBytes, 27, 29);
|
||||
this.overloadPower = BytesUtil.bcd2StrLittle(overloadPowerBytes);
|
||||
|
||||
byte qrCodeLightBytes = dataBytes[29];
|
||||
this.qrCodeLight = BytesUtil.bcd2StrLittle(new byte[]{qrCodeLightBytes});
|
||||
|
||||
byte longChargeModeBytes = dataBytes[30];
|
||||
this.longChargeMode = BytesUtil.bcd2StrLittle(new byte[]{longChargeModeBytes});
|
||||
|
||||
byte[] extraFloatChargeTimeBytes = Arrays.copyOfRange(dataBytes, 31, 33);
|
||||
this.extraFloatChargeTime = BytesUtil.bcd2StrLittle(extraFloatChargeTimeBytes);
|
||||
|
||||
byte skipShortCircuitDetectionBytes = dataBytes[33];
|
||||
this.skipShortCircuitDetection = BytesUtil.bcd2StrLittle(new byte[]{skipShortCircuitDetectionBytes});
|
||||
|
||||
byte noUserPullOutCheckBytes = dataBytes[34];
|
||||
this.noUserPullOutCheck = BytesUtil.bcd2StrLittle(new byte[]{noUserPullOutCheckBytes});
|
||||
|
||||
byte forceAutoStopWhenFullByte = dataBytes[35];
|
||||
this.forceAutoStopWhenFull = BytesUtil.bcd2StrLittle(new byte[]{forceAutoStopWhenFullByte});
|
||||
|
||||
byte fullChargePowerBytes = dataBytes[36];
|
||||
this.fullChargePower = BytesUtil.bcd2StrLittle(new byte[]{fullChargePowerBytes});
|
||||
|
||||
byte maxFullChargePowerCheckTimeBytes = dataBytes[37];
|
||||
this.maxFullChargePowerCheckTime = BytesUtil.bcd2StrLittle(new byte[]{maxFullChargePowerCheckTimeBytes});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,78 +0,0 @@
|
||||
package com.jsowell.pile.domain.ebike.serversend;
|
||||
|
||||
import com.jsowell.common.util.BytesUtil;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class SpecificData {
|
||||
private String rateMode; // 费率模式 (1字节)
|
||||
private String balanceOrValidity; // 余额/有效期 (4字节)
|
||||
private String portNumber; // 端口号 (1字节)
|
||||
private String chargeCommand; // 充电命令 (1字节)
|
||||
private String 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字节)
|
||||
|
||||
public SpecificData(byte[] dataBytes) {
|
||||
byte rateModeBytes = dataBytes[0];
|
||||
this.rateMode = BytesUtil.bcd2StrLittle(new byte[]{rateModeBytes});
|
||||
|
||||
byte[] balanceOrValidityBytes = Arrays.copyOfRange(dataBytes, 1, 5);
|
||||
this.balanceOrValidity = BytesUtil.bcd2StrLittle(balanceOrValidityBytes);
|
||||
|
||||
byte portNumberBytes = dataBytes[5];
|
||||
this.portNumber = BytesUtil.bcd2StrLittle(new byte[]{portNumberBytes});
|
||||
|
||||
byte chargeCommandBytes = dataBytes[6];
|
||||
this.chargeCommand = BytesUtil.bcd2StrLittle(new byte[]{chargeCommandBytes});
|
||||
|
||||
byte[] chargeDurationOrPowerBytes = Arrays.copyOfRange(dataBytes, 7, 9);
|
||||
this.chargeDurationOrPower = BytesUtil.bcd2StrLittle(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);
|
||||
|
||||
byte[] overloadPowerBytes = Arrays.copyOfRange(dataBytes, 27, 29);
|
||||
this.overloadPower = BytesUtil.bcd2StrLittle(overloadPowerBytes);
|
||||
|
||||
byte qrCodeLightBytes = dataBytes[29];
|
||||
this.qrCodeLight = BytesUtil.bcd2StrLittle(new byte[]{qrCodeLightBytes});
|
||||
|
||||
byte longChargeModeBytes = dataBytes[30];
|
||||
this.longChargeMode = BytesUtil.bcd2StrLittle(new byte[]{longChargeModeBytes});
|
||||
|
||||
byte[] extraFloatChargeTimeBytes = Arrays.copyOfRange(dataBytes, 31, 33);
|
||||
this.extraFloatChargeTime = BytesUtil.bcd2StrLittle(extraFloatChargeTimeBytes);
|
||||
|
||||
byte skipShortCircuitDetectionBytes = dataBytes[33];
|
||||
this.skipShortCircuitDetection = BytesUtil.bcd2StrLittle(new byte[]{skipShortCircuitDetectionBytes});
|
||||
|
||||
byte noUserPullOutCheckBytes = dataBytes[34];
|
||||
this.noUserPullOutCheck = BytesUtil.bcd2StrLittle(new byte[]{noUserPullOutCheckBytes});
|
||||
|
||||
byte forceAutoStopWhenFullByte = dataBytes[35];
|
||||
this.forceAutoStopWhenFull = BytesUtil.bcd2StrLittle(new byte[]{forceAutoStopWhenFullByte});
|
||||
|
||||
byte fullChargePowerBytes = dataBytes[36];
|
||||
this.fullChargePower = BytesUtil.bcd2StrLittle(new byte[]{fullChargePowerBytes});
|
||||
|
||||
byte maxFullChargePowerCheckTimeBytes = dataBytes[37];
|
||||
this.maxFullChargePowerCheckTime = BytesUtil.bcd2StrLittle(new byte[]{maxFullChargePowerCheckTimeBytes});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user