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
Show 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:设置项目需要的依赖库
...
@@ -14,7 +14,7 @@ requirements.txt:设置项目需要的依赖库
---
---
### (二)、安装部署
### (二)、安装部署
1、机器上安装了python3 和 pip包管理工具
1、机器上安装了python3 和 pip包管理工具
2、使用 :pip install -r requirement.txt 安装依赖库
2、使用 :pip install -r requirement
s
.txt 安装依赖库
3、python3 run.py 运行项目
3、python3 run.py 运行项目
4、访问 host:5000 即可进入模拟器页面
4、访问 host:5000 即可进入模拟器页面
...
...
config/messageTools/messageTools.conf
View file @
2f22a080
[
socket
]
[
socket
]
host
=
10
.
100
.
11
.
20
host
=
v
.
vandyo
.
cn
port
=
90
01
port
=
90
18
lib/protocol/appendix/EventClass.py
View file @
2f22a080
...
@@ -10,9 +10,12 @@ class EventClass(ProtocolBase):
...
@@ -10,9 +10,12 @@ class EventClass(ProtocolBase):
def
__init__
(
self
):
def
__init__
(
self
):
self
.
GPSPkg
=
"1401091213260265b86206ed8c70026103280000752f03030405af017102610bb800003200000186a0001ed2a25e16fe3a"
self
.
GPSPkg
=
"1401091213260265b86206ed8c70026103280000752f03030405af017102610bb800003200000186a0001ed2a25e16fe3a"
self
.
BaseStationPkg
=
"1401140a0c050207e407e607e807ea07ec4eea4eec4eee4ef04efc4efe4f004f024f040024025e07d00007a125000927c60000ea610100"
self
.
BaseStationPkg
=
"1401140a0c050207e407e607e807ea07ec4eea4eec4eee4ef04efc4efe4f004f024f040024025e07d00007a125000927c60000ea610100"
self
.
securityData
=
""
def
setGPSpkg
(
self
,
data
):
def
setGPSpkg
(
self
,
data
):
self
.
GPSPkg
=
data
self
.
GPSPkg
=
data
def
setSecurityData
(
self
,
data
):
self
.
securityData
=
data
# 3 点火事件附带信息
# 3 点火事件附带信息
def
fireExtraInfo
(
self
):
def
fireExtraInfo
(
self
):
...
@@ -21,7 +24,11 @@ class EventClass(ProtocolBase):
...
@@ -21,7 +24,11 @@ class EventClass(ProtocolBase):
allSharpTurn
=
self
.
int2hexStringByBytes
(
15
,
2
)
# 急转弯总次数
allSharpTurn
=
self
.
int2hexStringByBytes
(
15
,
2
)
# 急转弯总次数
securityObj
=
SecurityStatusReport_protocol
()
securityObj
=
SecurityStatusReport_protocol
()
securityObj
.
setGPSPkg
(
self
.
GPSPkg
)
securityObj
.
setGPSPkg
(
self
.
GPSPkg
)
securityData
=
""
if
self
.
securityData
==
""
:
securityData
=
securityObj
.
generateSecurityStatusData
()
# 安防数据
securityData
=
securityObj
.
generateSecurityStatusData
()
# 安防数据
else
:
securityData
=
self
.
securityData
data
=
allRapidlyAccelerateCount
+
allSharpSlowdownCount
+
allSharpTurn
+
securityData
data
=
allRapidlyAccelerateCount
+
allSharpSlowdownCount
+
allSharpTurn
+
securityData
return
data
return
data
...
@@ -32,18 +39,35 @@ class EventClass(ProtocolBase):
...
@@ -32,18 +39,35 @@ class EventClass(ProtocolBase):
allSharpTurn
=
self
.
int2hexStringByBytes
(
35
,
2
)
#急转弯总次数
allSharpTurn
=
self
.
int2hexStringByBytes
(
35
,
2
)
#急转弯总次数
securityObj
=
SecurityStatusReport_protocol
()
securityObj
=
SecurityStatusReport_protocol
()
securityObj
.
setGPSPkg
(
self
.
GPSPkg
)
securityObj
.
setGPSPkg
(
self
.
GPSPkg
)
securityData
=
securityObj
.
generateSecurityStatusData
()
#安防数据
securityData
=
""
if
self
.
securityData
==
""
:
securityData
=
securityObj
.
generateSecurityStatusData
()
# 安防数据
else
:
securityData
=
self
.
securityData
data
=
allRapidlyAccelerateCount
+
allSharpSlowdownCount
+
allSharpTurn
+
securityData
data
=
allRapidlyAccelerateCount
+
allSharpSlowdownCount
+
allSharpTurn
+
securityData
return
data
return
data
#5 设防事件附带信息
#5 设防事件附带信息
def
setUpDefencesExtraInfo
(
self
):
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
return
securityData
#6 撤防事件附带信息
#6 撤防事件附带信息
def
setDownDefencesExtraInfo
(
self
):
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
return
securityData
#7 锁车未成功事件附带信息
#7 锁车未成功事件附带信息
...
...
lib/protocol/report/EventReport_protocol.py
View file @
2f22a080
...
@@ -4,18 +4,22 @@ import time
...
@@ -4,18 +4,22 @@ import time
from
lib.protocol.report.GPSReport_protocol
import
GPSReport_protocol
from
lib.protocol.report.GPSReport_protocol
import
GPSReport_protocol
from
lib.protocol.report.ProtocolBase
import
ProtocolBase
from
lib.protocol.report.ProtocolBase
import
ProtocolBase
from
lib.protocol.appendix.EventClass
import
EventClass
from
lib.protocol.appendix.EventClass
import
EventClass
from
lib.protocol.report.SecurityStatusReport_protocol
import
SecurityStatusReport_protocol
'''
'''
终端上事件数据包
终端上事件数据包
'''
'''
class
EventReport_protocol
(
ProtocolBase
):
class
EventReport_protocol
(
ProtocolBase
):
#data = {"WATER_CODE":"0003","DEV_ID":"M121501010001","gpsInfo":{"UTCTime":"2020-04-14 11:03:20","latitude":"40.22077","longitude":"116.23128","speed":"80.8","directionAngle":"80.8","elevation":"2999.9","positionStar":"3","Pdop":"0.3","Hdop":"0.4","Vdop":"0.5","statusBit":162,"valtage":"36.9","OBDSpeed":"60.9","engineSpeed":"3000","GPSTotalMileage":"12800","totalOil":"100000","totalTime":"2020002","GPSTimestamp":"1586833400"},"securityData":{"securityStatus":107,"doorStatus":0,"lockStatus":0,"windowStatus":0,"lightStatus":0,"onoffStatusA":0,"onoffStatusB":112,"dataByte":249},"event":{}}
def
__init__
(
self
,
msgCount
=
1
,
WATER_CODE
=
26
,
DEV_ID
=
"M121501010001"
,
locationType
=
1
,
eventType
=
"0036"
):
data
=
{}
def
__init__
(
self
,
msgCount
=
1
,
WATER_CODE
=
26
,
DEV_ID
=
"M121501010001"
,
locationType
=
1
,
eventType
=
"0036"
,
data
=
{}):
super
()
.
__init__
()
super
()
.
__init__
()
self
.
data
=
data
if
len
(
data
)
==
0
:
self
.
msgCount
=
msgCount
#数据包个数
self
.
msgCount
=
msgCount
#数据包个数
self
.
WATER_CODE
=
int
(
WATER_CODE
);
#消息流水号
self
.
WATER_CODE
=
int
(
WATER_CODE
)
#消息流水号
self
.
DEV_ID
=
DEV_ID
#设备id
self
.
DEV_ID
=
DEV_ID
#设备id
self
.
locationType
=
int
(
locationType
)
# 定位类型
self
.
locationType
=
int
(
locationType
)
# 定位类型
...
@@ -23,6 +27,29 @@ class EventReport_protocol(ProtocolBase):
...
@@ -23,6 +27,29 @@ class EventReport_protocol(ProtocolBase):
self
.
GPSPkg
=
"1401091213260265b86206ed8c70026103280000752f03030405af017102610bb800003200000186a0001ed2a25e16fe3a"
self
.
GPSPkg
=
"1401091213260265b86206ed8c70026103280000752f03030405af017102610bb800003200000186a0001ed2a25e16fe3a"
self
.
BaseStationPkg
=
"1401140a0c050207e407e607e807ea07ec4eea4eec4eee4ef04efc4efe4f004f024f040024025e07d00007a125000927c60000ea610100"
self
.
BaseStationPkg
=
"1401140a0c050207e407e607e807ea07ec4eea4eec4eee4ef04efc4efe4f004f024f040024025e07d00007a125000927c60000ea610100"
self
.
eventType
=
eventType
#事件类别
self
.
eventType
=
eventType
#事件类别
else
:
self
.
msgCount
=
1
# 数据包个数
self
.
WATER_CODE
=
int
(
data
[
"WATER_CODE"
])
# 消息流水号
self
.
DEV_ID
=
data
[
"DEV_ID"
]
# 设备id
self
.
locationType
=
1
# 定位类型
gpsInfo
=
data
[
"gpsInfo"
]
self
.
gpsInfo
=
gpsInfo
securityData
=
data
[
"securityData"
]
self
.
securityData
=
securityData
event
=
data
[
"event"
]
self
.
event
=
event
self
.
GPSPkg
=
GPSReport_protocol
(
1
,
self
.
WATER_CODE
,
self
.
DEV_ID
,
gpsInfo
[
"UTCTime"
],
gpsInfo
[
"latitude"
],
gpsInfo
[
"longitude"
]
\
,
gpsInfo
[
"speed"
],
gpsInfo
[
"directionAngle"
],
gpsInfo
[
"elevation"
],
gpsInfo
[
"positionStar"
],
gpsInfo
[
"Pdop"
]
\
,
gpsInfo
[
"Hdop"
],
gpsInfo
[
"Vdop"
],
gpsInfo
[
"statusBit"
],
gpsInfo
[
"valtage"
],
gpsInfo
[
"OBDSpeed"
],
gpsInfo
[
"engineSpeed"
]
\
,
gpsInfo
[
"GPSTotalMileage"
],
gpsInfo
[
"totalOil"
],
gpsInfo
[
"totalTime"
],
gpsInfo
[
"GPSTimestamp"
])
.
generateGpsData
()
self
.
securityPkg
=
SecurityStatusReport_protocol
(
1
,
self
.
WATER_CODE
,
self
.
DEV_ID
,
1
,
self
.
GPSPkg
,
"ffffffffffffffffffff"
\
,
securityData
[
"securityStatus"
],
securityData
[
"doorStatus"
],
securityData
[
"lockStatus"
]
\
,
securityData
[
"windowStatus"
],
securityData
[
"lightStatus"
],
securityData
[
"onoffStatusA"
]
\
,
securityData
[
"onoffStatusB"
],
securityData
[
"dataByte"
])
.
generateSecurityStatusData
()
self
.
BaseStationPkg
=
"1401140a0c050207e407e607e807ea07ec4eea4eec4eee4ef04efc4efe4f004f024f040024025e07d00007a125000927c60000ea610100"
def
setLatitude
(
self
,
data
):
def
setLatitude
(
self
,
data
):
self
.
latitude
=
data
self
.
latitude
=
data
...
@@ -38,7 +65,6 @@ class EventReport_protocol(ProtocolBase):
...
@@ -38,7 +65,6 @@ class EventReport_protocol(ProtocolBase):
self
.
BaseStationPkg
=
data
self
.
BaseStationPkg
=
data
#####################################################
#####################################################
# 生成事件信息消息
# 生成事件信息消息
#####################################################
#####################################################
...
@@ -55,8 +81,11 @@ class EventReport_protocol(ProtocolBase):
...
@@ -55,8 +81,11 @@ class EventReport_protocol(ProtocolBase):
FUN_ID
=
"0021"
FUN_ID
=
"0021"
#数据段
#数据段
data
=
""
data
=
""
if
len
(
self
.
data
)
==
0
:
for
i
in
range
(
0
,
self
.
msgCount
):
for
i
in
range
(
0
,
self
.
msgCount
):
data
+=
self
.
generateEventPkg
(
self
.
msgCount
,
self
.
generateEventData
())
data
+=
self
.
generateEventPkg
(
self
.
msgCount
,
self
.
generateEventData
())
else
:
data
+=
self
.
generateEventData_GUI
()
# 消息长度
# 消息长度
LENGTH
=
self
.
getMsgLength
(
int
(
len
(
WATER_CODE
+
DEV_ID
+
FUN_ID
+
data
)
/
2
))
LENGTH
=
self
.
getMsgLength
(
int
(
len
(
WATER_CODE
+
DEV_ID
+
FUN_ID
+
data
)
/
2
))
...
@@ -95,9 +124,19 @@ class EventReport_protocol(ProtocolBase):
...
@@ -95,9 +124,19 @@ class EventReport_protocol(ProtocolBase):
eventType
=
self
.
eventType
eventType
=
self
.
eventType
extraInfo
=
self
.
getExtraData
(
eventType
)
#附带信息
extraInfo
=
self
.
getExtraData
(
eventType
)
#附带信息
extraInfoLen
=
self
.
int2hexStringByBytes
(
int
((
len
(
extraInfo
)
/
2
)),
2
)
#附带信息长度
extraInfoLen
=
self
.
int2hexStringByBytes
(
int
((
len
(
extraInfo
)
/
2
)),
2
)
#附带信息长度
data
=
locationType
+
locationData
+
eventType
+
extraInfoLen
+
extraInfo
data
=
locationType
+
locationData
+
eventType
+
extraInfoLen
+
extraInfo
return
data
return
data
def
generateEventData_GUI
(
self
):
data
=
""
locationType
=
self
.
int2hexString
(
self
.
locationType
)
#定位类型
locationData
=
""
#GPS包或基站包
if
self
.
locationType
==
1
:
locationData
=
self
.
GPSPkg
elif
self
.
locationType
==
2
:
locationData
=
self
.
BaseStationPkg
eventData
=
self
.
getExtraData_GUI
(
self
.
event
)
data
=
locationType
+
locationData
+
eventData
return
data
#####################################################
#####################################################
# 获取附带信息
# 获取附带信息
...
@@ -160,3 +199,65 @@ class EventReport_protocol(ProtocolBase):
...
@@ -160,3 +199,65 @@ class EventReport_protocol(ProtocolBase):
elif
eventType
==
"004A"
:
#剩余油量异常告警
elif
eventType
==
"004A"
:
#剩余油量异常告警
return
EventClass
()
.
surplusOilAlarm
()
return
EventClass
()
.
surplusOilAlarm
()
#####################################################
# 获取附带信息(针对图形界面)
#####################################################
def
getExtraData_GUI
(
self
,
eventData
):
data
=
""
dataNums
=
0
if
(
"0003"
in
eventData
.
keys
()):
#汽车电瓶低电压报警
dataNums
=
dataNums
+
1
theData
=
""
data
=
data
+
"0003"
+
self
.
int2hexStringByBytes
(
int
((
len
(
theData
)
/
2
)),
2
)
+
theData
if
(
"0004"
in
eventData
.
keys
()):
#终端主电断电报警
dataNums
=
dataNums
+
1
theData
=
""
data
=
data
+
"0004"
+
self
.
int2hexStringByBytes
(
int
((
len
(
theData
)
/
2
)),
2
)
+
theData
if
(
"0010"
in
eventData
.
keys
()):
#汽车点火上报
dataNums
=
dataNums
+
1
eventObj
=
EventClass
()
eventObj
.
setGPSpkg
(
self
.
GPSPkg
)
eventObj
.
setSecurityData
(
self
.
securityPkg
)
theData
=
eventObj
.
fireExtraInfo
()
data
=
data
+
"0010"
+
self
.
int2hexStringByBytes
(
int
((
len
(
theData
)
/
2
)),
2
)
+
theData
if
(
"0011"
in
eventData
.
keys
()):
#汽车熄火上报
dataNums
=
dataNums
+
1
eventObj
=
EventClass
()
eventObj
.
setGPSpkg
(
self
.
GPSPkg
)
eventObj
.
setSecurityData
(
self
.
securityPkg
)
theData
=
eventObj
.
fireExtraInfo
()
data
=
data
+
"0011"
+
self
.
int2hexStringByBytes
(
int
((
len
(
theData
)
/
2
)),
2
)
+
theData
if
(
"0012"
in
eventData
.
keys
()):
#汽车设防上报
dataNums
=
dataNums
+
1
eventObj
=
EventClass
()
eventObj
.
setGPSpkg
(
self
.
GPSPkg
)
eventObj
.
setSecurityData
(
self
.
securityPkg
)
theData
=
eventObj
.
setUpDefencesExtraInfo
()
data
=
data
+
"0012"
+
self
.
int2hexStringByBytes
(
int
((
len
(
theData
)
/
2
)),
2
)
+
theData
if
(
"0013"
in
eventData
.
keys
()):
#汽车撤防上报
dataNums
=
dataNums
+
1
eventObj
=
EventClass
()
eventObj
.
setGPSpkg
(
self
.
GPSPkg
)
eventObj
.
setSecurityData
(
self
.
securityPkg
)
theData
=
eventObj
.
setDownDefencesExtraInfo
()
data
=
data
+
"0013"
+
self
.
int2hexStringByBytes
(
int
((
len
(
theData
)
/
2
)),
2
)
+
theData
if
(
"0036"
in
eventData
.
keys
()):
#低档高速报警
dataNums
=
dataNums
+
1
eventObj
=
EventClass
()
theData
=
eventObj
.
lowGearHighSpeedAlarm
(
int
(
eventData
[
"0036"
][
"alarmType"
]),
int
(
eventData
[
"0036"
][
"durationTime"
]))
data
=
data
+
"0036"
+
self
.
int2hexStringByBytes
(
int
((
len
(
theData
)
/
2
)),
2
)
+
theData
if
(
"0037"
in
eventData
.
keys
()):
#高档低速报警
dataNums
=
dataNums
+
1
eventObj
=
EventClass
()
theData
=
eventObj
.
lowGearHighSpeedAlarm
(
int
(
eventData
[
"0036"
][
"alarmType"
]),
int
(
eventData
[
"0036"
][
"durationTime"
]))
data
=
data
+
"0037"
+
self
.
int2hexStringByBytes
(
int
((
len
(
theData
)
/
2
)),
2
)
+
theData
print
(
data
)
dataNumsHex
=
self
.
int2hexString
(
int
(
dataNums
))
data
=
dataNumsHex
+
data
return
data
if
__name__
==
"__main__"
:
data
=
{
"a"
:
1
,
"b"
:
2
,
"c"
:{
"d"
:
3
}}
data
=
{}
print
(
len
(
data
))
\ No newline at end of file
lib/socket/protocolTest_M500.py
View file @
2f22a080
...
@@ -40,11 +40,11 @@ port = 9008
...
@@ -40,11 +40,11 @@ port = 9008
# msg = SecurityStatusReport_protocol().generateSecurityStatusMsg() #终端上报安防状态协议
# msg = SecurityStatusReport_protocol().generateSecurityStatusMsg() #终端上报安防状态协议
# msg = BaseStationReport_protocol().generateBaseStationMsg() #终端上报基站定位协议
# msg = BaseStationReport_protocol().generateBaseStationMsg() #终端上报基站定位协议
# msg = TroubleReport_protocol().generateTroubleMsg() #终端上报故障码数据包
# msg = TroubleReport_protocol().generateTroubleMsg() #终端上报故障码数据包
#
msg = EventReport_protocol().generateEventMsg() #终端上报事件数据包
msg
=
EventReport_protocol
()
.
generateEventMsg
()
#终端上报事件数据包
# msg = VersionReport_protocol().generateVersionMsg() #终端上报版本信息数据包
# msg = VersionReport_protocol().generateVersionMsg() #终端上报版本信息数据包
# msg = SleepReport_protocol().generateSleepMsg() #终端休眠数据包
# msg = SleepReport_protocol().generateSleepMsg() #终端休眠数据包
# msg = CommonReport_protocol().generateCommonMsg() #通用应答消息
# msg = CommonReport_protocol().generateCommonMsg() #通用应答消息
msg
=
VoltageDataReport_protocol
()
.
generateMsg
()
#终端上报电瓶电压采样数据
#
msg = VoltageDataReport_protocol().generateMsg() #终端上报电瓶电压采样数据
print
(
msg
)
print
(
msg
)
BUF_SIZE
=
1024
BUF_SIZE
=
1024
...
...
run.py
View file @
2f22a080
...
@@ -15,6 +15,8 @@ from views.messageTools.msgSetting_view import msgSetting_view
...
@@ -15,6 +15,8 @@ from views.messageTools.msgSetting_view import msgSetting_view
from
views.messageTools.msgSetting_process
import
msgSetting_process
from
views.messageTools.msgSetting_process
import
msgSetting_process
from
views.messageTools.message_view
import
message_view
from
views.messageTools.message_view
import
message_view
from
views.messageTools.message_process
import
message_process
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
=
Flask
(
__name__
)
app
.
register_blueprint
(
setting_view
,
url_prefix
=
"/protocolTools/setting_view"
)
app
.
register_blueprint
(
setting_view
,
url_prefix
=
"/protocolTools/setting_view"
)
...
@@ -32,6 +34,8 @@ app.register_blueprint(msgSetting_view,url_prefix = "/messageTools/msgSetting_vi
...
@@ -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
(
msgSetting_process
,
url_prefix
=
"/messageTools/msgSetting_process"
)
app
.
register_blueprint
(
message_view
,
url_prefix
=
"/messageTools/message_view"
)
app
.
register_blueprint
(
message_view
,
url_prefix
=
"/messageTools/message_view"
)
app
.
register_blueprint
(
message_process
,
url_prefix
=
"/messageTools/message_process"
)
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
(
'/'
)
@
app
.
route
(
'/'
)
def
hello
():
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){
...
@@ -18,6 +18,8 @@ function protocolManTab(e){
$
(
location
).
attr
(
'
href
'
,
"
http://
"
+
window
.
location
.
host
+
"
/protocolTools/protocolReport_view/securityStatus_protocol_page
"
);
$
(
location
).
attr
(
'
href
'
,
"
http://
"
+
window
.
location
.
host
+
"
/protocolTools/protocolReport_view/securityStatus_protocol_page
"
);
}
else
if
(
id
==
"
voltageData_protocol
"
){
}
else
if
(
id
==
"
voltageData_protocol
"
){
$
(
location
).
attr
(
'
href
'
,
"
http://
"
+
window
.
location
.
host
+
"
/protocolTools/protocolReport_view/voltageData_protocol_page
"
);
$
(
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
{
}
else
{
alert
(
id
)
alert
(
id
)
}
}
...
...
templates/messageTools/index.html
View file @
2f22a080
...
@@ -23,10 +23,8 @@
...
@@ -23,10 +23,8 @@
$
(
location
).
attr
(
'
href
'
,
"
http://
"
+
window
.
location
.
host
+
"
/messageTools/msgSetting_view/msgSetting_page
"
);
$
(
location
).
attr
(
'
href
'
,
"
http://
"
+
window
.
location
.
host
+
"
/messageTools/msgSetting_view/msgSetting_page
"
);
}
else
if
(
id
==
"
msg_send
"
){
}
else
if
(
id
==
"
msg_send
"
){
$
(
location
).
attr
(
'
href
'
,
"
http://
"
+
window
.
location
.
host
+
"
/messageTools/message_view/heartBeat_msg_page
"
);
$
(
location
).
attr
(
'
href
'
,
"
http://
"
+
window
.
location
.
host
+
"
/messageTools/message_view/heartBeat_msg_page
"
);
}
else
if
(
id
==
"
test
"
){
}
else
if
(
id
==
"
car_simulater
"
){
$
(
location
).
attr
(
'
href
'
,
"
http://
"
+
window
.
location
.
host
+
"
/protocolTools/test_view/test_page
"
);
$
(
location
).
attr
(
'
href
'
,
"
http://
"
+
window
.
location
.
host
+
"
/messageTools/M_simulater_view/M_simulater_page
"
);
}
else
if
(
id
==
"
icon
"
){
$
(
location
).
attr
(
'
href
'
,
"
http://
"
+
window
.
location
.
host
+
"
/tab1/icon
"
);
}
}
}
}
</script>
</script>
...
@@ -38,7 +36,7 @@
...
@@ -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>
<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>
<ul
class=
"nav nav-sidebar"
style=
"margin-top:20px;"
>
<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>
</ul>
</div>
</div>
{% endblock %}
{% 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 @@
...
@@ -43,10 +43,10 @@
<ul
class=
"nav nav-sidebar"
style=
"margin-top:20px;"
>
<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>
<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>
<ul
class=
"nav nav-sidebar"
style=
"margin-top:20px;"
>
<!-- <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 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
>
<!-- <li><a><span class="glyphicon glyphicon-eye-open" aria-hidden="true"></span> 其他页面</a></li>--
>
</ul
>
<!-- </ul>--
>
</div>
</div>
{% endblock %}
{% endblock %}
...
...
templates/protocolTools/report/GPS_protocol_page.html
View file @
2f22a080
...
@@ -38,6 +38,7 @@
...
@@ -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=
"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=
"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=
"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>
</ul>
{% endblock %}
{% endblock %}
{% block content_1 %}
{% 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 @@
...
@@ -7,7 +7,7 @@
<label>
消息流水号:
</label><input
id=
"WATER_CODE"
type=
"text"
class=
"form-control"
value=
"0003"
style=
"width:100px;"
>
<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"
>
<label
style=
"margin-left:10px;"
>
车机号:
</label><input
id=
"DEV_ID"
type=
"text"
class=
"form-control"
value=
"M121501010001"
>
</div>
</div>
<H3
style=
"border-bottom: 1px solid #eee;"
>
设置
心跳
消息内容:
</H3>
<H3
style=
"border-bottom: 1px solid #eee;"
>
设置
电压上报
消息内容:
</H3>
<ul
class=
"protocol_content"
style=
"padding:0px;"
>
<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
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>
<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 @@
...
@@ -3,6 +3,7 @@
from
flask
import
Blueprint
,
Response
,
request
from
flask
import
Blueprint
,
Response
,
request
from
configparser
import
ConfigParser
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.HeartBeatReport_protocol
import
HeartBeatReport_protocol
from
lib.protocol.report.LoginReport_protocol
import
LoginReport_protocol
from
lib.protocol.report.LoginReport_protocol
import
LoginReport_protocol
from
lib.protocol.report.GPSReport_protocol
import
GPSReport_protocol
from
lib.protocol.report.GPSReport_protocol
import
GPSReport_protocol
...
@@ -175,7 +176,6 @@ def porcessGPSMsg():
...
@@ -175,7 +176,6 @@ def porcessGPSMsg():
return
Response
(
json
.
dumps
(
data
),
mimetype
=
'application/json'
)
return
Response
(
json
.
dumps
(
data
),
mimetype
=
'application/json'
)
else
:
else
:
try
:
try
:
# cliSocket = ClientSocket("183.230.194.65",8712)
# d读取config文件
# d读取config文件
conf_R
=
ConfigParser
()
conf_R
=
ConfigParser
()
conf_R
.
read
(
"config/protocolTools/protocolTools.conf"
)
conf_R
.
read
(
"config/protocolTools/protocolTools.conf"
)
...
@@ -375,7 +375,42 @@ def porcessVoltageDataMsg():
...
@@ -375,7 +375,42 @@ def porcessVoltageDataMsg():
data
[
"message"
]
=
"Error: 处理失败!"
data
[
"message"
]
=
"Error: 处理失败!"
return
Response
(
json
.
dumps
(
data
),
mimetype
=
'application/json'
)
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():
...
@@ -94,7 +94,7 @@ def securityStatus_protocol_page():
##########################################
##########################################
# 【视图类型】访问终端上报
安防状态
协议报文发送页面
# 【视图类型】访问终端上报
电瓶电压
协议报文发送页面
##########################################
##########################################
@
protocolReport_view
.
route
(
'/voltageData_protocol_page'
)
@
protocolReport_view
.
route
(
'/voltageData_protocol_page'
)
def
voltageData_protocol_page
():
def
voltageData_protocol_page
():
...
@@ -106,3 +106,18 @@ def voltageData_protocol_page():
...
@@ -106,3 +106,18 @@ def voltageData_protocol_page():
path
=
"protocolTools/report/voltageData_protocol_page.html"
path
=
"protocolTools/report/voltageData_protocol_page.html"
arg
[
"path"
]
=
reqPath
.
split
(
"/"
)
arg
[
"path"
]
=
reqPath
.
split
(
"/"
)
return
render_template
(
path
,
arg
=
arg
)
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