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 8629cf8c
authored
Nov 06, 2023
by
zhouhaibao
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
[+]登录注册服务处理
1 parent
dec88823
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
439 additions
and
0 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/login/ModelChargingReqData.java
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/tcp/data/login/ModelChargingRspData.java
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/tcp/data/login/ModelValReqData.java
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/tcp/data/login/ModelValRspData.java
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/tcp/handler/login/req/ModelChargingReqHandler.java
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/tcp/handler/login/req/ModelValReqHandler.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/test/java/cn/com/glsx/charging/gbt/ocpp16/ModelChargingTest.java
platform-charging/src/test/java/cn/com/glsx/charging/gbt/ocpp16/ModelValTest.java
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/tcp/base/TcpMapper.java
View file @
8629cf8
package
cn
.
com
.
glsx
.
charging
.
modules
.
gbt
.
ocpp16
.
tcp
.
base
;
package
cn
.
com
.
glsx
.
charging
.
modules
.
gbt
.
ocpp16
.
tcp
.
base
;
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
java.util.Map
;
import
java.util.Map
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
...
@@ -39,6 +41,14 @@ public final class TcpMapper {
...
@@ -39,6 +41,14 @@ public final class TcpMapper {
// TODO 补充完整所有协议
// TODO 补充完整所有协议
public
static
TcpMapper
CMD_REQ_MODEL_VALIDATION
=
regist
(
0x05
,
"计费模型验证请求"
,
ModelValReqHandler
.
class
);
public
static
TcpMapper
CMD_RSP_MODEL_VALIDATION
=
regist
(
0x06
,
"计费模型验证应答"
,
null
);
public
static
TcpMapper
CMD_REQ_MODEL_CHARGING
=
regist
(
0x09
,
"充电桩计费模型请求"
,
ModelChargingReqHandler
.
class
);
public
static
TcpMapper
CMD_RSP_MODEL_CHARGING
=
regist
(
0x0A
,
"计费模型请求应答"
,
null
);
public
static
TcpMapper
CMD_NOTIFY_TIME
=
regist
(
0x56
,
"对时设置"
,
TimeNotifyHandler
.
class
);
public
static
TcpMapper
CMD_NOTIFY_TIME
=
regist
(
0x56
,
"对时设置"
,
TimeNotifyHandler
.
class
);
public
static
TcpMapper
fromType
(
byte
type
)
{
public
static
TcpMapper
fromType
(
byte
type
)
{
...
...
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/tcp/data/login/ModelChargingReqData.java
0 → 100644
View file @
8629cf8
package
cn
.
com
.
glsx
.
charging
.
modules
.
gbt
.
ocpp16
.
tcp
.
data
.
login
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.base.TcpData
;
import
lombok.Getter
;
import
lombok.Setter
;
/**
* 充电桩计费模型请求
* 68(起始标志)0B(数据长度)0200(序列号域)00(加密标志)09(类型)55031412782305 (桩编码)DD25(帧校验域)
*
* @author zhouhb
* @date 2023年11月06日
*/
@Getter
@Setter
public
class
ModelChargingReqData
extends
TcpData
{
/**
* 充电桩id: BCD 码 ,不足 7 位补 0
*/
private
byte
[]
pointId
=
new
byte
[
7
];
}
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/tcp/data/login/ModelChargingRspData.java
0 → 100644
View file @
8629cf8
package
cn
.
com
.
glsx
.
charging
.
modules
.
gbt
.
ocpp16
.
tcp
.
data
.
login
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.base.TcpData
;
import
lombok.Getter
;
import
lombok.Setter
;
/**
* 计费模型请求应答
* 68(起始标志) 5E(数据长度) 02 00(序列号域) 00( 加密标志) 0A(帧类型标志) 55 03 14 12 78
* 23 05(桩编码) 01 00(计费模型编号) 40 0D 03 00(尖电费费率)9C 40 00 00(尖服务
* 费费率) E0 93 04 00(峰电费费率)9C 40 00 00(峰服务费费率)80 1A 06 00(平电费费
* 率)9C 40 00 00(平服务费费率)20 A1 07 00(谷电费费率)9C 40 00 00(谷服务费费率)
* 00(计损比例) 00(时段费率号 48 个)00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
* 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
* 00 00 00 5E 60(帧校验域)
*
* @author zhouhb
* @date 2023年11月06日
*/
@Getter
@Setter
public
class
ModelChargingRspData
extends
TcpData
{
/**
* 充电桩id: BCD 码 ,不足 7 位补 0
*/
private
byte
[]
pointId
=
new
byte
[
7
];
/**
* 计费模型编号:固定值:01 00
*/
private
byte
modelCode
;
/**
* 尖费电费费率
*/
private
byte
topEleRate
;
/**
* 尖服务费费率
*/
private
byte
topDreRate
;
/**
* 峰电费费率
*/
private
byte
peakEleRate
;
/**
* 峰服务费费率
*/
private
byte
peakDreRate
;
/**
* 平电费费率
*/
private
byte
flatEleRate
;
/**
* 平服务费费率
*/
private
byte
flatDreRate
;
/**
* 谷电费费率
*/
private
byte
valleyEleRate
;
/**
* 谷服务费费率
*/
private
byte
valleyDreRate
;
/**
* 计损比例
*/
private
byte
lossCalRatio
;
/**
* 0:00~0:30 时段费率号
*/
private
byte
periodRate1
;
private
byte
periodRate2
;
private
byte
periodRate3
;
private
byte
periodRate4
;
private
byte
periodRate5
;
private
byte
periodRate6
;
private
byte
periodRate7
;
private
byte
periodRate8
;
private
byte
periodRate9
;
private
byte
periodRate10
;
private
byte
periodRate11
;
private
byte
periodRate12
;
private
byte
periodRate13
;
private
byte
periodRate14
;
private
byte
periodRate15
;
private
byte
periodRate16
;
private
byte
periodRate17
;
private
byte
periodRate18
;
private
byte
periodRate19
;
private
byte
periodRate20
;
private
byte
periodRate21
;
private
byte
periodRate22
;
private
byte
periodRate23
;
private
byte
periodRate24
;
private
byte
periodRate25
;
private
byte
periodRate26
;
private
byte
periodRate27
;
private
byte
periodRate28
;
private
byte
periodRate29
;
private
byte
periodRate30
;
private
byte
periodRate31
;
private
byte
periodRate32
;
private
byte
periodRate33
;
private
byte
periodRate34
;
private
byte
periodRate35
;
private
byte
periodRate36
;
private
byte
periodRate37
;
private
byte
periodRate38
;
private
byte
periodRate39
;
private
byte
periodRate40
;
private
byte
periodRate41
;
private
byte
periodRate42
;
private
byte
periodRate43
;
private
byte
periodRate44
;
private
byte
periodRate45
;
private
byte
periodRate46
;
private
byte
periodRate47
;
private
byte
periodRate48
;
}
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/tcp/data/login/ModelValReqData.java
0 → 100644
View file @
8629cf8
package
cn
.
com
.
glsx
.
charging
.
modules
.
gbt
.
ocpp16
.
tcp
.
data
.
login
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.base.TcpData
;
import
com.fasterxml.jackson.databind.annotation.JsonSerialize
;
import
lombok.Getter
;
import
lombok.Setter
;
/**
* 计费模型验证请求
* 68(起始标志)0D(数据长度)0002(序列号域)00(加密标志)05(类型)32010200000001
* (桩编码)0001(计费模型编码)9C00(帧校验域)
*
* @author zhouhb
* @date 2023年11月06日
*/
@Getter
@Setter
public
class
ModelValReqData
extends
TcpData
{
/**
* 充电桩id: BCD 码 ,不足 7 位补 0
*/
private
byte
[]
pointId
=
new
byte
[
7
];
/**
* 计费模型编号:首次连接到平台时置零
*/
private
byte
modelCode
;
}
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/tcp/data/login/ModelValRspData.java
0 → 100644
View file @
8629cf8
package
cn
.
com
.
glsx
.
charging
.
modules
.
gbt
.
ocpp16
.
tcp
.
data
.
login
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.base.TcpData
;
import
lombok.Getter
;
import
lombok.Setter
;
/**
* 计费模型验证请求应答
* 68(起始标志)0E(数据长度)CE04(序列号域)00( 加密标志)06(帧类型标志)5503141278 23 05(桩编码)00 00(计费模型编号)00(验证结果)8E
* 2F(帧校验域)
*
* @author zhouhb
* @date 2023年11月06日
*/
@Getter
@Setter
public
class
ModelValRspData
extends
TcpData
{
/**
* 充电桩id: BCD 码 ,不足 7 位补 0
*/
private
byte
[]
pointId
=
new
byte
[
7
];
/**
* 计费模型编号
*/
private
byte
modelCode
;
/**
* 验证结果:0x00桩计费模型与平台一致 0x01桩计费模型与平台不一致
*/
private
byte
validationRes
;
}
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/tcp/handler/login/req/ModelChargingReqHandler.java
0 → 100644
View file @
8629cf8
package
cn
.
com
.
glsx
.
charging
.
modules
.
gbt
.
ocpp16
.
tcp
.
handler
.
login
.
req
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.base.TcpHandler
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data.login.ModelChargingRspData
;
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
com.alibaba.fastjson.JSONObject
;
import
io.netty.channel.Channel
;
import
lombok.extern.slf4j.Slf4j
;
@Slf4j
public
class
ModelChargingReqHandler
implements
TcpHandler
<
ModelChargingReq
,
ModelChargingRsp
>
{
@Override
public
ModelChargingRsp
handle
(
Channel
channel
,
ModelChargingReq
req
)
{
ModelChargingRsp
rsp
=
new
ModelChargingRsp
();
ModelChargingRspData
data
=
new
ModelChargingRspData
();
data
.
setPointId
(
req
.
getData
().
getPointId
());
data
.
setModelCode
((
byte
)
0100
);
log
.
info
(
"sendData{}"
,
JSONObject
.
toJSONString
(
data
));
rsp
.
setData
(
data
);
return
rsp
;
}
}
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/tcp/handler/login/req/ModelValReqHandler.java
0 → 100644
View file @
8629cf8
package
cn
.
com
.
glsx
.
charging
.
modules
.
gbt
.
ocpp16
.
tcp
.
handler
.
login
.
req
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.base.TcpHandler
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data.login.ModelValRspData
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.protocol.login.ModelValReq
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.protocol.login.ModelValRsp
;
import
com.alibaba.fastjson.JSONObject
;
import
io.netty.channel.Channel
;
import
lombok.extern.slf4j.Slf4j
;
@Slf4j
public
class
ModelValReqHandler
implements
TcpHandler
<
ModelValReq
,
ModelValRsp
>
{
@Override
public
ModelValRsp
handle
(
Channel
channel
,
ModelValReq
req
)
{
ModelValRsp
rsp
=
new
ModelValRsp
();
ModelValRspData
data
=
new
ModelValRspData
();
data
.
setPointId
(
req
.
getData
().
getPointId
());
data
.
setModelCode
(
req
.
getData
().
getModelCode
());
data
.
setValidationRes
((
byte
)
0x00
);
log
.
info
(
"sendData{}"
,
JSONObject
.
toJSONString
(
data
));
rsp
.
setData
(
data
);
return
rsp
;
}
}
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/tcp/protocol/login/ModelChargingReq.java
0 → 100644
View file @
8629cf8
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.ModelChargingReqData
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data.login.ModelValReqData
;
/**
* 计算模型验证
*
* @author zhouhb
* @date 2023年11月6日
*/
public
class
ModelChargingReq
extends
TcpReq
<
ModelChargingReqData
>
{
public
ModelChargingReq
()
{
super
(
TcpMapper
.
CMD_REQ_MODEL_CHARGING
.
getType
());
}
}
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/tcp/protocol/login/ModelChargingRsp.java
0 → 100644
View file @
8629cf8
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.TcpRsp
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data.login.ModelChargingRspData
;
/**
* 计算模型验证
*
* @author zhouhb
* @date 2023年11月6日
*/
public
class
ModelChargingRsp
extends
TcpRsp
<
ModelChargingRspData
>
{
public
ModelChargingRsp
()
{
super
(
TcpMapper
.
CMD_RSP_MODEL_CHARGING
.
getType
());
}
}
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/tcp/protocol/login/ModelValReq.java
0 → 100644
View file @
8629cf8
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.ModelValReqData
;
/**
* 计算模型验证
*
* @author zhouhb
* @date 2023年11月6日
*/
public
class
ModelValReq
extends
TcpReq
<
ModelValReqData
>
{
public
ModelValReq
()
{
super
(
TcpMapper
.
CMD_REQ_MODEL_VALIDATION
.
getType
());
}
}
platform-charging/src/main/java/cn/com/glsx/charging/modules/gbt/ocpp16/tcp/protocol/login/ModelValRsp.java
0 → 100644
View file @
8629cf8
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.TcpRsp
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data.login.HeartbeatRspData
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data.login.ModelValRspData
;
/**
* 计算模型验证应答
*
* @author zhouhb
* @date 2023年11月6日
*/
public
class
ModelValRsp
extends
TcpRsp
<
ModelValRspData
>
{
public
ModelValRsp
()
{
super
(
TcpMapper
.
CMD_RSP_MODEL_VALIDATION
.
getType
());
}
}
platform-charging/src/test/java/cn/com/glsx/charging/gbt/ocpp16/ModelChargingTest.java
0 → 100644
View file @
8629cf8
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.login.ModelChargingReqData
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data.login.ModelValReqData
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.protocol.login.ModelChargingReq
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.protocol.login.ModelValReq
;
/**
* 模拟充电桩端,连接云快充平台的测试服务器 实现登录,心跳,交互
*
* @author kome
* @date 2023年11月6日 上午9:49:10
*/
public
class
ModelChargingTest
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
Ocpp16Helper
.
scan
();
String
host
=
"localhost"
;
int
port
=
8888
;
TcpClient
client
=
ClientMain
.
getInstance
(
host
,
port
);
Thread
.
sleep
(
3000
);
ModelChargingReq
req
=
new
ModelChargingReq
();
ModelChargingReqData
modelChargingReqData
=
new
ModelChargingReqData
();
req
.
setData
(
new
ModelChargingReqData
());
req
.
getData
().
setPointId
(
Ocpp16Helper
.
strToBcd
(
"55031412782305"
,
req
.
getData
().
getPointId
()));
Ocpp16Helper
.
fillLen
(
req
);
req
.
setCrc
(
Ocpp16Helper
.
calculateCrc
(
req
));
client
.
sendSync
(
req
);
}
}
platform-charging/src/test/java/cn/com/glsx/charging/gbt/ocpp16/ModelValTest.java
0 → 100644
View file @
8629cf8
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.login.LoginReqData
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data.login.ModelValReqData
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.protocol.login.LoginReq
;
import
cn.com.glsx.charging.modules.gbt.ocpp16.tcp.protocol.login.ModelValReq
;
/**
* 模拟充电桩端,连接云快充平台的测试服务器 实现登录,心跳,交互
*
* @author kome
* @date 2023年11月6日 上午9:49:10
*/
public
class
ModelValTest
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
Ocpp16Helper
.
scan
();
String
host
=
"localhost"
;
int
port
=
8888
;
TcpClient
client
=
ClientMain
.
getInstance
(
host
,
port
);
Thread
.
sleep
(
3000
);
ModelValReq
req
=
new
ModelValReq
();
req
.
setData
(
new
ModelValReqData
());
req
.
getData
().
setPointId
(
Ocpp16Helper
.
strToBcd
(
"55031412782305"
,
req
.
getData
().
getPointId
()));
req
.
getData
().
setModelCode
((
byte
)
0001
);
Ocpp16Helper
.
fillLen
(
req
);
req
.
setCrc
(
Ocpp16Helper
.
calculateCrc
(
req
));
client
.
sendSync
(
req
);
}
}
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