Commit 465da30f by chenxi

实现功能:充电握手、充电结束协议

1 parent e626dc50
......@@ -2,6 +2,8 @@ package cn.com.glsx.charging.modules.gbt.ocpp16.tcp.base;
import java.util.Map;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.handler.ChargingCompletionReqHandler;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.handler.ChargingHandshakeReqHandler;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.google.common.collect.Maps;
......@@ -61,6 +63,12 @@ public final class TcpMapper {
public static TcpMapper CMD_REQ_UPLOAD_REAL_TIME_DATA = regist(0x13, "读取实时检测数据", UploadRealTimeReqHandler.class);
public static TcpMapper CMD_REQ_CHARGING_HAND_SHAKE= regist(0x15, "充电握手", ChargingHandshakeReqHandler.class);
public static TcpMapper CMD_REQ_CHARGING_COMPLETION= regist(0x19, "充电结束", ChargingCompletionReqHandler.class);
public static TcpMapper CMD_REQ_ERROR_MESSAGE= regist(0x1B, "错误报文", ChargingCompletionReqHandler.class);
// public static TcpMapper CMD_NOTIFY_TIME = regist(0x56, "对时设置", TimeNotifyHandler.class);
// 运营交互帧类型码数据定义 0x31~0x47
......
package cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.base.TcpData;
import lombok.Data;
/**
* @Author: chenx
* @Description: 充电结束请求参数
* @Date: 2023/11/8 09:45
* @Version: 1.0
*/
@Data
public class ChargingCompletionReqData extends TcpData {
/**
* 交易流水号
* 数据类型:byte[] (BCD码)
* 长度(Byte):16
* 备注:
*/
private byte[] transactionSerialNumber = new byte[16];
/**
* 桩编号
* 数据类型:byte[] (BCD码)
* 长度(Byte):7
* 备注:不足7位补0
*/
private byte[] pileId = new byte[7];
/**
* 枪号
* 数据类型:byte[] (BCD码)
* 长度(Byte):1
* 备注:
*/
private byte gunNumber;
/**
* BMS 中止荷电状态 SOC BIN
* 1%/位,0%偏移量;数据范围:0~100%
*/
private byte bmsSoc;
/**
* BMS 动力蓄电池单体最低电压 BIN
* 0.01 V/位,0 V 偏移量;数据范围:0 ~24 V
*/
private byte[] bmsBatteryLowestVoltage = new byte[2];
/**
* BMS 动力蓄电池单体最高电压 BIN
* 0.1 Ah /位,0 Ah 偏移量
*/
private byte[] bmsBatteryHighestVoltage = new byte[2];
/**
* BMS 动力蓄电池最低温度 BIN
* 1ºC/位,-50 ºC 偏移量;数据范围:-50 ºC ~+200 ºC
*/
private byte bmsBatteryLowestTemperature;
/**
* BMS 动力蓄电池最低温度 BIN
* 1ºC/位,-50 ºC 偏移量;数据范围:-50 ºC ~+200 ºC
*/
private byte bmsBatteryHighestTemperature;
/**
* 电桩累计充电时间 BIN
* 1 min/位,0 min 偏移量;数据范围:0~600 min
*/
private byte[] pileAccumulatedChargingTime = new byte[2];
/**
* 电桩输出能量 BIN
* 0.1 kWh/位,0 kWh 偏移量;数据范围:0~1000 kWh
*/
private byte[] pileAccumulatedOutputEnergy = new byte[2];
/**
* 电桩充电机编号 BIN
* 充 电 机编 号, 1/ 位, 1 偏移量 ,数 据范 围 : 0 ~0xFFFFFFFF
*/
private byte[] pileChargingMachineNumber = new byte[4];
}
package cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.base.TcpData;
import lombok.Data;
/**
* @Author: chenx
* @Description: 充电握手请求参数
* @Date: 2023/11/7 18:11
* @Version: 1.0
*/
@Data
public class ChargingHandshakeReqData extends TcpData {
/**
* 交易流水号
* 数据类型:byte[] (BCD码)
* 长度(Byte):16
* 备注:
*/
private byte[] transactionSerialNumber = new byte[16];
/**
* 桩编号
* 数据类型:byte[] (BCD码)
* 长度(Byte):7
* 备注:不足7位补0
*/
private byte[] pileId = new byte[7];
/**
* 枪号
* 数据类型:byte[] (BCD码)
* 长度(Byte):1
* 备注:
*/
private byte gunNumber;
/**
* BMS 通信协议版本号 BIN
* 当前版本为 V1.1,表示为:byte3,byte2—0001H;byte1—01H
*/
private byte[] bmsProtocolVersion = new byte[3];
/**
* BMS 电池类型 BIN
* 电池类型,01H:铅酸电池;02H:氢电池;03H:磷酸铁锂电池;04H:锰酸锂电池;05H:钴酸锂电池;06H:
*/
private byte bmsBatteryType;
/**
* BMS 整车动力蓄电池系统额定容量 BIN
* 0.1 Ah /位,0 Ah 偏移量
*/
private byte[] bmsBatteryRatedCapacity = new byte[2];
/**
* BMS 整车动力蓄电池系统额定总电压 BIN
* 0.1V/位,0V 偏移量
*/
private byte[] bmsBatteryRatedVoltage = new byte[2];
/**
* BMS 电池生产厂商名称
* 标准 ASCII 码
*/
private byte[] bmsBatteryManufacturer = new byte[4];
/**
* BMS 电池组序号
* 预留,由厂商自行定义
*/
private byte[] bmsBatteryNumber = new byte[4];
/**
* BMS 电池组生产日期年 BIN
* 1985 年偏移量,数据范围:1985~2235 年
*/
private byte bmsBatteryProductionYear;
/**
* BMS 电池组生产日期月 BIN
* 0 月偏移量,数据范围:1~12 月
*/
private byte bmsBatteryProductionMonth;
/**
* BMS 电池组生产日期日 BIN
* 0 日偏移量,数据范围:1~31 日
*/
private byte bmsBatteryProductionDay;
/**
* BMS 电池组充电次数
* 1 次/位,0 次偏移量,以 BMS 统计为准
*/
private byte[] bmsBatteryChargingTime = new byte[3];
/**
* BMS 电池组产权标识 BIN
* (<0>:=租赁;<1>:=车自有)
*/
private byte bmsBatteryPropertyIdentification;
/**
* 预留位 BIN
*/
private byte reserved;
/**
* BMS 车辆识别码
* VIN
*/
private byte[] bmsCarVin = new byte[17];
/**
* BMS 软件版本号 BIN
* Byte8、byte7、byte6—000001H~FFFFFEH,预留,填 FFFFFFH;
* Byte5-byte2 作为 BMS 软件版本编译时间信息标记,
* Byte5,byte4—0001H~FFFEH 表示“年”(例如 2015 年:填写
* Byte5—DFH, byte4—07H);
* Byte3—01H~0CH 表示“月”(例如 11 月:填写 Byte3—0BH);
* Byte2—01H~1FH 表示“日”(例如 10 日:填写 Byte2—0AH);
* Byte1—01H~FEH 表示版本流水号(例如 16:填写 Byte1—10H)。
*/
private byte[] bmsSoftwareVersion = new byte[8];
}
package cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.base.TcpData;
import lombok.Data;
/**
* @Author: chenx
* @Description: 错误报文请求参数
* @Date: 2023/11/8 10:17
* @Version: 1.0
*/
@Data
public class ErrorMessageReqData extends TcpData {
/**
* 交易流水号
* 数据类型:byte[] (BCD码)
* 长度(Byte):16
* 备注:
*/
private byte[] transactionSerialNumber = new byte[16];
/**
* 桩编号
* 数据类型:byte[] (BCD码)
* 长度(Byte):7
* 备注:不足7位补0
*/
private byte[] pileNumber = new byte[7];
/**
* 枪号
* 数据类型:byte[] (BCD码)
* 长度(Byte):1
* 备注:
*/
private byte gunNumber;
/**
* 接收 SPN2560=0x00 的充电机辨识报文超时 BIN
* <00>:=正常;<01>:=超时;<10>:=不可信状态
*/
private byte[] messageTimeOut1 = new byte[2];
/**
* 接收 SPN2560=0xAA 的充电机辨识报文超时 BIN
* <00>:=正常;<01>:=超时;<10>:=不可信状态
*/
private byte[] messageTimeOut2 = new byte[2];
/**
* 预留位 BIN
*/
private byte[] reserved1 = new byte[4];
/**
* 接收充电机的时间同步和充电机最大输出能力报文超时
* <00>:=正常;<01>:=超时;<10>:=不可信状态
*/
private byte[] timeSyncMachineMaxOutputMessageTimeout = new byte[2];
/**
* 接收充电机完成充电准备报文超时
* <00>:=正常;<01>:=超时;<10>:=不可信状态
*/
private byte[] machineChargingCompletionMessageTimeout = new byte[2];
/**
* 预留位 BIN
*/
private byte[] reserved2 = new byte[4];
/**
* 接收充电机充电状态报文超时
* <00>:=正常;<01>:=超时;<10>:=不可信状态
*/
private byte[] machineChargingStatusMessageTimeout = new byte[2];
/**
* 接收充电机中止充电报文超时
* <00>:=正常;<01>:=超时;<10>:=不可信状态
*/
private byte[] machineAbortingMessageTimeout = new byte[2];
/**
* 预留位 BIN
*/
private byte[] reserved3 = new byte[4];
/**
* 接收充电机充电统计报文超时
* <00>:=正常;<01>:=超时;<10>:=不可信状态
*/
private byte[] machineChargingStatisticsMessageTimeout = new byte[2];
/**
* BMS 其他
*/
private byte[] bmsOther = new byte[6];
/**
* 接收 BMS 和车辆的辨识报文超时
* <00>:=正常;<01>:=超时;<10>:=不可信状态
*/
private byte[] bmsCarRecognitionMessageTimeout = new byte[2];
/**
* 预留位 BIN
*/
private byte[] reserved4 = new byte[4];
/**
* 接收电池充电参数报文超时
* <00>:=正常;<01>:=超时;<10>:=不可信状态
*/
private byte[] batteryChargingParamMessageTimeout = new byte[2];
/**
* 接收 BMS 完成充电准备报文超时
* <00>:=正常;<01>:=超时;<10>:=不可信状态
*/
private byte[] batteryChargingCompletionMessageTimeout = new byte[2];
/**
* 预留位 BIN
*/
private byte[] reserved5 = new byte[4];
/**
* 接收电池充电要求报文超时 BIN
* <00>:=正常;<01>:=超时;<10>:=不可信状态
*/
private byte[] bmsChargingStatusMessageTimeout = new byte[2];
/**
* 接收电池充电要求报文超时 BIN
* <00>:=正常;<01>:=超时;<10>:=不可信状态
*/
private byte[] bmsChargingDemandMessageTimeout = new byte[2];
/**
* 接收电池充电要求报文超时 BIN
* <00>:=正常;<01>:=超时;<10>:=不可信状态
*/
private byte[] bmsChargingAbortingMessageTimeout = new byte[2];
/**
* 预留位6 BIN
*/
private byte[] reserved6 = new byte[4];
/**
* 接收 BMS 充电统计报文超时 BIN
* <00>:=正常;<01>:=超时;<10>:=不可信状态
*/
private byte[] bmsChargingStatisticsMessageTimeout = new byte[4];
/**
* 充电机其他 BIN
*/
private byte[] machineOther = new byte[6];
}
package cn.com.glsx.charging.modules.gbt.ocpp16.tcp.handler;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.base.TcpHandler;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.protocol.ChargingCompletionReq;
import io.netty.channel.Channel;
/**
* @Author: chenx
* @Description: 充电握手请求handler
* @Date: 2023/11/8 11:26
* @Version: 1.0
*/
public class ChargingCompletionReqHandler implements TcpHandler<ChargingCompletionReq, ChargingCompletionReq> {
@Override
public ChargingCompletionReq handle(Channel channel, ChargingCompletionReq chargingCompletionReq) {
return null;
}
}
package cn.com.glsx.charging.modules.gbt.ocpp16.tcp.handler;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.base.TcpHandler;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.protocol.ChargingCompletionReq;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.protocol.ChargingHandshakeReq;
import io.netty.channel.Channel;
/**
* @Author: chenx
* @Description: 充电握手请求handler
* @Date: 2023/11/8 11:26
* @Version: 1.0
*/
public class ChargingHandshakeReqHandler implements TcpHandler<ChargingHandshakeReq, ChargingCompletionReq> {
@Override
public ChargingCompletionReq handle(Channel channel, ChargingHandshakeReq chargingHandshakeReq) {
return null;
}
}
package cn.com.glsx.charging.modules.gbt.ocpp16.tcp.handler;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.base.TcpHandler;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.protocol.ErrorMessageReq;
import io.netty.channel.Channel;
/**
* @Author: chenx
* @Description: 错误报文请求handler
* @Date: 2023/11/8 13:57
* @Version: 1.0
*/
public class ErrorMessageReqHandler implements TcpHandler<ErrorMessageReq, ErrorMessageReq> {
@Override
public ErrorMessageReq handle(Channel channel, ErrorMessageReq errorMessageReq) {
return null;
}
}
package cn.com.glsx.charging.modules.gbt.ocpp16.tcp.protocol;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.base.TcpMapper;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.base.TcpReq;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data.ChargingCompletionReqData;
/**
* @author 读取实时检测数据
* @date 2023年11月7日 下午2:48:32
*/
public class ChargingCompletionReq extends TcpReq<ChargingCompletionReqData> {
public ChargingCompletionReq() {
super(TcpMapper.CMD_REQ_CHARGING_COMPLETION.getType());
}
}
package cn.com.glsx.charging.modules.gbt.ocpp16.tcp.protocol;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.base.TcpMapper;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.base.TcpReq;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data.ChargingHandshakeReqData;
/**
* @author 读取实时检测数据
* @date 2023年11月7日 下午2:48:32
*/
public class ChargingHandshakeReq extends TcpReq<ChargingHandshakeReqData> {
public ChargingHandshakeReq() {
super(TcpMapper.CMD_REQ_CHARGING_HAND_SHAKE.getType());
}
}
package cn.com.glsx.charging.modules.gbt.ocpp16.tcp.protocol;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.base.TcpMapper;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.base.TcpReq;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data.ErrorMessageReqData;
/**
* @Author: chenx
* @Description: 错误报文
* @Date: 2023/11/8 13:55
* @Version: 1.0
*/
public class ErrorMessageReq extends TcpReq<ErrorMessageReqData> {
public ErrorMessageReq() {
super(TcpMapper.CMD_REQ_ERROR_MESSAGE.getType());
}
}
package cn.com.glsx.charging.gbt.ocpp16;
import cn.com.glsx.charging.modules.gbt.ocpp16.ClientMain;
import cn.com.glsx.charging.modules.gbt.ocpp16.Ocpp16Helper;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.client.TcpClient;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data.ChargingCompletionReqData;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.protocol.ChargingCompletionReq;
/**
* 充电结束测试类
* @author chenxi
* @date 2023年11月18日 14:57:39
**/
public class ChargingCompletionTest {
public static void main(String[] args) throws Exception {
Ocpp16Helper.scan();
String host = "localhost";
int port = 8888;
TcpClient client = ClientMain.getInstance(host, port);
Thread.sleep(3000);
ChargingCompletionReq req = new ChargingCompletionReq();
ChargingCompletionReqData data = new ChargingCompletionReqData();
data.setTransactionSerialNumber(Ocpp16Helper.strToBcd("3201020000000011151116155535026", data.getTransactionSerialNumber()));
data.setPileId(Ocpp16Helper.strToBcd("32010200000001", data.getPileId()));
data.setGunNumber((byte) 1);
data.setBmsSoc((byte)0);
byte [] bmsBatteryLowestVoltage = new byte[]{(byte)0x00, 0x00};
data.setBmsBatteryLowestVoltage(bmsBatteryLowestVoltage);
data.setBmsBatteryHighestVoltage(bmsBatteryLowestVoltage);
data.setBmsBatteryLowestTemperature((byte)0);
data.setBmsBatteryHighestTemperature((byte)0);
data.setPileAccumulatedChargingTime(bmsBatteryLowestVoltage);
data.setPileAccumulatedOutputEnergy(bmsBatteryLowestVoltage);
byte [] pileChargingMachineNumber = new byte[]{(byte)0x00, 0x00, 0x00, 0x00};
data.setPileChargingMachineNumber(pileChargingMachineNumber);
req.setData(data);
client.sendSync(req);
}
}
package cn.com.glsx.charging.gbt.ocpp16;
import cn.com.glsx.charging.modules.gbt.ocpp16.ClientMain;
import cn.com.glsx.charging.modules.gbt.ocpp16.Ocpp16Helper;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.client.TcpClient;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data.ChargingHandshakeReqData;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.protocol.ChargingHandshakeReq;
/**
* 充电握手测试类
* @author chenxi
* @date 2023年11月18日 14:19:39
**/
public class ChargingHandshakeTest {
public static void main(String[] args) throws Exception {
Ocpp16Helper.scan();
String host = "localhost";
int port = 8888;
TcpClient client = ClientMain.getInstance(host, port);
Thread.sleep(3000);
ChargingHandshakeReq req = new ChargingHandshakeReq();
ChargingHandshakeReqData data = new ChargingHandshakeReqData();
data.setTransactionSerialNumber(Ocpp16Helper.strToBcd("3201020000000011151116155535026", data.getTransactionSerialNumber()));
data.setPileId(Ocpp16Helper.strToBcd("32010200000001",data.getPileId()));
data.setGunNumber((byte)1);
byte[] bmsProtocolVersion = new byte[]{(byte) 0x00, 0x00, 0x00};
data.setBmsProtocolVersion(bmsProtocolVersion);
data.setBmsBatteryType((byte)0);
byte [] bmsBatteryRatedCapacity = new byte[]{(byte)0x00, 0x00};
data.setBmsBatteryRatedCapacity(bmsBatteryRatedCapacity);
data.setBmsBatteryRatedVoltage(bmsBatteryRatedCapacity);
byte [] bmsBatteryManufacturer = new byte[]{(byte)0x00, 0x00, 0x00, 0x00};
data.setBmsBatteryManufacturer(bmsBatteryManufacturer);
data.setBmsBatteryNumber(bmsBatteryManufacturer);
data.setBmsBatteryProductionYear((byte)0);
data.setBmsBatteryProductionMonth((byte)0);
data.setBmsBatteryProductionDay((byte)0);
data.setBmsBatteryChargingTime(bmsProtocolVersion);
data.setBmsBatteryPropertyIdentification((byte)0);
data.setReserved((byte)0);
byte [] carVin = new byte[]{(byte)0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
data.setBmsCarVin(carVin);
byte [] bmsSoftwareVersion = new byte[]{(byte)0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
data.setBmsSoftwareVersion(bmsSoftwareVersion);
req.setData(data);
client.sendSync(req);
}
}
......@@ -10,7 +10,7 @@ import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.protocol.UploadRealtimeDataRe
/**
* 上传实时监测数据测试
* @author chenxi
* @date 2023年12月1日 下午6:00:39
* @date 2023年11月7日 下午6:00:39
**/
public class UploadRealTimeDataTest {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!