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 32460bdd
authored
Nov 10, 2023
by
chenxi
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
实现功能:读取实时监测数据
1 parent
106426f6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
172 additions
and
1 deletions
platform-charging/src/main/java/cn/com/glsx/charging/modules/controller/GetDataController.java
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/RealTimeDataReqData.java
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/tcp/handler/RealTimeDataReqHandler.java
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/tcp/protocol/RealTimeReq.java
platform-charging/src/test/java/cn/com/glsx/charging/gbt/ocpp16/GetDataTest.java
platform-charging/src/main/java/cn/com/glsx/charging/modules/controller/GetDataController.java
0 → 100644
View file @
32460bd
package
cn
.
com
.
glsx
.
charging
.
modules
.
controller
;
import
cn.com.glsx.charging.modules.BaseController
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.Ocpp16Helper
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.ServerMain
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.base.TcpCallback
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.base.TcpRsp
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data.RealTimeDataReqData
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.protocol.RealTimeReq
;
import
com.glsx.plat.core.annotation.ResponseResultBody
;
import
com.glsx.plat.core.web.R
;
import
io.swagger.v3.oas.annotations.Operation
;
import
io.swagger.v3.oas.annotations.tags.Tag
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.ibatis.annotations.Param
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
/**
* @Author: chenxi
* @Date: 2023/11/10
*/
@Slf4j
@Tag
(
name
=
""
)
@RestController
@RequestMapping
(
value
=
"/getdata"
)
@ResponseResultBody
public
class
GetDataController
extends
BaseController
{
@Operation
(
summary
=
"读取实时监测数据"
,
description
=
"读取实时监测数据"
)
@GetMapping
(
"/realtime"
)
public
R
<
Boolean
>
getRealTimeData
(
@Param
(
"pileId"
)
String
pileId
,
@Param
(
"gunNumber"
)
String
gunNumber
)
{
log
.
info
(
"读取实时监测数据,充电桩编号:{}"
,
pileId
);
log
.
info
(
"读取实时监测数据,枪号:{}"
,
gunNumber
);
RealTimeReq
req
=
new
RealTimeReq
();
RealTimeDataReqData
data
=
new
RealTimeDataReqData
();
data
.
setPileId
(
Ocpp16Helper
.
strToBcd
(
pileId
,
data
.
getPileId
()));
data
.
setPileId
(
Ocpp16Helper
.
strToBcd
(
pileId
,
new
byte
[]
{
data
.
getGunNumber
()}
));
TcpCallback
<
TcpRsp
>
tcpRspTcpCallback
=
ServerMain
.
getServer
().
sendSync
(
req
);
TcpRsp
tcpRsp
=
tcpRspTcpCallback
.
get
();
return
R
.
ok
().
data
(
tcpRsp
);
}
}
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/tcp/base/TcpMapper.java
View file @
32460bd
...
@@ -42,7 +42,9 @@ public final class TcpMapper {
...
@@ -42,7 +42,9 @@ public final class TcpMapper {
public
static
TcpMapper
CMD_RSP_MODEL_QUERY
=
regist
(
0x0A
,
"计费模型请求应答"
,
null
);
public
static
TcpMapper
CMD_RSP_MODEL_QUERY
=
regist
(
0x0A
,
"计费模型请求应答"
,
null
);
public
static
TcpMapper
CMD_REQ_UPLOAD_REAL_TIME_DATA
=
regist
(
0x13
,
"读取实时检测数据"
,
UploadRealTimeReqHandler
.
class
);
public
static
TcpMapper
CMD_REQ_GET_REAL_TIME_DATA
=
regist
(
0x12
,
"读取实时检测数据"
,
RealTimeDataReqHandler
.
class
);
public
static
TcpMapper
CMD_REQ_UPLOAD_REAL_TIME_DATA
=
regist
(
0x13
,
"上传实时检测数据"
,
UploadRealTimeReqHandler
.
class
);
public
static
TcpMapper
CMD_REQ_CHARGING_HAND_SHAKE
=
regist
(
0x15
,
"充电握手"
,
ChargingHandshakeReqHandler
.
class
);
public
static
TcpMapper
CMD_REQ_CHARGING_HAND_SHAKE
=
regist
(
0x15
,
"充电握手"
,
ChargingHandshakeReqHandler
.
class
);
...
...
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/tcp/data/RealTimeDataReqData.java
0 → 100644
View file @
32460bd
package
cn
.
com
.
glsx
.
charging
.
modules
.
gbt
.
ocpp16
.
tcp
.
data
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.base.TcpData
;
import
lombok.Data
;
/**
* @Author: chenx
* @Description: 读取实时监测数据请求类
* @Date: 2023/11/10 16:29
* @Version: 1.0
*/
@Data
public
class
RealTimeDataReqData
extends
TcpData
{
/**
* 桩编号
* 数据类型:byte[] (BCD码)
* 长度(Byte):7
* 备注:不足7位补0
*/
private
byte
[]
pileId
=
new
byte
[
7
];
/**
* 枪号
* 数据类型:byte[] (BCD码)
* 长度(Byte):1
* 备注:
*/
private
byte
gunNumber
;
}
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/tcp/handler/RealTimeDataReqHandler.java
0 → 100644
View file @
32460bd
package
cn
.
com
.
glsx
.
charging
.
modules
.
gbt
.
ocpp16
.
tcp
.
handler
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.base.TcpHandler
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.protocol.RealTimeReq
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.protocol.UploadRealtimeDataReq
;
import
io.netty.channel.Channel
;
/**
* @Author: chenx
* @Description:
* @Date: 2023/11/10 16:31
* @Version: 1.0
*/
public
class
RealTimeDataReqHandler
implements
TcpHandler
<
RealTimeReq
,
UploadRealtimeDataReq
>
{
@Override
public
UploadRealtimeDataReq
handle
(
Channel
channel
,
RealTimeReq
realTimeReq
)
{
return
null
;
}
}
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/tcp/protocol/RealTimeReq.java
0 → 100644
View file @
32460bd
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.TcpRsp
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data.RealTimeDataReqData
;
/**
* @Author: chenx
* @Description:
* @Date: 2023/11/10 16:45
* @Version: 1.0
*/
public
class
RealTimeReq
extends
TcpRsp
<
RealTimeDataReqData
>
{
public
RealTimeReq
()
{
super
(
TcpMapper
.
CMD_REQ_GET_REAL_TIME_DATA
.
getType
());
}
}
platform-charging/src/test/java/cn/com/glsx/charging/gbt/ocpp16/GetDataTest.java
0 → 100644
View file @
32460bd
package
cn
.
com
.
glsx
.
charging
.
gbt
.
ocpp16
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.Ocpp16Helper
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.ServerMain
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.base.TcpCallback
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.base.TcpRsp
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data.RealTimeDataReqData
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.protocol.RealTimeReq
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.server.TcpServer
;
import
lombok.extern.slf4j.Slf4j
;
import
org.junit.Test
;
/**
* @Author: chenx
* @Description: 读取实时监测数据
* @Date: 2023/11/10 17:06
* @Version: 1.0
*/
@Slf4j
public
class
GetDataTest
{
String
host
=
"localhost"
;
int
port
=
8888
;
private
TcpServer
serverStart
()
throws
Exception
{
// 启动服务端
TcpServer
start
=
ServerMain
.
start
(
host
,
port
);
Thread
.
sleep
(
15000
);
return
start
;
}
@Test
public
void
test
()
throws
Exception
{
TcpServer
tcpServer
=
serverStart
();
RealTimeDataReqData
data
=
new
RealTimeDataReqData
();
data
.
setPileId
(
Ocpp16Helper
.
strToBcd
(
"32010200000001"
,
data
.
getPileId
()));
data
.
setGunNumber
((
byte
)
01
);
RealTimeReq
req
=
new
RealTimeReq
();
req
.
setData
(
data
);
Thread
.
sleep
(
20000
);
TcpCallback
<
TcpRsp
>
callback
=
tcpServer
.
sendSync
(
req
);
Thread
.
sleep
(
10000
);
TcpRsp
rsp
=
callback
.
get
();
log
.
info
(
"callback{}"
,
rsp
.
getData
());
}
}
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