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
bd8a4961
Commit
bd8a4961
authored
Jun 11, 2020
by
liyuanhong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
M500模拟器增加了改变行驶方向的功能
parent
ef9207fd
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
62 additions
and
4 deletions
+62
-4
lib/socket/service/ProtocolSimulaterService.py
lib/socket/service/ProtocolSimulaterService.py
+12
-3
templates/protocolTools/report/M_carSimulater_page.html
templates/protocolTools/report/M_carSimulater_page.html
+13
-0
views/protocolTools/M_carSimulater_process.py
views/protocolTools/M_carSimulater_process.py
+37
-1
No files found.
lib/socket/service/ProtocolSimulaterService.py
View file @
bd8a4961
...
@@ -90,6 +90,8 @@ class ProtocolSimulaterService():
...
@@ -90,6 +90,8 @@ class ProtocolSimulaterService():
self
.
GPSValid
=
data
self
.
GPSValid
=
data
def
setLngLatIsOk
(
self
,
data
):
def
setLngLatIsOk
(
self
,
data
):
self
.
lngLatIsOk
=
data
self
.
lngLatIsOk
=
data
def
setTravelDirection
(
self
,
data
):
self
.
travelDirection
=
data
...
@@ -105,6 +107,8 @@ class ProtocolSimulaterService():
...
@@ -105,6 +107,8 @@ class ProtocolSimulaterService():
return
self
.
sn
return
self
.
sn
def
getCarData
(
self
):
def
getCarData
(
self
):
return
self
.
carData
return
self
.
carData
def
getTravelDirection
(
self
):
return
self
.
travelDirection
#######################################################
#######################################################
# type 为0表示正常发送,type为1表示数据写入本地
# type 为0表示正常发送,type为1表示数据写入本地
...
@@ -160,9 +164,14 @@ class ProtocolSimulaterService():
...
@@ -160,9 +164,14 @@ class ProtocolSimulaterService():
self
.
gpsLineIndex
=
self
.
gpsLineIndex
-
1
#反向行驶
self
.
gpsLineIndex
=
self
.
gpsLineIndex
-
1
#反向行驶
elif
self
.
gpsLineIndex
==
len
(
self
.
gpsLine
)
or
self
.
gpsLineIndex
==
-
1
:
#如果反向行驶和反向行驶刚好跑完
elif
self
.
gpsLineIndex
==
len
(
self
.
gpsLine
)
or
self
.
gpsLineIndex
==
-
1
:
#如果反向行驶和反向行驶刚好跑完
if
int
(
self
.
data
[
"travelData"
][
"travelLoop"
])
==
0
:
#没有设置循环行驶
if
int
(
self
.
data
[
"travelData"
][
"travelLoop"
])
==
0
:
#没有设置循环行驶
if
self
.
travelDirection
==
0
:
self
.
gpsLineIndex
=
self
.
gpsLineIndex
-
1
self
.
gpsLineIndex
=
self
.
gpsLineIndex
-
1
self
.
stopTravel
()
self
.
stopTravel
()
self
.
websocket
.
sendMsgToClient
(
"gps轨迹跑完,自动停止行驶!"
,
self
.
websocketId
)
self
.
websocket
.
sendMsgToClient
(
"gps轨迹跑完,自动停止行驶!"
,
self
.
websocketId
)
else
:
self
.
gpsLineIndex
=
self
.
gpsLineIndex
+
1
self
.
stopTravel
()
self
.
websocket
.
sendMsgToClient
(
"gps轨迹跑完,自动停止行驶!"
,
self
.
websocketId
)
else
:
#设置了循环行驶
else
:
#设置了循环行驶
if
self
.
travelDirection
==
0
:
if
self
.
travelDirection
==
0
:
self
.
gpsLineIndex
=
self
.
gpsLineIndex
-
1
self
.
gpsLineIndex
=
self
.
gpsLineIndex
-
1
...
...
templates/protocolTools/report/M_carSimulater_page.html
View file @
bd8a4961
...
@@ -185,6 +185,7 @@
...
@@ -185,6 +185,7 @@
<label><input
name=
"lngLatIsOk"
value=
"1"
type=
"radio"
onclick=
"changeLngLatIsOk(this)"
checked=
"checked"
>
经纬度正常
</label>
<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>
<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>
</div>
</div>
</div>
</div>
</div>
</div>
...
@@ -1000,6 +1001,18 @@ function changeLngLatIsOk(e){
...
@@ -1000,6 +1001,18 @@ function changeLngLatIsOk(e){
url
=
"
/protocolTools/M_carSimulater_process/controlLngLatIsOk
"
;
url
=
"
/protocolTools/M_carSimulater_process/controlLngLatIsOk
"
;
sendjson
(
data
,
url
);
sendjson
(
data
,
url
);
}
}
//改变行驶方向
function
changeTravelDirection
(){
var
data
=
{}
var
carId
=
$
(
"
#carId
"
).
val
()
data
[
"
carId
"
]
=
carId
//会话session数据
data
[
"
session
"
]
=
{}
var
sessionId
=
$
(
"
#curSession
"
).
val
()
data
[
"
session
"
][
"
sessionId
"
]
=
sessionId
url
=
"
/protocolTools/M_carSimulater_process/changeTravelDirection
"
;
sendjson
(
data
,
url
);
}
</script>
</script>
{% endblock %}
{% endblock %}
</div>
</div>
...
...
views/protocolTools/M_carSimulater_process.py
View file @
bd8a4961
...
@@ -1337,3 +1337,39 @@ def controlLngLatIsOk():
...
@@ -1337,3 +1337,39 @@ def controlLngLatIsOk():
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
(
"/changeTravelDirection"
,
methods
=
[
'POST'
])
def
changeTravelDirection
():
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
:
travelDirection
=
service
.
getTravelDirection
()
if
travelDirection
==
0
:
service
.
setTravelDirection
(
1
)
else
:
service
.
setTravelDirection
(
0
)
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