mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-21 11:35:12 +08:00
update 电单车
This commit is contained in:
@@ -41,25 +41,25 @@ public class ChargingOperationResponse extends AbsEBikeMessage2 {
|
||||
*/
|
||||
private String waitPortNumber;
|
||||
|
||||
public ChargingOperationResponse(byte[] dataBytes) {
|
||||
super(dataBytes);
|
||||
public ChargingOperationResponse(byte[] messageBytes) {
|
||||
super(messageBytes);
|
||||
|
||||
// 读取结果
|
||||
int startIndex = 12;
|
||||
int length = 1;
|
||||
this.result = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(dataBytes, startIndex, length));
|
||||
this.result = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length));
|
||||
|
||||
startIndex += length;
|
||||
length = 16;
|
||||
this.transactionCode = BytesUtil.bcd2Str(BytesUtil.copyBytes(dataBytes, startIndex, length));
|
||||
this.transactionCode = BytesUtil.bcd2Str(BytesUtil.copyBytes(messageBytes, startIndex, length));
|
||||
|
||||
startIndex += length;
|
||||
length = 1;
|
||||
this.portNumber = YouDianUtils.convertPortNumberToString(BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(dataBytes, startIndex, length)));
|
||||
this.portNumber = YouDianUtils.convertPortNumberToString(BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length)));
|
||||
|
||||
// startIndex += length;
|
||||
// length = 2;
|
||||
// this.waitPortNumber = YouDianUtils.convertPortNumberToString(BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(dataBytes, startIndex, length)));
|
||||
// this.waitPortNumber = YouDianUtils.convertPortNumberToString(BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
package com.jsowell.pile.domain.ebike.deviceupload;
|
||||
|
||||
import com.jsowell.common.util.BytesUtil;
|
||||
import com.jsowell.pile.domain.ebike.AbsEBikeMessage2;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
/**
|
||||
* 刷卡操作(02指令)
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString(callSuper = true)
|
||||
public class Cmd02 extends AbsEBikeMessage2 {
|
||||
/**
|
||||
* 卡片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 Cmd02(byte[] messageBytes) {
|
||||
super(messageBytes);
|
||||
|
||||
int startIndex = 12;
|
||||
int length = 4;
|
||||
this.cardId = BytesUtil.bcd2Str(BytesUtil.copyBytes(messageBytes, startIndex, length)) + "";
|
||||
|
||||
startIndex += length;
|
||||
length = 1;
|
||||
this.cardType = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length)) + "";
|
||||
|
||||
startIndex += length;
|
||||
length = 1;
|
||||
this.portNumber = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length)) + "";
|
||||
|
||||
startIndex += length;
|
||||
length = 2;
|
||||
this.cardBalance = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length)) + "";
|
||||
|
||||
// length = 4;
|
||||
// this.timestamp = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(dataBytes, startIndex, startIndex = startIndex + length)) + "";
|
||||
|
||||
if (messageBytes.length > startIndex) {
|
||||
startIndex += length;
|
||||
length = 1;
|
||||
card2Length = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length));
|
||||
|
||||
this.card2Code = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length)) + "";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
package com.jsowell.pile.domain.ebike.deviceupload;
|
||||
|
||||
import com.jsowell.common.YouDianUtils;
|
||||
import com.jsowell.common.util.BytesUtil;
|
||||
import com.jsowell.pile.domain.ebike.AbsEBikeMessage2;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString(callSuper = true)
|
||||
public class Cmd03 extends AbsEBikeMessage2 {
|
||||
private int chargingTime; // 充电时长, 单位:"秒"
|
||||
private int maxPower; // 最大功率, 单位:"0.1W"
|
||||
private int consumedEnergy; // 耗电量, 单位:"0.01度"
|
||||
private String portNumber; // 端口号
|
||||
private int startMode; // 在线/离线启动/验证码
|
||||
private int cardNumberOrVerificationCode; // 卡号/验证码
|
||||
private int stopReason; // 停止原因
|
||||
private String orderNumber; // 订单编号
|
||||
private int secondMaxPower; // 第二最大功率
|
||||
// private String timestamp; // 时间戳 上发指令当时的时间,有时候不准确,该字段属于调试使用,服务器无需关心此字段
|
||||
// private String placeholderDuration; // 占位时长 充电柜专用,其他设备忽略此字段 表示充满后占用设备的时长,单位为分钟
|
||||
|
||||
public Cmd03(byte[] messageBytes) {
|
||||
super(messageBytes);
|
||||
|
||||
int startIndex = 12;
|
||||
int length = 2;
|
||||
this.chargingTime = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length));
|
||||
|
||||
startIndex += length;
|
||||
length = 2;
|
||||
this.maxPower = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length));
|
||||
|
||||
startIndex += length;
|
||||
length = 2;
|
||||
this.consumedEnergy = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length));
|
||||
|
||||
startIndex += length;
|
||||
length = 1;
|
||||
this.portNumber = YouDianUtils.convertPortNumberToString(BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length)));
|
||||
|
||||
startIndex += length;
|
||||
length = 1;
|
||||
this.startMode = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length));
|
||||
|
||||
startIndex += length;
|
||||
length = 4;
|
||||
this.cardNumberOrVerificationCode = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length));
|
||||
|
||||
startIndex += length;
|
||||
length = 1;
|
||||
this.stopReason = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length));
|
||||
|
||||
startIndex += length;
|
||||
length = 16;
|
||||
this.orderNumber = BytesUtil.bcd2Str(BytesUtil.copyBytes(messageBytes, startIndex, length));
|
||||
|
||||
startIndex += length;
|
||||
length = 2;
|
||||
this.secondMaxPower = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length));
|
||||
|
||||
// this.timestamp = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(messageBytes, 31, 35)) + "";
|
||||
// this.placeholderDuration = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(messageBytes, 35, 37)) + "";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package com.jsowell.pile.domain.ebike.deviceupload;
|
||||
|
||||
import com.jsowell.common.util.BytesUtil;
|
||||
import com.jsowell.pile.domain.ebike.AbsEBikeMessage2;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString(callSuper = true)
|
||||
public class Cmd04 extends AbsEBikeMessage2 {
|
||||
/**
|
||||
* 端口号
|
||||
*/
|
||||
private String portNumber;
|
||||
|
||||
/**
|
||||
* 在线/离线启动
|
||||
*/
|
||||
private String startMode;
|
||||
|
||||
/**
|
||||
* 卡片ID
|
||||
*/
|
||||
private String cardId;
|
||||
|
||||
/**
|
||||
* 充电时长
|
||||
*/
|
||||
private String chargingTime;
|
||||
|
||||
/**
|
||||
* 订单编号
|
||||
*/
|
||||
private String orderCode;
|
||||
|
||||
public Cmd04(byte[] messageBytes) {
|
||||
super(messageBytes);
|
||||
|
||||
int startIndex = 12;
|
||||
int length = 1;
|
||||
this.portNumber = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length)) + "";
|
||||
|
||||
startIndex += length;
|
||||
length = 1;
|
||||
this.startMode = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length)) + "";
|
||||
|
||||
startIndex += length;
|
||||
length = 4;
|
||||
this.cardId = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length)) + "";
|
||||
|
||||
startIndex += length;
|
||||
length = 2;
|
||||
this.chargingTime = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length)) + "";
|
||||
|
||||
startIndex += length;
|
||||
length = 16;
|
||||
this.orderCode = BytesUtil.bcd2StrLittle(BytesUtil.copyBytes(messageBytes, startIndex, length));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,187 @@
|
||||
package com.jsowell.pile.domain.ebike.deviceupload;
|
||||
|
||||
import com.jsowell.common.YouDianUtils;
|
||||
import com.jsowell.common.util.BytesUtil;
|
||||
import com.jsowell.pile.domain.ebike.AbsEBikeMessage2;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString(callSuper = true)
|
||||
public class Cmd06 extends AbsEBikeMessage2 {
|
||||
/**
|
||||
* 端口号:当前充电的端口号。注:00表示1号端口,01表示2号端口; port+1为实际端口
|
||||
*/
|
||||
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 Cmd06(byte[] messageBytes) {
|
||||
super(messageBytes);
|
||||
|
||||
int startIndex = 12;
|
||||
int length = 1;
|
||||
this.port = YouDianUtils.convertPortNumberToString(BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length)));
|
||||
|
||||
startIndex += length;
|
||||
length = 1;
|
||||
this.portStatus = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length)) + "";
|
||||
|
||||
startIndex += length;
|
||||
length = 2;
|
||||
this.chargingTime = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length)) + "";
|
||||
|
||||
startIndex += length;
|
||||
length = 2;
|
||||
this.totalUsedElectricity = new BigDecimal(BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length)))
|
||||
.multiply(new BigDecimal("0.01")).toString();
|
||||
|
||||
startIndex += length;
|
||||
length = 1;
|
||||
this.startMode = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length)) + "";
|
||||
|
||||
startIndex += length;
|
||||
length = 2;
|
||||
this.realTimePower = new BigDecimal(BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length)))
|
||||
.multiply(new BigDecimal("0.1")).toString();
|
||||
|
||||
startIndex += length;
|
||||
length = 2;
|
||||
this.maxPower = new BigDecimal(BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length)))
|
||||
.multiply(new BigDecimal("0.1")).toString();
|
||||
|
||||
startIndex += length;
|
||||
length = 2;
|
||||
this.minPower = new BigDecimal(BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length)))
|
||||
.multiply(new BigDecimal("0.1")).toString();
|
||||
|
||||
startIndex += length;
|
||||
length = 2;
|
||||
this.avgPower = new BigDecimal(BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length)))
|
||||
.multiply(new BigDecimal("0.1")).toString();
|
||||
|
||||
startIndex += length;
|
||||
length = 16;
|
||||
this.orderCode = BytesUtil.bcd2Str(BytesUtil.copyBytes(messageBytes, startIndex, length));
|
||||
|
||||
startIndex += length;
|
||||
length = 2;
|
||||
this.timePeriodElectricity = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length)) + "";
|
||||
|
||||
startIndex += length;
|
||||
length = 2;
|
||||
this.peakPower = new BigDecimal(BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length)))
|
||||
.multiply(new BigDecimal("0.1")).toString();
|
||||
|
||||
startIndex += length;
|
||||
length = 2;
|
||||
this.voltage = new BigDecimal(BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length)))
|
||||
.multiply(new BigDecimal("0.1")).toString();
|
||||
|
||||
startIndex += length;
|
||||
length = 2;
|
||||
this.current = new BigDecimal(BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length)))
|
||||
.multiply(new BigDecimal("0.001")).toString();
|
||||
|
||||
startIndex += length;
|
||||
length = 1;
|
||||
this.ambientTemperature = new BigDecimal(BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length)))
|
||||
.subtract(new BigDecimal("65")).toString();
|
||||
|
||||
startIndex += length;
|
||||
length = 1;
|
||||
this.portTemperature = new BigDecimal(BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length)))
|
||||
.subtract(new BigDecimal("65")).toString();
|
||||
|
||||
startIndex += length;
|
||||
length = 2;
|
||||
this.occupancyTime = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length)) + "";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.jsowell.pile.domain.ebike.deviceupload;
|
||||
|
||||
import com.jsowell.pile.domain.ebike.AbsEBikeMessage2;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString(callSuper = true)
|
||||
public class Cmd11 extends AbsEBikeMessage2 {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.jsowell.pile.domain.ebike.deviceupload;
|
||||
|
||||
import com.jsowell.pile.domain.ebike.AbsEBikeMessage2;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString(callSuper = true)
|
||||
public class Cmd12 extends AbsEBikeMessage2 {
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
package com.jsowell.pile.domain.ebike.deviceupload;
|
||||
|
||||
import com.jsowell.common.util.BytesUtil;
|
||||
import com.jsowell.pile.domain.ebike.AbsEBikeMessage2;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString(callSuper = true)
|
||||
public class Cmd20 extends AbsEBikeMessage2 {
|
||||
/**
|
||||
* 固件版本,如100则表示V1.00版本
|
||||
*/
|
||||
private String firmwareVersion;
|
||||
|
||||
/**
|
||||
* 端口数量 表示设备总共有多少个端口
|
||||
*/
|
||||
private int 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 Cmd20(byte[] messageBytes) {
|
||||
super(messageBytes);
|
||||
|
||||
int startIndex = 12;
|
||||
int length = 2;
|
||||
this.firmwareVersion = new BigDecimal(BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length)))
|
||||
.multiply(new BigDecimal("0.1")).toString();
|
||||
|
||||
startIndex += length;
|
||||
length = 1;
|
||||
this.portNumber = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length));
|
||||
|
||||
startIndex += length;
|
||||
length = 1;
|
||||
this.virtualId = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length)) + "";
|
||||
|
||||
startIndex += length;
|
||||
length = 1;
|
||||
this.deviceType = BytesUtil.printHexBinary(BytesUtil.copyBytes(messageBytes, startIndex, length));
|
||||
|
||||
startIndex += length;
|
||||
length = 1;
|
||||
this.workMode = BytesUtil.bcd2StrLittle(BytesUtil.copyBytes(messageBytes, startIndex, length));
|
||||
|
||||
startIndex += length;
|
||||
length = 2;
|
||||
this.powerBoardVersion = BytesUtil.bcd2StrLittle(BytesUtil.copyBytes(messageBytes, startIndex, length));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
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.AbsEBikeMessage2;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString(callSuper = true)
|
||||
public class Cmd21 extends AbsEBikeMessage2 {
|
||||
/**
|
||||
* 电压:设备的当前电压(打包发送心跳包指令时的当前时间点的实时电压)
|
||||
* 2024年8月26日15点02分 已经转为标准单位V
|
||||
*/
|
||||
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;
|
||||
|
||||
private List<String> statusDescList;
|
||||
|
||||
/**
|
||||
* 信号强度:指分机与主机之间的无线信号强度,如LORA信号。00则为有线组网或无信号强度功能
|
||||
*/
|
||||
private String rssi;
|
||||
|
||||
/**
|
||||
* 当前环境温度:表示当前设备内的温度,可能和真正的当前环境温度有一定的误差,如00则表示无此功能
|
||||
*/
|
||||
private String temperature;
|
||||
|
||||
|
||||
public Cmd21(byte[] messageBytes) {
|
||||
super(messageBytes);
|
||||
|
||||
// 读取结果
|
||||
int startIndex = 12;
|
||||
int length = 2;
|
||||
this.voltage = new BigDecimal(BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length)))
|
||||
.multiply(new BigDecimal("0.1")).toString();
|
||||
|
||||
startIndex += length;
|
||||
length = 1;
|
||||
this.portNumber = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length));
|
||||
|
||||
startIndex += length;
|
||||
length = this.portNumber;
|
||||
byte[] statusBytes = BytesUtil.copyBytes(messageBytes, startIndex, length);
|
||||
// 解析
|
||||
List<String> statusList = Lists.newArrayList();
|
||||
List<String> statusDescList = Lists.newArrayList();
|
||||
for (byte statusByte : statusBytes) {
|
||||
int status = BytesUtil.bytesToIntLittle(new byte[]{statusByte});
|
||||
statusList.add(String.valueOf(status));
|
||||
statusDescList.add(PortStatusEnum.getDescriptionByValue(status));
|
||||
}
|
||||
this.portStatus = statusList;
|
||||
this.statusDescList = statusDescList;
|
||||
|
||||
startIndex += length;
|
||||
length = 1;
|
||||
this.rssi = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length)) + "";
|
||||
|
||||
startIndex += length;
|
||||
length = 1;
|
||||
int i = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length));
|
||||
if (i > 65) {
|
||||
i = i - 65;
|
||||
}
|
||||
this.temperature = i + "";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.jsowell.pile.domain.ebike.deviceupload;
|
||||
|
||||
import com.jsowell.pile.domain.ebike.AbsEBikeMessage2;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString(callSuper = true)
|
||||
public class Cmd22 extends AbsEBikeMessage2 {
|
||||
}
|
||||
Reference in New Issue
Block a user