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
80d037dc
Commit
80d037dc
authored
Jun 18, 2020
by
liyuanhong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
M500模拟器添加了怠速过长报警功能
parent
1534c01e
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
92 additions
and
3 deletions
+92
-3
data/protocolTools/carData/M202003060520.json
data/protocolTools/carData/M202003060520.json
+1
-1
lib/protocol/report/EventReport_protocol.py
lib/protocol/report/EventReport_protocol.py
+4
-0
templates/protocolTools/report/M_carSimulater_page.html
templates/protocolTools/report/M_carSimulater_page.html
+12
-0
templates/protocolTools/report/event_protocol_page.html
templates/protocolTools/report/event_protocol_page.html
+26
-0
views/protocolTools/M_carSimulater_process.py
views/protocolTools/M_carSimulater_process.py
+49
-2
No files found.
data/protocolTools/carData/M202003060520.json
View file @
80d037dc
{
"time"
:
{
"dateTime"
:
"2020-06-18 09:52:18"
,
"date"
:
"2020-06-18"
,
"time"
:
"09:52:18"
},
"curDayTravel"
:
{
"todayTotalMilleage"
:
20967
,
"todayTotalOil"
:
1842
,
"todayTotalTime"
:
1275
,
"theMilleage"
:
996
,
"theOil"
:
96
,
"theTime"
:
60
},
"travelData"
:
{
"totalMilleage"
:
448537
,
"totalOil"
:
41857
,
"totalTime"
:
26768
},
"event"
:
{
"threeRapid"
:
{
"totalRapidlyAccelerate"
:
33
,
"totalSharpSlowdown"
:
23
,
"totalSharpTurn"
:
26
}}}
\ No newline at end of file
{
"time"
:
{
"dateTime"
:
"2020-06-18 09:52:18"
,
"date"
:
"2020-06-18"
,
"time"
:
"09:52:18"
},
"curDayTravel"
:
{
"todayTotalMilleage"
:
24370
,
"todayTotalOil"
:
2170
,
"todayTotalTime"
:
1480
,
"theMilleage"
:
415
,
"theOil"
:
40
,
"theTime"
:
25
},
"travelData"
:
{
"totalMilleage"
:
451940
,
"totalOil"
:
42185
,
"totalTime"
:
26973
},
"event"
:
{
"threeRapid"
:
{
"totalRapidlyAccelerate"
:
33
,
"totalSharpSlowdown"
:
23
,
"totalSharpTurn"
:
26
}}}
\ No newline at end of file
lib/protocol/report/EventReport_protocol.py
View file @
80d037dc
...
...
@@ -303,6 +303,10 @@ class EventReport_protocol(ProtocolBase):
theData
=
eventObj
.
tiredDrivingAlarm
(
int
(
eventData
[
"0028"
][
"alarmType"
]),
int
(
eventData
[
"0028"
][
"durTime"
]),)
data
=
data
+
"0028"
+
self
.
int2hexStringByBytes
(
int
((
len
(
theData
)
/
2
)),
2
)
+
theData
if
(
"0032"
in
eventData
.
keys
()):
#怠速时间过长报警
eventObj
=
EventClass
()
theData
=
eventObj
.
idlingOverTime
(
int
(
eventData
[
"0032"
][
"alarmType"
]),
int
(
eventData
[
"0032"
][
"durationTime"
]),
int
(
eventData
[
"0032"
][
"oilExpend"
]))
data
=
data
+
"0032"
+
self
.
int2hexStringByBytes
(
int
((
len
(
theData
)
/
2
)),
2
)
+
theData
if
(
"0036"
in
eventData
.
keys
()):
#低档高速报警
eventObj
=
EventClass
()
theData
=
eventObj
.
lowGearHighSpeedAlarm
(
int
(
eventData
[
"0036"
][
"alarmType"
]),
int
(
eventData
[
"0036"
][
"durationTime"
]))
...
...
templates/protocolTools/report/M_carSimulater_page.html
View file @
80d037dc
...
...
@@ -142,6 +142,7 @@
<label
style=
"padding: 0px 10px;"
><input
type=
"checkbox"
id=
"surplusOil_check"
onclick=
"eventSelect(this)"
checked
/>
剩余油量异常告警
</label>
<label
style=
"padding: 0px 10px;"
><input
type=
"checkbox"
id=
"overSpeed_check"
onclick=
"eventSelect(this)"
checked
/>
超速报警
</label>
<label
style=
"padding: 0px 10px;"
><input
type=
"checkbox"
id=
"tiredDriving_check"
onclick=
"eventSelect(this)"
checked
/>
疲劳驾驶
</label>
<label
style=
"padding: 0px 10px;"
><input
type=
"checkbox"
id=
"idlingOverTime_check"
onclick=
"eventSelect(this)"
checked
/>
怠速过长
</label>
</div>
<div
style=
"padding:10px;"
>
<span
id=
"insertAlarm_button"
style=
"display:inline;"
><button
type=
"button"
class=
"btn btn-primary"
onclick=
"sendInsertAlarmEvent(this)"
>
终端插入报警
</button></label></span>
...
...
@@ -159,6 +160,7 @@
<span
id=
"surplusOil_button"
style=
"display:inline;"
><button
type=
"button"
class=
"btn btn-primary"
onclick=
"sendSurplusOilAlarmEvent(this)"
>
剩余油量异常
</button></label></span>
<span
id=
"overSpeed_button"
style=
"display:inline;"
><button
type=
"button"
class=
"btn btn-primary"
onclick=
"sendOverSpeedEvent(this)"
>
超速报警
</button></label></span>
<span
id=
"tiredDriving_button"
style=
"display:inline;"
><button
type=
"button"
class=
"btn btn-primary"
onclick=
"sendTiredDrivingAlarmEvent(this)"
>
疲劳驾驶
</button></label></span>
<span
id=
"idlingOverTime_button"
style=
"display:inline;"
><button
type=
"button"
class=
"btn btn-primary"
onclick=
"sendIdlingOverTimeEvent(this)"
>
怠速过长
</button></label></span>
</div>
</div>
</div>
...
...
@@ -688,6 +690,8 @@ function eventSelect(e){
$
(
"
#overSpeed_button
"
).
css
(
"
display
"
,
"
inline
"
)
}
else
if
(
$
(
e
).
attr
(
"
id
"
)
==
"
tiredDriving_check
"
){
$
(
"
#tiredDriving_button
"
).
css
(
"
display
"
,
"
inline
"
)
}
else
if
(
$
(
e
).
attr
(
"
id
"
)
==
"
idlingOverTime_check
"
){
$
(
"
#idlingOverTime_button
"
).
css
(
"
display
"
,
"
inline
"
)
}
}
else
{
if
(
$
(
e
).
attr
(
"
id
"
)
==
"
insertAlarm_check
"
){
...
...
@@ -720,6 +724,8 @@ function eventSelect(e){
$
(
"
#overSpeed_button
"
).
css
(
"
display
"
,
"
none
"
)
}
else
if
(
$
(
e
).
attr
(
"
id
"
)
==
"
tiredDriving_check
"
){
$
(
"
#tiredDriving_button
"
).
css
(
"
display
"
,
"
none
"
)
}
else
if
(
$
(
e
).
attr
(
"
id
"
)
==
"
idlingOverTime_check
"
){
$
(
"
#idlingOverTime_button
"
).
css
(
"
display
"
,
"
none
"
)
}
}
}
...
...
@@ -813,6 +819,12 @@ function sendTiredDrivingAlarmEvent(){
url
=
"
/protocolTools/M_carSimulater_process/sendTiredDrivingAlarmEvent
"
;
sendjson
(
data
,
url
);
}
//怠速过长报警
function
sendIdlingOverTimeEvent
(){
var
data
=
getPageData
()
url
=
"
/protocolTools/M_carSimulater_process/sendIdlingOverTimeEvent
"
;
sendjson
(
data
,
url
);
}
// -------------------------------- 实时控制js代码-------------------------------------------
//设置隐藏或显示实时控制区域
...
...
templates/protocolTools/report/event_protocol_page.html
View file @
80d037dc
...
...
@@ -309,6 +309,7 @@
<label
style=
"padding: 0px 10px;"
><input
type=
"checkbox"
id=
"0027"
onclick=
"eventSelect(this)"
/>
超速告警
</label>
<label
style=
"padding: 0px 10px;"
><input
type=
"checkbox"
id=
"0028"
onclick=
"eventSelect(this)"
/>
疲劳驾驶告警
</label>
<label
style=
"padding: 0px 10px;"
><input
type=
"checkbox"
id=
"0032"
onclick=
"eventSelect(this)"
/>
怠速时间过长报警
</label>
<label
style=
"padding: 0px 10px;"
><input
type=
"checkbox"
id=
"0036"
onclick=
"eventSelect(this)"
/>
低档高速报警
</label>
<label
style=
"padding: 0px 10px;"
><input
type=
"checkbox"
id=
"0037"
onclick=
"eventSelect(this)"
/>
高档低速报警
</label>
<label
style=
"padding: 0px 10px;"
><input
type=
"checkbox"
id=
"004A"
onclick=
"eventSelect(this)"
/>
剩余油量异常告警
</label>
...
...
@@ -387,6 +388,17 @@
</select></span>
<span><label>
累计驾驶时间(秒):
</label><input
style=
"width:80px;"
id=
"0028_durTime"
type=
"text"
class=
"form-control"
value=
"11000"
></span>
</div>
<div
id=
"0032_area"
style=
"display:none;margin-top:10px;width:100%;border-width:1px;border-style:solid;border-color:darkgray;border-radius:10px;padding:2px;_background:skyblue;"
>
<h5><b>
怠速时间过长报警:
</b></h5>
<span><label>
报警属性:
</label>
<select
id=
"0032_alarmType"
class=
"form-control"
style=
"width:120px;"
>
<option
value=
"1"
>
报警触发
</option>
<option
value=
"0"
>
报警结束
</option>
</select>
</span>
<span><label>
持续时间(秒):
</label><input
style=
"width:80px;"
id=
"0032_durationTime"
type=
"text"
class=
"form-control"
value=
"6"
></span>
<span><label>
累计耗油量(毫升):
</label><input
style=
"width:80px;"
id=
"0032_oilExpend"
type=
"text"
class=
"form-control"
value=
"300"
></span>
</div>
<div
id=
"0036_area"
style=
"display:none;margin-top:10px;width:100%;border-width:1px;border-style:solid;border-color:darkgray;border-radius:10px;padding:2px;_background:skyblue;"
>
<h5><b>
低档高速报警:
</b></h5>
<span><label>
报警属性:
</label>
...
...
@@ -630,6 +642,9 @@ function getData(){
if
(
$
(
"
#0028
"
).
is
(
'
:checked
'
)){
data
[
"
event
"
][
"
0028
"
]
=
get0028
();
//获取疲劳驾驶事件数据
}
if
(
$
(
"
#0032
"
).
is
(
'
:checked
'
)){
data
[
"
event
"
][
"
0032
"
]
=
get0032
();
//怠速时间过长报警附
}
if
(
$
(
"
#0036
"
).
is
(
'
:checked
'
)){
data
[
"
event
"
][
"
0036
"
]
=
get0036
();
//低档高速报警
}
...
...
@@ -710,6 +725,13 @@ function get0028(){
data
[
"
durTime
"
]
=
$
(
"
#0028_durTime
"
).
val
();
return
data
}
function
get0032
(){
//怠速时间过长报警
data
=
{};
data
[
"
alarmType
"
]
=
$
(
"
#0032_alarmType
"
).
val
();
data
[
"
durationTime
"
]
=
$
(
"
#0032_durationTime
"
).
val
();
data
[
"
oilExpend
"
]
=
$
(
"
#0032_oilExpend
"
).
val
();
return
data
;
}
function
get0036
(){
//低档高速报警
data
=
{};
data
[
"
alarmType
"
]
=
$
(
"
#alarmType_1
"
).
val
();
...
...
@@ -768,6 +790,8 @@ function eventSelect(e){
$
(
"
#0027_area
"
).
css
(
"
display
"
,
"
block
"
)
}
else
if
(
$
(
e
).
attr
(
"
id
"
)
==
"
0028
"
){
$
(
"
#0028_area
"
).
css
(
"
display
"
,
"
block
"
)
}
else
if
(
$
(
e
).
attr
(
"
id
"
)
==
"
0032
"
){
$
(
"
#0032_area
"
).
css
(
"
display
"
,
"
block
"
)
}
else
if
(
$
(
e
).
attr
(
"
id
"
)
==
"
0036
"
){
$
(
"
#0036_area
"
).
css
(
"
display
"
,
"
block
"
)
}
else
if
(
$
(
e
).
attr
(
"
id
"
)
==
"
0037
"
){
...
...
@@ -794,6 +818,8 @@ function eventSelect(e){
$
(
"
#0027_area
"
).
css
(
"
display
"
,
"
none
"
)
}
else
if
(
$
(
e
).
attr
(
"
id
"
)
==
"
0028
"
){
$
(
"
#0028_area
"
).
css
(
"
display
"
,
"
none
"
)
}
else
if
(
$
(
e
).
attr
(
"
id
"
)
==
"
0032
"
){
$
(
"
#0032_area
"
).
css
(
"
display
"
,
"
none
"
)
}
else
if
(
$
(
e
).
attr
(
"
id
"
)
==
"
0036
"
){
$
(
"
#0036_area
"
).
css
(
"
display
"
,
"
none
"
)
}
else
if
(
$
(
e
).
attr
(
"
id
"
)
==
"
0037
"
){
...
...
views/protocolTools/M_carSimulater_process.py
View file @
80d037dc
...
...
@@ -1036,7 +1036,7 @@ def sendOverSpeedAlarmEvent():
"totalTime"
:
"2020002"
,
"GPSTimestamp"
:
"1588229973"
},
"securityData"
:
{
"securityStatus"
:
107
,
"doorStatus"
:
0
,
"lockStatus"
:
0
,
"windowStatus"
:
0
,
"lightStatus"
:
0
,
"onoffStatusA"
:
0
,
"onoffStatusB"
:
112
,
"dataByte"
:
249
},
"event"
:
{
"0027"
:
{
"alarmType"
:
"1"
,
"durTime"
:
"360"
}}}
"0027"
:
{
"alarmType"
:
"1"
,
"dur
ation
Time"
:
"360"
}}}
jdata
[
"DEV_ID"
]
=
params
[
"carId"
]
obj
=
EventReport_protocol
(
data
=
jdata
)
gpsData
=
service
.
genGPSData2
()
...
...
@@ -1083,7 +1083,7 @@ def sendTiredDrivingAlarmEvent():
"totalTime"
:
"2020002"
,
"GPSTimestamp"
:
"1588229973"
},
"securityData"
:
{
"securityStatus"
:
107
,
"doorStatus"
:
0
,
"lockStatus"
:
0
,
"windowStatus"
:
0
,
"lightStatus"
:
0
,
"onoffStatusA"
:
0
,
"onoffStatusB"
:
112
,
"dataByte"
:
249
},
"event"
:
{
"0028"
:
{
"alarmType"
:
"1"
,
"durTime"
:
"1100"
}}}
"0028"
:
{
"alarmType"
:
"1"
,
"dur
ation
Time"
:
"1100"
}}}
jdata
[
"DEV_ID"
]
=
params
[
"carId"
]
obj
=
EventReport_protocol
(
data
=
jdata
)
gpsData
=
service
.
genGPSData2
()
...
...
@@ -1101,6 +1101,53 @@ def sendTiredDrivingAlarmEvent():
data
[
"message"
]
=
"Error: 发送疲劳驾驶告警事件失败!"
return
Response
(
json
.
dumps
(
data
),
mimetype
=
'application/json'
)
##########################################
# 【接口类型】发送怠速时间过长报警事件
##########################################
@
M_carSimulater_process
.
route
(
"/sendIdlingOverTimeEvent"
,
methods
=
[
'POST'
])
def
sendIdlingOverTimeEvent
():
params
=
request
.
get_data
()
params
=
json
.
loads
(
params
.
decode
(
"utf-8"
))
sessionId
=
params
[
"session"
][
"sessionId"
]
data
=
{}
if
not
sessionId
in
connects
.
keys
():
data
[
"status"
]
=
"4003"
data
[
"message"
]
=
"Error: 未启动服务,不可发送怠速时间过长告警事件!"
return
Response
(
json
.
dumps
(
data
),
mimetype
=
'application/json'
)
service
=
connects
[
sessionId
][
"service"
]
travelStatus
=
service
.
getTravelStatus
()
#获取汽车行驶状态
if
travelStatus
==
0
or
travelStatus
==
2
:
data
[
"status"
]
=
"4003"
data
[
"message"
]
=
"Error: 汽车还未行驶,不可发送怠速时间过长告警事件!"
elif
travelStatus
==
1
:
try
:
jdata
=
{
"WATER_CODE"
:
"0003"
,
"DEV_ID"
:
"M121501010001"
,
"gpsInfo"
:
{
"UTCTime"
:
"2020-04-30 14:59:33"
,
"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"
:
"1588229973"
},
"securityData"
:
{
"securityStatus"
:
107
,
"doorStatus"
:
0
,
"lockStatus"
:
0
,
"windowStatus"
:
0
,
"lightStatus"
:
0
,
"onoffStatusA"
:
0
,
"onoffStatusB"
:
112
,
"dataByte"
:
249
},
"event"
:
{
"0032"
:
{
"alarmType"
:
"1"
,
"durationTime"
:
"1100"
,
"oilExpend"
:
"300"
}}}
jdata
[
"DEV_ID"
]
=
params
[
"carId"
]
obj
=
EventReport_protocol
(
data
=
jdata
)
gpsData
=
service
.
genGPSData2
()
obj
.
setGPSPkg
(
gpsData
)
obj
.
setEventType
(
"0032"
)
msg
=
obj
.
generateEventMsg
()
service
.
serviceSendMsg
(
msg
,
"怠速时间过长告警事件"
)
service
.
setSn
(
service
.
getSn
()
+
1
)
data
[
"status"
]
=
"200"
data
[
"message"
]
=
"发送怠速时间过长告警事件成功!"
except
BaseException
as
e
:
# 打印异常信息
traceback
.
print_exc
()
data
[
"status"
]
=
"4003"
data
[
"message"
]
=
"Error: 发送怠速时间过长告警事件失败!"
return
Response
(
json
.
dumps
(
data
),
mimetype
=
'application/json'
)
#--------------------------------------- 实时控制逻辑 ---------------------------------------
##########################################
# 【接口类型】改变车速
...
...
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