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
f0ba206c
Commit
f0ba206c
authored
Jun 11, 2020
by
liyuanhong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
M500模拟器增加了终端拔出报警和实时改变发动机转速功能
parent
7abfb059
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
103 additions
and
5 deletions
+103
-5
data/protocolTools/carData/M202003060520.json
data/protocolTools/carData/M202003060520.json
+1
-1
lib/protocol/report/OBDReport_CAN_protocol.py
lib/protocol/report/OBDReport_CAN_protocol.py
+1
-1
lib/socket/service/ProtocolSimulaterService.py
lib/socket/service/ProtocolSimulaterService.py
+5
-2
templates/protocolTools/report/M_carSimulater_page.html
templates/protocolTools/report/M_carSimulater_page.html
+23
-1
views/protocolTools/M_carSimulater_process.py
views/protocolTools/M_carSimulater_process.py
+73
-0
No files found.
data/protocolTools/carData/M202003060520.json
View file @
f0ba206c
{
"time"
:
{
"dateTime"
:
"2020-06-09 15:05:39"
,
"date"
:
"2020-06-09"
,
"time"
:
"15:05:39"
},
"curDayTravel"
:
{
"todayTotalMilleage"
:
20477
,
"todayTotalOil"
:
1862
,
"todayTotalTime"
:
1241
,
"theMilleage"
:
14223
,
"theOil"
:
1293
,
"theTime"
:
862
},
"travelData"
:
{
"totalMilleage"
:
366916
,
"totalOil"
:
34396
,
"totalTime"
:
21824
},
"event"
:
{
"threeRapid"
:
{
"totalRapidlyAccelerate"
:
21
,
"totalSharpSlowdown"
:
19
,
"totalSharpTurn"
:
19
}}}
{
"time"
:
{
"dateTime"
:
"2020-06-11 11:33:44"
,
"date"
:
"2020-06-11"
,
"time"
:
"11:33:44"
},
"curDayTravel"
:
{
"todayTotalMilleage"
:
7469
,
"todayTotalOil"
:
629
,
"todayTotalTime"
:
456
,
"theMilleage"
:
640
,
"theOil"
:
40
,
"theTime"
:
40
},
"travelData"
:
{
"totalMilleage"
:
374385
,
"totalOil"
:
35025
,
"totalTime"
:
22280
},
"event"
:
{
"threeRapid"
:
{
"totalRapidlyAccelerate"
:
23
,
"totalSharpSlowdown"
:
20
,
"totalSharpTurn"
:
21
}}}
\ No newline at end of file
\ No newline at end of file
lib/protocol/report/OBDReport_CAN_protocol.py
View file @
f0ba206c
...
@@ -9,7 +9,7 @@ from lib.protocol.report.ProtocolBase import ProtocolBase
...
@@ -9,7 +9,7 @@ from lib.protocol.report.ProtocolBase import ProtocolBase
class
OBDReport_CAN_protocol
(
ProtocolBase
):
class
OBDReport_CAN_protocol
(
ProtocolBase
):
def
__init__
(
self
,
msgCount
=
1
,
WATER_CODE
=
1000
,
DEV_ID
=
"M121501010001"
,
infoTime
=
"2020-01-10 16:29:19"
,
dataFlowCode
=
"ffffffffff"
,
protocolType
=
"0101"
,
fireStatus
=
1
,
ACCStatus
=
1
,
voltage
=
12
,
troubleLightStatus
=
0
,
toubleCodeCount
=
0
,
engineSpeed
=
4
000
,
speed
=
60
,
meterMileage
=
128500
,
mileageStatisticsStyle
=
"01"
,
totalMileage
=
4129040
,
troubleMileage
=
500
,
totalOilExpend
=
3500
,
surplusOil
=
505
,
totalRunTime
=
50000000
,
totalEngineTime
=
5000
,
airIntoAisleTemperture
=
42
,
coolingLiquidTemperture
=
38
,
envTemperture
=
68
,
ariIntoPress
=
20
,
oilPressure
=
550
,
atmosphericPressure
=
120
,
airFlow
=
3600
,
valveLocationSensor
=
4000
,
acceleratorLocation
=
50
,
engineLoad
=
55
,
fuelTrim
=
34
,
fireAngle
=
800
,
B1S1oxygenSensorVoltage
=
18
,
B1S2oxygenSensorVoltage
=
20
,
B1S1oxygenSensorElectricity
=
13000
,
B1S2oxygenSensorElectricity
=
13200
,
momentOilExpend
=
15
,
meterOilExpend
=
20000
,
engineAbsoluteLoad
=
32
,
steeringWheelAngle
=
10
,
torquePercentage
=
31
,
gearsLocation
=
1
,
GPSSpeed
=
72.4
,
GPSMileage
=
380000
):
def
__init__
(
self
,
msgCount
=
1
,
WATER_CODE
=
1000
,
DEV_ID
=
"M121501010001"
,
infoTime
=
"2020-01-10 16:29:19"
,
dataFlowCode
=
"ffffffffff"
,
protocolType
=
"0101"
,
fireStatus
=
1
,
ACCStatus
=
1
,
voltage
=
12
,
troubleLightStatus
=
0
,
toubleCodeCount
=
0
,
engineSpeed
=
3
000
,
speed
=
60
,
meterMileage
=
128500
,
mileageStatisticsStyle
=
"01"
,
totalMileage
=
4129040
,
troubleMileage
=
500
,
totalOilExpend
=
3500
,
surplusOil
=
505
,
totalRunTime
=
50000000
,
totalEngineTime
=
5000
,
airIntoAisleTemperture
=
42
,
coolingLiquidTemperture
=
38
,
envTemperture
=
68
,
ariIntoPress
=
20
,
oilPressure
=
550
,
atmosphericPressure
=
120
,
airFlow
=
3600
,
valveLocationSensor
=
4000
,
acceleratorLocation
=
50
,
engineLoad
=
55
,
fuelTrim
=
34
,
fireAngle
=
800
,
B1S1oxygenSensorVoltage
=
18
,
B1S2oxygenSensorVoltage
=
20
,
B1S1oxygenSensorElectricity
=
13000
,
B1S2oxygenSensorElectricity
=
13200
,
momentOilExpend
=
15
,
meterOilExpend
=
20000
,
engineAbsoluteLoad
=
32
,
steeringWheelAngle
=
10
,
torquePercentage
=
31
,
gearsLocation
=
1
,
GPSSpeed
=
72.4
,
GPSMileage
=
380000
):
pass
pass
self
.
msgCount
=
int
(
msgCount
)
# 设置默认要发送的数据包个数
self
.
msgCount
=
int
(
msgCount
)
# 设置默认要发送的数据包个数
...
...
lib/socket/service/ProtocolSimulaterService.py
View file @
f0ba206c
...
@@ -48,9 +48,9 @@ class ProtocolSimulaterService():
...
@@ -48,9 +48,9 @@ class ProtocolSimulaterService():
self
.
GPSValid
=
1
#用来控制GPS数据是有效还是无效 0:无效 1:有效
self
.
GPSValid
=
1
#用来控制GPS数据是有效还是无效 0:无效 1:有效
self
.
lngLatIsOk
=
1
#用来控制经纬度是否都为0 0:都为0 1:正常
self
.
lngLatIsOk
=
1
#用来控制经纬度是否都为0 0:都为0 1:正常
# 定义要发送的obd数据
# 定义要发送的obd数据
self
.
OBDdata
=
{
"fireStatus"
:
1
,
"ACCStatus"
:
0
,
"engineSpeed"
:
300
,
"speed"
:
0
,
"meterMileage"
:
6000
,
"totailMileage"
:
600
,
"totalOilExpen"
:
30
,
"totalRunTime"
:
10
,
"surplusOil"
:
505
}
self
.
OBDdata
=
{
"fireStatus"
:
1
,
"ACCStatus"
:
0
,
"engineSpeed"
:
300
0
,
"speed"
:
0
,
"meterMileage"
:
6000
,
"totailMileage"
:
600
,
"totalOilExpen"
:
30
,
"totalRunTime"
:
10
,
"surplusOil"
:
505
}
# 定义初始的obd数据,与上面的OBD数据保持一致,主要用于汽车行驶过程中数据变化量的计算
# 定义初始的obd数据,与上面的OBD数据保持一致,主要用于汽车行驶过程中数据变化量的计算
self
.
OBDdataOri
=
{
"fireStatus"
:
1
,
"ACCStatus"
:
0
,
"engineSpeed"
:
300
,
"speed"
:
0
,
"meterMileage"
:
6000
,
"totailMileage"
:
600
,
"totalOilExpen"
:
30
,
"totalRunTime"
:
10
,
"surplusOil"
:
50.
5
}
self
.
OBDdataOri
=
{
"fireStatus"
:
1
,
"ACCStatus"
:
0
,
"engineSpeed"
:
300
0
,
"speed"
:
0
,
"meterMileage"
:
6000
,
"totailMileage"
:
600
,
"totalOilExpen"
:
30
,
"totalRunTime"
:
10
,
"surplusOil"
:
50
5
}
#设置套接字
#设置套接字
def
setSocket
(
self
,
data
):
def
setSocket
(
self
,
data
):
...
@@ -76,6 +76,8 @@ class ProtocolSimulaterService():
...
@@ -76,6 +76,8 @@ class ProtocolSimulaterService():
self
.
serviceStatus
=
data
self
.
serviceStatus
=
data
def
setCarSpeed
(
self
,
data
):
def
setCarSpeed
(
self
,
data
):
self
.
data
[
"travelData"
][
"carSpeed"
]
=
data
self
.
data
[
"travelData"
][
"carSpeed"
]
=
data
def
setEngineSpeed
(
self
,
data
):
self
.
OBDdata
[
"engineSpeed"
]
=
data
def
setOilExpend
(
self
,
data
):
def
setOilExpend
(
self
,
data
):
self
.
data
[
"travelData"
][
"oilExpend"
]
=
data
self
.
data
[
"travelData"
][
"oilExpend"
]
=
data
def
setSurplusOil
(
self
,
data
):
def
setSurplusOil
(
self
,
data
):
...
@@ -534,6 +536,7 @@ class ProtocolSimulaterService():
...
@@ -534,6 +536,7 @@ class ProtocolSimulaterService():
OBDObj
.
setTotalOilExpend
(
totalOilExpend
)
# 设置总耗油量
OBDObj
.
setTotalOilExpend
(
totalOilExpend
)
# 设置总耗油量
OBDObj
.
setTotalRunTime
(
totalRunTime
)
# 设置车辆运行时间
OBDObj
.
setTotalRunTime
(
totalRunTime
)
# 设置车辆运行时间
OBDObj
.
setSurplusOil
(
self
.
OBDdata
[
"surplusOil"
])
# 设置剩余油量
OBDObj
.
setSurplusOil
(
self
.
OBDdata
[
"surplusOil"
])
# 设置剩余油量
OBDObj
.
setEngineSpeed
(
self
.
OBDdata
[
"engineSpeed"
])
# 设置发动机转速
msg
=
OBDObj
.
generateOBDReportCANMsg
()
msg
=
OBDObj
.
generateOBDReportCANMsg
()
return
msg
return
msg
...
...
templates/protocolTools/report/M_carSimulater_page.html
View file @
f0ba206c
...
@@ -128,6 +128,7 @@
...
@@ -128,6 +128,7 @@
<div
id=
"event_area"
style=
"display:none;"
>
<div
id=
"event_area"
style=
"display:none;"
>
<div
style=
"margin-top:10px;width:100%;border-width:1px;border-style:solid;border-color:darkgray;border-radius:10px;padding:2px;background:skyblue;"
>
<div
style=
"margin-top:10px;width:100%;border-width:1px;border-style:solid;border-color:darkgray;border-radius:10px;padding:2px;background:skyblue;"
>
<label
style=
"padding: 0px 10px;"
><input
type=
"checkbox"
id=
"insertAlarm_check"
onclick=
"eventSelect(this)"
checked
/>
终端插入报警
</label>
<label
style=
"padding: 0px 10px;"
><input
type=
"checkbox"
id=
"insertAlarm_check"
onclick=
"eventSelect(this)"
checked
/>
终端插入报警
</label>
<label
style=
"padding: 0px 10px;"
><input
type=
"checkbox"
id=
"pulloutAlarm_check"
onclick=
"eventSelect(this)"
checked
/>
终端拔出报警
</label>
<label
style=
"padding: 0px 10px;"
><input
type=
"checkbox"
id=
"lowVoltage_check"
onclick=
"eventSelect(this)"
checked
/>
汽车电瓶低电压报警
</label>
<label
style=
"padding: 0px 10px;"
><input
type=
"checkbox"
id=
"lowVoltage_check"
onclick=
"eventSelect(this)"
checked
/>
汽车电瓶低电压报警
</label>
<label
style=
"padding: 0px 10px;"
><input
type=
"checkbox"
id=
"powerOff_check"
onclick=
"eventSelect(this)"
checked
/>
终端主电断电报警
</label>
<label
style=
"padding: 0px 10px;"
><input
type=
"checkbox"
id=
"powerOff_check"
onclick=
"eventSelect(this)"
checked
/>
终端主电断电报警
</label>
<label
style=
"padding: 0px 10px;"
><input
type=
"checkbox"
id=
"rapidlyAccelerateEvent_check"
onclick=
"eventSelect(this)"
checked
/>
急加速
</label>
<label
style=
"padding: 0px 10px;"
><input
type=
"checkbox"
id=
"rapidlyAccelerateEvent_check"
onclick=
"eventSelect(this)"
checked
/>
急加速
</label>
...
@@ -144,6 +145,7 @@
...
@@ -144,6 +145,7 @@
</div>
</div>
<div
style=
"padding:10px;"
>
<div
style=
"padding:10px;"
>
<span
id=
"insertAlarm_button"
style=
"display:inline;"
><button
type=
"button"
class=
"btn btn-primary"
onclick=
"sendInsertAlarmEvent(this)"
>
终端插入报警
</button></label></span>
<span
id=
"insertAlarm_button"
style=
"display:inline;"
><button
type=
"button"
class=
"btn btn-primary"
onclick=
"sendInsertAlarmEvent(this)"
>
终端插入报警
</button></label></span>
<span
id=
"pulloutAlarm_button"
style=
"display:inline;"
><button
type=
"button"
class=
"btn btn-primary"
onclick=
"sendPulloutAlarmEvent(this)"
>
终端拔出报警
</button></label></span>
<span
id=
"lowVoltage_button"
style=
"display:inline;"
><button
type=
"button"
class=
"btn btn-primary"
onclick=
"sendLowVoltageEvent(this)"
>
汽车电瓶低电压报警
</button></label></span>
<span
id=
"lowVoltage_button"
style=
"display:inline;"
><button
type=
"button"
class=
"btn btn-primary"
onclick=
"sendLowVoltageEvent(this)"
>
汽车电瓶低电压报警
</button></label></span>
<span
id=
"powerOff_button"
style=
"display:inline;"
><button
type=
"button"
class=
"btn btn-primary"
onclick=
"sendPowerOffEvent(this)"
>
终端主电断电报警
</button></label></span>
<span
id=
"powerOff_button"
style=
"display:inline;"
><button
type=
"button"
class=
"btn btn-primary"
onclick=
"sendPowerOffEvent(this)"
>
终端主电断电报警
</button></label></span>
<span
id=
"rapidlyAccelerateEvent_button"
style=
"display:inline;"
><button
type=
"button"
class=
"btn btn-primary"
onclick=
"sendRapidlyAccelerateEvent(this)"
>
急加速
</button></label></span>
<span
id=
"rapidlyAccelerateEvent_button"
style=
"display:inline;"
><button
type=
"button"
class=
"btn btn-primary"
onclick=
"sendRapidlyAccelerateEvent(this)"
>
急加速
</button></label></span>
...
@@ -174,6 +176,7 @@
...
@@ -174,6 +176,7 @@
<span
style=
"margin-left:10px;display: inline-block;"
><label>
上报间隔(秒):
</label><input
style=
"width:80px;margin-right:5px;"
id=
"change_durTime"
type=
"text"
class=
"form-control"
value=
"5"
><button
type=
"button"
class=
"btn btn-primary"
onclick=
"changeDurTime()"
>
改变上报间隔
</button></span>
<span
style=
"margin-left:10px;display: inline-block;"
><label>
上报间隔(秒):
</label><input
style=
"width:80px;margin-right:5px;"
id=
"change_durTime"
type=
"text"
class=
"form-control"
value=
"5"
><button
type=
"button"
class=
"btn btn-primary"
onclick=
"changeDurTime()"
>
改变上报间隔
</button></span>
<span
style=
"margin-left:10px;display: inline-block;"
><button
title=
"点击后,将会把上报的消息存到本地,不上报消息;用来模拟车机无信号的情况"
type=
"button"
class=
"btn btn-primary"
onclick=
"storeMsg()"
id=
"storeMsgBut"
>
存储上报消息
</button><label
style=
"color:red;"
id=
"storeMsgLab"
>
未存储...
</label></span>
<span
style=
"margin-left:10px;display: inline-block;"
><button
title=
"点击后,将会把上报的消息存到本地,不上报消息;用来模拟车机无信号的情况"
type=
"button"
class=
"btn btn-primary"
onclick=
"storeMsg()"
id=
"storeMsgBut"
>
存储上报消息
</button><label
style=
"color:red;"
id=
"storeMsgLab"
>
未存储...
</label></span>
<span
style=
"margin-left:10px;display: inline-block;"
><label>
剩余油量(%):
</label><input
style=
"width:80px;margin-right:5px;"
id=
"change_surplusOil"
type=
"text"
class=
"form-control"
value=
"50.5"
><button
type=
"button"
class=
"btn btn-primary"
onclick=
"changeSurplusOil()"
>
改变剩余油量
</button></span>
<span
style=
"margin-left:10px;display: inline-block;"
><label>
剩余油量(%):
</label><input
style=
"width:80px;margin-right:5px;"
id=
"change_surplusOil"
type=
"text"
class=
"form-control"
value=
"50.5"
><button
type=
"button"
class=
"btn btn-primary"
onclick=
"changeSurplusOil()"
>
改变剩余油量
</button></span>
<span
style=
"margin-left:10px;display: inline-block;"
><label>
发动机转速:
</label><input
style=
"width:80px;margin-right:5px;"
id=
"change_engineSpeed"
type=
"text"
class=
"form-control"
value=
"3000"
><button
type=
"button"
class=
"btn btn-primary"
onclick=
"changeEngineSpeed()"
>
改变发动机转速
</button></span>
<span
style=
"margin-top:10px;display:inline-block;border-width:1px;border-style:solid;border-color:darkgray;border-radius:10px;padding:1px 10px;margin-left:10px;"
>
<span
style=
"margin-top:10px;display:inline-block;border-width:1px;border-style:solid;border-color:darkgray;border-radius:10px;padding:1px 10px;margin-left:10px;"
>
<label><input
name=
"GPSValie"
value=
"1"
type=
"radio"
onclick=
"changeGPSValid(this)"
checked=
"checked"
>
GPS有效
</label>
<label><input
name=
"GPSValie"
value=
"1"
type=
"radio"
onclick=
"changeGPSValid(this)"
checked=
"checked"
>
GPS有效
</label>
<label
style=
"margin-left:10px;color:red;"
><input
name=
"GPSValie"
value=
"0"
type=
"radio"
onclick=
"changeGPSValid(this)"
>
GPS无效
</label>
<label
style=
"margin-left:10px;color:red;"
><input
name=
"GPSValie"
value=
"0"
type=
"radio"
onclick=
"changeGPSValid(this)"
>
GPS无效
</label>
...
@@ -721,6 +724,12 @@ function sendInsertAlarmEvent(){
...
@@ -721,6 +724,12 @@ function sendInsertAlarmEvent(){
url
=
"
/protocolTools/M_carSimulater_process/sendInsertAlarmEvent
"
;
url
=
"
/protocolTools/M_carSimulater_process/sendInsertAlarmEvent
"
;
sendjson
(
data
,
url
);
sendjson
(
data
,
url
);
}
}
//发送终端拔出报警
function
sendPulloutAlarmEvent
(){
var
data
=
getPageData
()
url
=
"
/protocolTools/M_carSimulater_process/sendPulloutAlarmEvent
"
;
sendjson
(
data
,
url
);
}
//发送汽车电瓶低电压报警
//发送汽车电瓶低电压报警
function
sendLowVoltageEvent
(){
function
sendLowVoltageEvent
(){
var
data
=
getPageData
()
var
data
=
getPageData
()
...
@@ -837,7 +846,20 @@ function changeOilExpend(){
...
@@ -837,7 +846,20 @@ function changeOilExpend(){
var
sessionId
=
$
(
"
#curSession
"
).
val
()
var
sessionId
=
$
(
"
#curSession
"
).
val
()
data
[
"
session
"
][
"
sessionId
"
]
=
sessionId
data
[
"
session
"
][
"
sessionId
"
]
=
sessionId
url
=
"
/protocolTools/M_carSimulater_process/changeOilExpend
"
;
url
=
"
/protocolTools/M_carSimulater_process/changeOilExpend
"
;
$
(
"
#oilExpend
"
).
val
(
oilExpend
)
sendjson
(
data
,
url
);
}
//改变发动机转速
function
changeEngineSpeed
(){
var
data
=
{}
var
carId
=
$
(
"
#carId
"
).
val
()
var
engineSpeed
=
$
(
"
#change_engineSpeed
"
).
val
()
data
[
"
carId
"
]
=
carId
data
[
"
engineSpeed
"
]
=
engineSpeed
//会话session数据
data
[
"
session
"
]
=
{}
var
sessionId
=
$
(
"
#curSession
"
).
val
()
data
[
"
session
"
][
"
sessionId
"
]
=
sessionId
url
=
"
/protocolTools/M_carSimulater_process/changeEngineSpeed
"
;
sendjson
(
data
,
url
);
sendjson
(
data
,
url
);
}
}
//改变发送间隔
//改变发送间隔
...
...
views/protocolTools/M_carSimulater_process.py
View file @
f0ba206c
...
@@ -437,6 +437,48 @@ def sendInsertAlarmEvent():
...
@@ -437,6 +437,48 @@ def sendInsertAlarmEvent():
data
[
"message"
]
=
"Error: 发送终端插入报警事件失败!"
data
[
"message"
]
=
"Error: 发送终端插入报警事件失败!"
return
Response
(
json
.
dumps
(
data
),
mimetype
=
'application/json'
)
return
Response
(
json
.
dumps
(
data
),
mimetype
=
'application/json'
)
##########################################
# 【接口类型】发送终端拔出报警事件
##########################################
@
M_carSimulater_process
.
route
(
"/sendPulloutAlarmEvent"
,
methods
=
[
'POST'
])
def
sendPulloutAlarmEvent
():
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"
]
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"
:
{
"0002"
:
{}}}
jdata
[
"DEV_ID"
]
=
params
[
"carId"
]
obj
=
EventReport_protocol
(
data
=
jdata
)
gpsData
=
service
.
genGPSData2
()
obj
.
setGPSPkg
(
gpsData
)
obj
.
setEventType
(
"0002"
)
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'
)
##########################################
##########################################
# 【接口类型】发送汽车电瓶低电压事件
# 【接口类型】发送汽车电瓶低电压事件
##########################################
##########################################
...
@@ -1122,6 +1164,37 @@ def changeOilExpend():
...
@@ -1122,6 +1164,37 @@ def changeOilExpend():
data
[
"message"
]
=
"Error: 改变油耗失败!"
data
[
"message"
]
=
"Error: 改变油耗失败!"
return
Response
(
json
.
dumps
(
data
),
mimetype
=
'application/json'
)
return
Response
(
json
.
dumps
(
data
),
mimetype
=
'application/json'
)
##########################################
# 【接口类型】改变发动机转速
##########################################
@
M_carSimulater_process
.
route
(
"/changeEngineSpeed"
,
methods
=
[
'POST'
])
def
changeEngineSpeed
():
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
:
service
.
setEngineSpeed
(
int
(
params
[
"engineSpeed"
]))
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