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
bf0c5e45
Commit
bf0c5e45
authored
Jul 10, 2020
by
liyuanhong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
M500模拟器增加固定在当前位置的功能
parent
1f519742
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
73 additions
and
8 deletions
+73
-8
data/protocolTools/carData/M202003060520.json
data/protocolTools/carData/M202003060520.json
+1
-1
lib/socket/service/ProtocolSimulaterService.py
lib/socket/service/ProtocolSimulaterService.py
+8
-5
templates/protocolTools/report/M_carSimulater_page.html
templates/protocolTools/report/M_carSimulater_page.html
+32
-2
views/protocolTools/M_carSimulater_process.py
views/protocolTools/M_carSimulater_process.py
+32
-0
No files found.
data/protocolTools/carData/M202003060520.json
View file @
bf0c5e45
{
"time"
:
{
"dateTime"
:
"2020-07-10 10:37:16"
,
"date"
:
"2020-07-10"
,
"time"
:
"10:37:16"
},
"curDayTravel"
:
{
"todayTotalMilleage"
:
2573
,
"todayTotalOil"
:
248
,
"todayTotalTime"
:
155
,
"theMilleage"
:
581
,
"theOil"
:
56
,
"theTime"
:
35
},
"travelData"
:
{
"totalMilleage"
:
566997
,
"totalOil"
:
51642
,
"totalTime"
:
34013
},
"event"
:
{
"threeRapid"
:
{
"totalRapidlyAccelerate"
:
43
,
"totalSharpSlowdown"
:
31
,
"totalSharpTurn"
:
34
}}}
\ No newline at end of file
{
"time"
:
{
"dateTime"
:
"2020-07-10 10:37:16"
,
"date"
:
"2020-07-10"
,
"time"
:
"10:37:16"
},
"curDayTravel"
:
{
"todayTotalMilleage"
:
6554
,
"todayTotalOil"
:
539
,
"todayTotalTime"
:
401
,
"theMilleage"
:
1904
,
"theOil"
:
119
,
"theTime"
:
119
},
"travelData"
:
{
"totalMilleage"
:
570978
,
"totalOil"
:
51933
,
"totalTime"
:
34259
},
"event"
:
{
"threeRapid"
:
{
"totalRapidlyAccelerate"
:
43
,
"totalSharpSlowdown"
:
31
,
"totalSharpTurn"
:
34
}}}
\ No newline at end of file
lib/socket/service/ProtocolSimulaterService.py
View file @
bf0c5e45
...
...
@@ -40,6 +40,7 @@ class ProtocolSimulaterService():
self
.
sn
=
0
#消息流水号
self
.
travelDirection
=
0
#行驶方向,0表示正向行驶,1表示反向行驶
self
.
directAngle
=
60
#汽车方向角
self
.
fixPosition
=
0
#是否固定当前GPS,0:否,1:是
'''
为0表示正常发送,type为1表示数据写入本地
# 用来控制发送消息的方式(是正常发送,还是将发送的数据保存到本地,不发送)
...
...
@@ -94,7 +95,8 @@ class ProtocolSimulaterService():
self
.
travelDirection
=
data
def
setVoltage
(
self
,
data
):
self
.
data
[
"other"
][
"valtage"
]
=
data
def
setFixPosition
(
self
,
data
):
self
.
fixPosition
=
data
def
getWebsocket
(
self
):
...
...
@@ -160,6 +162,7 @@ class ProtocolSimulaterService():
longitude
=
self
.
gpsLine
[
self
.
gpsLineIndex
][
"lng"
]
# print("经度:" + str(longitude) + " 维度:" + str(latitude))
gpsMsg
=
self
.
genGPSMsg
(
latitude
,
longitude
)
if
self
.
fixPosition
==
0
:
#是否固定当前位置的判断
if
self
.
travelDirection
==
0
:
self
.
gpsLineIndex
=
self
.
gpsLineIndex
+
1
#正向行驶
else
:
...
...
templates/protocolTools/report/M_carSimulater_page.html
View file @
bf0c5e45
...
...
@@ -194,6 +194,7 @@
</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=
"12"
><button
type=
"button"
class=
"btn btn-primary"
onclick=
"changeVoltage()"
>
改变电瓶电压
</button></span>
<span
style=
"margin-left:10px;display: inline-block;"
><button
title=
"点击后,车机将会在当前位置发送gps和obd数据"
type=
"button"
class=
"btn btn-primary"
onclick=
"fixCurPosition(this)"
>
固定在当前位置
</button></span>
</div>
</div>
</div>
...
...
@@ -1051,7 +1052,6 @@ function storeMsg(){
}
});
}
}
//控制GPS是否有效
function
changeGPSValid
(
e
){
...
...
@@ -1108,7 +1108,37 @@ function changeVoltage(){
url
=
"
/protocolTools/M_carSimulater_process/changeValtage
"
;
sendjson
(
data
,
url
);
}
//控制是否固定在当前位置
function
fixCurPosition
(
e
){
var
butTxt
=
$
(
e
).
text
()
if
(
butTxt
==
"
固定在当前位置
"
){
var
data
=
{}
var
carId
=
$
(
"
#carId
"
).
val
()
data
[
"
carId
"
]
=
carId
data
[
"
fixPosition
"
]
=
1
//会话session数据
data
[
"
session
"
]
=
{}
var
sessionId
=
$
(
"
#curSession
"
).
val
()
data
[
"
session
"
][
"
sessionId
"
]
=
sessionId
url
=
"
/protocolTools/M_carSimulater_process/fixCurPosition
"
;
var
host
=
window
.
location
.
host
;
sendjson
(
data
,
url
);
$
(
e
).
text
(
"
取消固定在当前位置
"
)
}
else
{
var
data
=
{}
var
carId
=
$
(
"
#carId
"
).
val
()
data
[
"
carId
"
]
=
carId
data
[
"
fixPosition
"
]
=
0
//会话session数据
data
[
"
session
"
]
=
{}
var
sessionId
=
$
(
"
#curSession
"
).
val
()
data
[
"
session
"
][
"
sessionId
"
]
=
sessionId
url
=
"
/protocolTools/M_carSimulater_process/fixCurPosition
"
;
var
host
=
window
.
location
.
host
;
sendjson
(
data
,
url
);
$
(
e
).
text
(
"
取消固定在当前位置
"
)
}
}
// -------------------------------- 其他操作js代码-------------------------------------------
//设置隐藏或显示其他操作区域
function
isShowOtheroperCtrArea
(
e
){
...
...
views/protocolTools/M_carSimulater_process.py
View file @
bf0c5e45
...
...
@@ -1484,6 +1484,38 @@ def changeValtage():
data
[
"message"
]
=
"Error: 改变电瓶电压失败!"
return
Response
(
json
.
dumps
(
data
),
mimetype
=
'application/json'
)
##########################################
# 【接口类型】固定或者取消固定当前GPS点
##########################################
@
M_carSimulater_process
.
route
(
"/fixCurPosition"
,
methods
=
[
'POST'
])
def
fixCurPosition
():
params
=
request
.
get_data
()
params
=
json
.
loads
(
params
.
decode
(
"utf-8"
))
sessionId
=
params
[
"session"
][
"sessionId"
]
fixPosition
=
params
[
"fixPosition"
]
data
=
{}
if
not
sessionId
in
connects
.
keys
():
data
[
"status"
]
=
"4003"
data
[
"message"
]
=
"Error: 未启动服务,不可设置是否固定gps点!"
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: 汽车还未行驶,不可设置是否固定gps点!"
elif
travelStatus
==
1
:
try
:
service
.
setFixPosition
(
fixPosition
)
data
[
"status"
]
=
"200"
data
[
"message"
]
=
"设置是否固定gps点成功!"
except
BaseException
as
e
:
# 打印异常信息
traceback
.
print_exc
()
data
[
"status"
]
=
"4003"
data
[
"message"
]
=
"Error: 设置是否固定gps点失败!"
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