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
d698737c
Commit
d698737c
authored
Jun 05, 2020
by
liyuanhong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
M300模拟器完成3急事件开发
parent
bb1cc051
Changes
12
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
570 additions
and
137 deletions
+570
-137
data/m300Tools/carData/M202003060518.json
data/m300Tools/carData/M202003060518.json
+1
-1
lib/protocol/m300/TravelAct_protocol_m300.py
lib/protocol/m300/TravelAct_protocol_m300.py
+66
-0
lib/socket/protocolTest_M300.py
lib/socket/protocolTest_M300.py
+3
-1
lib/socket/service/M300SimulaterDataService.py
lib/socket/service/M300SimulaterDataService.py
+47
-0
lib/socket/service/M300SimulaterService.py
lib/socket/service/M300SimulaterService.py
+8
-1
static/js/m300Tools/m300.js
static/js/m300Tools/m300.js
+2
-0
templates/m300Tools/report/M_m300Simulater_page.html
templates/m300Tools/report/M_m300Simulater_page.html
+26
-134
templates/m300Tools/report/P_heartBeat_m300_page.html
templates/m300Tools/report/P_heartBeat_m300_page.html
+1
-0
templates/m300Tools/report/P_travelAct_m300_page.html
templates/m300Tools/report/P_travelAct_m300_page.html
+187
-0
views/m300Tools/M_m300Simulater_process.py
views/m300Tools/M_m300Simulater_process.py
+175
-0
views/m300Tools/P_m300Protocol_process.py
views/m300Tools/P_m300Protocol_process.py
+40
-0
views/m300Tools/P_m300Protocol_view.py
views/m300Tools/P_m300Protocol_view.py
+14
-0
No files found.
data/m300Tools/carData/M202003060518.json
View file @
d698737c
{
"time"
:
{
"dateTime"
:
"2020-06-04 16:47:12"
,
"date"
:
"2020-06-04"
,
"time"
:
"16:47:12"
},
"curDayTravel"
:
{
"todayTotalMilleage"
:
664
,
"todayTotalOil"
:
64
,
"todayTotalTime"
:
40
,
"theMilleage"
:
664
,
"theOil"
:
64
,
"theTime"
:
40
},
"travelData"
:
{
"totalMilleage"
:
830
,
"totalOil"
:
80
,
"totalTime"
:
50
}}
{
"time"
:
{
"dateTime"
:
"2020-06-05 11:21:47"
,
"date"
:
"2020-06-05"
,
"time"
:
"11:21:47"
},
"curDayTravel"
:
{
"todayTotalMilleage"
:
4095
,
"todayTotalOil"
:
330
,
"todayTotalTime"
:
251
,
"theMilleage"
:
1088
,
"theOil"
:
68
,
"theTime"
:
68
},
"travelData"
:
{
"totalMilleage"
:
4925
,
"totalOil"
:
410
,
"totalTime"
:
301
},
"event"
:
{
"threeRapid"
:
{
"totalRapidlyAccelerate"
:
5
,
"totalSharpSlowdown"
:
2
,
"totalSharpTurn"
:
0
}}}
\ No newline at end of file
\ No newline at end of file
lib/protocol/m300/TravelAct_protocol_m300.py
0 → 100644
View file @
d698737c
#encoding:utf-8
from
lib.protocol.m300.GPS_protocol_m300
import
GPS_protocol_m300
from
lib.protocol.m300.M300Base
import
M300Base
'''
定义驾驶行为协议类
'''
class
TravelAct_protocol_m300
(
M300Base
):
def
__init__
(
self
,
waterCode
=
3
,
DEV_ID
=
"M121501010001"
,
encryptionType
=
0
,
actType
=
1
,
accelerateTotalTimes
=
2
,
\
decelerateTotalTimes
=
2
,
sharpTurnTotalTimes
=
2
,
acceleration
=
500
,
speed
=
60
,
gps
=
{}):
super
()
.
__init__
()
# 不执行该方法,无法使用父类里面定义的属性
self
.
waterCode
=
waterCode
# 消息流水号
self
.
DEV_ID
=
DEV_ID
# 设备Id
self
.
encryptionType
=
encryptionType
# 消息属性里面的是否加密字段
if
len
(
gps
)
==
0
:
self
.
GPSPkg
=
"14031b0e22160265b86206ed8c7002029402290000006e00016802988100000000000000"
else
:
gpsObj
=
GPS_protocol_m300
(
3
,
"M121501010001"
,
0
,
gps
[
"dateInfo"
],
float
(
gps
[
"latitude"
]),
float
(
gps
[
"longitude"
]),
int
(
gps
[
"positionStar"
]),
float
(
gps
[
"speed"
]),
\
float
(
gps
[
"direction"
]),
float
(
gps
[
"altitude"
]),
int
(
gps
[
"ACCStatus"
]),
float
(
gps
[
"valtage"
]),
float
(
gps
[
"OBDSpeed"
]),
\
int
(
gps
[
"valid"
]),
int
(
gps
[
"tripMark"
]))
self
.
GPSPkg
=
gpsObj
.
getMsgBody
()
self
.
actType
=
actType
# 驾驶行为类别
self
.
accelerateTotalTimes
=
accelerateTotalTimes
# 急加速总次数
self
.
decelerateTotalTimes
=
decelerateTotalTimes
# 急减速总次数
self
.
sharpTurnTotalTimes
=
sharpTurnTotalTimes
# 急转弯总次数
self
.
acceleration
=
acceleration
# 事件发生时,加速度值
self
.
speed
=
speed
# 事件发生时,车速度
self
.
tripMark
=
"0000"
# 驾驶循环标签
#################################################
# 生成消息
#################################################
def
generateMsg
(
self
):
msg
=
self
.
IDENTIFY
FUNID
=
"0022"
#功能id
waterCode
=
self
.
int2hexStringByBytes
(
self
.
waterCode
,
2
)
#消息流水号
DEV_ID
=
self
.
devid2hexString
(
self
.
DEV_ID
)
#设备id
msgBody
=
self
.
getMsgBody
()
# 消息体
msgLen
=
int
(
len
(
msgBody
)
/
2
)
property
=
self
.
getMsgProperty
(
msgBodyLen
=
msgLen
,
encryptionType
=
self
.
encryptionType
)
checkCode
=
self
.
getCheckCode
(
FUNID
+
waterCode
+
DEV_ID
+
property
+
msgBody
)
msg
=
msg
+
FUNID
+
waterCode
+
DEV_ID
+
property
+
msgBody
+
checkCode
+
self
.
IDENTIFY
return
msg
#################################################
# 获取消息体
#################################################
def
getMsgBody
(
self
):
gps
=
self
.
GPSPkg
actType
=
self
.
int2hexStringByBytes
(
self
.
actType
)
accelerateTotalTimes
=
self
.
int2hexStringByBytes
(
self
.
accelerateTotalTimes
,
4
)
decelerateTotalTimes
=
self
.
int2hexStringByBytes
(
self
.
decelerateTotalTimes
,
4
)
sharpTurnTotalTimes
=
self
.
int2hexStringByBytes
(
self
.
sharpTurnTotalTimes
,
4
)
acceleration
=
self
.
int2hexStringByBytes
(
self
.
acceleration
,
2
)
speed
=
self
.
int2hexStringByBytes
(
self
.
speed
)
tripMark
=
self
.
tripMark
data
=
gps
+
actType
+
accelerateTotalTimes
+
decelerateTotalTimes
+
sharpTurnTotalTimes
data
=
data
+
acceleration
+
speed
+
tripMark
return
data
lib/socket/protocolTest_M300.py
View file @
d698737c
...
@@ -6,6 +6,7 @@ from lib.protocol.m300.Alarm_protocol_m300 import Alarm_protocol_m300
...
@@ -6,6 +6,7 @@ from lib.protocol.m300.Alarm_protocol_m300 import Alarm_protocol_m300
from
lib.protocol.m300.GPS_protocol_m300
import
GPS_protocol_m300
from
lib.protocol.m300.GPS_protocol_m300
import
GPS_protocol_m300
from
lib.protocol.m300.Heartbeat_protocol_300
import
Heartbeat_protocol_300
from
lib.protocol.m300.Heartbeat_protocol_300
import
Heartbeat_protocol_300
from
lib.protocol.m300.OBDCAN_protocol_m300
import
OBDCAN_protocol_m300
from
lib.protocol.m300.OBDCAN_protocol_m300
import
OBDCAN_protocol_m300
from
lib.protocol.m300.TravelAct_protocol_m300
import
TravelAct_protocol_m300
from
lib.protocol.m300.VersionInfo_protocol_m300
import
VersionInfo_protocol_m300
from
lib.protocol.m300.VersionInfo_protocol_m300
import
VersionInfo_protocol_m300
from
lib.protocol.report.GPSReport_protocol
import
GPSReport_protocol
from
lib.protocol.report.GPSReport_protocol
import
GPSReport_protocol
from
lib.protocol.report.OBDReport_CAN_protocol
import
OBDReport_CAN_protocol
from
lib.protocol.report.OBDReport_CAN_protocol
import
OBDReport_CAN_protocol
...
@@ -34,7 +35,8 @@ port = 9009
...
@@ -34,7 +35,8 @@ port = 9009
# msg = VersionInfo_protocol_m300().generateMsg() #终端版本报文
# msg = VersionInfo_protocol_m300().generateMsg() #终端版本报文
# msg = "7e000400e14d2019120315000000957e" #终端上报心跳协议
# msg = "7e000400e14d2019120315000000957e" #终端上报心跳协议
# msg = OBDCAN_protocol_m300().generateMsg() #OBD CAN报文
# msg = OBDCAN_protocol_m300().generateMsg() #OBD CAN报文
msg
=
Alarm_protocol_m300
()
.
generateMsg
()
#OBD CAN报文
# msg = Alarm_protocol_m300().generateMsg() #报警报文
msg
=
TravelAct_protocol_m300
()
.
generateMsg
()
#驾驶行为报文
print
(
msg
)
print
(
msg
)
...
...
lib/socket/service/M300SimulaterDataService.py
View file @
d698737c
...
@@ -43,6 +43,28 @@ class M300SimulaterDataService():
...
@@ -43,6 +43,28 @@ class M300SimulaterDataService():
data
[
"travelData"
][
"totalMilleage"
]
=
0
#行驶总里程
data
[
"travelData"
][
"totalMilleage"
]
=
0
#行驶总里程
data
[
"travelData"
][
"totalOil"
]
=
0
#行驶总油耗
data
[
"travelData"
][
"totalOil"
]
=
0
#行驶总油耗
data
[
"travelData"
][
"totalTime"
]
=
0
#行驶总时间
data
[
"travelData"
][
"totalTime"
]
=
0
#行驶总时间
data
[
"event"
]
=
{}
data
[
"event"
][
"threeRapid"
]
=
{}
#急加速,急减速,急转弯基本数据
data
[
"event"
][
"threeRapid"
][
"totalRapidlyAccelerate"
]
=
0
#急加速总次数
data
[
"event"
][
"threeRapid"
][
"totalSharpSlowdown"
]
=
0
#急减速总次数
data
[
"event"
][
"threeRapid"
][
"totalSharpTurn"
]
=
0
#急转弯总次数
return
data
####################################################
# 修复默认数据模板
# 用于在升级模拟器的时候,对增加的字段进行初始化
####################################################
def
fixDataTemplate
(
self
,
data
):
if
not
"event"
in
data
:
data
[
"event"
]
=
{}
data
[
"event"
][
"threeRapid"
]
=
{}
data
[
"event"
][
"threeRapid"
][
"totalRapidlyAccelerate"
]
=
0
# 急加速总次数
data
[
"event"
][
"threeRapid"
][
"totalSharpSlowdown"
]
=
0
# 急减速总次数
data
[
"event"
][
"threeRapid"
][
"totalSharpTurn"
]
=
0
# 急转弯总次数
if
not
"threeRapid"
in
data
[
"event"
]:
data
[
"event"
][
"threeRapid"
]
=
{}
data
[
"event"
][
"threeRapid"
][
"totalRapidlyAccelerate"
]
=
0
#急加速总次数
data
[
"event"
][
"threeRapid"
][
"totalSharpSlowdown"
]
=
0
#急减速总次数
data
[
"event"
][
"threeRapid"
][
"totalSharpTurn"
]
=
0
#急转弯总次数
return
data
return
data
#设今日行驶总里程,同时写入文件
#设今日行驶总里程,同时写入文件
...
@@ -84,6 +106,31 @@ class M300SimulaterDataService():
...
@@ -84,6 +106,31 @@ class M300SimulaterDataService():
self
.
data
[
"travelData"
][
"totalTime"
]
=
data
self
.
data
[
"travelData"
][
"totalTime"
]
=
data
self
.
writeToFile
(
self
.
path
+
self
.
fileName
,
self
.
data
)
self
.
writeToFile
(
self
.
path
+
self
.
fileName
,
self
.
data
)
#设置急加速总次数,同时写入文件
def
setTotalRapidlyAccelerateCount
(
self
,
data
):
if
not
"event"
in
data
:
data
[
"event"
]
=
{}
if
not
"threeRapid"
in
data
[
"event"
]:
data
[
"event"
][
"threeRapid"
]
=
{}
data
[
"event"
][
"threeRapid"
][
"totalRapidlyAccelerate"
]
=
data
self
.
writeToFile
(
self
.
path
+
self
.
fileName
,
self
.
data
)
# 设置急减速总次数,同时写入文件
def
setTotalSharpSlowdown
(
self
,
data
):
if
not
"event"
in
data
:
data
[
"event"
]
=
{}
if
not
"threeRapid"
in
data
[
"event"
]:
data
[
"event"
][
"threeRapid"
]
=
{}
data
[
"event"
][
"threeRapid"
][
"totalSharpSlowdown"
]
=
data
self
.
writeToFile
(
self
.
path
+
self
.
fileName
,
self
.
data
)
# 设置急转弯总次数,同时写入文件
def
setTotalSharpTurn
(
self
,
data
):
if
not
"event"
in
data
:
data
[
"event"
]
=
{}
if
not
"threeRapid"
in
data
[
"event"
]:
data
[
"event"
][
"threeRapid"
]
=
{}
data
[
"event"
][
"threeRapid"
][
"totalSharpTurn"
]
=
data
self
.
writeToFile
(
self
.
path
+
self
.
fileName
,
self
.
data
)
#设今日日期时间
#设今日日期时间
def
setDateTime2file
(
self
,
data
):
def
setDateTime2file
(
self
,
data
):
self
.
data
[
"time"
][
"dateTime"
]
=
data
self
.
data
[
"time"
][
"dateTime"
]
=
data
...
...
lib/socket/service/M300SimulaterService.py
View file @
d698737c
...
@@ -61,6 +61,10 @@ class M300SimulaterService():
...
@@ -61,6 +61,10 @@ class M300SimulaterService():
return
self
.
gpsLine
[
self
.
gpsLineIndex
][
"lat"
]
return
self
.
gpsLine
[
self
.
gpsLineIndex
][
"lat"
]
def
getCurLongtitude
(
self
):
def
getCurLongtitude
(
self
):
return
self
.
gpsLine
[
self
.
gpsLineIndex
][
"lng"
]
return
self
.
gpsLine
[
self
.
gpsLineIndex
][
"lng"
]
def
getCarData
(
self
):
return
self
.
carData
def
getSpeed
(
self
):
return
int
(
self
.
data
[
"travelData"
][
"carSpeed"
])
#设置套接字
#设置套接字
...
@@ -74,6 +78,8 @@ class M300SimulaterService():
...
@@ -74,6 +78,8 @@ class M300SimulaterService():
self
.
carId
=
data
self
.
carId
=
data
def
setData
(
self
,
data
):
def
setData
(
self
,
data
):
self
.
data
=
data
self
.
data
=
data
def
setCarData
(
self
,
data
):
self
.
carData
=
data
def
setWebsocketId
(
self
):
def
setWebsocketId
(
self
):
sleep
(
0.1
)
sleep
(
0.1
)
self
.
websocketId
=
self
.
websocket
.
getCurrentClientId
()
self
.
websocketId
=
self
.
websocket
.
getCurrentClientId
()
...
@@ -169,7 +175,8 @@ class M300SimulaterService():
...
@@ -169,7 +175,8 @@ class M300SimulaterService():
self
.
OBDdataOri
[
"totalOil"
]
=
conJson
[
"travelData"
][
"totalOil"
]
self
.
OBDdataOri
[
"totalOil"
]
=
conJson
[
"travelData"
][
"totalOil"
]
self
.
OBDdata
[
"carTotalRunTime"
]
=
conJson
[
"travelData"
][
"totalTime"
]
self
.
OBDdata
[
"carTotalRunTime"
]
=
conJson
[
"travelData"
][
"totalTime"
]
self
.
OBDdataOri
[
"carTotalRunTime"
]
=
conJson
[
"travelData"
][
"totalTime"
]
self
.
OBDdataOri
[
"carTotalRunTime"
]
=
conJson
[
"travelData"
][
"totalTime"
]
self
.
carData
=
conJson
self
.
carData
=
self
.
carDataObj
.
fixDataTemplate
(
conJson
)
# self.carData = conJson
############################# 发送点火数据 ############################
############################# 发送点火数据 ############################
fireOnParams
=
{
"FUNID"
:
"0021"
,
"waterCode"
:
"1"
,
"DEV_ID"
:
"M202004070000"
,
"encryptionType"
:
"0"
,
fireOnParams
=
{
"FUNID"
:
"0021"
,
"waterCode"
:
"1"
,
"DEV_ID"
:
"M202004070000"
,
"encryptionType"
:
"0"
,
...
...
static/js/m300Tools/m300.js
View file @
d698737c
...
@@ -20,6 +20,8 @@ function m300ProtocolManTab(e){
...
@@ -20,6 +20,8 @@ function m300ProtocolManTab(e){
$
(
location
).
attr
(
'
href
'
,
"
http://
"
+
window
.
location
.
host
+
"
/m300Tools/P_m300Protocol_view/P_CAN_m300_page
"
);
$
(
location
).
attr
(
'
href
'
,
"
http://
"
+
window
.
location
.
host
+
"
/m300Tools/P_m300Protocol_view/P_CAN_m300_page
"
);
}
else
if
(
id
==
"
P_alarm_m300_msg
"
){
}
else
if
(
id
==
"
P_alarm_m300_msg
"
){
$
(
location
).
attr
(
'
href
'
,
"
http://
"
+
window
.
location
.
host
+
"
/m300Tools/P_m300Protocol_view/P_alarm_m300_page
"
);
$
(
location
).
attr
(
'
href
'
,
"
http://
"
+
window
.
location
.
host
+
"
/m300Tools/P_m300Protocol_view/P_alarm_m300_page
"
);
}
else
if
(
id
==
"
P_travelAct_m300_msg
"
){
$
(
location
).
attr
(
'
href
'
,
"
http://
"
+
window
.
location
.
host
+
"
/m300Tools/P_m300Protocol_view/P_travelAct_m300_page
"
);
}
else
{
}
else
{
alert
(
id
)
alert
(
id
)
}
}
...
...
templates/m300Tools/report/M_m300Simulater_page.html
View file @
d698737c
This diff is collapsed.
Click to expand it.
templates/m300Tools/report/P_heartBeat_m300_page.html
View file @
d698737c
...
@@ -40,6 +40,7 @@
...
@@ -40,6 +40,7 @@
<li
role=
"presentation"
><a
id=
"P_GPS_m300_msg"
{%
if
arg.path[2]=
="P_GPS_m300_page"
%}
class=
"link-tab"
{%
endif
%}
onclick=
"m300ProtocolManTab(this)"
>
GPS消息
</b></a></li>
<li
role=
"presentation"
><a
id=
"P_GPS_m300_msg"
{%
if
arg.path[2]=
="P_GPS_m300_page"
%}
class=
"link-tab"
{%
endif
%}
onclick=
"m300ProtocolManTab(this)"
>
GPS消息
</b></a></li>
<li
role=
"presentation"
><a
id=
"P_CAN_m300_msg"
{%
if
arg.path[2]=
="P_CAN_m300_page"
%}
class=
"link-tab"
{%
endif
%}
onclick=
"m300ProtocolManTab(this)"
>
CAN消息
</b></a></li>
<li
role=
"presentation"
><a
id=
"P_CAN_m300_msg"
{%
if
arg.path[2]=
="P_CAN_m300_page"
%}
class=
"link-tab"
{%
endif
%}
onclick=
"m300ProtocolManTab(this)"
>
CAN消息
</b></a></li>
<li
role=
"presentation"
><a
id=
"P_alarm_m300_msg"
{%
if
arg.path[2]=
="P_alarm_m300_page"
%}
class=
"link-tab"
{%
endif
%}
onclick=
"m300ProtocolManTab(this)"
>
报警消息
</b></a></li>
<li
role=
"presentation"
><a
id=
"P_alarm_m300_msg"
{%
if
arg.path[2]=
="P_alarm_m300_page"
%}
class=
"link-tab"
{%
endif
%}
onclick=
"m300ProtocolManTab(this)"
>
报警消息
</b></a></li>
<li
role=
"presentation"
><a
id=
"P_travelAct_m300_msg"
{%
if
arg.path[2]=
="P_travelAct_m300_page"
%}
class=
"link-tab"
{%
endif
%}
onclick=
"m300ProtocolManTab(this)"
>
驾驶行为消息
</b></a></li>
</ul>
</ul>
{% endblock %}
{% endblock %}
{% block content_1 %}
{% block content_1 %}
...
...
templates/m300Tools/report/P_travelAct_m300_page.html
0 → 100644
View file @
d698737c
{% extends "m300Tools/report/P_heartBeat_m300_page.html" %}
{% block title %}travelAct_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;"
>
<div
style=
"width:100%;_background:green;padding:5px;padding-top:0px;"
>
<h3
style=
"border-bottom: 1px solid #eee;"
>
设置消息头:
</h3>
<label>
功能ID:
</label><input
id=
"FUNID"
type=
"text"
class=
"form-control"
disabled=
"disabled"
value=
"0007"
style=
"width:80px;"
>
<label>
消息序列号:
</label><input
id=
"waterCode"
type=
"text"
class=
"form-control"
value=
"1"
style=
"width:60px;"
>
<label>
设备ID:
</label><input
id=
"DEV_ID"
type=
"text"
class=
"form-control"
value=
"M202004070000"
style=
"width:150px;"
>
<label>
是否加密:
</label><select
style=
"width:100px;"
id=
"encryptionType"
class=
"form-control"
>
<option
value=
"0"
>
不加密
</option>
<option
value=
"1024"
>
加密
</option>
</select>
</div>
<H3
style=
"border-bottom: 1px solid #eee;"
>
设置驾驶行为消息内容:
</H3>
<div
style=
"width:100%;border-width:1px;border-style:solid;border-color:darkgray;border-radius:10px;padding:2px;"
>
<h5>
GPS报警信息
<span
style=
"margin-left:10px;border-width:1px;border-style:solid;border-color:darkgray;border-radius:10px;padding:1px 10px;"
>
<label><input
name=
"gps_radio"
type=
"radio"
value=
"0"
checked=
"checked"
onclick=
"isShowGPS_area(this)"
/>
隐藏
</label>
<label
style=
"margin-left:10px;"
><input
name=
"gps_radio"
type=
"radio"
value=
"1"
onclick=
"isShowGPS_area(this)"
/>
显示
</label>
</span></h5>
<ul
class=
"protocol_content"
style=
"padding:0px;display:none;"
id=
"GPS_area"
>
<li><label>
日期:
</label><input
id=
"dateInfo"
type=
"text"
class=
"form-control"
value=
""
></li>
<li
style=
"width:495px;"
><label>
维度:
</label><span>
<input
id=
"latitude"
type=
"text"
class=
"form-control"
value=
"40.22077"
>
<select
style=
"width:80px;"
id=
"latitudeType"
class=
"form-control"
>
<option
value=
"0"
>
北纬
</option>
<option
value=
"1"
>
南纬
</option></select>
</span></li>
<li
style=
"width:495px;"
><label>
经度:
</label><span>
<input
id=
"longitude"
type=
"text"
class=
"form-control"
value=
"116.23128"
>
<select
style=
"width:80px;"
id=
"longitudeType"
class=
"form-control"
>
<option
value=
"0"
>
东经
</option>
<option
value=
"1"
>
西经
</option></select>
</span></li>
<li><label>
定位星数:
</label><input
id=
"positionStar"
type=
"text"
class=
"form-control"
value=
"2"
></li>
<li><label>
速度:
</label><input
id=
"speed"
type=
"text"
class=
"form-control"
value=
"66.0"
></li>
<li><label>
方向角:
</label><input
id=
"direction"
type=
"text"
class=
"form-control"
value=
"55.3"
></li>
<li><label>
海拔高度:
</label><input
id=
"altitude"
type=
"text"
class=
"form-control"
value=
"11.0"
></li>
<li><label>
ACC状态:
</label><select
style=
"width:155px;"
id=
"ACCStatus"
class=
"form-control"
>
<option
value=
"0"
>
关
</option>
<option
value=
"1"
selected=
"selected"
>
开
</option></select></li>
<li><label
style=
"word-break:break-all;font-size:10px;"
>
汽车电瓶电压:
</label><input
id=
"valtage"
type=
"text"
class=
"form-control"
value=
"36.0"
></li>
<li><label
style=
"word-break:break-all;font-size:10px;"
>
汽车OBD速度:
</label><input
id=
"OBDSpeed"
type=
"text"
class=
"form-control"
value=
"66.4"
></li>
<li><label
style=
"word-break:break-all;font-size:10px;"
>
GPS定位是否有效:
</label><select
style=
"width:155px;"
id=
"valid_1"
class=
"form-control"
>
<option
value=
"0"
>
否
</option>
<option
value=
"1"
selected=
"selected"
>
是
</option></select></li>
<li><label
style=
"word-break:break-all;font-size:10px;"
>
车机是否处于修车模式:
</label><select
style=
"width:155px;"
id=
"valid_2"
class=
"form-control"
>
<option
value=
"0"
>
否
</option>
<option
value=
"128"
>
是
</option></select></li>
<li><label
style=
"word-break:break-all;font-size:10px;"
>
驾驶循环标签:
</label><input
id=
"tripMark"
type=
"text"
class=
"form-control"
value=
"0"
></li>
</ul>
</div>
<ul
class=
"protocol_content"
style=
"padding:0px;"
>
<li><label
style=
"word-break:break-all;font-size:10px;"
>
驾驶行为类别:
</label><select
id=
"actType"
class=
"form-control"
>
<option
value=
"1"
>
急加速
</option>
<option
value=
"2"
>
急减速
</option>
<option
value=
"3"
>
急转弯
</option></select>
</li>
<li><label
style=
"word-break:break-all;font-size:10px;"
>
急加速总次数:
</label><input
id=
"accelerateTotalTimes"
type=
"text"
class=
"form-control"
value=
"2"
></li>
<li><label
style=
"word-break:break-all;font-size:10px;"
>
急减速总次数:
</label><input
id=
"decelerateTotalTimes"
type=
"text"
class=
"form-control"
value=
"2"
></li>
<li><label
style=
"word-break:break-all;font-size:10px;"
>
急转弯总次数:
</label><input
id=
"sharpTurnTotalTimes"
type=
"text"
class=
"form-control"
value=
"2"
></li>
<li><label
style=
"word-break:break-all;font-size:10px;"
>
事件发生时加速度值(mg):
</label><input
id=
"acceleration"
type=
"text"
class=
"form-control"
value=
"500"
></li>
<li><label
style=
"word-break:break-all;font-size:10px;"
>
事件发生时车辆速度:
</label><input
id=
"TC_speed"
type=
"text"
class=
"form-control"
value=
"60"
></li>
</ul>
<H3
style=
"border-bottom: 1px solid #eee;"
>
控制:
</H3>
<div
style=
"width:100%;padding:5px;margin-top:10px;"
>
<button
type=
"button"
class=
"btn btn-primary"
id=
"sendMsgBtn"
>
发送消息
</button>
</div>
<H3
style=
"border-bottom: 1px solid #eee;"
>
返回信息:
</H3>
<div
style=
"width:100%;padding:5px;margin-top:10px;"
>
<textarea
id=
"showFeedback"
style=
"width:100%;padding:5px;"
rows=
"8"
></textarea>
</div>
</div>
<script>
//发送GPS数据
$
(
"
#sendMsgBtn
"
).
click
(
function
(){
var
FUNID
=
$
(
"
#FUNID
"
).
val
();
var
waterCode
=
$
(
"
#waterCode
"
).
val
();
var
DEV_ID
=
$
(
"
#DEV_ID
"
).
val
();
var
encryptionType
=
$
(
"
#encryptionType
"
).
val
();
var
gps
=
getGpsData
()
var
actType
=
$
(
"
#actType
"
).
val
();
var
accelerateTotalTimes
=
$
(
"
#accelerateTotalTimes
"
).
val
();
var
decelerateTotalTimes
=
$
(
"
#decelerateTotalTimes
"
).
val
();
var
sharpTurnTotalTimes
=
$
(
"
#sharpTurnTotalTimes
"
).
val
();
var
acceleration
=
$
(
"
#acceleration
"
).
val
();
var
speed
=
$
(
"
#TC_speed
"
).
val
();
var
data
=
{};
data
[
"
FUNID
"
]
=
FUNID
;
data
[
"
waterCode
"
]
=
waterCode
;
data
[
"
DEV_ID
"
]
=
DEV_ID
;
data
[
"
encryptionType
"
]
=
encryptionType
;
data
[
"
gps
"
]
=
gps
;
data
[
"
actType
"
]
=
actType
;
data
[
"
accelerateTotalTimes
"
]
=
accelerateTotalTimes
;
data
[
"
decelerateTotalTimes
"
]
=
decelerateTotalTimes
;
data
[
"
sharpTurnTotalTimes
"
]
=
sharpTurnTotalTimes
;
data
[
"
acceleration
"
]
=
acceleration
;
data
[
"
speed
"
]
=
speed
;
//console.log(JSON.stringify(data))
var
host
=
window
.
location
.
host
;
$
(
"
#showFeedback
"
).
val
(
""
)
$
.
ajax
({
url
:
"
http://
"
+
host
+
"
/m300Tools/P_m300Protocol_process/porcessTravelActMsg
"
,
type
:
"
post
"
,
data
:
JSON
.
stringify
(
data
),
contentType
:
"
application/json
"
,
dataType
:
"
json
"
,
success
:
function
(
data
){
if
(
data
.
status
==
200
){
//window.location.reload()
var
theShow
=
"
原始数据:
"
+
data
.
msgSend
+
"
\n
"
;
theShow
=
theShow
+
"
收到数据:
"
+
data
.
result
+
"
\n
"
;
theShow
=
theShow
+
"
收到数据16进制:
"
+
data
.
rev
+
"
\n
"
;
theShow
=
theShow
+
"
解析数据:
"
+
JSON
.
stringify
(
data
.
orgRev
)
+
"
\n
"
;
$
(
"
#showFeedback
"
).
val
(
theShow
)
}
else
{
$
(
"
#showFeedback
"
).
val
(
data
.
message
)
alert
(
data
.
message
);
}
}
});
});
//获取GPS数据
function
getGpsData
(){
var
dateInfo
=
$
(
"
#dateInfo
"
).
val
();
var
latitude
=
parseFloat
(
$
(
"
#latitude
"
).
val
());
var
latitudeType
=
parseInt
(
$
(
"
#latitudeType
"
).
val
());
if
(
latitudeType
==
1
){
latitude
=
latitude
+
2147483648
/
1000000
}
var
longitude
=
parseFloat
(
$
(
"
#longitude
"
).
val
());
var
longitudeType
=
parseInt
(
$
(
"
#longitudeType
"
).
val
());
if
(
longitudeType
==
1
){
longitude
=
longitude
+
2147483648
/
1000000
}
var
positionStar
=
$
(
"
#positionStar
"
).
val
();
var
speed
=
$
(
"
#speed
"
).
val
();
var
direction
=
$
(
"
#direction
"
).
val
();
var
altitude
=
$
(
"
#altitude
"
).
val
();
var
ACCStatus
=
$
(
"
#ACCStatus
"
).
val
();
var
valtage
=
$
(
"
#valtage
"
).
val
();
var
OBDSpeed
=
$
(
"
#OBDSpeed
"
).
val
();
var
valid_1
=
parseInt
(
$
(
"
#valid_1
"
).
val
());
var
valid_2
=
parseInt
(
$
(
"
#valid_2
"
).
val
());
var
valid
=
valid_1
+
valid_2
var
tripMark
=
$
(
"
#tripMark
"
).
val
();
var
data
=
{};
data
[
"
dateInfo
"
]
=
dateInfo
;
data
[
"
latitude
"
]
=
latitude
;
data
[
"
longitude
"
]
=
longitude
;
data
[
"
positionStar
"
]
=
positionStar
;
data
[
"
speed
"
]
=
speed
;
data
[
"
direction
"
]
=
direction
;
data
[
"
altitude
"
]
=
altitude
;
data
[
"
ACCStatus
"
]
=
ACCStatus
;
data
[
"
valtage
"
]
=
valtage
;
data
[
"
OBDSpeed
"
]
=
OBDSpeed
;
data
[
"
valid
"
]
=
valid
;
data
[
"
tripMark
"
]
=
tripMark
;
return
data
}
//gps区域的显示与隐藏
function
isShowGPS_area
(
e
){
var
val
=
$
(
e
).
val
()
if
(
val
==
"
0
"
){
$
(
"
#GPS_area
"
).
css
(
"
display
"
,
"
none
"
)
}
else
{
$
(
"
#GPS_area
"
).
css
(
"
display
"
,
"
block
"
)
}
}
//设置当前时间到UTC时间输入框
(
function
(){
var
curTime
=
getCurTime
();
$
(
"
#dateInfo
"
).
val
(
curTime
);
})();
</script>
{% endblock %}
\ No newline at end of file
views/m300Tools/M_m300Simulater_process.py
View file @
d698737c
This diff is collapsed.
Click to expand it.
views/m300Tools/P_m300Protocol_process.py
View file @
d698737c
...
@@ -8,6 +8,7 @@ from lib.protocol.m300.GPS_protocol_m300 import GPS_protocol_m300
...
@@ -8,6 +8,7 @@ from lib.protocol.m300.GPS_protocol_m300 import GPS_protocol_m300
from
lib.protocol.m300.Heartbeat_protocol_300
import
Heartbeat_protocol_300
from
lib.protocol.m300.Heartbeat_protocol_300
import
Heartbeat_protocol_300
from
lib.protocol.m300.Login_protocol_m300
import
Login_protocol_m300
from
lib.protocol.m300.Login_protocol_m300
import
Login_protocol_m300
from
lib.protocol.m300.OBDCAN_protocol_m300
import
OBDCAN_protocol_m300
from
lib.protocol.m300.OBDCAN_protocol_m300
import
OBDCAN_protocol_m300
from
lib.protocol.m300.TravelAct_protocol_m300
import
TravelAct_protocol_m300
from
lib.protocol.m300.VersionInfo_protocol_m300
import
VersionInfo_protocol_m300
from
lib.protocol.m300.VersionInfo_protocol_m300
import
VersionInfo_protocol_m300
from
lib.protocol.m300Plateform.M300Common_res
import
M300Common_res
from
lib.protocol.m300Plateform.M300Common_res
import
M300Common_res
from
lib.protocol.m300Plateform.M300Login_res
import
M300Login_res
from
lib.protocol.m300Plateform.M300Login_res
import
M300Login_res
...
@@ -406,3 +407,42 @@ def porcessAlarmMsg():
...
@@ -406,3 +407,42 @@ def porcessAlarmMsg():
data
[
"status"
]
=
"4003"
data
[
"status"
]
=
"4003"
data
[
"message"
]
=
"Error: 处理失败!"
data
[
"message"
]
=
"Error: 处理失败!"
return
Response
(
json
.
dumps
(
data
),
mimetype
=
'application/json'
)
return
Response
(
json
.
dumps
(
data
),
mimetype
=
'application/json'
)
##########################################
# 【接口类型】处理发送的驾驶行为报文
##########################################
@
P_m300Protocol_process
.
route
(
"/porcessTravelActMsg"
,
methods
=
[
'POST'
])
def
porcessTravelActMsg
():
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/m300Tools/m300Tools.conf"
)
cliSocket
=
ClientSocket
(
conf_R
.
get
(
"socket"
,
"host"
),
conf_R
.
getint
(
"socket"
,
"port"
))
cliSocket
.
connect
()
protocolObj
=
TravelAct_protocol_m300
(
waterCode
=
int
(
params
[
"waterCode"
]),
DEV_ID
=
params
[
"DEV_ID"
],
encryptionType
=
int
(
params
[
"encryptionType"
]),
\
actType
=
int
(
params
[
"actType"
]),
accelerateTotalTimes
=
int
(
params
[
"accelerateTotalTimes"
]),
decelerateTotalTimes
=
int
(
params
[
"decelerateTotalTimes"
]),
\
sharpTurnTotalTimes
=
int
(
params
[
"sharpTurnTotalTimes"
]),
acceleration
=
int
(
params
[
"acceleration"
]),
speed
=
int
(
params
[
"speed"
]),
gps
=
params
[
"gps"
])
msg
=
protocolObj
.
generateMsg
()
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"
]
=
json
.
loads
(
M300Common_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'
)
\ No newline at end of file
views/m300Tools/P_m300Protocol_view.py
View file @
d698737c
...
@@ -123,3 +123,17 @@ def P_alarm_m300_page():
...
@@ -123,3 +123,17 @@ def P_alarm_m300_page():
path
=
"m300Tools/report/P_alarm_m300_page.html"
path
=
"m300Tools/report/P_alarm_m300_page.html"
arg
[
"path"
]
=
reqPath
.
split
(
"/"
)
arg
[
"path"
]
=
reqPath
.
split
(
"/"
)
return
render_template
(
path
,
arg
=
arg
)
return
render_template
(
path
,
arg
=
arg
)
##########################################
# 【视图类型】访问OBD CAN协议页面
##########################################
@
P_m300Protocol_view
.
route
(
'/P_travelAct_m300_page'
)
def
P_travelAct_m300_page
():
#获取请求的路劲
url
=
request
.
url
reqPath
=
re
.
findall
(
"http://(.*)$"
,
url
)[
0
]
reqPath
=
re
.
findall
(
"/(.*)$"
,
reqPath
)[
0
]
arg
=
{}
path
=
"m300Tools/report/P_travelAct_m300_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