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 240ebb67
authored
Nov 10, 2023
by
叶立庆
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
[+]修改协议实现类
1 parent
35e05da1
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
44 additions
and
19 deletions
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/tcp/handler/ShutdownMachineRespHandler.java
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/tcp/handler/StartMachineRespHandler.java
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/tcp/protocol/ShutdownMachineResp.java
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/tcp/protocol/TransactionRecordsResp.java
platform-charging/src/test/java/cn/com/glsx/charging/gbt/ocpp16/RemoteChargingTest.java
platform-charging/src/test/java/cn/com/glsx/charging/gbt/ocpp16/TransactionRecordsTest.java
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/tcp/handler/ShutdownMachineRespHandler.java
View file @
240ebb6
package
cn
.
com
.
glsx
.
charging
.
modules
.
gbt
.
ocpp16
.
tcp
.
handler
;
package
cn
.
com
.
glsx
.
charging
.
modules
.
gbt
.
ocpp16
.
tcp
.
handler
;
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.base.TcpCallback
;
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.base.TcpRsp
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data.ShutdownMachineRespData
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data.ShutdownMachineRespData
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.protocol.ShutdownMachineResp
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.protocol.ShutdownMachineResp
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.server.ProxyHelper
;
import
io.netty.channel.Channel
;
import
io.netty.channel.Channel
;
import
java.util.Objects
;
/**
/**
* @Description 远程停止充电命令回复处理类
* @Description 远程停止充电命令回复处理类
* @Author yelq
* @Author yelq
...
@@ -16,12 +21,19 @@ public class ShutdownMachineRespHandler implements TcpHandler<ShutdownMachineRes
...
@@ -16,12 +21,19 @@ public class ShutdownMachineRespHandler implements TcpHandler<ShutdownMachineRes
@Override
@Override
public
ShutdownMachineResp
handle
(
Channel
channel
,
ShutdownMachineResp
shutdownMachineResp
)
{
public
ShutdownMachineResp
handle
(
Channel
channel
,
ShutdownMachineResp
shutdownMachineResp
)
{
System
.
out
.
println
(
"客户端已经收到消息了"
);
ShutdownMachineRespData
data
=
shutdownMachineResp
.
getData
();
ShutdownMachineRespData
data
=
shutdownMachineResp
.
getData
();
log
.
info
(
"桩编号:{}"
,
Ocpp16Helper
.
bcdToStr
(
data
.
getPileId
()));
log
.
info
(
"桩编号:{}"
,
Ocpp16Helper
.
bcdToStr
(
data
.
getPileId
()));
log
.
info
(
"枪号:{}"
,
data
.
getGunNumber
());
log
.
info
(
"枪号:{}"
,
data
.
getGunNumber
());
log
.
info
(
"停止结果:{}"
,
data
.
getShutdownResult
());
log
.
info
(
"停止结果:{}"
,
data
.
getShutdownResult
());
log
.
info
(
"失败原因:{}"
,
data
.
getFailureReason
());
log
.
info
(
"失败原因:{}"
,
data
.
getFailureReason
());
System
.
out
.
println
(
"客户端已经收到消息了"
);
String
key
=
ProxyHelper
.
getCallbackKey
(
shutdownMachineResp
,
channel
);
TcpCallback
<
TcpRsp
>
callback
=
ProxyHelper
.
getCallback
(
key
);
if
(
Objects
.
nonNull
(
callback
))
{
callback
.
callback
(
shutdownMachineResp
);
}
else
{
log
.
info
(
"callback为空===StartMachineRespHandler"
);
}
return
null
;
return
null
;
}
}
}
}
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/tcp/handler/StartMachineRespHandler.java
View file @
240ebb6
package
cn
.
com
.
glsx
.
charging
.
modules
.
gbt
.
ocpp16
.
tcp
.
handler
;
package
cn
.
com
.
glsx
.
charging
.
modules
.
gbt
.
ocpp16
.
tcp
.
handler
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.
Ocpp16Helper
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.
tcp.base.TcpCallback
;
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.base.TcpRsp
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data.StartMachineRspData
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data.StartMachineRspData
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.protocol.StartMachineResp
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.protocol.StartMachineResp
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.server.ProxyHelper
;
import
io.netty.channel.Channel
;
import
io.netty.channel.Channel
;
import
java.util.Objects
;
/**
/**
* @Description 远程启动充电命令回复处理类
* @Description 远程启动充电命令回复处理类
* @Author yelq
* @Author yelq
...
@@ -27,6 +31,13 @@ public class StartMachineRespHandler implements TcpHandler<StartMachineResp, Sta
...
@@ -27,6 +31,13 @@ public class StartMachineRespHandler implements TcpHandler<StartMachineResp, Sta
data
.
setGunNumber
((
byte
)
1
);
data
.
setGunNumber
((
byte
)
1
);
data
.
setFailureReason
((
byte
)
0
);
data
.
setFailureReason
((
byte
)
0
);
resp
.
setData
(
data
);
resp
.
setData
(
data
);
String
key
=
ProxyHelper
.
getCallbackKey
(
startMachineResp
,
channel
);
TcpCallback
<
TcpRsp
>
callback
=
ProxyHelper
.
getCallback
(
key
);
if
(
Objects
.
nonNull
(
callback
))
{
callback
.
callback
(
startMachineResp
);
}
else
{
log
.
info
(
"callback为空===StartMachineRespHandler"
);
}
return
null
;
return
null
;
}
}
}
}
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/tcp/protocol/ShutdownMachineResp.java
View file @
240ebb6
package
cn
.
com
.
glsx
.
charging
.
modules
.
gbt
.
ocpp16
.
tcp
.
protocol
;
package
cn
.
com
.
glsx
.
charging
.
modules
.
gbt
.
ocpp16
.
tcp
.
protocol
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.base.TcpMapper
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.base.TcpMapper
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.base.TcpR
eq
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.base.TcpR
sp
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data.ShutdownMachineRespData
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data.ShutdownMachineRespData
;
/**
/**
...
@@ -10,7 +10,7 @@ import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data.ShutdownMachineRespData;
...
@@ -10,7 +10,7 @@ import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data.ShutdownMachineRespData;
* @Date 2023/11/7-16:21
* @Date 2023/11/7-16:21
* @Version 1.0
* @Version 1.0
*/
*/
public
class
ShutdownMachineResp
extends
TcpR
eq
<
ShutdownMachineRespData
>
{
public
class
ShutdownMachineResp
extends
TcpR
sp
<
ShutdownMachineRespData
>
{
public
ShutdownMachineResp
()
{
public
ShutdownMachineResp
()
{
super
(
TcpMapper
.
CMD_RSP_STOP_CHARGING
.
getType
());
super
(
TcpMapper
.
CMD_RSP_STOP_CHARGING
.
getType
());
}
}
...
...
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/tcp/protocol/TransactionRecordsResp.java
View file @
240ebb6
...
@@ -2,6 +2,7 @@ package cn.com.glsx.charging.modules.gbt.ocpp16.tcp.protocol;
...
@@ -2,6 +2,7 @@ package cn.com.glsx.charging.modules.gbt.ocpp16.tcp.protocol;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.base.TcpMapper
;
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.base.TcpReq
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.base.TcpRsp
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data.TransactionRecordsRespData
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data.TransactionRecordsRespData
;
/**
/**
...
@@ -13,7 +14,7 @@ import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data.TransactionRecordsRespDa
...
@@ -13,7 +14,7 @@ import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data.TransactionRecordsRespDa
* @Date 2023/11/7-17:38
* @Date 2023/11/7-17:38
* @Version 1.0
* @Version 1.0
*/
*/
public
class
TransactionRecordsResp
extends
TcpR
eq
<
TransactionRecordsRespData
>
{
public
class
TransactionRecordsResp
extends
TcpR
sp
<
TransactionRecordsRespData
>
{
public
TransactionRecordsResp
()
{
public
TransactionRecordsResp
()
{
super
(
TcpMapper
.
CMD_RSP_TRADE_UPLOAD
.
getType
());
super
(
TcpMapper
.
CMD_RSP_TRADE_UPLOAD
.
getType
());
}
}
...
...
platform-charging/src/test/java/cn/com/glsx/charging/gbt/ocpp16/RemoteChargingTest.java
View file @
240ebb6
...
@@ -9,6 +9,7 @@ import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data.StartMachineReqData;
...
@@ -9,6 +9,7 @@ import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data.StartMachineReqData;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.protocol.ShutdownMachineReq
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.protocol.ShutdownMachineReq
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.protocol.StartMachineReq
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.protocol.StartMachineReq
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.server.TcpServer
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.server.TcpServer
;
import
com.alibaba.fastjson.JSON
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.junit.After
;
import
org.junit.After
;
import
org.junit.Before
;
import
org.junit.Before
;
...
@@ -32,11 +33,11 @@ public class RemoteChargingTest {
...
@@ -32,11 +33,11 @@ public class RemoteChargingTest {
@Before
@Before
public
void
beforeTest
()
throws
InterruptedException
{
public
void
beforeTest
()
throws
InterruptedException
{
//
Ocpp16Helper.scan();
Ocpp16Helper
.
scan
();
//
String host = "localhost";
String
host
=
"localhost"
;
//
int port = 8888;
int
port
=
8888
;
//
server = ServerMain.start(host,port);
server
=
ServerMain
.
start
(
host
,
port
);
// Thread.sleep(1
0000);
Thread
.
sleep
(
2
0000
);
}
}
@After
@After
...
@@ -47,7 +48,7 @@ public class RemoteChargingTest {
...
@@ -47,7 +48,7 @@ public class RemoteChargingTest {
/**
/**
*
远程关闭
充电桩
*
运营平台远程停机 运营平台->
充电桩
* @throws Exception
* @throws Exception
*/
*/
@Test
@Test
...
@@ -60,7 +61,7 @@ public class RemoteChargingTest {
...
@@ -60,7 +61,7 @@ public class RemoteChargingTest {
server
.
sendSync
(
req
);
server
.
sendSync
(
req
);
}
}
//
远程启动
充电桩
//
运营平台远程控制启机 运营平台->
充电桩
@Test
@Test
public
void
startMachineReqTest
()
throws
Exception
{
public
void
startMachineReqTest
()
throws
Exception
{
StartMachineReq
req
=
new
StartMachineReq
();
StartMachineReq
req
=
new
StartMachineReq
();
...
@@ -74,13 +75,8 @@ public class RemoteChargingTest {
...
@@ -74,13 +75,8 @@ public class RemoteChargingTest {
byte
[]
accountBytes
=
Ocpp16Helper
.
binToBytes
(
Ocpp16Helper
.
hexToBinStr
(
"A0860100"
));
byte
[]
accountBytes
=
Ocpp16Helper
.
binToBytes
(
Ocpp16Helper
.
hexToBinStr
(
"A0860100"
));
data
.
setAccountBalance
(
accountBytes
);
data
.
setAccountBalance
(
accountBytes
);
req
.
setData
(
data
);
req
.
setData
(
data
);
Ocpp16Helper
.
scan
();
String
host
=
"localhost"
;
int
port
=
8888
;
server
=
ServerMain
.
start
(
host
,
port
);
Thread
.
sleep
(
10000
);
TcpCallback
<
TcpRsp
>
callback
=
server
.
sendSync
(
req
);
TcpCallback
<
TcpRsp
>
callback
=
server
.
sendSync
(
req
);
TcpRsp
tcpRsp
=
callback
.
get
();
TcpRsp
tcpRsp
=
callback
.
get
();
log
.
info
(
"callback:{}"
,
tcpRsp
);
log
.
info
(
"callback:{}"
,
JSON
.
toJSONString
(
tcpRsp
)
);
}
}
}
}
platform-charging/src/test/java/cn/com/glsx/charging/gbt/ocpp16/TransactionRecordsTest.java
View file @
240ebb6
...
@@ -43,10 +43,15 @@ public class TransactionRecordsTest {
...
@@ -43,10 +43,15 @@ public class TransactionRecordsTest {
@After
@After
public
void
afterTest
()
throws
InterruptedException
{
public
void
afterTest
()
throws
InterruptedException
{
Thread
.
sleep
(
30000
);
Thread
.
sleep
(
30000
0
);
System
.
out
.
println
(
"========================="
);
System
.
out
.
println
(
"========================="
);
}
}
/**
* 充电桩->运营平台
* 交易记录
* @throws Exception
*/
@Test
@Test
public
void
transactionRecordsTest
()
throws
Exception
{
public
void
transactionRecordsTest
()
throws
Exception
{
/**
/**
...
...
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