Commit 5435cb18 by zhouhaibao

[+]新增主动充电

1 parent 896a4e6c
package cn.com.glsx.charging.modules.gbt.ocpp16.tcp.base;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.handler.AdminSwipeConfirmRspHandler;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.handler.BalanceUpdateRspHandler;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.handler.BmsAbortChargingReqHandler;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.handler.ChargingCompletionReqHandler;
......@@ -80,7 +81,7 @@ public final class TcpMapper {
// public static TcpMapper CMD_NOTIFY_TIME = regist(0x56, "对时设置", TimeNotifyHandler.class);
// 运营交互帧类型码数据定义 0x31~0x47
public static TcpMapper CMD_REQ_START_CHARGING = regist(0x31, "充电桩主动申请启动充电 ", DefaultReqHandler.class);
public static TcpMapper CMD_REQ_START_CHARGING = regist(0x31, "充电桩主动申请启动充电 ", AdminSwipeConfirmRspHandler.class);
public static TcpMapper CMD_RSP_START_CHARGING = regist(0x32, "充电桩主动申请启动充电应答", null);
......
package cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.base.TcpData;
import lombok.Data;
/**
* 充电桩主动申请启动充电
*
* 68(起始标志)37(数据长度)0004(序列号域)00(加密标志)31(类型)32010200000001
* (桩编码)01(枪号:1 枪)01(启动方式:刷卡启动)00(是否需要密码:不需要)00000000D14B0A54
* (物理卡号:D14B0A54)00000000000000000000000000000000(输入密码)
* 0000000000000000000000000000000000(VIN 码)F496
*
* @Title:
* @Description:
* @Author wangxw
* @Date 2023/11/10
**/
@Data
public class AdminSwipeConfirmReqData extends TcpData {
/**
* 桩编号
* 充电桩id: BCD 码 ,不足 7 位补 0
*/
private byte[] pileId = new byte[7];
/**
* 枪号
* 数据类型: (BCD码)
* 长度(Byte):1
* 备注:
*/
private byte gunNumber;
/**
* 是否需要密码 0x00 不需要 0x01 需要
*/
private byte passwordFlag;
/**
* 账号或者物理卡号
*/
private byte[] logicalCardNumber = new byte[8];
/**
* 输入密码
*/
private byte[] accountBalance = new byte[16];
/**
* VIN 码
*/
private byte[] vinCode = new byte[17];
}
package cn.com.glsx.charging.modules.gbt.ocpp16.tcp.handler;
import cn.com.glsx.charging.modules.gbt.ocpp16.Ocpp16Helper;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.base.TcpHandler;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data.AdminSwipeConfirmRspData;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.protocol.AdminSwipeConfirmReq;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.protocol.AdminSwipeConfirmRsp;
import cn.com.glsx.charging.util.ByteUtils;
import io.netty.channel.Channel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
@Slf4j
@Component
public class AdminSwipeConfirmRspHandler implements TcpHandler<AdminSwipeConfirmReq, AdminSwipeConfirmRsp> {
@Override
public AdminSwipeConfirmRsp handle(Channel channel, AdminSwipeConfirmReq req) {
AdminSwipeConfirmRsp rsp = new AdminSwipeConfirmRsp();
AdminSwipeConfirmRspData data = new AdminSwipeConfirmRspData();
log.info("主动充电应答的桩号{}", Ocpp16Helper.bcdToStr(req.getData().getPileId()));
data.setPileId(req.getData().getPileId());
data.setGunNumber(req.getData().getGunNumber());
data.setSucceedStatus((byte) 1);
byte[] byteArray = new byte[]{(byte) 0x9C, 0x40, 0x01, 0x00};
data.setAccountBalance(byteArray);
data.setTransactionSerialNumber(Ocpp16Helper.strToBcd("0000010021212121", data.getTransactionSerialNumber()));
data.setLogicalCardNumber(req.getData().getLogicalCardNumber());
rsp.setData(data);
return rsp;
}
}
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.TcpRsp;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data.AdminSwipeConfirmReqData;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data.AdminSwipeConfirmRspData;
import lombok.Data;
/**
* 启动充电鉴权结果
*
* 68(起始标志)2A(数据长度)00 04(系列号域)00(加密标志)32(标志)32 01 02 00
* 00 00 01 01 20 18 06 12 19 59 57 85(交易流水号) 32 01 02 00 00 00 01(桩编码)
* 01(枪号:1 枪) 00 00 00 00 00 00 00 00(逻辑卡号) 00 00 00 00(账户余额) 00(鉴
* 权成功标志) 01(失败原因)E8 29(帧校验域)
*
* @Title:
* @Description:
* @Author wangxw
* @Date 2023/11/10
**/
@Data
public class AdminSwipeConfirmReq extends TcpRsp<AdminSwipeConfirmReqData> {
public AdminSwipeConfirmReq() {
super(TcpMapper.CMD_REQ_START_CHARGING.getType());
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!