Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
platform
/
platform-charging-server
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 930dc6bc
authored
Nov 07, 2023
by
tiger
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
重命名
1 parent
ba7607ce
Show whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
59 additions
and
110 deletions
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/tcp/base/TcpMapper.java
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/tcp/handler/DefaultRspHandler.java
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/tcp/handler/login/notify/TimeNotifyHandler.java
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/tcp/handler/login/rsp/LoginRspHandler.java
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/tcp/protocol/interactive/req/StartMachineReq.java
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/tcp/protocol/interactive/resp/StartMachineResp.java
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/tcp/protocol/login/ModelChargingReq.java
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/tcp/protocol/login/ModelChargingRsp.java
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/tcp/protocol/login/ModelValReq.java
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/tcp/protocol/login/ModelValRsp.java
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/tcp/protocol/login/TimeNotify.java
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/tcp/protocol/param/ParamSettingReq.java
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/tcp/protocol/param/ParamSettingRsp.java
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/tcp/protocol/time/TimeSettingReq.java
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/tcp/protocol/time/TimeSettingRsp.java
platform-charging/src/test/java/cn/com/glsx/charging/gbt/ocpp16/CrcTest.java
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/tcp/base/TcpMapper.java
View file @
930dc6b
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.StartMachineReqHandler
;
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
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.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.ParamSettingRspHandler
;
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
com.fasterxml.jackson.annotation.JsonIgnore
;
import
com.google.common.collect.Maps
;
import
lombok.AllArgsConstructor
;
import
lombok.Getter
;
import
lombok.extern.slf4j.Slf4j
;
import
java.util.Map
;
/**
* 管理与server的交互
*
...
...
@@ -38,45 +38,44 @@ public final class TcpMapper {
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_RSP_HEARTBEAT
=
regist
(
0x04
,
"心跳包应答"
,
null
);
// public static TcpMapper CMD_RSP_HEARTBEAT = regist(0x04, "心跳包应答", HeartbeatRspHandler.class);
// 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);
// 运营交互帧类型码数据定义 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
)
{
...
...
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/tcp/handler/DefaultRspHandler.java
View file @
930dc6b
...
...
@@ -9,7 +9,7 @@ public class DefaultRspHandler implements TcpHandler<TcpRsp<TcpData>, TcpRsp<Tcp
@Override
public
TcpRsp
<
TcpData
>
handle
(
Channel
channel
,
TcpRsp
<
TcpData
>
rsp
)
{
log
.
info
(
"【{}】{}"
,
rsp
.
getClass
().
getSimpleName
(),
rsp
);
log
.
info
(
"【{}】{}
啥也不干
"
,
rsp
.
getClass
().
getSimpleName
(),
rsp
);
return
null
;
}
...
...
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/tcp/handler/login/notify/TimeNotifyHandler.java
deleted
100644 → 0
View file @
ba7607c
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
;
}
}
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/tcp/handler/login/rsp/LoginRspHandler.java
View file @
930dc6b
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.data.login.LoginRspData
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.protocol.login.LoginRsp
;
import
io.netty.channel.Channel
;
...
...
@@ -9,17 +8,7 @@ public class LoginRspHandler implements TcpHandler<LoginRsp, LoginRsp> {
@Override
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
;
}
...
...
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/tcp/protocol/interactive/req/StartMachineReq.java
View file @
930dc6b
...
...
@@ -12,6 +12,6 @@ import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data.interactive.StartMachine
*/
public
class
StartMachineReq
extends
TcpReq
<
StartMachineReqData
>
{
public
StartMachineReq
()
{
super
(
TcpMapper
.
FTCD_REQ_REMOTE_CONTROL_STARTUP
.
getType
());
super
(
TcpMapper
.
CMD_REQ_START_CHARGING
.
getType
());
}
}
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/tcp/protocol/interactive/resp/StartMachineResp.java
View file @
930dc6b
...
...
@@ -12,6 +12,6 @@ import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data.interactive.StartMachine
*/
public
class
StartMachineResp
extends
TcpRsp
<
StartMachineRspData
>
{
public
StartMachineResp
()
{
super
(
TcpMapper
.
FTCD_RSP_REMOTE
_START_CHARGING
.
getType
());
super
(
TcpMapper
.
CMD_RSP
_START_CHARGING
.
getType
());
}
}
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/tcp/protocol/login/ModelChargingReq.java
View file @
930dc6b
...
...
@@ -14,6 +14,6 @@ import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data.login.ModelValReqData;
public
class
ModelChargingReq
extends
TcpReq
<
ModelChargingReqData
>
{
public
ModelChargingReq
()
{
super
(
TcpMapper
.
CMD_REQ_MODEL_
CHARGING
.
getType
());
super
(
TcpMapper
.
CMD_REQ_MODEL_
QUERY
.
getType
());
}
}
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/tcp/protocol/login/ModelChargingRsp.java
View file @
930dc6b
...
...
@@ -13,6 +13,6 @@ import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data.login.ModelChargingRspDa
public
class
ModelChargingRsp
extends
TcpRsp
<
ModelChargingRspData
>
{
public
ModelChargingRsp
()
{
super
(
TcpMapper
.
CMD_RSP_MODEL_
CHARGING
.
getType
());
super
(
TcpMapper
.
CMD_RSP_MODEL_
QUERY
.
getType
());
}
}
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/tcp/protocol/login/ModelValReq.java
View file @
930dc6b
...
...
@@ -13,6 +13,6 @@ import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data.login.ModelValReqData;
public
class
ModelValReq
extends
TcpReq
<
ModelValReqData
>
{
public
ModelValReq
()
{
super
(
TcpMapper
.
CMD_REQ_MODEL_
VALIDATION
.
getType
());
super
(
TcpMapper
.
CMD_REQ_MODEL_
CHECK
.
getType
());
}
}
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/tcp/protocol/login/ModelValRsp.java
View file @
930dc6b
...
...
@@ -14,6 +14,6 @@ import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data.login.ModelValRspData;
public
class
ModelValRsp
extends
TcpRsp
<
ModelValRspData
>
{
public
ModelValRsp
()
{
super
(
TcpMapper
.
CMD_RSP_MODEL_
VALIDATION
.
getType
());
super
(
TcpMapper
.
CMD_RSP_MODEL_
CHECK
.
getType
());
}
}
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/tcp/protocol/login/TimeNotify.java
deleted
100644 → 0
View file @
ba7607c
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());
}
}
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/tcp/protocol/param/ParamSettingReq.java
View file @
930dc6b
...
...
@@ -13,6 +13,6 @@ import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data.param.ParamSettingReqDat
public
class
ParamSettingReq
extends
TcpReq
<
ParamSettingReqData
>
{
public
ParamSettingReq
()
{
super
(
TcpMapper
.
CMD_REQ_
PARAM_SETTING
.
getType
());
super
(
TcpMapper
.
CMD_REQ_
CFG_DOWNLOAD
.
getType
());
}
}
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/tcp/protocol/param/ParamSettingRsp.java
View file @
930dc6b
...
...
@@ -12,7 +12,7 @@ import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data.param.ParamSettingRspDat
**/
public
class
ParamSettingRsp
extends
TcpRsp
<
ParamSettingRspData
>
{
public
ParamSettingRsp
()
{
super
(
TcpMapper
.
CMD_RSP_
PARAM_SETTING
.
getType
());
super
(
TcpMapper
.
CMD_RSP_
CFG_DOWNLOAD
.
getType
());
}
}
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/tcp/protocol/time/TimeSettingReq.java
View file @
930dc6b
...
...
@@ -13,6 +13,6 @@ import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data.time.TimeSettingReqData;
public
class
TimeSettingReq
extends
TcpReq
<
TimeSettingReqData
>
{
public
TimeSettingReq
()
{
super
(
TcpMapper
.
CMD_REQ_TIME_
SETTING
.
getType
());
super
(
TcpMapper
.
CMD_REQ_TIME_
CHECK
.
getType
());
}
}
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/tcp/protocol/time/TimeSettingRsp.java
View file @
930dc6b
...
...
@@ -12,7 +12,7 @@ import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data.time.TimeSettingRspData;
**/
public
class
TimeSettingRsp
extends
TcpRsp
<
TimeSettingRspData
>
{
public
TimeSettingRsp
()
{
super
(
TcpMapper
.
CMD_RSP_TIME_
SETTING
.
getType
());
super
(
TcpMapper
.
CMD_RSP_TIME_
CHECK
.
getType
());
}
}
platform-charging/src/test/java/cn/com/glsx/charging/gbt/ocpp16/CrcTest.java
View file @
930dc6b
...
...
@@ -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.util.ByteUtils
;
import
cn.com.glsx.charging.util.CrcUtils
;
import
lombok.extern.slf4j.Slf4j
;
@Slf4j
public
class
CrcTest
{
@BeforeAll
...
...
@@ -23,19 +25,19 @@ public class CrcTest {
@Test
public
void
test_LoginReq_crc
()
throws
Exception
{
String
hex
=
"6822000100015503141278230500020AFFFFFF5000000000000000000000000000000000B9BA"
;
System
.
out
.
println
(
hex
);
log
.
info
(
hex
);
byte
[]
bytes
=
ByteUtils
.
fromHex
(
hex
);
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
);
System
.
out
.
println
(
"actual: "
+
CrcUtils
.
calculateCRC
(
data
));
log
.
info
(
"actual: "
+
CrcUtils
.
calculateCRC
(
data
));
bytes
=
Ocpp16Helper
.
build
(
protocol
);
System
.
out
.
println
(
ByteUtils
.
toHex
(
bytes
));
System
.
out
.
println
(
protocol
);
log
.
info
(
ByteUtils
.
toHex
(
bytes
));
log
.
info
(
"{}"
,
protocol
);
Assert
.
assertEquals
(
protocol
.
getCrc
(),
CrcUtils
.
calculateCRC
(
data
));
}
...
...
@@ -43,19 +45,19 @@ public class CrcTest {
@Test
public
void
test_LoginRsp_crc
()
{
String
hex
=
"680C000100025503141278230500DEB0"
;
System
.
out
.
println
(
hex
);
log
.
info
(
hex
);
byte
[]
bytes
=
ByteUtils
.
fromHex
(
hex
);
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
);
System
.
out
.
println
(
"actual: "
+
CrcUtils
.
calculateCRC
(
data
));
log
.
info
(
"actual: "
+
CrcUtils
.
calculateCRC
(
data
));
bytes
=
Ocpp16Helper
.
build
(
protocol
);
System
.
out
.
println
(
ByteUtils
.
toHex
(
bytes
));
System
.
out
.
println
(
protocol
);
log
.
info
(
ByteUtils
.
toHex
(
bytes
));
log
.
info
(
"{}"
,
protocol
);
Assert
.
assertEquals
(
protocol
.
getCrc
(),
CrcUtils
.
calculateCRC
(
data
));
}
...
...
@@ -63,19 +65,19 @@ public class CrcTest {
@Test
public
void
test_HeartbeatReq_crc
()
{
String
hex
=
"680D000200035503141278230500006599"
;
System
.
out
.
println
(
hex
);
log
.
info
(
hex
);
byte
[]
bytes
=
ByteUtils
.
fromHex
(
hex
);
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
);
System
.
out
.
println
(
"actual: "
+
CrcUtils
.
calculateCRC
(
data
));
log
.
info
(
"actual: "
+
CrcUtils
.
calculateCRC
(
data
));
bytes
=
Ocpp16Helper
.
build
(
protocol
);
System
.
out
.
println
(
ByteUtils
.
toHex
(
bytes
));
System
.
out
.
println
(
protocol
);
log
.
info
(
ByteUtils
.
toHex
(
bytes
));
log
.
info
(
"{}"
,
protocol
);
Assert
.
assertEquals
(
protocol
.
getCrc
(),
CrcUtils
.
calculateCRC
(
data
));
}
...
...
@@ -83,19 +85,19 @@ public class CrcTest {
@Test
public
void
test_HeartbeatRsp_crc
()
{
String
hex
=
"680D000300045503141278230500002980"
;
System
.
out
.
println
(
hex
);
log
.
info
(
hex
);
byte
[]
bytes
=
ByteUtils
.
fromHex
(
hex
);
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
);
System
.
out
.
println
(
"actual: "
+
CrcUtils
.
calculateCRC
(
data
));
log
.
info
(
"actual: "
+
CrcUtils
.
calculateCRC
(
data
));
bytes
=
Ocpp16Helper
.
build
(
protocol
);
System
.
out
.
println
(
ByteUtils
.
toHex
(
bytes
));
System
.
out
.
println
(
protocol
);
log
.
info
(
ByteUtils
.
toHex
(
bytes
));
log
.
info
(
"{}"
,
protocol
);
Assert
.
assertEquals
(
protocol
.
getCrc
(),
CrcUtils
.
calculateCRC
(
data
));
}
...
...
@@ -103,19 +105,19 @@ public class CrcTest {
@Test
public
void
test_TimeNotify_crc
()
{
String
hex
=
"68120002005655031412782305F055020E070B178676"
;
System
.
out
.
println
(
hex
);
log
.
info
(
hex
);
byte
[]
bytes
=
ByteUtils
.
fromHex
(
hex
);
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
);
System
.
out
.
println
(
"actual: "
+
CrcUtils
.
calculateCRC
(
data
));
log
.
info
(
"actual: "
+
CrcUtils
.
calculateCRC
(
data
));
bytes
=
Ocpp16Helper
.
build
(
protocol
);
System
.
out
.
println
(
ByteUtils
.
toHex
(
bytes
));
System
.
out
.
println
(
protocol
);
log
.
info
(
ByteUtils
.
toHex
(
bytes
));
log
.
info
(
"{}"
,
protocol
);
Assert
.
assertEquals
(
protocol
.
getCrc
(),
CrcUtils
.
calculateCRC
(
data
));
}
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment