Commit 31fa6fd8 by chenxi

实现功能:充电阶段BMS中止、充电阶段充电机中止协议对接

1 parent 6fbb4531
......@@ -2,9 +2,12 @@ package cn.com.glsx.charging.modules.gbt.ocpp16.tcp.base;
import java.util.Map;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.handler.BmsAbortChargingReqHandler;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.handler.ChargingCompletionReqHandler;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.handler.ChargingHandshakeReqHandler;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.handler.ErrorMessageReqHandler;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.handler.MachineChargingReqHandler;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.protocol.MachineAbortChargingReq;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.google.common.collect.Maps;
......@@ -70,6 +73,10 @@ public final class TcpMapper {
public static TcpMapper CMD_REQ_ERROR_MESSAGE= regist(0x1B, "错误报文", ErrorMessageReqHandler.class);
public static TcpMapper CMD_REQ_BMS_ABORT_CHARGING= regist(0x1D, "充电阶段BMS中止", BmsAbortChargingReqHandler.class);
public static TcpMapper CMD_REQ_MACHINE_ABORT_CHARGING= regist(0x21, "充电阶段充电机中止", MachineChargingReqHandler.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: 充电阶段BMS中止
* @Date: 2023/11/9 14:57
* @Version: 1.0
*/
@Data
public class BmsAbortingChargingData 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
* 1-2 位——所需求的 SOC 目标值
* 3-4 位——达到总电压的设定值
* 5-6 位——达到单体电压设定值
* 7-8 位——充电机主动中止
*/
private byte bmsAbortChargingReason;
/**
* BMS 中止充电原因 BIN
* 1-2 位——绝缘故障
* 3-4 位——输出连接器过温故障
* 5-6 位——BMS 元件、输出连接器过温
* 7-8 位——充电连接器故障
* 9-10 位——电池组温度过高故障
* 11-12 位——高压继电器故障
* 13 位-14 位——检测点 2 电压检测故障
* 15-16 位——其他故障
*/
private byte[] bmsAbortChargingMalfunctionReason = new byte[2];
/**
* BMS 中止充电原因 BIN
* 1-2 位——电流过大
* 3-4 位——电压异常
* 5-8 位——预留位
*/
private byte bmsAbortChargingErrorReason;
}
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: 充电阶段充电机BMS中止
* @Date: 2023/11/9 14:57
* @Version: 1.0
*/
@Data
public class MachineAbortingChargingData 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
* 1-2 位——达到充电机设定的条件中止
* 3-4 位——人工中止
* 5-6 位——异常中止
* 7-8 位——BMS 主动中止
*/
private byte machineAbortChargingReason;
/**
* BMS 中止充电原因 BIN
* 1-2 位——充电机过温故障
* 3-4 位——充电连接器故障
* 5-6 位——充电机内部过温故障
* 7-8 位——所需电量不能传送
* 9-10 位——充电机急停故障
* 11-12 位——其他故障
* 13-16 位——预留位
*/
private byte[] machineAbortChargingMalfunctionReason = new byte[2];
/**
* BMS 中止充电原因 BIN
* 1-2 位——电流不匹配
* 3-4 位——电压异常
* 5-8 位——预留位
*/
private byte machineAbortChargingErrorReason;
}
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.BmsAbortChargingReq;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.protocol.ChargingCompletionReq;
import io.netty.channel.Channel;
/**
* @Author: chenx
* @Description: 充电阶段BMS中止请求handler
* @Date: 2023/11/9 15:49
* @Version: 1.0
*/
public class BmsAbortChargingReqHandler implements TcpHandler<BmsAbortChargingReq, BmsAbortChargingReq> {
@Override
public BmsAbortChargingReq handle(Channel channel, BmsAbortChargingReq chargingCompletionReq) {
log.info("充电阶段BMS中止请求消息:{}", chargingCompletionReq.toString());
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.MachineAbortChargingReq;
import io.netty.channel.Channel;
/**
* @Author: chenx
* @Description: 充电阶段充电机中止请求handler
* @Date: 2023/11/9 15:49
* @Version: 1.0
*/
public class MachineChargingReqHandler implements TcpHandler<MachineAbortChargingReq, MachineAbortChargingReq> {
@Override
public MachineAbortChargingReq handle(Channel channel, MachineAbortChargingReq chargingCompletionReq) {
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.BmsAbortingChargingData;
/**
* @Author: chenx
* @Description: 充电阶段BMS中止请求
* @Date: 2023/11/9 15:39
* @Version: 1.0
*/
public class BmsAbortChargingReq extends TcpReq<BmsAbortingChargingData> {
public BmsAbortChargingReq() {
super(TcpMapper.CMD_REQ_BMS_ABORT_CHARGING.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.MachineAbortingChargingData;
/**
* @Author: chenx
* @Description: 充电阶段BMS中止
* @Date: 2023/11/9 15:40
* @Version: 1.0
*/
public class MachineAbortChargingReq extends TcpReq<MachineAbortingChargingData> {
public MachineAbortChargingReq() {
super(TcpMapper.CMD_REQ_MACHINE_ABORT_CHARGING.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.BmsAbortingChargingData;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data.ChargingCompletionReqData;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.protocol.BmsAbortChargingReq;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.protocol.ChargingCompletionReq;
/**
* 充电阶段BMS中止测试类
* @author chenxi
* @date 2023年11月9日 15:53
**/
public class BmsAbortChargingTest {
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);
BmsAbortChargingReq req = new BmsAbortChargingReq();
BmsAbortingChargingData data = new BmsAbortingChargingData();
data.setTransactionSerialNumber(Ocpp16Helper.strToBcd("3201020000000011151116155535026", data.getTransactionSerialNumber()));
data.setPileId(Ocpp16Helper.strToBcd("32010200000001", data.getPileId()));
data.setGunNumber((byte) 0x01);
data.setBmsAbortChargingReason((byte)0x00);
byte [] bmsAbortChargingMalfunctionReason = new byte[]{(byte)0x00, 0x00};
data.setBmsAbortChargingMalfunctionReason(bmsAbortChargingMalfunctionReason);
data.setBmsAbortChargingErrorReason((byte)0x00);
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.BmsAbortingChargingData;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data.ChargingCompletionReqData;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data.MachineAbortingChargingData;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.protocol.BmsAbortChargingReq;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.protocol.ChargingCompletionReq;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.protocol.MachineAbortChargingReq;
/**
* 充电阶段充电机中止测试类
* @author chenxi
* @date 2023年11月9日 15:53
**/
public class MachineAbortChargingTest {
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);
MachineAbortChargingReq req = new MachineAbortChargingReq();
MachineAbortingChargingData data = new MachineAbortingChargingData();
data.setTransactionSerialNumber(Ocpp16Helper.strToBcd("3201020000000011151116155535026", data.getTransactionSerialNumber()));
data.setPileId(Ocpp16Helper.strToBcd("32010200000001", data.getPileId()));
data.setGunNumber((byte) 0x01);
data.setMachineAbortChargingReason((byte)0x00);
byte [] machineAbortChargingMalfunctionReason = new byte[]{(byte)0x00, 0x00};
data.setMachineAbortChargingMalfunctionReason(machineAbortChargingMalfunctionReason);
data.setMachineAbortChargingErrorReason((byte)0x00);
req.setData(data);
client.sendSync(req);
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!