Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
new-socketemulator
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
李远洪
new-socketemulator
Commits
2f22a080
Commit
2f22a080
authored
Apr 14, 2020
by
liyuanhong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
M500 事件协议图形界面完成80%
parent
836043b1
Changes
19
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
1098 additions
and
36 deletions
+1098
-36
README.md
README.md
+1
-1
config/messageTools/messageTools.conf
config/messageTools/messageTools.conf
+2
-2
lib/protocol/appendix/EventClass.py
lib/protocol/appendix/EventClass.py
+28
-4
lib/protocol/report/EventReport_protocol.py
lib/protocol/report/EventReport_protocol.py
+115
-14
lib/socket/protocolTest_M500.py
lib/socket/protocolTest_M500.py
+2
-2
run.py
run.py
+4
-0
static/js/messageTools/simulater.js
static/js/messageTools/simulater.js
+14
-0
static/js/protocolTools/protocols.js
static/js/protocolTools/protocols.js
+2
-0
templates/messageTools/index.html
templates/messageTools/index.html
+3
-5
templates/messageTools/message/M_simulaterSetting_page.html
templates/messageTools/message/M_simulaterSetting_page.html
+65
-0
templates/messageTools/message/M_simulater_page.html
templates/messageTools/message/M_simulater_page.html
+105
-0
templates/protocolTools/index.html
templates/protocolTools/index.html
+4
-4
templates/protocolTools/report/GPS_protocol_page.html
templates/protocolTools/report/GPS_protocol_page.html
+1
-0
templates/protocolTools/report/event_protocol_page.html
templates/protocolTools/report/event_protocol_page.html
+620
-0
templates/protocolTools/report/voltageData_protocol_page.html
...lates/protocolTools/report/voltageData_protocol_page.html
+1
-1
views/messageTools/M_simulater_process.py
views/messageTools/M_simulater_process.py
+44
-0
views/messageTools/M_simulater_view.py
views/messageTools/M_simulater_view.py
+34
-0
views/protocolTools/protocolReport_process.py
views/protocolTools/protocolReport_process.py
+37
-2
views/protocolTools/protocolReport_view.py
views/protocolTools/protocolReport_view.py
+16
-1
No files found.
README.md
View file @
2f22a080
...
...
@@ -14,7 +14,7 @@ requirements.txt:设置项目需要的依赖库
---
### (二)、安装部署
1、机器上安装了python3 和 pip包管理工具
2、使用 :pip install -r requirement.txt 安装依赖库
2、使用 :pip install -r requirement
s
.txt 安装依赖库
3、python3 run.py 运行项目
4、访问 host:5000 即可进入模拟器页面
...
...
config/messageTools/messageTools.conf
View file @
2f22a080
[
socket
]
host
=
10
.
100
.
11
.
20
port
=
90
01
host
=
v
.
vandyo
.
cn
port
=
90
18
lib/protocol/appendix/EventClass.py
View file @
2f22a080
...
...
@@ -10,9 +10,12 @@ class EventClass(ProtocolBase):
def
__init__
(
self
):
self
.
GPSPkg
=
"1401091213260265b86206ed8c70026103280000752f03030405af017102610bb800003200000186a0001ed2a25e16fe3a"
self
.
BaseStationPkg
=
"1401140a0c050207e407e607e807ea07ec4eea4eec4eee4ef04efc4efe4f004f024f040024025e07d00007a125000927c60000ea610100"
self
.
securityData
=
""
def
setGPSpkg
(
self
,
data
):
self
.
GPSPkg
=
data
def
setSecurityData
(
self
,
data
):
self
.
securityData
=
data
# 3 点火事件附带信息
def
fireExtraInfo
(
self
):
...
...
@@ -21,7 +24,11 @@ class EventClass(ProtocolBase):
allSharpTurn
=
self
.
int2hexStringByBytes
(
15
,
2
)
# 急转弯总次数
securityObj
=
SecurityStatusReport_protocol
()
securityObj
.
setGPSPkg
(
self
.
GPSPkg
)
securityData
=
securityObj
.
generateSecurityStatusData
()
# 安防数据
securityData
=
""
if
self
.
securityData
==
""
:
securityData
=
securityObj
.
generateSecurityStatusData
()
# 安防数据
else
:
securityData
=
self
.
securityData
data
=
allRapidlyAccelerateCount
+
allSharpSlowdownCount
+
allSharpTurn
+
securityData
return
data
...
...
@@ -32,18 +39,35 @@ class EventClass(ProtocolBase):
allSharpTurn
=
self
.
int2hexStringByBytes
(
35
,
2
)
#急转弯总次数
securityObj
=
SecurityStatusReport_protocol
()
securityObj
.
setGPSPkg
(
self
.
GPSPkg
)
securityData
=
securityObj
.
generateSecurityStatusData
()
#安防数据
securityData
=
""
if
self
.
securityData
==
""
:
securityData
=
securityObj
.
generateSecurityStatusData
()
# 安防数据
else
:
securityData
=
self
.
securityData
data
=
allRapidlyAccelerateCount
+
allSharpSlowdownCount
+
allSharpTurn
+
securityData
return
data
#5 设防事件附带信息
def
setUpDefencesExtraInfo
(
self
):
securityData
=
SecurityStatusReport_protocol
.
generateSecurityStatusData
()
# 安防数据
securityObj
=
SecurityStatusReport_protocol
()
securityObj
.
setGPSPkg
(
self
.
GPSPkg
)
securityData
=
""
if
self
.
securityData
==
""
:
securityData
=
securityObj
.
generateSecurityStatusData
()
# 安防数据
else
:
securityData
=
self
.
securityData
return
securityData
#6 撤防事件附带信息
def
setDownDefencesExtraInfo
(
self
):
securityData
=
SecurityStatusReport_protocol
.
generateSecurityStatusData
()
# 安防数据
securityObj
=
SecurityStatusReport_protocol
()
securityObj
.
setGPSPkg
(
self
.
GPSPkg
)
securityData
=
""
if
self
.
securityData
==
""
:
securityData
=
securityObj
.
generateSecurityStatusData
()
# 安防数据
else
:
securityData
=
self
.
securityData
return
securityData
return
securityData
#7 锁车未成功事件附带信息
...
...
lib/protocol/report/EventReport_protocol.py
View file @
2f22a080
This diff is collapsed.
Click to expand it.
lib/socket/protocolTest_M500.py
View file @
2f22a080
...
...
@@ -40,11 +40,11 @@ port = 9008
# msg = SecurityStatusReport_protocol().generateSecurityStatusMsg() #终端上报安防状态协议
# msg = BaseStationReport_protocol().generateBaseStationMsg() #终端上报基站定位协议
# msg = TroubleReport_protocol().generateTroubleMsg() #终端上报故障码数据包
#
msg = EventReport_protocol().generateEventMsg() #终端上报事件数据包
msg
=
EventReport_protocol
()
.
generateEventMsg
()
#终端上报事件数据包
# msg = VersionReport_protocol().generateVersionMsg() #终端上报版本信息数据包
# msg = SleepReport_protocol().generateSleepMsg() #终端休眠数据包
# msg = CommonReport_protocol().generateCommonMsg() #通用应答消息
msg
=
VoltageDataReport_protocol
()
.
generateMsg
()
#终端上报电瓶电压采样数据
#
msg = VoltageDataReport_protocol().generateMsg() #终端上报电瓶电压采样数据
print
(
msg
)
BUF_SIZE
=
1024
...
...
run.py
View file @
2f22a080
...
...
@@ -15,6 +15,8 @@ from views.messageTools.msgSetting_view import msgSetting_view
from
views.messageTools.msgSetting_process
import
msgSetting_process
from
views.messageTools.message_view
import
message_view
from
views.messageTools.message_process
import
message_process
from
views.messageTools.M_simulater_view
import
M_simulater_view
from
views.messageTools.M_simulater_process
import
M_simulater_process
app
=
Flask
(
__name__
)
app
.
register_blueprint
(
setting_view
,
url_prefix
=
"/protocolTools/setting_view"
)
...
...
@@ -32,6 +34,8 @@ app.register_blueprint(msgSetting_view,url_prefix = "/messageTools/msgSetting_vi
app
.
register_blueprint
(
msgSetting_process
,
url_prefix
=
"/messageTools/msgSetting_process"
)
app
.
register_blueprint
(
message_view
,
url_prefix
=
"/messageTools/message_view"
)
app
.
register_blueprint
(
message_process
,
url_prefix
=
"/messageTools/message_process"
)
app
.
register_blueprint
(
M_simulater_view
,
url_prefix
=
"/messageTools/M_simulater_view"
)
app
.
register_blueprint
(
M_simulater_process
,
url_prefix
=
"/messageTools/M_simulater_process"
)
@
app
.
route
(
'/'
)
def
hello
():
...
...
static/js/messageTools/simulater.js
0 → 100644
View file @
2f22a080
/**
*模拟器 页面顶部的Tab切换
*/
function
simulaterManTab
(
e
){
var
url
=
window
.
location
.
href
;
var
id
=
$
(
e
).
attr
(
"
id
"
);
if
(
id
==
"
car_simulater_tab
"
){
$
(
location
).
attr
(
'
href
'
,
"
http://
"
+
window
.
location
.
host
+
"
/messageTools/M_simulater_view/M_simulater_page
"
);
}
else
if
(
id
==
"
car_simulaterSetting_tab
"
){
$
(
location
).
attr
(
'
href
'
,
"
http://
"
+
window
.
location
.
host
+
"
/messageTools/M_simulater_view/M_simulaterSetting_page
"
);
}
else
{
alert
(
id
)
}
}
\ No newline at end of file
static/js/protocolTools/protocols.js
View file @
2f22a080
...
...
@@ -18,6 +18,8 @@ function protocolManTab(e){
$
(
location
).
attr
(
'
href
'
,
"
http://
"
+
window
.
location
.
host
+
"
/protocolTools/protocolReport_view/securityStatus_protocol_page
"
);
}
else
if
(
id
==
"
voltageData_protocol
"
){
$
(
location
).
attr
(
'
href
'
,
"
http://
"
+
window
.
location
.
host
+
"
/protocolTools/protocolReport_view/voltageData_protocol_page
"
);
}
else
if
(
id
==
"
event_protocol
"
){
$
(
location
).
attr
(
'
href
'
,
"
http://
"
+
window
.
location
.
host
+
"
/protocolTools/protocolReport_view/event_protocol_page
"
);
}
else
{
alert
(
id
)
}
...
...
templates/messageTools/index.html
View file @
2f22a080
...
...
@@ -23,10 +23,8 @@
$
(
location
).
attr
(
'
href
'
,
"
http://
"
+
window
.
location
.
host
+
"
/messageTools/msgSetting_view/msgSetting_page
"
);
}
else
if
(
id
==
"
msg_send
"
){
$
(
location
).
attr
(
'
href
'
,
"
http://
"
+
window
.
location
.
host
+
"
/messageTools/message_view/heartBeat_msg_page
"
);
}
else
if
(
id
==
"
test
"
){
$
(
location
).
attr
(
'
href
'
,
"
http://
"
+
window
.
location
.
host
+
"
/protocolTools/test_view/test_page
"
);
}
else
if
(
id
==
"
icon
"
){
$
(
location
).
attr
(
'
href
'
,
"
http://
"
+
window
.
location
.
host
+
"
/tab1/icon
"
);
}
else
if
(
id
==
"
car_simulater
"
){
$
(
location
).
attr
(
'
href
'
,
"
http://
"
+
window
.
location
.
host
+
"
/messageTools/M_simulater_view/M_simulater_page
"
);
}
}
</script>
...
...
@@ -38,7 +36,7 @@
<li
id=
"msg_send"
onclick=
"swichLeftTab(this)"
><a
{%
if
arg.path[1]=
="message_view"
%}
class=
"active_left_tab"
{%
endif
%}
><span
class=
"glyphicon glyphicon-list-alt"
aria-hidden=
"true"
></span>
终端消息发送
<span
class=
"sr-only"
></span></a></li>
</ul>
<ul
class=
"nav nav-sidebar"
style=
"margin-top:20px;"
>
<li
><a><span
class=
"glyphicon glyphicon-eye-open"
aria-hidden=
"true"
></span>
其他页面
</a></li>
<li
id=
"car_simulater"
onclick=
"swichLeftTab(this)"
><a
{%
if
arg.path[1]=
="M_simulater_view"
%}
class=
"active_left_tab"
{%
endif
%}
><span
class=
"glyphicon glyphicon-hand-right"
aria-hidden=
"true"
></span></span>
车机模拟器
</a></li>
</ul>
</div>
{% endblock %}
...
...
templates/messageTools/message/M_simulaterSetting_page.html
0 → 100644
View file @
2f22a080
{% extends "messageTools/message/M_simulater_page.html" %}
{% block title %}heartBeat_msg{% endblock %}
{% block content_1 %}
<div
id=
"container3"
style=
"width:100%;min-height:750px;float:left;_background:green;margin-top:10px;_border-top: 1px solid #eee;"
>
<H3
style=
"border-bottom: 1px solid #eee;"
>
设置操作界面
</H3>
</div>
<script>
//发送GPS数据
$
(
"
#sendMsgBtn
"
).
click
(
function
(){
var
msgID
=
$
(
"
#msgID
"
).
val
();
var
phoneNum
=
$
(
"
#phoneNum
"
).
val
();
var
msgWaterCode
=
$
(
"
#msgWaterCode
"
).
val
();
var
encryptionType
=
$
(
"
#encryptionType
"
).
val
();
var
subPkg
=
$
(
"
#subPkg
"
).
val
();
var
pkgCounts
=
""
if
(
subPkg
!=
"
8192
"
){
pkgCounts
=
"
0
"
}
else
{
pkgCounts
=
$
(
"
#pkgCounts
"
).
val
();
}
var
data
=
{};
data
[
"
msgID
"
]
=
msgID
;
data
[
"
phoneNum
"
]
=
phoneNum
;
data
[
"
msgWaterCode
"
]
=
msgWaterCode
;
data
[
"
encryptionType
"
]
=
encryptionType
;
data
[
"
subPkg
"
]
=
subPkg
;
data
[
"
pkgCounts
"
]
=
pkgCounts
;
var
host
=
window
.
location
.
host
;
$
(
"
#showFeedback
"
).
val
(
""
)
$
.
ajax
({
url
:
"
http://
"
+
host
+
"
/messageTools/message_process/porcessHeartBeatMsg
"
,
type
:
"
post
"
,
data
:
data
,
dataType
:
"
json
"
,
success
:
function
(
data
){
if
(
data
.
status
==
200
){
//window.location.reload()
var
theShow
=
"
原始数据:
"
+
data
.
original
+
"
\n
"
;
theShow
=
theShow
+
"
收到数据:
"
+
data
.
result
+
"
\n
"
;
theShow
=
theShow
+
"
收到数据16进制:
"
+
data
.
resultH
+
"
\n
"
;
theShow
=
theShow
+
"
解析数据:
"
+
JSON
.
stringify
(
data
.
parse
)
+
"
\n
"
;
$
(
"
#showFeedback
"
).
val
(
theShow
)
}
else
{
$
(
"
#showFeedback
"
).
val
(
data
.
message
)
alert
(
data
.
message
);
}
}
});
});
function
hasSubPkg
(){
value
=
$
(
"
#subPkg
"
).
val
()
if
(
value
==
"
8192
"
){
$
(
"
#subPkg_label
"
).
css
(
"
color
"
,
"
black
"
)
$
(
"
#pkgCounts
"
).
removeAttr
(
"
disabled
"
)
}
else
{
$
(
"
#subPkg_label
"
).
css
(
"
color
"
,
"
grey
"
)
$
(
"
#pkgCounts
"
).
attr
(
"
disabled
"
,
"
disabled
"
)
}
}
</script>
{% endblock %}
\ No newline at end of file
templates/messageTools/message/M_simulater_page.html
0 → 100644
View file @
2f22a080
{% extends "messageTools/index.html" %}
{% block title %}heartBeat_msg{% endblock %}
{% block content_01 %}
<script
src=
"../../static/js/messageTools/simulater.js"
></script>
<style>
.nav-pills
li
{
margin-bottom
:
5px
;
}
.form-control
{
display
:
inline
;
width
:
160px
;
}
.protocol_content
:after
{
clear
:
both
;
display
:
block
;
content
:
" "
;
}
.protocol_content
li
{
width
:
250px
;
_background
:
yellow
;
list-style
:
none
;
margin-top
:
5px
;
float
:
left
;
}
.protocol_content
label
{
width
:
90px
;
text-align
:
right
;
}
</style>
<div
id=
"container2"
style=
"width:83%;min-height:750px;float:left;_background:grey;margin-top:50px;"
>
{% block content_02 %}
<ul
class=
"nav nav-pills"
style=
"font-size:14px;"
>
<li
role=
"presentation"
><a
id=
"car_simulaterSetting_tab"
{%
if
arg.path[2]=
="M_simulaterSetting_page"
%}
class=
"link-tab"
{%
endif
%}
onclick=
"simulaterManTab(this)"
>
设置
</b></a></li>
<li
role=
"presentation"
><a
id=
"car_simulater_tab"
{%
if
arg.path[2]=
="M_simulater_page"
%}
class=
"link-tab"
{%
endif
%}
onclick=
"simulaterManTab(this)"
>
模拟器
</b></a></li>
</ul>
{% endblock %}
{% block content_1 %}
<div
id=
"container3"
style=
"width:100%;min-height:750px;float:left;_background:green;margin-top:10px;_border-top: 1px solid #eee;"
>
<H3
style=
"border-bottom: 1px solid #eee;"
>
模拟器操作界面
</H3>
</div>
<script>
//发送GPS数据
$
(
"
#sendMsgBtn
"
).
click
(
function
(){
var
msgID
=
$
(
"
#msgID
"
).
val
();
var
phoneNum
=
$
(
"
#phoneNum
"
).
val
();
var
msgWaterCode
=
$
(
"
#msgWaterCode
"
).
val
();
var
encryptionType
=
$
(
"
#encryptionType
"
).
val
();
var
subPkg
=
$
(
"
#subPkg
"
).
val
();
var
pkgCounts
=
""
if
(
subPkg
!=
"
8192
"
){
pkgCounts
=
"
0
"
}
else
{
pkgCounts
=
$
(
"
#pkgCounts
"
).
val
();
}
var
data
=
{};
data
[
"
msgID
"
]
=
msgID
;
data
[
"
phoneNum
"
]
=
phoneNum
;
data
[
"
msgWaterCode
"
]
=
msgWaterCode
;
data
[
"
encryptionType
"
]
=
encryptionType
;
data
[
"
subPkg
"
]
=
subPkg
;
data
[
"
pkgCounts
"
]
=
pkgCounts
;
var
host
=
window
.
location
.
host
;
$
(
"
#showFeedback
"
).
val
(
""
)
$
.
ajax
({
url
:
"
http://
"
+
host
+
"
/messageTools/message_process/porcessHeartBeatMsg
"
,
type
:
"
post
"
,
data
:
data
,
dataType
:
"
json
"
,
success
:
function
(
data
){
if
(
data
.
status
==
200
){
//window.location.reload()
var
theShow
=
"
原始数据:
"
+
data
.
original
+
"
\n
"
;
theShow
=
theShow
+
"
收到数据:
"
+
data
.
result
+
"
\n
"
;
theShow
=
theShow
+
"
收到数据16进制:
"
+
data
.
resultH
+
"
\n
"
;
theShow
=
theShow
+
"
解析数据:
"
+
JSON
.
stringify
(
data
.
parse
)
+
"
\n
"
;
$
(
"
#showFeedback
"
).
val
(
theShow
)
}
else
{
$
(
"
#showFeedback
"
).
val
(
data
.
message
)
alert
(
data
.
message
);
}
}
});
});
function
hasSubPkg
(){
value
=
$
(
"
#subPkg
"
).
val
()
if
(
value
==
"
8192
"
){
$
(
"
#subPkg_label
"
).
css
(
"
color
"
,
"
black
"
)
$
(
"
#pkgCounts
"
).
removeAttr
(
"
disabled
"
)
}
else
{
$
(
"
#subPkg_label
"
).
css
(
"
color
"
,
"
grey
"
)
$
(
"
#pkgCounts
"
).
attr
(
"
disabled
"
,
"
disabled
"
)
}
}
</script>
{% endblock %}
</div>
{% endblock %}
\ No newline at end of file
templates/protocolTools/index.html
View file @
2f22a080
...
...
@@ -43,10 +43,10 @@
<ul
class=
"nav nav-sidebar"
style=
"margin-top:20px;"
>
<li
id=
"car_simulater"
onclick=
"swichLeftTab(this)"
><a
{%
if
arg.path[1]=
="M_carSimulater_view"
%}
class=
"active_left_tab"
{%
endif
%}
><span
class=
"glyphicon glyphicon-hand-right"
aria-hidden=
"true"
></span>
车辆行为模拟
</a></li>
</ul>
<ul
class=
"nav nav-sidebar"
style=
"margin-top:20px;"
>
<li
id=
"test"
onclick=
"swichLeftTab(this)"
><a
{%
if
arg.path[1]=
="test_view"
%}
class=
"active_left_tab"
{%
endif
%}
><span
class=
"glyphicon glyphicon-text-size"
aria-hidden=
"true"
></span>
测试页面
</a></li
>
<li><a><span
class=
"glyphicon glyphicon-eye-open"
aria-hidden=
"true"
></span>
其他页面
</a></li
>
</ul
>
<!-- <ul class="nav nav-sidebar" style="margin-top:20px;">--
>
<!-- <li id="test" onclick="swichLeftTab(this)"><a {% if arg.path[1]=="test_view" %} class="active_left_tab" {% endif %}><span class="glyphicon glyphicon-text-size" aria-hidden="true"></span> 测试页面</a></li>--
>
<!-- <li><a><span class="glyphicon glyphicon-eye-open" aria-hidden="true"></span> 其他页面</a></li>--
>
<!-- </ul>--
>
</div>
{% endblock %}
...
...
templates/protocolTools/report/GPS_protocol_page.html
View file @
2f22a080
...
...
@@ -38,6 +38,7 @@
<li
role=
"presentation"
><a
id=
"OBD_CAN_protocol"
{%
if
arg.path[2]=
="OBD_CAN_protocol_page"
%}
class=
"link-tab"
{%
endif
%}
onclick=
"protocolManTab(this)"
>
OBD-CAN报文
</b></a></li>
<li
role=
"presentation"
><a
id=
"securityStatus_protocol"
{%
if
arg.path[2]=
="securityStatus_protocol_page"
%}
class=
"link-tab"
{%
endif
%}
onclick=
"protocolManTab(this)"
>
安防状态报文
</b></a></li>
<li
role=
"presentation"
><a
id=
"voltageData_protocol"
{%
if
arg.path[2]=
="voltageData_protocol_page"
%}
class=
"link-tab"
{%
endif
%}
onclick=
"protocolManTab(this)"
>
电瓶电压采样报文
</b></a></li>
<li
role=
"presentation"
><a
id=
"event_protocol"
{%
if
arg.path[2]=
="event_protocol_page"
%}
class=
"link-tab"
{%
endif
%}
onclick=
"protocolManTab(this)"
>
事件报文
</b></a></li>
</ul>
{% endblock %}
{% block content_1 %}
...
...
templates/protocolTools/report/event_protocol_page.html
0 → 100644
View file @
2f22a080
This diff is collapsed.
Click to expand it.
templates/protocolTools/report/voltageData_protocol_page.html
View file @
2f22a080
...
...
@@ -7,7 +7,7 @@
<label>
消息流水号:
</label><input
id=
"WATER_CODE"
type=
"text"
class=
"form-control"
value=
"0003"
style=
"width:100px;"
>
<label
style=
"margin-left:10px;"
>
车机号:
</label><input
id=
"DEV_ID"
type=
"text"
class=
"form-control"
value=
"M121501010001"
>
</div>
<H3
style=
"border-bottom: 1px solid #eee;"
>
设置
心跳
消息内容:
</H3>
<H3
style=
"border-bottom: 1px solid #eee;"
>
设置
电压上报
消息内容:
</H3>
<ul
class=
"protocol_content"
style=
"padding:0px;"
>
<li
style=
"width:170px"
><label>
采样个数:
</label><input
style=
"width:80px;"
id=
"sampleNums"
type=
"text"
class=
"form-control"
value=
"2"
></li>
<li><label
style=
"font-size:10px;"
>
采样开始时间:
</label><input
id=
"curTime"
type=
"text"
class=
"form-control"
value=
""
></li>
...
...
views/messageTools/M_simulater_process.py
0 → 100644
View file @
2f22a080
#coding:utf-8
import
os
from
time
import
sleep
from
flask
import
Blueprint
,
Response
,
request
,
send_from_directory
from
configparser
import
ConfigParser
import
json
import
traceback
M_simulater_process
=
Blueprint
(
'M_simulater_process'
,
__name__
)
connects
=
[]
#用来保存连接的信息
##########################################
# 【接口类型】设置socket信息
##########################################
@
M_simulater_process
.
route
(
"/porcessSocketSetting"
,
methods
=
[
'POST'
])
def
porcessSocketSetting
():
host
=
request
.
form
.
get
(
"host"
)
port
=
request
.
form
.
get
(
"port"
)
data
=
{}
if
(
host
==
None
or
port
==
None
):
data
[
"status"
]
=
"4003"
data
[
"message"
]
=
"Info: 请检查是否传入了空数据!"
return
Response
(
json
.
dumps
(
data
),
mimetype
=
'application/json'
)
else
:
try
:
# d读取config文件
conf_R
=
ConfigParser
()
conf_R
.
read
(
"config/protocolTools/carSimulater.conf"
)
conf_W
=
conf_R
conf_W
[
"socket"
][
"host"
]
=
host
conf_W
[
"socket"
][
"port"
]
=
port
with
open
(
"config/protocolTools/carSimulater.conf"
,
"w"
)
as
fi
:
conf_W
.
write
(
fi
)
data
[
"status"
]
=
"200"
data
[
"message"
]
=
"Sucess: "
except
BaseException
as
e
:
# 打印异常信息
traceback
.
print_exc
()
data
[
"status"
]
=
"4003"
data
[
"message"
]
=
"Error: 处理失败!"
return
Response
(
json
.
dumps
(
data
),
mimetype
=
'application/json'
)
\ No newline at end of file
views/messageTools/M_simulater_view.py
0 → 100644
View file @
2f22a080
#coding:utf-8
from
flask
import
Blueprint
,
render_template
,
request
import
re
M_simulater_view
=
Blueprint
(
'M_simulater_view'
,
__name__
)
##########################################
# 【视图类型】访问模拟器页面
##########################################
@
M_simulater_view
.
route
(
'/M_simulater_page'
)
def
M_simulater_page
():
#获取请求的路劲
url
=
request
.
url
reqPath
=
re
.
findall
(
"http://(.*)$"
,
url
)[
0
]
reqPath
=
re
.
findall
(
"/(.*)$"
,
reqPath
)[
0
]
arg
=
{}
path
=
"messageTools/message/M_simulater_page.html"
arg
[
"path"
]
=
reqPath
.
split
(
"/"
)
return
render_template
(
path
,
arg
=
arg
)
##########################################
# 【视图类型】访问模拟器设置页面
##########################################
@
M_simulater_view
.
route
(
'/M_simulaterSetting_page'
)
def
M_simulaterSetting_page
():
#获取请求的路劲
url
=
request
.
url
reqPath
=
re
.
findall
(
"http://(.*)$"
,
url
)[
0
]
reqPath
=
re
.
findall
(
"/(.*)$"
,
reqPath
)[
0
]
arg
=
{}
path
=
"messageTools/message/M_simulaterSetting_page.html"
arg
[
"path"
]
=
reqPath
.
split
(
"/"
)
return
render_template
(
path
,
arg
=
arg
)
\ No newline at end of file
views/protocolTools/protocolReport_process.py
View file @
2f22a080
...
...
@@ -3,6 +3,7 @@
from
flask
import
Blueprint
,
Response
,
request
from
configparser
import
ConfigParser
from
lib.protocol.report.EventReport_protocol
import
EventReport_protocol
from
lib.protocol.report.HeartBeatReport_protocol
import
HeartBeatReport_protocol
from
lib.protocol.report.LoginReport_protocol
import
LoginReport_protocol
from
lib.protocol.report.GPSReport_protocol
import
GPSReport_protocol
...
...
@@ -175,7 +176,6 @@ def porcessGPSMsg():
return
Response
(
json
.
dumps
(
data
),
mimetype
=
'application/json'
)
else
:
try
:
# cliSocket = ClientSocket("183.230.194.65",8712)
# d读取config文件
conf_R
=
ConfigParser
()
conf_R
.
read
(
"config/protocolTools/protocolTools.conf"
)
...
...
@@ -375,7 +375,42 @@ def porcessVoltageDataMsg():
data
[
"message"
]
=
"Error: 处理失败!"
return
Response
(
json
.
dumps
(
data
),
mimetype
=
'application/json'
)
##########################################
# 【接口类型】处理发送的事件报文
##########################################
@
protocolReport_process
.
route
(
"/porcessEventMsg"
,
methods
=
[
'POST'
])
def
porcessEventMsg
():
params
=
request
.
get_data
()
params
=
json
.
loads
(
params
.
decode
(
"utf-8"
))
data
=
{}
if
(
hasJsonDataIsNone
(
params
)):
data
[
"status"
]
=
"4003"
data
[
"message"
]
=
"Info: 请检查是否传入了空数据!"
return
Response
(
json
.
dumps
(
data
),
mimetype
=
'application/json'
)
else
:
try
:
conf_R
=
ConfigParser
()
conf_R
.
read
(
"config/protocolTools/protocolTools.conf"
)
cliSocket
=
ClientSocket
(
conf_R
.
get
(
"socket"
,
"host"
),
conf_R
.
getint
(
"socket"
,
"port"
))
cliSocket
.
connect
()
protocolObj
=
EventReport_protocol
(
data
=
params
)
msg
=
protocolObj
.
generateEventMsg
()
cliSocket
.
send
(
msg
)
socRecv
=
cliSocket
.
receive
()
socRecvo
=
str
(
socRecv
)
cliSocket
.
close
()
data
[
"status"
]
=
"200"
data
[
"message"
]
=
"Sucess: "
data
[
"msgSend"
]
=
msg
data
[
"result"
]
=
socRecvo
data
[
"rev"
]
=
str
(
binascii
.
b2a_hex
(
socRecv
))[
2
:][:
-
1
]
data
[
"orgRev"
]
=
data
[
"orgRev"
]
=
json
.
loads
(
Common_res
(
data
[
"rev"
])
.
getMsg
())
except
BaseException
as
e
:
# 打印异常信息
traceback
.
print_exc
()
data
[
"status"
]
=
"4003"
data
[
"message"
]
=
"Error: 处理失败!"
return
Response
(
json
.
dumps
(
data
),
mimetype
=
'application/json'
)
...
...
views/protocolTools/protocolReport_view.py
View file @
2f22a080
...
...
@@ -94,7 +94,7 @@ def securityStatus_protocol_page():
##########################################
# 【视图类型】访问终端上报
安防状态
协议报文发送页面
# 【视图类型】访问终端上报
电瓶电压
协议报文发送页面
##########################################
@
protocolReport_view
.
route
(
'/voltageData_protocol_page'
)
def
voltageData_protocol_page
():
...
...
@@ -106,3 +106,18 @@ def voltageData_protocol_page():
path
=
"protocolTools/report/voltageData_protocol_page.html"
arg
[
"path"
]
=
reqPath
.
split
(
"/"
)
return
render_template
(
path
,
arg
=
arg
)
##########################################
# 【视图类型】访问终端上报事件协议报文发送页面
##########################################
@
protocolReport_view
.
route
(
'/event_protocol_page'
)
def
event_protocol_page
():
#获取请求的路劲
url
=
request
.
url
reqPath
=
re
.
findall
(
"http://(.*)$"
,
url
)[
0
]
reqPath
=
re
.
findall
(
"/(.*)$"
,
reqPath
)[
0
]
arg
=
{}
path
=
"protocolTools/report/event_protocol_page.html"
arg
[
"path"
]
=
reqPath
.
split
(
"/"
)
return
render_template
(
path
,
arg
=
arg
)
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment