Commit a137f4b4 by zhouhaibao

[+]登录模块测试

1 parent edfe5861
...@@ -25,6 +25,6 @@ public class ModelValReqData extends TcpData { ...@@ -25,6 +25,6 @@ public class ModelValReqData extends TcpData {
/** /**
* 计费模型编号:首次连接到平台时置零 * 计费模型编号:首次连接到平台时置零
*/ */
private byte modelCode; private byte[] modelCode=new byte[2];
} }
...@@ -24,7 +24,7 @@ public class ModelValRspData extends TcpData { ...@@ -24,7 +24,7 @@ public class ModelValRspData extends TcpData {
/** /**
* 计费模型编号 * 计费模型编号
*/ */
private byte modelCode; private byte[] modelCode=new byte[2];
/** /**
* 验证结果:0x00桩计费模型与平台一致 0x01桩计费模型与平台不一致 * 验证结果:0x00桩计费模型与平台一致 0x01桩计费模型与平台不一致
......
package cn.com.glsx.charging.modules.gbt.ocpp16.tcp.handler.login.req; package cn.com.glsx.charging.modules.gbt.ocpp16.tcp.handler.login.req;
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.base.TcpHandler;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data.login.ModelChargingRspData; import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data.login.ModelChargingRspData;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.protocol.login.ModelChargingReq; import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.protocol.login.ModelChargingReq;
...@@ -19,7 +20,7 @@ public class ModelChargingReqHandler implements TcpHandler<ModelChargingReq, Mod ...@@ -19,7 +20,7 @@ public class ModelChargingReqHandler implements TcpHandler<ModelChargingReq, Mod
ModelChargingRsp rsp = new ModelChargingRsp(); ModelChargingRsp rsp = new ModelChargingRsp();
ModelChargingRspData data = new ModelChargingRspData(); ModelChargingRspData data = new ModelChargingRspData();
// 查业务系统 // 查业务系统
log.info("请求验证的桩号{}", Ocpp16Helper.bcdToStr(req.getData().getPointId()));
data.setPointId(req.getData().getPointId()); data.setPointId(req.getData().getPointId());
data.setModelCode((byte) 0100); data.setModelCode((byte) 0100);
byte[] byteArray = new byte[]{(byte) 0x9C, 0x40, 0x00, 0x00}; byte[] byteArray = new byte[]{(byte) 0x9C, 0x40, 0x00, 0x00};
......
package cn.com.glsx.charging.modules.gbt.ocpp16.tcp.handler.login.req; package cn.com.glsx.charging.modules.gbt.ocpp16.tcp.handler.login.req;
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.base.TcpHandler;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data.login.ModelValRspData; import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data.login.ModelValRspData;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.protocol.login.ModelValReq; import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.protocol.login.ModelValReq;
...@@ -16,7 +17,9 @@ public class ModelValReqHandler implements TcpHandler<ModelValReq, ModelValRsp> ...@@ -16,7 +17,9 @@ public class ModelValReqHandler implements TcpHandler<ModelValReq, ModelValRsp>
ModelValRsp rsp = new ModelValRsp(); ModelValRsp rsp = new ModelValRsp();
ModelValRspData data = new ModelValRspData(); ModelValRspData data = new ModelValRspData();
log.info("请求验证的桩号{}", Ocpp16Helper.bcdToStr(req.getData().getPointId()));
data.setPointId(req.getData().getPointId()); data.setPointId(req.getData().getPointId());
log.info("请求验证的计费模型编号{}", Ocpp16Helper.bcdToStr(req.getData().getModelCode()));
data.setModelCode(req.getData().getModelCode()); data.setModelCode(req.getData().getModelCode());
data.setValidationRes((byte) 0x00); data.setValidationRes((byte) 0x00);
......
...@@ -4,11 +4,9 @@ import cn.com.glsx.charging.modules.gbt.ocpp16.ClientMain; ...@@ -4,11 +4,9 @@ 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.Ocpp16Helper;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.client.TcpClient; import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.client.TcpClient;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data.login.ModelChargingReqData; import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data.login.ModelChargingReqData;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.protocol.login.LoginRsp;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.protocol.login.ModelChargingReq; import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.protocol.login.ModelChargingReq;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.protocol.login.ModelChargingRsp; import java.nio.ByteBuffer;
import cn.com.glsx.charging.util.ByteUtils; import lombok.extern.slf4j.Slf4j;
import cn.com.glsx.charging.util.CrcUtils;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
/** /**
...@@ -17,6 +15,7 @@ import org.junit.jupiter.api.Test; ...@@ -17,6 +15,7 @@ import org.junit.jupiter.api.Test;
* @author kome * @author kome
* @date 2023年11月6日 上午9:49:10 * @date 2023年11月6日 上午9:49:10
*/ */
@Slf4j
public class ModelChargingTest { public class ModelChargingTest {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
...@@ -40,20 +39,7 @@ public class ModelChargingTest { ...@@ -40,20 +39,7 @@ public class ModelChargingTest {
@Test @Test
public void testCrc() { public void testCrc() {
Ocpp16Helper.scan();
// 68(起始标志)0C(数据长度)0000(序列号域)00(加密标志)02(类型)55 03 14 12 78 23 05(桩编码)00(登陆结果:成功)DA 4C(帧校验域)
String hex = "68450001000A55031412782305400000000000000000000101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010733";
System.out.println(hex);
byte[] bytes = ByteUtils.fromHex(hex);
ModelChargingRsp rsp = Ocpp16Helper.parse(bytes);
System.out.println("expect: " + rsp.getCrc());
byte[] data = ByteUtils.getBytes(bytes, 2, bytes.length - 4);
System.out.println("actual: " + CrcUtils.calculateCRC(data));
System.out.println("actual1: " + CrcUtils.calculateCRC1(data));
System.out.println("actual2: " + CrcUtils.calculateCRC2(data));
System.out.println("actual3: " + CrcUtils.calculateCRC3(data));
} }
} }
...@@ -27,7 +27,7 @@ public class ModelValTest { ...@@ -27,7 +27,7 @@ public class ModelValTest {
ModelValReq req = new ModelValReq(); ModelValReq req = new ModelValReq();
req.setData(new ModelValReqData()); req.setData(new ModelValReqData());
req.getData().setPointId(Ocpp16Helper.strToBcd("55031412782305", req.getData().getPointId())); req.getData().setPointId(Ocpp16Helper.strToBcd("55031412782305", req.getData().getPointId()));
req.getData().setModelCode((byte) 0001); req.getData().setModelCode(Ocpp16Helper.strToBcd("0000", req.getData().getModelCode()));
client.sendSync(req); client.sendSync(req);
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!