Commit 930dc6bc by tiger

重命名

1 parent ba7607ce
Showing 16 changed files with 59 additions and 110 deletions
package cn.com.glsx.charging.modules.gbt.ocpp16.tcp.base; package cn.com.glsx.charging.modules.gbt.ocpp16.tcp.base;
import java.util.Map;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.google.common.collect.Maps;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.handler.interactive.req.ShutdownMachineReqHandler; import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.handler.interactive.req.ShutdownMachineReqHandler;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.handler.interactive.req.StartMachineReqHandler; import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.handler.interactive.req.StartMachineReqHandler;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.handler.interactive.resp.ShutdownMachineRespHandler; import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.handler.interactive.resp.ShutdownMachineRespHandler;
...@@ -8,19 +13,14 @@ import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.handler.login.req.HeartbeatRe ...@@ -8,19 +13,14 @@ import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.handler.login.req.HeartbeatRe
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.handler.login.req.LoginReqHandler; import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.handler.login.req.LoginReqHandler;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.handler.login.req.ModelChargingReqHandler; import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.handler.login.req.ModelChargingReqHandler;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.handler.login.req.ModelValReqHandler; import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.handler.login.req.ModelValReqHandler;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.handler.login.rsp.LoginRspHandler;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.handler.param.ParamSettingReqHandler; import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.handler.param.ParamSettingReqHandler;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.handler.param.ParamSettingRspHandler; import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.handler.param.ParamSettingRspHandler;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.handler.time.TimeSettingReqHandler; import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.handler.time.TimeSettingReqHandler;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.handler.time.TimeSettingRspHandler; import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.handler.time.TimeSettingRspHandler;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.google.common.collect.Maps;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Getter; import lombok.Getter;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import java.util.Map;
/** /**
* 管理与server的交互 * 管理与server的交互
* *
...@@ -38,45 +38,44 @@ public final class TcpMapper { ...@@ -38,45 +38,44 @@ public final class TcpMapper {
public static TcpMapper CMD_REQ_LOGIN = regist(0x01, "充电桩登录认证", LoginReqHandler.class); public static TcpMapper CMD_REQ_LOGIN = regist(0x01, "充电桩登录认证", LoginReqHandler.class);
public static TcpMapper CMD_RSP_LOGIN = regist(0x02, "登录认证应答", LoginRspHandler.class); public static TcpMapper CMD_RSP_LOGIN = regist(0x02, "登录认证应答", null);
public static TcpMapper CMD_REQ_HEARTBEAT = regist(0x03, "充电桩心跳包", HeartbeatReqHandler.class); public static TcpMapper CMD_REQ_HEARTBEAT = regist(0x03, "充电桩心跳包", HeartbeatReqHandler.class);
public static TcpMapper CMD_RSP_HEARTBEAT = regist(0x04, "心跳包应答", null); public static TcpMapper CMD_RSP_HEARTBEAT = regist(0x04, "心跳包应答", null);
// public static TcpMapper CMD_RSP_HEARTBEAT = regist(0x04, "心跳包应答", HeartbeatRspHandler.class);
// TODO 补充完整所有协议 // TODO 补充完整所有协议
public static TcpMapper CMD_REQ_MODEL_VALIDATION = regist(0x05, "计费模型验证请求", ModelValReqHandler.class); public static TcpMapper CMD_REQ_MODEL_CHECK = regist(0x05, "计费模型验证请求", ModelValReqHandler.class);
public static TcpMapper CMD_RSP_MODEL_VALIDATION = regist(0x06, "计费模型验证应答", null); public static TcpMapper CMD_RSP_MODEL_CHECK = regist(0x06, "计费模型验证应答", null);
public static TcpMapper CMD_REQ_MODEL_CHARGING = regist(0x09, "充电桩计费模型请求", ModelChargingReqHandler.class); public static TcpMapper CMD_REQ_MODEL_QUERY = regist(0x09, "充电桩计费模型请求", ModelChargingReqHandler.class);
public static TcpMapper CMD_RSP_MODEL_CHARGING = regist(0x0A, "计费模型请求应答", null); public static TcpMapper CMD_RSP_MODEL_QUERY = regist(0x0A, "计费模型请求应答", null);
// public static TcpMapper CMD_NOTIFY_TIME = regist(0x56, "对时设置", TimeNotifyHandler.class); // public static TcpMapper CMD_NOTIFY_TIME = regist(0x56, "对时设置", TimeNotifyHandler.class);
// 运营交互帧类型码数据定义 0x31~0x47 // 运营交互帧类型码数据定义 0x31~0x47
public static TcpMapper FTCD_RSP_REMOTE_START_CHARGING = regist(0x33, "远程启动充电命令回复", StartMachineRespHandler.class); public static TcpMapper CMD_RSP_START_CHARGING = regist(0x33, "远程启动充电命令回复", StartMachineRespHandler.class);
public static TcpMapper FTCD_REQ_REMOTE_CONTROL_STARTUP = regist(0x34, "运营平台远程控制启机", StartMachineReqHandler.class); public static TcpMapper CMD_REQ_START_CHARGING = regist(0x34, "运营平台远程控制启机", StartMachineReqHandler.class);
public static TcpMapper FTCD_RSP_REMOTE_SHUTDOWN = regist(0x35, "远程停机命令回复", ShutdownMachineRespHandler.class); public static TcpMapper CMD_RSP_STOP_CHARGING = regist(0x35, "远程停机命令回复", ShutdownMachineRespHandler.class);
public static TcpMapper FTCD_REQ_REMOTE_SHUTDOWN = regist(0x36, "运营平台远程停机", ShutdownMachineReqHandler.class); public static TcpMapper CMD_REQ_STOP_CHARGING = regist(0x36, "运营平台远程停机", ShutdownMachineReqHandler.class);
public static TcpMapper FTCD_REQ_TRANSACTION_RECORDS = regist(0x3B, "交易记录", null); public static TcpMapper CMD_REQ_TRADE_UPLOAD = regist(0x3B, "交易记录上报", null);
public static TcpMapper FTCD_RSP_TRANSACTION_CONFIRMATION = regist(0x40, "交易记录确认", null); public static TcpMapper CMD_RSP_TRADE_UPLOAD = regist(0x40, "交易记录上报确认", null);
public static TcpMapper CMD_REQ_PARAM_SETTING = regist(0x52, "充电桩工作参数设置", ParamSettingReqHandler.class); public static TcpMapper CMD_REQ_CFG_DOWNLOAD = regist(0x52, "充电桩工作参数设置", ParamSettingReqHandler.class);
public static TcpMapper CMD_RSP_PARAM_SETTING = regist(0x51, "充电桩工作参数设置应答", ParamSettingRspHandler.class); public static TcpMapper CMD_RSP_CFG_DOWNLOAD = regist(0x51, "充电桩工作参数设置应答", ParamSettingRspHandler.class);
public static TcpMapper CMD_REQ_TIME_SETTING = regist(0x56, "对时设置", TimeSettingReqHandler.class); public static TcpMapper CMD_REQ_TIME_CHECK = regist(0x56, "对时设置", TimeSettingReqHandler.class);
public static TcpMapper CMD_RSP_TIME_SETTING = regist(0x55, "对时设置应答", TimeSettingRspHandler.class); public static TcpMapper CMD_RSP_TIME_CHECK = regist(0x55, "对时设置应答", TimeSettingRspHandler.class);
public static TcpMapper fromType(byte type) { public static TcpMapper fromType(byte type) {
......
...@@ -9,7 +9,7 @@ public class DefaultRspHandler implements TcpHandler<TcpRsp<TcpData>, TcpRsp<Tcp ...@@ -9,7 +9,7 @@ public class DefaultRspHandler implements TcpHandler<TcpRsp<TcpData>, TcpRsp<Tcp
@Override @Override
public TcpRsp<TcpData> handle(Channel channel, TcpRsp<TcpData> rsp) { public TcpRsp<TcpData> handle(Channel channel, TcpRsp<TcpData> rsp) {
log.info("【{}】{}", rsp.getClass().getSimpleName(), rsp); log.info("【{}】{} 啥也不干", rsp.getClass().getSimpleName(), rsp);
return null; return null;
} }
......
package cn.com.glsx.charging.modules.gbt.ocpp16.tcp.handler.login.notify;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.base.TcpHandler;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.base.TcpRsp;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.protocol.login.TimeNotify;
import cn.com.glsx.charging.util.ByteUtils;
import cn.com.glsx.charging.util.DateUtils;
import io.netty.channel.Channel;
/**
* 充电桩收到服务端下发的对时命令
*
* @author kome
* @date 2023年11月6日 上午10:19:34
*/
public class TimeNotifyHandler implements TcpHandler<TimeNotify, TcpRsp> {
@Override
public TcpRsp handle(Channel channel, TimeNotify notify) {
//
log.info("【服务器时间】{}", DateUtils.datetimeToStr(ByteUtils.parseCp56Time2a(notify.getData().getTime())));
return null;
}
}
package cn.com.glsx.charging.modules.gbt.ocpp16.tcp.handler.login.rsp; package cn.com.glsx.charging.modules.gbt.ocpp16.tcp.handler.login.rsp;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.base.TcpHandler; import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.base.TcpHandler;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data.login.LoginRspData;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.protocol.login.LoginRsp; import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.protocol.login.LoginRsp;
import io.netty.channel.Channel; import io.netty.channel.Channel;
...@@ -9,17 +8,7 @@ public class LoginRspHandler implements TcpHandler<LoginRsp, LoginRsp> { ...@@ -9,17 +8,7 @@ public class LoginRspHandler implements TcpHandler<LoginRsp, LoginRsp> {
@Override @Override
public LoginRsp handle(Channel channel, LoginRsp req) { public LoginRsp handle(Channel channel, LoginRsp req) {
LoginRsp trsp = new LoginRsp(); // 充电桩端收到登录成功后,啥也不干
LoginRspData data = new LoginRspData();
// data.setPointId(null);
data.setResult((byte) 1);
// SpringContextUtil.getApplicationContext().getBean(null);
// log.info("xxxx");
trsp.setData(data);
return null; return null;
} }
......
...@@ -12,6 +12,6 @@ import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data.interactive.StartMachine ...@@ -12,6 +12,6 @@ import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data.interactive.StartMachine
*/ */
public class StartMachineReq extends TcpReq<StartMachineReqData> { public class StartMachineReq extends TcpReq<StartMachineReqData> {
public StartMachineReq() { public StartMachineReq() {
super(TcpMapper.FTCD_REQ_REMOTE_CONTROL_STARTUP.getType()); super(TcpMapper.CMD_REQ_START_CHARGING.getType());
} }
} }
...@@ -12,6 +12,6 @@ import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data.interactive.StartMachine ...@@ -12,6 +12,6 @@ import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data.interactive.StartMachine
*/ */
public class StartMachineResp extends TcpRsp<StartMachineRspData> { public class StartMachineResp extends TcpRsp<StartMachineRspData> {
public StartMachineResp() { public StartMachineResp() {
super(TcpMapper.FTCD_RSP_REMOTE_START_CHARGING.getType()); super(TcpMapper.CMD_RSP_START_CHARGING.getType());
} }
} }
...@@ -14,6 +14,6 @@ import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data.login.ModelValReqData; ...@@ -14,6 +14,6 @@ import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data.login.ModelValReqData;
public class ModelChargingReq extends TcpReq<ModelChargingReqData> { public class ModelChargingReq extends TcpReq<ModelChargingReqData> {
public ModelChargingReq() { public ModelChargingReq() {
super(TcpMapper.CMD_REQ_MODEL_CHARGING.getType()); super(TcpMapper.CMD_REQ_MODEL_QUERY.getType());
} }
} }
...@@ -13,6 +13,6 @@ import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data.login.ModelChargingRspDa ...@@ -13,6 +13,6 @@ import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data.login.ModelChargingRspDa
public class ModelChargingRsp extends TcpRsp<ModelChargingRspData> { public class ModelChargingRsp extends TcpRsp<ModelChargingRspData> {
public ModelChargingRsp() { public ModelChargingRsp() {
super(TcpMapper.CMD_RSP_MODEL_CHARGING.getType()); super(TcpMapper.CMD_RSP_MODEL_QUERY.getType());
} }
} }
...@@ -13,6 +13,6 @@ import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data.login.ModelValReqData; ...@@ -13,6 +13,6 @@ import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data.login.ModelValReqData;
public class ModelValReq extends TcpReq<ModelValReqData> { public class ModelValReq extends TcpReq<ModelValReqData> {
public ModelValReq() { public ModelValReq() {
super(TcpMapper.CMD_REQ_MODEL_VALIDATION.getType()); super(TcpMapper.CMD_REQ_MODEL_CHECK.getType());
} }
} }
...@@ -14,6 +14,6 @@ import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data.login.ModelValRspData; ...@@ -14,6 +14,6 @@ import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data.login.ModelValRspData;
public class ModelValRsp extends TcpRsp<ModelValRspData> { public class ModelValRsp extends TcpRsp<ModelValRspData> {
public ModelValRsp() { public ModelValRsp() {
super(TcpMapper.CMD_RSP_MODEL_VALIDATION.getType()); super(TcpMapper.CMD_RSP_MODEL_CHECK.getType());
} }
} }
package cn.com.glsx.charging.modules.gbt.ocpp16.tcp.protocol.login;
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.login.TimeNotifyData;
/**
* @author kome.jiang
* @date 2022年9月28日 下午2:48:32
*/
public class TimeNotify extends TcpReq<TimeNotifyData> {
public TimeNotify() {
// super(TcpMapper.CMD_NOTIFY_TIME.getType());
}
}
...@@ -13,6 +13,6 @@ import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data.param.ParamSettingReqDat ...@@ -13,6 +13,6 @@ import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data.param.ParamSettingReqDat
public class ParamSettingReq extends TcpReq<ParamSettingReqData> { public class ParamSettingReq extends TcpReq<ParamSettingReqData> {
public ParamSettingReq() { public ParamSettingReq() {
super(TcpMapper.CMD_REQ_PARAM_SETTING.getType()); super(TcpMapper.CMD_REQ_CFG_DOWNLOAD.getType());
} }
} }
...@@ -12,7 +12,7 @@ import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data.param.ParamSettingRspDat ...@@ -12,7 +12,7 @@ import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data.param.ParamSettingRspDat
**/ **/
public class ParamSettingRsp extends TcpRsp<ParamSettingRspData> { public class ParamSettingRsp extends TcpRsp<ParamSettingRspData> {
public ParamSettingRsp() { public ParamSettingRsp() {
super(TcpMapper.CMD_RSP_PARAM_SETTING.getType()); super(TcpMapper.CMD_RSP_CFG_DOWNLOAD.getType());
} }
} }
...@@ -13,6 +13,6 @@ import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data.time.TimeSettingReqData; ...@@ -13,6 +13,6 @@ import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data.time.TimeSettingReqData;
public class TimeSettingReq extends TcpReq<TimeSettingReqData> { public class TimeSettingReq extends TcpReq<TimeSettingReqData> {
public TimeSettingReq() { public TimeSettingReq() {
super(TcpMapper.CMD_REQ_TIME_SETTING.getType()); super(TcpMapper.CMD_REQ_TIME_CHECK.getType());
} }
} }
...@@ -12,7 +12,7 @@ import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data.time.TimeSettingRspData; ...@@ -12,7 +12,7 @@ import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data.time.TimeSettingRspData;
**/ **/
public class TimeSettingRsp extends TcpRsp<TimeSettingRspData> { public class TimeSettingRsp extends TcpRsp<TimeSettingRspData> {
public TimeSettingRsp() { public TimeSettingRsp() {
super(TcpMapper.CMD_RSP_TIME_SETTING.getType()); super(TcpMapper.CMD_RSP_TIME_CHECK.getType());
} }
} }
...@@ -12,7 +12,9 @@ import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.protocol.login.LoginRsp; ...@@ -12,7 +12,9 @@ import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.protocol.login.LoginRsp;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.protocol.login.TimeNotify; import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.protocol.login.TimeNotify;
import cn.com.glsx.charging.util.ByteUtils; import cn.com.glsx.charging.util.ByteUtils;
import cn.com.glsx.charging.util.CrcUtils; import cn.com.glsx.charging.util.CrcUtils;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class CrcTest { public class CrcTest {
@BeforeAll @BeforeAll
...@@ -23,19 +25,19 @@ public class CrcTest { ...@@ -23,19 +25,19 @@ public class CrcTest {
@Test @Test
public void test_LoginReq_crc() throws Exception { public void test_LoginReq_crc() throws Exception {
String hex = "6822000100015503141278230500020AFFFFFF5000000000000000000000000000000000B9BA"; String hex = "6822000100015503141278230500020AFFFFFF5000000000000000000000000000000000B9BA";
System.out.println(hex); log.info(hex);
byte[] bytes = ByteUtils.fromHex(hex); byte[] bytes = ByteUtils.fromHex(hex);
LoginReq protocol = Ocpp16Helper.parse(bytes); LoginReq protocol = Ocpp16Helper.parse(bytes);
System.out.println("expect: " + protocol.getCrc()); log.info("expect: " + protocol.getCrc());
byte[] data = ByteUtils.getBytes(bytes, 2, bytes.length - 4); byte[] data = ByteUtils.getBytes(bytes, 2, bytes.length - 4);
System.out.println("actual: " + CrcUtils.calculateCRC(data)); log.info("actual: " + CrcUtils.calculateCRC(data));
bytes = Ocpp16Helper.build(protocol); bytes = Ocpp16Helper.build(protocol);
System.out.println(ByteUtils.toHex(bytes)); log.info(ByteUtils.toHex(bytes));
System.out.println(protocol); log.info("{}", protocol);
Assert.assertEquals(protocol.getCrc(), CrcUtils.calculateCRC(data)); Assert.assertEquals(protocol.getCrc(), CrcUtils.calculateCRC(data));
} }
...@@ -43,19 +45,19 @@ public class CrcTest { ...@@ -43,19 +45,19 @@ public class CrcTest {
@Test @Test
public void test_LoginRsp_crc() { public void test_LoginRsp_crc() {
String hex = "680C000100025503141278230500DEB0"; String hex = "680C000100025503141278230500DEB0";
System.out.println(hex); log.info(hex);
byte[] bytes = ByteUtils.fromHex(hex); byte[] bytes = ByteUtils.fromHex(hex);
LoginRsp protocol = Ocpp16Helper.parse(bytes); LoginRsp protocol = Ocpp16Helper.parse(bytes);
System.out.println("expect: " + protocol.getCrc()); log.info("expect: " + protocol.getCrc());
byte[] data = ByteUtils.getBytes(bytes, 2, bytes.length - 4); byte[] data = ByteUtils.getBytes(bytes, 2, bytes.length - 4);
System.out.println("actual: " + CrcUtils.calculateCRC(data)); log.info("actual: " + CrcUtils.calculateCRC(data));
bytes = Ocpp16Helper.build(protocol); bytes = Ocpp16Helper.build(protocol);
System.out.println(ByteUtils.toHex(bytes)); log.info(ByteUtils.toHex(bytes));
System.out.println(protocol); log.info("{}", protocol);
Assert.assertEquals(protocol.getCrc(), CrcUtils.calculateCRC(data)); Assert.assertEquals(protocol.getCrc(), CrcUtils.calculateCRC(data));
} }
...@@ -63,19 +65,19 @@ public class CrcTest { ...@@ -63,19 +65,19 @@ public class CrcTest {
@Test @Test
public void test_HeartbeatReq_crc() { public void test_HeartbeatReq_crc() {
String hex = "680D000200035503141278230500006599"; String hex = "680D000200035503141278230500006599";
System.out.println(hex); log.info(hex);
byte[] bytes = ByteUtils.fromHex(hex); byte[] bytes = ByteUtils.fromHex(hex);
HeartbeatReq protocol = Ocpp16Helper.parse(bytes); HeartbeatReq protocol = Ocpp16Helper.parse(bytes);
System.out.println("expect: " + protocol.getCrc()); log.info("expect: " + protocol.getCrc());
byte[] data = ByteUtils.getBytes(bytes, 2, bytes.length - 4); byte[] data = ByteUtils.getBytes(bytes, 2, bytes.length - 4);
System.out.println("actual: " + CrcUtils.calculateCRC(data)); log.info("actual: " + CrcUtils.calculateCRC(data));
bytes = Ocpp16Helper.build(protocol); bytes = Ocpp16Helper.build(protocol);
System.out.println(ByteUtils.toHex(bytes)); log.info(ByteUtils.toHex(bytes));
System.out.println(protocol); log.info("{}", protocol);
Assert.assertEquals(protocol.getCrc(), CrcUtils.calculateCRC(data)); Assert.assertEquals(protocol.getCrc(), CrcUtils.calculateCRC(data));
} }
...@@ -83,19 +85,19 @@ public class CrcTest { ...@@ -83,19 +85,19 @@ public class CrcTest {
@Test @Test
public void test_HeartbeatRsp_crc() { public void test_HeartbeatRsp_crc() {
String hex = "680D000300045503141278230500002980"; String hex = "680D000300045503141278230500002980";
System.out.println(hex); log.info(hex);
byte[] bytes = ByteUtils.fromHex(hex); byte[] bytes = ByteUtils.fromHex(hex);
HeartbeatRsp protocol = Ocpp16Helper.parse(bytes); HeartbeatRsp protocol = Ocpp16Helper.parse(bytes);
System.out.println("expect: " + protocol.getCrc()); log.info("expect: " + protocol.getCrc());
byte[] data = ByteUtils.getBytes(bytes, 2, bytes.length - 4); byte[] data = ByteUtils.getBytes(bytes, 2, bytes.length - 4);
System.out.println("actual: " + CrcUtils.calculateCRC(data)); log.info("actual: " + CrcUtils.calculateCRC(data));
bytes = Ocpp16Helper.build(protocol); bytes = Ocpp16Helper.build(protocol);
System.out.println(ByteUtils.toHex(bytes)); log.info(ByteUtils.toHex(bytes));
System.out.println(protocol); log.info("{}", protocol);
Assert.assertEquals(protocol.getCrc(), CrcUtils.calculateCRC(data)); Assert.assertEquals(protocol.getCrc(), CrcUtils.calculateCRC(data));
} }
...@@ -103,19 +105,19 @@ public class CrcTest { ...@@ -103,19 +105,19 @@ public class CrcTest {
@Test @Test
public void test_TimeNotify_crc() { public void test_TimeNotify_crc() {
String hex = "68120002005655031412782305F055020E070B178676"; String hex = "68120002005655031412782305F055020E070B178676";
System.out.println(hex); log.info(hex);
byte[] bytes = ByteUtils.fromHex(hex); byte[] bytes = ByteUtils.fromHex(hex);
TimeNotify protocol = Ocpp16Helper.parse(bytes); TimeNotify protocol = Ocpp16Helper.parse(bytes);
System.out.println("expect: " + protocol.getCrc()); log.info("expect: " + protocol.getCrc());
byte[] data = ByteUtils.getBytes(bytes, 2, bytes.length - 4); byte[] data = ByteUtils.getBytes(bytes, 2, bytes.length - 4);
System.out.println("actual: " + CrcUtils.calculateCRC(data)); log.info("actual: " + CrcUtils.calculateCRC(data));
bytes = Ocpp16Helper.build(protocol); bytes = Ocpp16Helper.build(protocol);
System.out.println(ByteUtils.toHex(bytes)); log.info(ByteUtils.toHex(bytes));
System.out.println(protocol); log.info("{}", protocol);
Assert.assertEquals(protocol.getCrc(), CrcUtils.calculateCRC(data)); Assert.assertEquals(protocol.getCrc(), CrcUtils.calculateCRC(data));
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!