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
b7797ad1
Commit
b7797ad1
authored
May 19, 2020
by
liyuanhong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
M500 模拟器增加了经纬度设置为0的功能
parent
f6a8a2c6
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
55 additions
and
1 deletion
+55
-1
data/protocolTools/carData/M202003060520.json
data/protocolTools/carData/M202003060520.json
+1
-1
lib/socket/service/ProtocolSimulaterService.py
lib/socket/service/ProtocolSimulaterService.py
+9
-0
templates/protocolTools/report/M_carSimulater_page.html
templates/protocolTools/report/M_carSimulater_page.html
+18
-0
views/protocolTools/M_carSimulater_process.py
views/protocolTools/M_carSimulater_process.py
+27
-0
No files found.
data/protocolTools/carData/M202003060520.json
View file @
b7797ad1
{
"time"
:
{
"dateTime"
:
"2020-05-18 11:54:49"
,
"date"
:
"2020-05-18"
,
"time"
:
"11:54:49"
},
"curDayTravel"
:
{
"todayTotalMilleage"
:
20920
,
"todayTotalOil"
:
2020
,
"todayTotalTime"
:
1260
,
"theMilleage"
:
1000
,
"theOil"
:
100
,
"theTime"
:
60
},
"travelData"
:
{
"totalMilleage"
:
283737
,
"totalOil"
:
26847
,
"totalTime"
:
16782
},
"event"
:
{
"threeRapid"
:
{
"totalRapidlyAccelerate"
:
14
,
"totalSharpSlowdown"
:
13
,
"totalSharpTurn"
:
13
}}}
\ No newline at end of file
{
"time"
:
{
"dateTime"
:
"2020-05-19 11:09:47"
,
"date"
:
"2020-05-19"
,
"time"
:
"11:09:47"
},
"curDayTravel"
:
{
"todayTotalMilleage"
:
6190
,
"todayTotalOil"
:
595
,
"todayTotalTime"
:
373
,
"theMilleage"
:
83
,
"theOil"
:
8
,
"theTime"
:
5
},
"travelData"
:
{
"totalMilleage"
:
289927
,
"totalOil"
:
27442
,
"totalTime"
:
17155
},
"event"
:
{
"threeRapid"
:
{
"totalRapidlyAccelerate"
:
14
,
"totalSharpSlowdown"
:
13
,
"totalSharpTurn"
:
13
}}}
\ No newline at end of file
lib/socket/service/ProtocolSimulaterService.py
View file @
b7797ad1
...
...
@@ -45,6 +45,7 @@ class ProtocolSimulaterService():
'''
self
.
sendType
=
0
self
.
GPSValid
=
1
#用来控制GPS数据是有效还是无效 0:无效 1:有效
self
.
lngLatIsOk
=
1
#用来控制经纬度是否都为0 0:都为0 1:正常
# 定义要发送的obd数据
self
.
OBDdata
=
{
"fireStatus"
:
1
,
"ACCStatus"
:
0
,
"engineSpeed"
:
300
,
"speed"
:
0
,
"meterMileage"
:
6000
,
"totailMileage"
:
600
,
"totalOilExpen"
:
30
,
"totalRunTime"
:
10
}
# 定义初始的obd数据,与上面的OBD数据保持一致,主要用于汽车行驶过程中数据变化量的计算
...
...
@@ -82,6 +83,8 @@ class ProtocolSimulaterService():
self
.
sendType
=
data
def
setGPSValid
(
self
,
data
):
self
.
GPSValid
=
data
def
setLngLatIsOk
(
self
,
data
):
self
.
lngLatIsOk
=
data
...
...
@@ -463,6 +466,9 @@ class ProtocolSimulaterService():
gpsObj
=
GPSReport_protocol
(
DEV_ID
=
self
.
carId
,
WATER_CODE
=
self
.
sn
)
gpsObj
.
setLatitude
(
latitude
)
gpsObj
.
setLongitude
(
longtitude
)
if
self
.
lngLatIsOk
==
0
:
gpsObj
.
setLatitude
(
0
)
gpsObj
.
setLongitude
(
0
)
if
self
.
GPSValid
==
1
:
gpsObj
.
setGpsValid
(
1
)
elif
self
.
GPSValid
==
0
:
...
...
@@ -480,6 +486,9 @@ class ProtocolSimulaterService():
gpsObj
=
GPSReport_protocol
(
DEV_ID
=
self
.
carId
,
WATER_CODE
=
self
.
sn
)
gpsObj
.
setLatitude
(
latitude
)
gpsObj
.
setLongitude
(
longtitude
)
if
self
.
lngLatIsOk
==
0
:
gpsObj
.
setLatitude
(
0
)
gpsObj
.
setLongitude
(
0
)
if
self
.
GPSValid
==
1
:
gpsObj
.
setGpsValid
(
1
)
elif
self
.
GPSValid
==
0
:
...
...
templates/protocolTools/report/M_carSimulater_page.html
View file @
b7797ad1
...
...
@@ -170,6 +170,10 @@
<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>
</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;"
>
<label><input
name=
"lngLatIsOk"
value=
"1"
type=
"radio"
onclick=
"changeLngLatIsOk(this)"
checked=
"checked"
>
经纬度正常
</label>
<label
style=
"margin-left:10px;color:red;"
><input
name=
"lngLatIsOk"
value=
"0"
type=
"radio"
onclick=
"changeLngLatIsOk(this)"
>
经纬度为0
</label>
</span>
</div>
</div>
</div>
...
...
@@ -915,6 +919,20 @@ function changeGPSValid(e){
url
=
"
/protocolTools/M_carSimulater_process/controlGPSValid
"
;
sendjson
(
data
,
url
);
}
//控制经纬度为0还是正常
function
changeLngLatIsOk
(
e
){
var
data
=
{}
var
carId
=
$
(
"
#carId
"
).
val
()
var
lngLatIsOk
=
$
(
e
).
val
()
data
[
"
carId
"
]
=
carId
data
[
"
lngLatIsOk
"
]
=
lngLatIsOk
//会话session数据
data
[
"
session
"
]
=
{}
var
sessionId
=
$
(
"
#curSession
"
).
val
()
data
[
"
session
"
][
"
sessionId
"
]
=
sessionId
url
=
"
/protocolTools/M_carSimulater_process/controlLngLatIsOk
"
;
sendjson
(
data
,
url
);
}
</script>
{% endblock %}
</div>
...
...
views/protocolTools/M_carSimulater_process.py
View file @
b7797ad1
...
...
@@ -1112,3 +1112,30 @@ def controlGPSValid():
data
[
"status"
]
=
"4003"
data
[
"message"
]
=
"Error: 设置GPS有效信息失败!"
return
Response
(
json
.
dumps
(
data
),
mimetype
=
'application/json'
)
##########################################
# 【接口类型】控制经纬度是正常,还是为0
##########################################
@
M_carSimulater_process
.
route
(
"/controlLngLatIsOk"
,
methods
=
[
'POST'
])
def
controlLngLatIsOk
():
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
:
lngLatIsOk
=
int
(
params
[
"lngLatIsOk"
])
service
.
setLngLatIsOk
(
lngLatIsOk
)
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'
)
\ 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