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 27dc2ac1
authored
Nov 07, 2023
by
叶立庆
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
[+]运营平台远程控制启机协议
1 parent
9c3cd2bd
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
246 additions
and
2 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/data/interactive/ShutdownMachineReqData.java
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/tcp/data/interactive/ShutdownMachineRespData.java
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/tcp/handler/interactive/req/ShutdownMachineReqHandler.java
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/tcp/handler/interactive/resp/ShutdownMachineRespHandler.java
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/tcp/protocol/interactive/req/ShutdownMachineReq.java
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/tcp/protocol/interactive/resp/ShutdownMachineResp.java
platform-charging/src/test/java/cn/com/glsx/charging/gbt/ocpp16/InteractiveTest.java
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/tcp/base/TcpMapper.java
View file @
27dc2ac
...
...
@@ -2,6 +2,8 @@ package cn.com.glsx.charging.modules.gbt.ocpp16.tcp.base;
import
java.util.Map
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.handler.interactive.req.ShutdownMachineReqHandler
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.handler.interactive.resp.ShutdownMachineRespHandler
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
com.google.common.collect.Maps
;
...
...
@@ -58,9 +60,9 @@ public final class TcpMapper {
public
static
TcpMapper
FTCD_REQ_REMOTE_CONTROL_STARTUP
=
regist
(
0x34
,
"运营平台远程控制启机"
,
StartMachineReqHandler
.
class
);
public
static
TcpMapper
FTCD_RSP_REMOTE_SHUTDOWN
=
regist
(
0x35
,
"远程停机命令回复"
,
null
);
public
static
TcpMapper
FTCD_RSP_REMOTE_SHUTDOWN
=
regist
(
0x35
,
"远程停机命令回复"
,
ShutdownMachineRespHandler
.
class
);
public
static
TcpMapper
FTCD_REQ_REMOTE_SHUTDOWN
=
regist
(
0x36
,
"运营平台远程停机"
,
null
);
public
static
TcpMapper
FTCD_REQ_REMOTE_SHUTDOWN
=
regist
(
0x36
,
"运营平台远程停机"
,
ShutdownMachineReqHandler
.
class
);
public
static
TcpMapper
FTCD_REQ_TRANSACTION_RECORDS
=
regist
(
0x3B
,
"交易记录"
,
null
);
...
...
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/tcp/data/interactive/ShutdownMachineReqData.java
0 → 100644
View file @
27dc2ac
package
cn
.
com
.
glsx
.
charging
.
modules
.
gbt
.
ocpp16
.
tcp
.
data
.
interactive
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.base.TcpData
;
import
lombok.Getter
;
import
lombok.Setter
;
/**
* @Description 运营平台远程停机
* 功能 当用户通过远程停止充电时,发送本命令,如 APP 停止充电
* 样例报文 68(起始标志)0C(数据长度)0003(序列号域)00(加密标志)36(类型)32010200000001
* (桩编码)01(枪号:1 枪)C1A9(帧校验域)
* @Author yelq
* @Date 2023/11/7-16:10
* @Version 1.0
*/
@Getter
@Setter
public
class
ShutdownMachineReqData
extends
TcpData
{
/**
* 桩编号
* 数据类型: (BCD码)
* 长度(Byte):7
* 备注:不足7位补0
*/
private
byte
[]
pileNumber
=
new
byte
[
7
];
/**
* 枪号
* 数据类型: (BCD码)
* 长度(Byte):1
* 备注:
*/
private
byte
gunNumber
;
}
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/tcp/data/interactive/ShutdownMachineRespData.java
0 → 100644
View file @
27dc2ac
package
cn
.
com
.
glsx
.
charging
.
modules
.
gbt
.
ocpp16
.
tcp
.
data
.
interactive
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.base.TcpData
;
import
lombok.Getter
;
import
lombok.Setter
;
/**
* @Description 远程停止充电命令回复
* 功能 远程停止充电命令回复,平台发送 0x36 后即关闭订单,接收到停机指令后设备务必保证停机。
* 样例报文 68(起始标志)0E(数据长度)0003(序列号域)00(加密标志)35(类型)32010200000001
* (桩编码)01(枪号:1 枪)01(停止结果:成功)00(失败原因:00)907E(帧校验域)
* @Author yelq
* @Date 2023/11/7-16:10
* @Version 1.0
*/
@Getter
@Setter
public
class
ShutdownMachineRespData
extends
TcpData
{
/**
* 桩编号
* 数据类型:byte[] (BCD码)
* 长度(Byte):7
* 备注:不足7位补0
*/
private
byte
[]
pileNumber
=
new
byte
[
7
];
/**
* 枪号
* 数据类型:byte[] (BCD码)
* 长度(Byte):1
* 备注:
*/
private
byte
gunNumber
;
/**
* 停止结果
* 数据类型:byte[] (BCD码)
* 长度(Byte):1
* 备注:0x00失败 0x01成功
*/
private
byte
shutdownResult
;
/**
* 失败原因
* 数据类型:byte[] (BIN码)
* 长度(Byte):1
* 备注:
* 0x00 无
* 0x01 设备编号不匹配
* 0x02 枪未处于充电状态
* 0x03 其他
*/
private
byte
failureReason
;
}
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/tcp/handler/interactive/req/ShutdownMachineReqHandler.java
0 → 100644
View file @
27dc2ac
package
cn
.
com
.
glsx
.
charging
.
modules
.
gbt
.
ocpp16
.
tcp
.
handler
.
interactive
.
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.data.interactive.ShutdownMachineRespData
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.protocol.interactive.req.ShutdownMachineReq
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.protocol.interactive.resp.ShutdownMachineResp
;
import
io.netty.channel.Channel
;
/**
* @Description 运营平台远程停机处理类
* @Author yelq
* @Date 2023/11/7-16:10
* @Version 1.0
*/
public
class
ShutdownMachineReqHandler
implements
TcpHandler
<
ShutdownMachineReq
,
ShutdownMachineResp
>
{
// * 功能 远程停止充电命令回复,平台发送 0x36 后即关闭订单,接收到停机指令后设备务必保证停机。
// * 样例报文 68(起始标志)0E(数据长度)0003(序列号域)00(加密标志)35(类型)32010200000001
// * (桩编码)01(枪号:1 枪)01(停止结果:成功)00(失败原因:00)907E(帧校验域)
@Override
public
ShutdownMachineResp
handle
(
Channel
channel
,
ShutdownMachineReq
shutdownMachineReq
)
{
/**请求日志打印*/
log
.
info
(
"桩编号:"
+
Ocpp16Helper
.
bcdToStr
(
shutdownMachineReq
.
getData
().
getPileNumber
()));
log
.
info
(
"枪号:"
+
shutdownMachineReq
.
getData
().
getGunNumber
());
/**请求日志打印*/
ShutdownMachineResp
resp
=
new
ShutdownMachineResp
();
ShutdownMachineRespData
data
=
new
ShutdownMachineRespData
();
data
.
setPileNumber
(
Ocpp16Helper
.
strToBcd
(
"32010200000001"
,
data
.
getPileNumber
()));
data
.
setGunNumber
((
byte
)
1
);
data
.
setShutdownResult
((
byte
)
1
);
data
.
setFailureReason
((
byte
)
0
);
resp
.
setData
(
data
);
return
resp
;
}
}
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/tcp/handler/interactive/resp/ShutdownMachineRespHandler.java
0 → 100644
View file @
27dc2ac
package
cn
.
com
.
glsx
.
charging
.
modules
.
gbt
.
ocpp16
.
tcp
.
handler
.
interactive
.
resp
;
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.interactive.ShutdownMachineRespData
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.protocol.interactive.resp.ShutdownMachineResp
;
import
io.netty.channel.Channel
;
/**
* @Description 远程停止充电命令回复处理类
* @Author yelq
* @Date 2023/11/7-16:10
* @Version 1.0
*/
public
class
ShutdownMachineRespHandler
implements
TcpHandler
<
ShutdownMachineResp
,
ShutdownMachineResp
>
{
@Override
public
ShutdownMachineResp
handle
(
Channel
channel
,
ShutdownMachineResp
shutdownMachineResp
)
{
ShutdownMachineRespData
data
=
shutdownMachineResp
.
getData
();
log
.
info
(
"桩编号:{}"
,
Ocpp16Helper
.
bcdToStr
(
data
.
getPileNumber
()));
log
.
info
(
"枪号:{}"
,
data
.
getGunNumber
());
log
.
info
(
"停止结果:{}"
,
data
.
getShutdownResult
());
log
.
info
(
"失败原因:{}"
,
data
.
getFailureReason
());
System
.
out
.
println
(
"客户端已经收到消息了"
);
return
null
;
}
}
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/tcp/protocol/interactive/req/ShutdownMachineReq.java
0 → 100644
View file @
27dc2ac
package
cn
.
com
.
glsx
.
charging
.
modules
.
gbt
.
ocpp16
.
tcp
.
protocol
.
interactive
.
req
;
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.interactive.ShutdownMachineReqData
;
/**
* @Description todo
* @Author yelq
* @Date 2023/11/7-16:21
* @Version 1.0
*/
public
class
ShutdownMachineReq
extends
TcpReq
<
ShutdownMachineReqData
>
{
public
ShutdownMachineReq
()
{
super
(
TcpMapper
.
FTCD_REQ_REMOTE_SHUTDOWN
.
getType
());
}
}
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/tcp/protocol/interactive/resp/ShutdownMachineResp.java
0 → 100644
View file @
27dc2ac
package
cn
.
com
.
glsx
.
charging
.
modules
.
gbt
.
ocpp16
.
tcp
.
protocol
.
interactive
.
resp
;
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.interactive.ShutdownMachineRespData
;
/**
* @Description todo
* @Author yelq
* @Date 2023/11/7-16:21
* @Version 1.0
*/
public
class
ShutdownMachineResp
extends
TcpReq
<
ShutdownMachineRespData
>
{
public
ShutdownMachineResp
()
{
super
(
TcpMapper
.
FTCD_RSP_REMOTE_SHUTDOWN
.
getType
());
}
}
platform-charging/src/test/java/cn/com/glsx/charging/gbt/ocpp16/InteractiveTest.java
0 → 100644
View file @
27dc2ac
package
cn
.
com
.
glsx
.
charging
.
gbt
.
ocpp16
;
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.tcp.client.TcpClient
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data.interactive.ShutdownMachineReqData
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data.interactive.StartMachineReqData
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.protocol.interactive.req.ShutdownMachineReq
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.protocol.interactive.req.StartMachineReq
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.mockito.junit.MockitoJUnitRunner
;
/**
* @Description 运营交互帧类型码数据定义协议测试类
* @Author yelq
* @Date 2023/11/7-15:19
* @Version 1.0
*/
@RunWith
(
MockitoJUnitRunner
.
class
)
public
class
InteractiveTest
{
@Test
public
void
shutdownMachineTest
()
throws
Exception
{
Ocpp16Helper
.
scan
();
TcpClient
client
=
ClientMain
.
getInstance
(
"localhost"
,
8888
);
Thread
.
sleep
(
3000
);
ShutdownMachineReq
req
=
new
ShutdownMachineReq
();
ShutdownMachineReqData
data
=
new
ShutdownMachineReqData
();
data
.
setGunNumber
((
byte
)
1
);
data
.
setPileNumber
(
Ocpp16Helper
.
strToBcd
(
"32010200000001"
,
data
.
getPileNumber
()));
req
.
setData
(
data
);
client
.
sendSync
(
req
);
Thread
.
sleep
(
3000
);
System
.
out
.
println
(
"========================="
);
}
@Test
public
void
startMachineReqTest
()
throws
Exception
{
Ocpp16Helper
.
scan
();
TcpClient
client
=
ClientMain
.
getInstance
(
"localhost"
,
8888
);
Thread
.
sleep
(
3000
);
StartMachineReq
req
=
new
StartMachineReq
();
StartMachineReqData
data
=
new
StartMachineReqData
();
data
.
setTransactionSerialNumber
(
Ocpp16Helper
.
strToBcd
(
"32010200000000111511161555350261"
,
data
.
getTransactionSerialNumber
()));
data
.
setPileNumber
(
Ocpp16Helper
.
strToBcd
(
"32010200000001"
,
data
.
getPileNumber
()));
data
.
setGunNumber
((
byte
)
1
);
data
.
setLogicalCardNumber
(
Ocpp16Helper
.
strToBcd
(
"1000000573"
,
data
.
getLogicalCardNumber
()));
data
.
setPhysicalCardNumber
(
Ocpp16Helper
.
strToBcd
(
"D14B0A54"
,
data
.
getPhysicalCardNumber
()));
data
.
setAccountBalance
(
Ocpp16Helper
.
strToBcd
(
"00000064"
,
data
.
getAccountBalance
()));
req
.
setData
(
data
);
client
.
sendSync
(
req
);
System
.
out
.
println
(
"========================="
);
}
}
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