Commit edfe5861 by zhouhaibao

[+]模型接口新增

1 parent a9f13c7c
...@@ -34,42 +34,42 @@ public class ModelChargingRspData extends TcpData { ...@@ -34,42 +34,42 @@ public class ModelChargingRspData extends TcpData {
/** /**
* 尖费电费费率 * 尖费电费费率
*/ */
private byte topEleRate; private byte[] topEleRate=new byte[4];
/** /**
* 尖服务费费率 * 尖服务费费率
*/ */
private byte topDreRate; private byte[] topDreRate=new byte[4];
/** /**
* 峰电费费率 * 峰电费费率
*/ */
private byte peakEleRate; private byte[] peakEleRate=new byte[4];
/** /**
* 峰服务费费率 * 峰服务费费率
*/ */
private byte peakDreRate; private byte[] peakDreRate=new byte[4];
/** /**
* 平电费费率 * 平电费费率
*/ */
private byte flatEleRate; private byte[] flatEleRate=new byte[4];
/** /**
* 平服务费费率 * 平服务费费率
*/ */
private byte flatDreRate; private byte[] flatDreRate=new byte[4];
/** /**
* 谷电费费率 * 谷电费费率
*/ */
private byte valleyEleRate; private byte[] valleyEleRate=new byte[4];
/** /**
* 谷服务费费率 * 谷服务费费率
*/ */
private byte valleyDreRate; private byte[] valleyDreRate=new byte[4];
/** /**
* 计损比例 * 计损比例
......
...@@ -14,10 +14,23 @@ public class ModelChargingReqHandler implements TcpHandler<ModelChargingReq, Mod ...@@ -14,10 +14,23 @@ public class ModelChargingReqHandler implements TcpHandler<ModelChargingReq, Mod
@Override @Override
public ModelChargingRsp handle(Channel channel, ModelChargingReq req) { public ModelChargingRsp handle(Channel channel, ModelChargingReq req) {
//
ModelChargingRsp rsp = new ModelChargingRsp(); ModelChargingRsp rsp = new ModelChargingRsp();
ModelChargingRspData data = new ModelChargingRspData(); ModelChargingRspData data = new ModelChargingRspData();
// 查业务系统
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};
data.setValleyDreRate(byteArray);
data.setValleyEleRate(byteArray);
data.setTopDreRate(byteArray);
data.setTopEleRate(byteArray);
data.setFlatDreRate(byteArray);
data.setFlatEleRate(byteArray);
data.setPeakDreRate(byteArray);
data.setPeakEleRate(byteArray);
data.setPeriodRate1((byte) 0x01); data.setPeriodRate1((byte) 0x01);
data.setPeriodRate2((byte) 0x01); data.setPeriodRate2((byte) 0x01);
......
...@@ -4,7 +4,12 @@ import cn.com.glsx.charging.modules.gbt.ocpp16.ClientMain; ...@@ -4,7 +4,12 @@ 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 cn.com.glsx.charging.util.ByteUtils;
import cn.com.glsx.charging.util.CrcUtils;
import org.junit.jupiter.api.Test;
/** /**
* 模拟充电桩端,连接云快充平台的测试服务器 实现登录,心跳,交互 * 模拟充电桩端,连接云快充平台的测试服务器 实现登录,心跳,交互
...@@ -33,4 +38,22 @@ public class ModelChargingTest { ...@@ -33,4 +38,22 @@ public class ModelChargingTest {
} }
@Test
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));
}
} }
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!