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
6421fbbd
Commit
6421fbbd
authored
Jul 09, 2020
by
liyuanhong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
M500模拟器增加了改变电瓶电压功能
parent
aabc231c
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
99 additions
and
10 deletions
+99
-10
data/m300Tools/carData/M202003060518.json
data/m300Tools/carData/M202003060518.json
+1
-1
data/messageTools/carData/012201500010.json
data/messageTools/carData/012201500010.json
+1
-1
data/protocolTools/carData/M202003060520.json
data/protocolTools/carData/M202003060520.json
+1
-1
data/protocolTools/sendMsg/genBigPkg.py
data/protocolTools/sendMsg/genBigPkg.py
+7
-7
lib/protocol/report/OBDReport_CAN_protocol.py
lib/protocol/report/OBDReport_CAN_protocol.py
+2
-0
lib/socket/service/ProtocolSimulaterService.py
lib/socket/service/ProtocolSimulaterService.py
+6
-0
templates/protocolTools/report/M_carSimulater_page.html
templates/protocolTools/report/M_carSimulater_page.html
+37
-0
views/protocolTools/M_carSimulater_process.py
views/protocolTools/M_carSimulater_process.py
+44
-0
No files found.
data/m300Tools/carData/M202003060518.json
View file @
6421fbbd
{
"time"
:
{
"dateTime"
:
"2020-06-17 11:04:45"
,
"date"
:
"2020-06-17"
,
"time"
:
"11:04:45"
},
"curDayTravel"
:
{
"todayTotalMilleage"
:
30521
,
"todayTotalOil"
:
2966
,
"todayTotalTime"
:
1837
,
"theMilleage"
:
1584
,
"theOil"
:
144
,
"theTime"
:
96
},
"travelData"
:
{
"totalMilleage"
:
38123
,
"totalOil"
:
3623
,
"totalTime"
:
2300
},
"event"
:
{
"threeRapid"
:
{
"totalRapidlyAccelerate"
:
11
,
"totalSharpSlowdown"
:
10
,
"totalSharpTurn"
:
0
}}}
{
"time"
:
{
"dateTime"
:
"2020-07-09 15:28:25"
,
"date"
:
"2020-07-09"
,
"time"
:
"15:28:25"
},
"curDayTravel"
:
{
"todayTotalMilleage"
:
3075
,
"todayTotalOil"
:
195
,
"todayTotalTime"
:
192
,
"theMilleage"
:
3075
,
"theOil"
:
195
,
"theTime"
:
192
},
"travelData"
:
{
"totalMilleage"
:
41198
,
"totalOil"
:
3818
,
"totalTime"
:
2492
},
"event"
:
{
"threeRapid"
:
{
"totalRapidlyAccelerate"
:
11
,
"totalSharpSlowdown"
:
10
,
"totalSharpTurn"
:
0
}}}
\ No newline at end of file
\ No newline at end of file
data/messageTools/carData/012201500010.json
View file @
6421fbbd
{
"time"
:
{
"dateTime"
:
"2020-06-17 09:52:48"
,
"date"
:
"2020-06-17"
,
"time"
:
"09:52:48"
},
"curDayTravel"
:
{
"todayTotalMilleage"
:
16423
,
"todayTotalOil"
:
1588
,
"todayTotalTime"
:
989
,
"theMilleage"
:
2129
,
"theOil"
:
194
,
"theTime"
:
129
},
"travelData"
:
{
"totalMilleage"
:
108720
,
"totalOil"
:
9913
,
"totalTime"
:
6658
}}
{
"time"
:
{
"dateTime"
:
"2020-07-09 11:30:36"
,
"date"
:
"2020-07-09"
,
"time"
:
"11:30:36"
},
"curDayTravel"
:
{
"todayTotalMilleage"
:
3091
,
"todayTotalOil"
:
196
,
"todayTotalTime"
:
193
,
"theMilleage"
:
3091
,
"theOil"
:
196
,
"theTime"
:
193
},
"travelData"
:
{
"totalMilleage"
:
111811
,
"totalOil"
:
10109
,
"totalTime"
:
6851
}}
\ No newline at end of file
\ No newline at end of file
data/protocolTools/carData/M202003060520.json
View file @
6421fbbd
{
"time"
:
{
"dateTime"
:
"2020-06-23 11:03:33"
,
"date"
:
"2020-06-23"
,
"time"
:
"11:03:33"
},
"curDayTravel"
:
{
"todayTotalMilleage"
:
540
,
"todayTotalOil"
:
45
,
"todayTotalTime"
:
33
,
"theMilleage"
:
540
,
"theOil"
:
45
,
"theTime"
:
33
},
"travelData"
:
{
"totalMilleage"
:
466175
,
"totalOil"
:
43550
,
"totalTime"
:
27831
},
"event"
:
{
"threeRapid"
:
{
"totalRapidlyAccelerate"
:
33
,
"totalSharpSlowdown"
:
23
,
"totalSharpTurn"
:
26
}}}
{
"time"
:
{
"dateTime"
:
"2020-07-09 16:58:36"
,
"date"
:
"2020-07-09"
,
"time"
:
"16:58:36"
},
"curDayTravel"
:
{
"todayTotalMilleage"
:
1162
,
"todayTotalOil"
:
112
,
"todayTotalTime"
:
70
,
"theMilleage"
:
1162
,
"theOil"
:
112
,
"theTime"
:
70
},
"travelData"
:
{
"totalMilleage"
:
564424
,
"totalOil"
:
51394
,
"totalTime"
:
33858
},
"event"
:
{
"threeRapid"
:
{
"totalRapidlyAccelerate"
:
43
,
"totalSharpSlowdown"
:
31
,
"totalSharpTurn"
:
34
}}}
\ No newline at end of file
\ No newline at end of file
data/protocolTools/sendMsg/genBigPkg.py
View file @
6421fbbd
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
import
binascii
import
binascii
import
socket
import
socket
din
=
"M202003060520"
#####################################################
#####################################################
# 数字转换为16进制字符串
# 数字转换为16进制字符串
#####################################################
#####################################################
...
@@ -96,7 +96,7 @@ def getEventPkg():
...
@@ -96,7 +96,7 @@ def getEventPkg():
pkgCounts
=
int2hexStringByBytes
(
pkgCounts
)
pkgCounts
=
int2hexStringByBytes
(
pkgCounts
)
HEADER
=
"4040"
HEADER
=
"4040"
WATER_CODE
=
int2hexStringByBytes
(
1
,
2
)
WATER_CODE
=
int2hexStringByBytes
(
1
,
2
)
DEV_ID
=
devid2hexString
(
"M202003060520"
)
DEV_ID
=
devid2hexString
(
din
)
FUN_ID
=
"0021"
FUN_ID
=
"0021"
LENGTH
=
int2hexStringByBytes
(
int
(
len
(
WATER_CODE
+
DEV_ID
+
FUN_ID
+
pkgCounts
+
pkg
)
/
2
),
2
)
LENGTH
=
int2hexStringByBytes
(
int
(
len
(
WATER_CODE
+
DEV_ID
+
FUN_ID
+
pkgCounts
+
pkg
)
/
2
),
2
)
CHECK_CODE
=
crc16
(
HEADER
+
LENGTH
+
WATER_CODE
+
DEV_ID
+
FUN_ID
+
pkgCounts
+
pkg
)
CHECK_CODE
=
crc16
(
HEADER
+
LENGTH
+
WATER_CODE
+
DEV_ID
+
FUN_ID
+
pkgCounts
+
pkg
)
...
@@ -107,7 +107,7 @@ def getEventPkg():
...
@@ -107,7 +107,7 @@ def getEventPkg():
pkgCounts
=
int2hexStringByBytes
(
pkgCounts
)
pkgCounts
=
int2hexStringByBytes
(
pkgCounts
)
HEADER
=
"4040"
HEADER
=
"4040"
WATER_CODE
=
int2hexStringByBytes
(
1
,
2
)
WATER_CODE
=
int2hexStringByBytes
(
1
,
2
)
DEV_ID
=
devid2hexString
(
"M202003060520"
)
DEV_ID
=
devid2hexString
(
din
)
FUN_ID
=
"0021"
FUN_ID
=
"0021"
LENGTH
=
int2hexStringByBytes
(
int
(
len
(
WATER_CODE
+
DEV_ID
+
FUN_ID
+
pkgCounts
+
pkg
)
/
2
),
2
)
LENGTH
=
int2hexStringByBytes
(
int
(
len
(
WATER_CODE
+
DEV_ID
+
FUN_ID
+
pkgCounts
+
pkg
)
/
2
),
2
)
CHECK_CODE
=
crc16
(
HEADER
+
LENGTH
+
WATER_CODE
+
DEV_ID
+
FUN_ID
+
pkgCounts
+
pkg
)
CHECK_CODE
=
crc16
(
HEADER
+
LENGTH
+
WATER_CODE
+
DEV_ID
+
FUN_ID
+
pkgCounts
+
pkg
)
...
@@ -136,7 +136,7 @@ def getGpsPkg():
...
@@ -136,7 +136,7 @@ def getGpsPkg():
pkgCounts
=
int2hexStringByBytes
(
pkgCounts
)
pkgCounts
=
int2hexStringByBytes
(
pkgCounts
)
HEADER
=
"4040"
HEADER
=
"4040"
WATER_CODE
=
int2hexStringByBytes
(
1
,
2
)
WATER_CODE
=
int2hexStringByBytes
(
1
,
2
)
DEV_ID
=
devid2hexString
(
"M202003060520"
)
DEV_ID
=
devid2hexString
(
din
)
FUN_ID
=
"0010"
FUN_ID
=
"0010"
LENGTH
=
int2hexStringByBytes
(
int
(
len
(
WATER_CODE
+
DEV_ID
+
FUN_ID
+
pkgCounts
+
pkg
)
/
2
),
2
)
LENGTH
=
int2hexStringByBytes
(
int
(
len
(
WATER_CODE
+
DEV_ID
+
FUN_ID
+
pkgCounts
+
pkg
)
/
2
),
2
)
CHECK_CODE
=
crc16
(
HEADER
+
LENGTH
+
WATER_CODE
+
DEV_ID
+
FUN_ID
+
pkgCounts
+
pkg
)
CHECK_CODE
=
crc16
(
HEADER
+
LENGTH
+
WATER_CODE
+
DEV_ID
+
FUN_ID
+
pkgCounts
+
pkg
)
...
@@ -147,7 +147,7 @@ def getGpsPkg():
...
@@ -147,7 +147,7 @@ def getGpsPkg():
pkgCounts
=
int2hexStringByBytes
(
pkgCounts
)
pkgCounts
=
int2hexStringByBytes
(
pkgCounts
)
HEADER
=
"4040"
HEADER
=
"4040"
WATER_CODE
=
int2hexStringByBytes
(
1
,
2
)
WATER_CODE
=
int2hexStringByBytes
(
1
,
2
)
DEV_ID
=
devid2hexString
(
"M202003060520"
)
DEV_ID
=
devid2hexString
(
din
)
FUN_ID
=
"0010"
FUN_ID
=
"0010"
LENGTH
=
int2hexStringByBytes
(
int
(
len
(
WATER_CODE
+
DEV_ID
+
FUN_ID
+
pkgCounts
+
pkg
)
/
2
),
2
)
LENGTH
=
int2hexStringByBytes
(
int
(
len
(
WATER_CODE
+
DEV_ID
+
FUN_ID
+
pkgCounts
+
pkg
)
/
2
),
2
)
CHECK_CODE
=
crc16
(
HEADER
+
LENGTH
+
WATER_CODE
+
DEV_ID
+
FUN_ID
+
pkgCounts
+
pkg
)
CHECK_CODE
=
crc16
(
HEADER
+
LENGTH
+
WATER_CODE
+
DEV_ID
+
FUN_ID
+
pkgCounts
+
pkg
)
...
@@ -177,7 +177,7 @@ def getObdPkg():
...
@@ -177,7 +177,7 @@ def getObdPkg():
pkgCounts
=
int2hexStringByBytes
(
pkgCounts
)
pkgCounts
=
int2hexStringByBytes
(
pkgCounts
)
HEADER
=
"4040"
HEADER
=
"4040"
WATER_CODE
=
int2hexStringByBytes
(
1
,
2
)
WATER_CODE
=
int2hexStringByBytes
(
1
,
2
)
DEV_ID
=
devid2hexString
(
"M202003060520"
)
DEV_ID
=
devid2hexString
(
din
)
FUN_ID
=
"0012"
FUN_ID
=
"0012"
LENGTH
=
int2hexStringByBytes
(
int
(
len
(
WATER_CODE
+
DEV_ID
+
FUN_ID
+
pkgCounts
+
pkg
)
/
2
),
2
)
LENGTH
=
int2hexStringByBytes
(
int
(
len
(
WATER_CODE
+
DEV_ID
+
FUN_ID
+
pkgCounts
+
pkg
)
/
2
),
2
)
CHECK_CODE
=
crc16
(
HEADER
+
LENGTH
+
WATER_CODE
+
DEV_ID
+
FUN_ID
+
pkgCounts
+
pkg
)
CHECK_CODE
=
crc16
(
HEADER
+
LENGTH
+
WATER_CODE
+
DEV_ID
+
FUN_ID
+
pkgCounts
+
pkg
)
...
@@ -188,7 +188,7 @@ def getObdPkg():
...
@@ -188,7 +188,7 @@ def getObdPkg():
pkgCounts
=
int2hexStringByBytes
(
pkgCounts
)
pkgCounts
=
int2hexStringByBytes
(
pkgCounts
)
HEADER
=
"4040"
HEADER
=
"4040"
WATER_CODE
=
int2hexStringByBytes
(
1
,
2
)
WATER_CODE
=
int2hexStringByBytes
(
1
,
2
)
DEV_ID
=
devid2hexString
(
"M202003060520"
)
DEV_ID
=
devid2hexString
(
din
)
FUN_ID
=
"0012"
FUN_ID
=
"0012"
LENGTH
=
int2hexStringByBytes
(
int
(
len
(
WATER_CODE
+
DEV_ID
+
FUN_ID
+
pkgCounts
+
pkg
)
/
2
),
2
)
LENGTH
=
int2hexStringByBytes
(
int
(
len
(
WATER_CODE
+
DEV_ID
+
FUN_ID
+
pkgCounts
+
pkg
)
/
2
),
2
)
CHECK_CODE
=
crc16
(
HEADER
+
LENGTH
+
WATER_CODE
+
DEV_ID
+
FUN_ID
+
pkgCounts
+
pkg
)
CHECK_CODE
=
crc16
(
HEADER
+
LENGTH
+
WATER_CODE
+
DEV_ID
+
FUN_ID
+
pkgCounts
+
pkg
)
...
...
lib/protocol/report/OBDReport_CAN_protocol.py
View file @
6421fbbd
...
@@ -81,6 +81,8 @@ class OBDReport_CAN_protocol(ProtocolBase):
...
@@ -81,6 +81,8 @@ class OBDReport_CAN_protocol(ProtocolBase):
self
.
surplusOil
=
data
self
.
surplusOil
=
data
def
setTotalRunTime
(
self
,
data
):
#车辆总运行时间
def
setTotalRunTime
(
self
,
data
):
#车辆总运行时间
self
.
totalRunTime
=
data
self
.
totalRunTime
=
data
def
setVoltage
(
self
,
data
):
self
.
voltage
=
float
(
data
)
#####################################################
#####################################################
...
...
lib/socket/service/ProtocolSimulaterService.py
View file @
6421fbbd
...
@@ -92,6 +92,8 @@ class ProtocolSimulaterService():
...
@@ -92,6 +92,8 @@ class ProtocolSimulaterService():
self
.
lngLatIsOk
=
data
self
.
lngLatIsOk
=
data
def
setTravelDirection
(
self
,
data
):
def
setTravelDirection
(
self
,
data
):
self
.
travelDirection
=
data
self
.
travelDirection
=
data
def
setVoltage
(
self
,
data
):
self
.
data
[
"other"
][
"valtage"
]
=
data
...
@@ -503,6 +505,7 @@ class ProtocolSimulaterService():
...
@@ -503,6 +505,7 @@ class ProtocolSimulaterService():
gpsObj
.
setLongitude
(
longtitude
)
gpsObj
.
setLongitude
(
longtitude
)
gpsObj
.
setSpeed
(
int
(
self
.
data
[
"travelData"
][
"carSpeed"
]))
gpsObj
.
setSpeed
(
int
(
self
.
data
[
"travelData"
][
"carSpeed"
]))
gpsObj
.
setOBDSpeed
(
int
(
self
.
data
[
"travelData"
][
"carSpeed"
]))
gpsObj
.
setOBDSpeed
(
int
(
self
.
data
[
"travelData"
][
"carSpeed"
]))
gpsObj
.
setValtage
(
self
.
data
[
"other"
][
"valtage"
])
if
self
.
lngLatIsOk
==
0
:
if
self
.
lngLatIsOk
==
0
:
gpsObj
.
setLatitude
(
0
)
gpsObj
.
setLatitude
(
0
)
gpsObj
.
setLongitude
(
0
)
gpsObj
.
setLongitude
(
0
)
...
@@ -525,6 +528,7 @@ class ProtocolSimulaterService():
...
@@ -525,6 +528,7 @@ class ProtocolSimulaterService():
gpsObj
.
setLongitude
(
longtitude
)
gpsObj
.
setLongitude
(
longtitude
)
gpsObj
.
setSpeed
(
int
(
self
.
data
[
"travelData"
][
"carSpeed"
]))
gpsObj
.
setSpeed
(
int
(
self
.
data
[
"travelData"
][
"carSpeed"
]))
gpsObj
.
setOBDSpeed
(
int
(
self
.
data
[
"travelData"
][
"carSpeed"
]))
gpsObj
.
setOBDSpeed
(
int
(
self
.
data
[
"travelData"
][
"carSpeed"
]))
gpsObj
.
setValtage
(
self
.
data
[
"other"
][
"valtage"
])
if
self
.
lngLatIsOk
==
0
:
if
self
.
lngLatIsOk
==
0
:
gpsObj
.
setLatitude
(
0
)
gpsObj
.
setLatitude
(
0
)
gpsObj
.
setLongitude
(
0
)
gpsObj
.
setLongitude
(
0
)
...
@@ -552,6 +556,7 @@ class ProtocolSimulaterService():
...
@@ -552,6 +556,7 @@ class ProtocolSimulaterService():
gpsObj
.
setLongitude
(
self
.
gpsLine
[
gpsLineIndex
][
"lng"
])
gpsObj
.
setLongitude
(
self
.
gpsLine
[
gpsLineIndex
][
"lng"
])
gpsObj
.
setSpeed
(
int
(
self
.
data
[
"travelData"
][
"carSpeed"
]))
gpsObj
.
setSpeed
(
int
(
self
.
data
[
"travelData"
][
"carSpeed"
]))
gpsObj
.
setOBDSpeed
(
int
(
self
.
data
[
"travelData"
][
"carSpeed"
]))
gpsObj
.
setOBDSpeed
(
int
(
self
.
data
[
"travelData"
][
"carSpeed"
]))
gpsObj
.
setValtage
(
self
.
data
[
"other"
][
"valtage"
])
if
self
.
lngLatIsOk
==
0
:
if
self
.
lngLatIsOk
==
0
:
gpsObj
.
setLatitude
(
0
)
gpsObj
.
setLatitude
(
0
)
gpsObj
.
setLongitude
(
0
)
gpsObj
.
setLongitude
(
0
)
...
@@ -586,6 +591,7 @@ class ProtocolSimulaterService():
...
@@ -586,6 +591,7 @@ class ProtocolSimulaterService():
OBDObj
.
setTotalRunTime
(
totalRunTime
)
# 设置车辆运行时间
OBDObj
.
setTotalRunTime
(
totalRunTime
)
# 设置车辆运行时间
OBDObj
.
setSurplusOil
(
self
.
OBDdata
[
"surplusOil"
])
# 设置剩余油量
OBDObj
.
setSurplusOil
(
self
.
OBDdata
[
"surplusOil"
])
# 设置剩余油量
OBDObj
.
setEngineSpeed
(
self
.
OBDdata
[
"engineSpeed"
])
# 设置发动机转速
OBDObj
.
setEngineSpeed
(
self
.
OBDdata
[
"engineSpeed"
])
# 设置发动机转速
OBDObj
.
setVoltage
(
self
.
data
[
"other"
][
"valtage"
])
# 设置电瓶电压
msg
=
OBDObj
.
generateOBDReportCANMsg
()
msg
=
OBDObj
.
generateOBDReportCANMsg
()
return
msg
return
msg
...
...
templates/protocolTools/report/M_carSimulater_page.html
View file @
6421fbbd
...
@@ -30,6 +30,10 @@
...
@@ -30,6 +30,10 @@
button
.btn.btn-primary
{
button
.btn.btn-primary
{
margin-bottom
:
2px
;
margin-bottom
:
2px
;
}
}
h1
,
h2
,
h3
,
h4
,
h5
{
margin-top
:
5px
;
margin-bottom
:
5px
;
}
</style>
</style>
<div
id=
"container2"
style=
"width:83%;min-height:750px;float:left;_background:grey;margin-top:50px;"
>
<div
id=
"container2"
style=
"width:83%;min-height:750px;float:left;_background:grey;margin-top:50px;"
>
{% block content_02 %}
{% block content_02 %}
...
@@ -189,6 +193,20 @@
...
@@ -189,6 +193,20 @@
<label
style=
"margin-left:10px;color:red;"
><input
name=
"lngLatIsOk"
value=
"0"
type=
"radio"
onclick=
"changeLngLatIsOk(this)"
>
经纬度为0
</label>
<label
style=
"margin-left:10px;color:red;"
><input
name=
"lngLatIsOk"
value=
"0"
type=
"radio"
onclick=
"changeLngLatIsOk(this)"
>
经纬度为0
</label>
</span>
</span>
<span
style=
"margin-left:10px;display: inline-block;"
><button
type=
"button"
class=
"btn btn-primary"
onclick=
"changeTravelDirection()"
>
改变行驶方向
</button></span>
<span
style=
"margin-left:10px;display: inline-block;"
><button
type=
"button"
class=
"btn btn-primary"
onclick=
"changeTravelDirection()"
>
改变行驶方向
</button></span>
<span
style=
"margin-left:10px;display: inline-block;"
><label>
电瓶电压(v) :
</label><input
style=
"width:80px;margin-right:5px;"
id=
"change_voltage"
type=
"text"
class=
"form-control"
value=
"1.2"
><button
type=
"button"
class=
"btn btn-primary"
onclick=
"changeVoltage()"
>
改变电瓶电压
</button></span>
</div>
</div>
</div>
<div
style=
"display: block; width: 100%; border-width: 1px; border-style: solid; border-color: darkgray; border-radius: 10px; padding: 2px; margin-top: 5px;"
>
<h5><b>
其他操作:
</b>
<span
style=
"border-width:1px;border-style:solid;border-color:darkgray;border-radius:10px;padding:1px 10px;"
>
<label><input
name=
"otheroper"
type=
"radio"
value=
"0"
checked=
"checked"
onclick=
"isShowOtheroperCtrArea(this)"
/>
隐藏
</label>
<label
style=
"margin-left:10px;"
><input
name=
"otheroper"
type=
"radio"
value=
"1"
onclick=
"isShowOtheroperCtrArea(this)"
/>
显示
</label>
</span>
</h5>
<div
id=
"other_area"
style=
"display:none;"
>
<div
style=
"padding:10px;"
>
</div>
</div>
</div>
</div>
</div>
</div>
...
@@ -255,6 +273,10 @@ function getPageData(){
...
@@ -255,6 +273,10 @@ function getPageData(){
data
[
"
travelData
"
][
"
carSpeed
"
]
=
carSpeed
data
[
"
travelData
"
][
"
carSpeed
"
]
=
carSpeed
data
[
"
travelData
"
][
"
oilExpend
"
]
=
oilExpend
data
[
"
travelData
"
][
"
oilExpend
"
]
=
oilExpend
data
[
"
travelData
"
][
"
travelLoop
"
]
=
travelLoop
data
[
"
travelData
"
][
"
travelLoop
"
]
=
travelLoop
//其他默认数据
data
[
"
other
"
]
=
{}
var
valtage
=
1.2
*
100
data
[
"
other
"
][
"
valtage
"
]
=
valtage
return
data
;
return
data
;
}
}
//连接
//连接
...
@@ -1055,6 +1077,21 @@ function changeTravelDirection(){
...
@@ -1055,6 +1077,21 @@ function changeTravelDirection(){
url
=
"
/protocolTools/M_carSimulater_process/changeTravelDirection
"
;
url
=
"
/protocolTools/M_carSimulater_process/changeTravelDirection
"
;
sendjson
(
data
,
url
);
sendjson
(
data
,
url
);
}
}
//改变电瓶电压
function
changeVoltage
(){
var
data
=
{}
var
carId
=
$
(
"
#carId
"
).
val
()
data
[
"
carId
"
]
=
carId
//会话session数据
data
[
"
session
"
]
=
{}
data
[
"
other
"
]
=
{}
var
sessionId
=
$
(
"
#curSession
"
).
val
()
var
voltage
=
$
(
"
#change_voltage
"
).
val
()
data
[
"
session
"
][
"
sessionId
"
]
=
sessionId
data
[
"
other
"
][
"
voltage
"
]
=
voltage
url
=
"
/protocolTools/M_carSimulater_process/changeValtage
"
;
sendjson
(
data
,
url
);
}
</script>
</script>
{% endblock %}
{% endblock %}
</div>
</div>
...
...
views/protocolTools/M_carSimulater_process.py
View file @
6421fbbd
...
@@ -1449,3 +1449,47 @@ def changeTravelDirection():
...
@@ -1449,3 +1449,47 @@ def changeTravelDirection():
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'
)
##########################################
# 【接口类型】改变电瓶电压
##########################################
@
M_carSimulater_process
.
route
(
"/changeValtage"
,
methods
=
[
'POST'
])
def
changeValtage
():
params
=
request
.
get_data
()
params
=
json
.
loads
(
params
.
decode
(
"utf-8"
))
sessionId
=
params
[
"session"
][
"sessionId"
]
voltage
=
params
[
"other"
][
"voltage"
]
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
.
setVoltage
(
voltage
)
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