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
d57114d3
Commit
d57114d3
authored
Apr 09, 2020
by
liyuanhong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
模拟器行驶参数开发完成
parent
d3f73f3a
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
108 additions
and
72 deletions
+108
-72
data/protocolTools/GPSLines/6_先涛的车轨迹(短).txt
data/protocolTools/GPSLines/6_先涛的车轨迹(短).txt
+2
-0
lib/socket/service/ProtocolSimulaterService.py
lib/socket/service/ProtocolSimulaterService.py
+42
-9
templates/m300Tools/report/P_version_m300_page.html
templates/m300Tools/report/P_version_m300_page.html
+2
-2
templates/protocolTools/report/M_carSimulater_page.html
templates/protocolTools/report/M_carSimulater_page.html
+45
-53
views/protocolTools/M_carSimulater_process.py
views/protocolTools/M_carSimulater_process.py
+17
-8
No files found.
data/protocolTools/GPSLines/6_先涛的车轨迹(短).txt
0 → 100644
View file @
d57114d3
{"name": "gpsLine", "GPSLine": [{"lng": "106.279711", "lat": "29.585448\n"}, {"lng": "106.279711", "lat": "29.585448\n"}, {"lng": "106.279711", "lat": "29.585448\n"}, {"lng": "106.279711", "lat": "29.585448\n"}, {"lng": "106.279711", "lat": "29.585448\n"}, {"lng": "106.279711", "lat": "29.585448\n"}, {"lng": "106.279711", "lat": "29.585448\n"}, {"lng": "106.279711", "lat": "29.585448\n"}, {"lng": "106.279711", "lat": "29.585448\n"}, {"lng": "106.279711", "lat": "29.585448\n"}, {"lng": "106.279711", "lat": "29.585448\n"}, {"lng": "106.287903", "lat": "29.586623\n"}, {"lng": "106.289041", "lat": "29.586608\n"}, {"lng": "106.293958", "lat": "29.586631\n"}, {"lng": "106.296643", "lat": "29.586603\n"}, {"lng": "106.29702", "lat": "29.586588\n"}, {"lng": "106.297076", "lat": "29.586625\n"}, {"lng": "106.297116", "lat": "29.586675\n"}, {"lng": "106.297148", "lat": "29.58674\n"}, {"lng": "106.297161", "lat": "29.586818\n"}, {"lng": "106.297168", "lat": "29.586906\n"}, {"lng": "106.297275", "lat": "29.58793\n"}, {"lng": "106.297461", "lat": "29.588408\n"}, {"lng": "106.297783", "lat": "29.588835\n"}, {"lng": "106.298863", "lat": "29.589848\n"}, {"lng": "106.299571", "lat": "29.59043\n"}, {"lng": "106.30007", "lat": "29.590666\n"}, {"lng": "106.300655", "lat": "29.59083\n"}, {"lng": "106.301408", "lat": "29.59091\n"}, {"lng": "106.301695", "lat": "29.590925\n"}, {"lng": "106.303111", "lat": "29.590928\n"}, {"lng": "106.30319", "lat": "29.590958\n"}, {"lng": "106.30325", "lat": "29.591001\n"}, {"lng": "106.303288", "lat": "29.59106\n"}, {"lng": "106.303306", "lat": "29.591125\n"}, {"lng": "106.303311", "lat": "29.591196\n"}, {"lng": "106.303321", "lat": "29.59202\n"}, {"lng": "106.303418", "lat": "29.594665\n"}, {"lng": "106.303493", "lat": "29.596323\n"}, {"lng": "106.30351", "lat": "29.597693\n"}]}
\ No newline at end of file
lib/socket/service/ProtocolSimulaterService.py
View file @
d57114d3
...
@@ -20,6 +20,7 @@ from lib.socket.service.websocket_service import Websocket_service
...
@@ -20,6 +20,7 @@ from lib.socket.service.websocket_service import Websocket_service
class
ProtocolSimulaterService
():
class
ProtocolSimulaterService
():
def
__init__
(
self
):
def
__init__
(
self
):
self
.
data
=
{}
#用来接收模拟器传过来的参数
self
.
socket
=
None
self
.
socket
=
None
self
.
sendDur
=
5
#设置默认多久发一条消息
self
.
sendDur
=
5
#设置默认多久发一条消息
self
.
serviceStatus
=
0
#服务状态,0表示未启动,1表示启动
self
.
serviceStatus
=
0
#服务状态,0表示未启动,1表示启动
...
@@ -30,9 +31,9 @@ class ProtocolSimulaterService():
...
@@ -30,9 +31,9 @@ class ProtocolSimulaterService():
self
.
travelStatus
=
0
#0,表示为行驶,1表示开始行驶
self
.
travelStatus
=
0
#0,表示为行驶,1表示开始行驶
self
.
carId
=
""
#车机号
self
.
carId
=
""
#车机号
self
.
sn
=
0
#消息流水号
self
.
sn
=
0
#消息流水号
self
.
travelDirection
=
0
#行驶方向,0表示正向行驶,1表示反向行驶
# 定义要发送的obd数据
# 定义要发送的obd数据
self
.
OBDdata
=
{
"fireStatus"
:
1
,
"ACCStatus"
:
0
,
"engineSpeed"
:
300
,
"speed"
:
0
,
"meterMileage"
:
6000
,
"totailMileage"
:
600
,
"totalOilExpen"
:
30
,
"totalRunTime"
:
10
}
self
.
OBDdata
=
{
"fireStatus"
:
1
,
"ACCStatus"
:
0
,
"engineSpeed"
:
300
,
"speed"
:
0
,
"meterMileage"
:
6000
,
"totailMileage"
:
600
,
"totalOilExpen"
:
30
,
"totalRunTime"
:
10
}
self
.
OBDdataIndex
=
0
#发发送OBD数据的索引
#设置套接字
#设置套接字
def
setSocket
(
self
,
data
):
def
setSocket
(
self
,
data
):
...
@@ -43,9 +44,12 @@ class ProtocolSimulaterService():
...
@@ -43,9 +44,12 @@ class ProtocolSimulaterService():
self
.
timeout
=
data
self
.
timeout
=
data
def
setCarId
(
self
,
data
):
def
setCarId
(
self
,
data
):
self
.
carId
=
data
self
.
carId
=
data
def
setData
(
self
,
data
):
self
.
data
=
data
def
getWebsocket
(
self
):
def
getWebsocket
(
self
):
return
self
.
websocket
return
self
.
websocket
def
sendMsg
(
self
,
msg
):
def
sendMsg
(
self
,
msg
):
self
.
socket
.
setTimeOut
(
self
.
timeout
)
self
.
socket
.
setTimeOut
(
self
.
timeout
)
self
.
socket
.
send
(
msg
)
self
.
socket
.
send
(
msg
)
...
@@ -60,7 +64,6 @@ class ProtocolSimulaterService():
...
@@ -60,7 +64,6 @@ class ProtocolSimulaterService():
def
serviceSend
(
self
):
def
serviceSend
(
self
):
while
self
.
serviceStatus
==
1
:
while
self
.
serviceStatus
==
1
:
# msg = "4040000b00034d1215010100010003f50b"
gpsMsg
=
""
gpsMsg
=
""
OBDMsg
=
""
OBDMsg
=
""
if
self
.
travelStatus
==
0
:
if
self
.
travelStatus
==
0
:
...
@@ -68,23 +71,53 @@ class ProtocolSimulaterService():
...
@@ -68,23 +71,53 @@ class ProtocolSimulaterService():
longitude
=
self
.
gpsLine
[
self
.
gpsLineIndex
][
"lng"
]
longitude
=
self
.
gpsLine
[
self
.
gpsLineIndex
][
"lng"
]
gpsMsg
=
self
.
genGPSMsg
(
latitude
,
longitude
)
gpsMsg
=
self
.
genGPSMsg
(
latitude
,
longitude
)
elif
self
.
travelStatus
==
1
:
elif
self
.
travelStatus
==
1
:
if
self
.
gpsLineIndex
<
len
(
self
.
gpsLine
):
if
self
.
gpsLineIndex
<
len
(
self
.
gpsLine
)
and
self
.
gpsLineIndex
!=
-
1
:
OBDMsg
=
self
.
genOBDMsg
(
self
.
OBDdata
[
"fireStatus"
],
self
.
OBDdata
[
"ACCStatus"
],
self
.
OBDdata
[
"engineSpeed"
],
\
OBDMsg
=
self
.
genOBDMsg
(
self
.
OBDdata
[
"fireStatus"
],
self
.
OBDdata
[
"ACCStatus"
],
self
.
OBDdata
[
"engineSpeed"
],
\
self
.
OBDdata
[
"speed"
],
self
.
OBDdata
[
"meterMileage"
],
self
.
OBDdata
[
"totailMileage"
],
\
self
.
OBDdata
[
"speed"
],
self
.
OBDdata
[
"meterMileage"
],
self
.
OBDdata
[
"totailMileage"
],
\
self
.
OBDdata
[
"totalOilExpen"
],
self
.
OBDdata
[
"totalRunTime"
])
self
.
OBDdata
[
"totalOilExpen"
],
self
.
OBDdata
[
"totalRunTime"
])
self
.
OBDdata
[
"engineSpeed"
]
=
3000
self
.
OBDdata
[
"engineSpeed"
]
=
3000
self
.
OBDdata
[
"speed"
]
=
60
self
.
OBDdata
[
"speed"
]
=
int
(
self
.
data
[
"travelData"
][
"carSpeed"
])
self
.
OBDdata
[
"meterMileage"
]
=
self
.
OBDdata
[
"meterMileage"
]
+
int
(
self
.
sendDur
*
(
self
.
OBDdata
[
"speed"
]
*
1000
/
3600
))
self
.
OBDdata
[
"meterMileage"
]
=
self
.
OBDdata
[
"meterMileage"
]
+
int
(
self
.
sendDur
*
(
self
.
OBDdata
[
"speed"
]
*
1000
/
3600
))
self
.
OBDdata
[
"totailMileage"
]
=
self
.
OBDdata
[
"totailMileage"
]
+
int
(
self
.
sendDur
*
(
self
.
OBDdata
[
"speed"
]
*
1000
/
3600
))
self
.
OBDdata
[
"totailMileage"
]
=
self
.
OBDdata
[
"totailMileage"
]
+
int
(
self
.
sendDur
*
(
self
.
OBDdata
[
"speed"
]
*
1000
/
3600
))
self
.
OBDdata
[
"totalOilExpen"
]
=
self
.
OBDdata
[
"totalOilExpen"
]
+
int
((
self
.
sendDur
*
(
self
.
OBDdata
[
"speed"
]
*
1000
/
3600
))
*
(
1000
/
(
15
*
1000
)))
oilExpend
=
int
(
self
.
data
[
"travelData"
][
"oilExpend"
])
self
.
OBDdata
[
"totalOilExpen"
]
=
self
.
OBDdata
[
"totalOilExpen"
]
+
int
((
self
.
sendDur
*
(
self
.
OBDdata
[
"speed"
]
*
1000
/
3600
))
*
(
1000
/
(
oilExpend
*
1000
)))
self
.
OBDdata
[
"totalRunTime"
]
=
self
.
OBDdata
[
"totalRunTime"
]
+
self
.
sendDur
self
.
OBDdata
[
"totalRunTime"
]
=
self
.
OBDdata
[
"totalRunTime"
]
+
self
.
sendDur
latitude
=
self
.
gpsLine
[
self
.
gpsLineIndex
][
"lat"
]
latitude
=
self
.
gpsLine
[
self
.
gpsLineIndex
][
"lat"
]
longitude
=
self
.
gpsLine
[
self
.
gpsLineIndex
][
"lng"
]
longitude
=
self
.
gpsLine
[
self
.
gpsLineIndex
][
"lng"
]
gpsMsg
=
self
.
genGPSMsg
(
latitude
,
longitude
)
gpsMsg
=
self
.
genGPSMsg
(
latitude
,
longitude
)
self
.
gpsLineIndex
=
self
.
gpsLineIndex
+
1
if
self
.
travelDirection
==
0
:
elif
self
.
gpsLineIndex
==
len
(
self
.
gpsLine
):
self
.
gpsLineIndex
=
self
.
gpsLineIndex
+
1
#正向行驶
else
:
self
.
gpsLineIndex
=
self
.
gpsLineIndex
-
1
#反向行驶
elif
self
.
gpsLineIndex
==
len
(
self
.
gpsLine
)
or
self
.
gpsLineIndex
==
-
1
:
if
int
(
self
.
data
[
"travelData"
][
"travelLoop"
])
==
0
:
self
.
stopTravel
()
self
.
stopTravel
()
self
.
websocket
.
send
(
"gps轨迹跑完,自动停止行驶!"
)
self
.
websocket
.
send
(
"gps轨迹跑完,自动停止行驶!"
)
else
:
if
self
.
travelDirection
==
0
:
self
.
gpsLineIndex
=
self
.
gpsLineIndex
-
1
self
.
travelDirection
=
1
self
.
websocket
.
send
(
"gps轨迹正向行驶跑完,变换行驶方向......"
)
else
:
self
.
gpsLineIndex
=
self
.
gpsLineIndex
+
1
self
.
travelDirection
=
0
self
.
websocket
.
send
(
"gps轨迹反向行驶跑完,变换行驶方向......"
)
OBDMsg
=
self
.
genOBDMsg
(
self
.
OBDdata
[
"fireStatus"
],
self
.
OBDdata
[
"ACCStatus"
],
self
.
OBDdata
[
"engineSpeed"
],
\
self
.
OBDdata
[
"speed"
],
self
.
OBDdata
[
"meterMileage"
],
self
.
OBDdata
[
"totailMileage"
],
\
self
.
OBDdata
[
"totalOilExpen"
],
self
.
OBDdata
[
"totalRunTime"
])
self
.
OBDdata
[
"engineSpeed"
]
=
3000
self
.
OBDdata
[
"speed"
]
=
int
(
self
.
data
[
"travelData"
][
"carSpeed"
])
self
.
OBDdata
[
"meterMileage"
]
=
self
.
OBDdata
[
"meterMileage"
]
+
int
(
self
.
sendDur
*
(
self
.
OBDdata
[
"speed"
]
*
1000
/
3600
))
self
.
OBDdata
[
"totailMileage"
]
=
self
.
OBDdata
[
"totailMileage"
]
+
int
(
self
.
sendDur
*
(
self
.
OBDdata
[
"speed"
]
*
1000
/
3600
))
oilExpend
=
int
(
self
.
data
[
"travelData"
][
"oilExpend"
])
self
.
OBDdata
[
"totalOilExpen"
]
=
self
.
OBDdata
[
"totalOilExpen"
]
+
int
(
(
self
.
sendDur
*
(
self
.
OBDdata
[
"speed"
]
*
1000
/
3600
))
*
(
1000
/
(
oilExpend
*
1000
)))
self
.
OBDdata
[
"totalRunTime"
]
=
self
.
OBDdata
[
"totalRunTime"
]
+
self
.
sendDur
latitude
=
self
.
gpsLine
[
self
.
gpsLineIndex
][
"lat"
]
longitude
=
self
.
gpsLine
[
self
.
gpsLineIndex
][
"lng"
]
gpsMsg
=
self
.
genGPSMsg
(
latitude
,
longitude
)
if
OBDMsg
!=
""
:
if
OBDMsg
!=
""
:
self
.
sendMsg
(
OBDMsg
)
self
.
sendMsg
(
OBDMsg
)
self
.
sn
=
self
.
sn
+
1
self
.
sn
=
self
.
sn
+
1
...
...
templates/m300Tools/report/P_version_m300_page.html
View file @
d57114d3
...
@@ -20,8 +20,8 @@
...
@@ -20,8 +20,8 @@
<li><label>
硬件版本:
</label><input
id=
"HWVersion"
type=
"text"
class=
"form-control"
value=
"M1.0"
></li>
<li><label>
硬件版本:
</label><input
id=
"HWVersion"
type=
"text"
class=
"form-control"
value=
"M1.0"
></li>
<li><label>
GSM 型号:
</label><input
id=
"GSMType"
type=
"text"
class=
"form-control"
value=
"GSM_type_123456"
></li>
<li><label>
GSM 型号:
</label><input
id=
"GSMType"
type=
"text"
class=
"form-control"
value=
"GSM_type_123456"
></li>
<li><label>
车系车型ID:
</label><input
id=
"carType"
type=
"text"
class=
"form-control"
value=
"150D"
></li>
<li><label>
车系车型ID:
</label><input
id=
"carType"
type=
"text"
class=
"form-control"
value=
"150D"
></li>
<li><label
style=
"word-break:break-all;font-size:1
2
px;"
>
发动机编码类别:
</label><input
id=
"engineCode"
type=
"text"
class=
"form-control"
value=
"1"
></li>
<li><label
style=
"word-break:break-all;font-size:1
0
px;"
>
发动机编码类别:
</label><input
id=
"engineCode"
type=
"text"
class=
"form-control"
value=
"1"
></li>
<li
style=
"width:350px;"
><label
style=
"word-break:break-all;font-size:1
2
px;"
>
汽车VIN码或发动机ECU编码:
</label><input
style=
"width:250px;"
id=
"VINCode"
type=
"text"
class=
"form-control"
value=
"VIN_CODE_01234567890"
></li>
<li
style=
"width:350px;"
><label
style=
"word-break:break-all;font-size:1
0
px;"
>
汽车VIN码或发动机ECU编码:
</label><input
style=
"width:250px;"
id=
"VINCode"
type=
"text"
class=
"form-control"
value=
"VIN_CODE_01234567890"
></li>
</ul>
</ul>
<H3
style=
"border-bottom: 1px solid #eee;"
>
控制:
</H3>
<H3
style=
"border-bottom: 1px solid #eee;"
>
控制:
</H3>
<div
style=
"width:100%;padding:5px;margin-top:10px;"
>
<div
style=
"width:100%;padding:5px;margin-top:10px;"
>
...
...
templates/protocolTools/report/M_carSimulater_page.html
View file @
d57114d3
...
@@ -79,6 +79,14 @@
...
@@ -79,6 +79,14 @@
<!-- <div style="display: block;margin:10px; width: 95%; border-width: 1px; border-style: solid; border-color: darkgray; border-radius: 10px; padding: 2px; margin-top: 5px;">-->
<!-- <div style="display: block;margin:10px; width: 95%; border-width: 1px; border-style: solid; border-color: darkgray; border-radius: 10px; padding: 2px; margin-top: 5px;">-->
<!-- </div>-->
<!-- </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></h5>
<span><label>
速度(Km/h):
</label><input
type=
"text"
id=
"carSpeed"
class=
"form-control"
style=
"display:inline;width:80px;"
value=
"60"
/></span>
<span><label>
油耗(Km/L):
</label><input
type=
"text"
id=
"oilExpend"
class=
"form-control"
style=
"display:inline;width:80px;"
value=
"10"
/></span>
<span><label>
是否循环行驶:
</label><select
style=
"width:80px;"
id=
"travelLoop"
class=
"form-control"
>
<option
value=
"0"
>
否
</option>
<option
value=
"1"
>
是
</option></select><label
style=
"font-size:9px;width: 100px;"
>
开启后会在所选择的轨迹上来回行驶
</label></span>
</div>
<div
style=
"width:100%;padding-bottom:10px;border-bottom: 1px solid #eee;"
>
<div
style=
"width:100%;padding-bottom:10px;border-bottom: 1px solid #eee;"
>
<h3>
操作:
</h3>
<h3>
操作:
</h3>
<button
id=
"connect_B"
type=
"button"
class=
"btn btn-primary"
onclick=
"connect()"
>
1、连网
</button>
<button
id=
"connect_B"
type=
"button"
class=
"btn btn-primary"
onclick=
"connect()"
>
1、连网
</button>
...
@@ -98,33 +106,18 @@
...
@@ -98,33 +106,18 @@
</div>
</div>
</div>
</div>
<script>
<script>
//连接
//通过函数获取页面参数
function
connect
(){
function
getPageData
(){
var
data
=
{};
var
carId
=
$
(
"
#carId
"
).
val
()
var
carId
=
$
(
"
#carId
"
).
val
()
var
WATER_CODE
=
$
(
"
#WATER_CODE
"
).
val
()
var
WATER_CODE
=
$
(
"
#WATER_CODE
"
).
val
()
var
durTime
=
$
(
"
#durTime
"
).
val
()
var
durTime
=
$
(
"
#durTime
"
).
val
()
var
timeout
=
$
(
"
#timeout
"
).
val
()
var
timeout
=
$
(
"
#timeout
"
).
val
()
data
=
{};
data
[
"
carId
"
]
=
carId
data
[
"
carId
"
]
=
carId
data
[
"
WATER_CODE
"
]
=
WATER_CODE
data
[
"
WATER_CODE
"
]
=
WATER_CODE
data
[
"
durTime
"
]
=
durTime
data
[
"
durTime
"
]
=
durTime
data
[
"
timeout
"
]
=
timeout
data
[
"
timeout
"
]
=
timeout
url
=
"
/protocolTools/M_carSimulater_process/createConect
"
;
send
(
data
,
url
);
//setTimeout(function(){
// WebSocketTest()
//},1000); //1秒之后启动websocket连接
WebSocketTest
()
$
(
"
#curStatus
"
).
val
(
"
连网
"
)
}
//登录
function
login
(){
var
data
=
{};
var
carId
=
$
(
"
#carId
"
).
val
()
var
WATER_CODE
=
$
(
"
#WATER_CODE
"
).
val
()
var
durTime
=
$
(
"
#durTime
"
).
val
()
//登录数据
//登录数据
data
[
"
login
"
]
=
{}
data
[
"
login
"
]
=
{}
var
cpuId
=
$
(
"
#cpuId
"
).
val
()
var
cpuId
=
$
(
"
#cpuId
"
).
val
()
...
@@ -142,43 +135,50 @@ function login(){
...
@@ -142,43 +135,50 @@ function login(){
var
GSM
=
$
(
"
#GSM
"
).
val
()
var
GSM
=
$
(
"
#GSM
"
).
val
()
data
[
"
version
"
][
"
verInfo
"
]
=
verInfo
data
[
"
version
"
][
"
verInfo
"
]
=
verInfo
data
[
"
version
"
][
"
compileDate
"
]
=
compileDate
data
[
"
version
"
][
"
compileDate
"
]
=
compileDate
$
(
"
#curStatus
"
).
val
(
"
登录
"
)
data
[
"
version
"
][
"
GSM
"
]
=
GSM
data
[
"
version
"
][
"
GSM
"
]
=
GSM
data
[
"
carId
"
]
=
carId
//GPS轨迹数据
data
[
"
WATER_CODE
"
]
=
WATER_CODE
var
gpsLine
=
$
(
"
#selectGPSLine
"
).
val
()
data
[
"
durTime
"
]
=
durTime
data
[
"
gpsLine
"
]
=
gpsLine
//行驶参数数据
data
[
"
travelData
"
]
=
{}
var
carSpeed
=
$
(
"
#carSpeed
"
).
val
()
var
oilExpend
=
$
(
"
#oilExpend
"
).
val
()
var
travelLoop
=
$
(
"
#travelLoop
"
).
val
()
data
[
"
travelData
"
][
"
carSpeed
"
]
=
carSpeed
data
[
"
travelData
"
][
"
oilExpend
"
]
=
oilExpend
data
[
"
travelData
"
][
"
travelLoop
"
]
=
travelLoop
return
data
;
}
//连接
function
connect
(){
var
data
=
getPageData
()
url
=
"
/protocolTools/M_carSimulater_process/createConect
"
;
sendjson
(
data
,
url
);
//setTimeout(function(){
// WebSocketTest()
//},1000); //1秒之后启动websocket连接
WebSocketTest
()
$
(
"
#curStatus
"
).
val
(
"
连网
"
)
}
//登录
function
login
(){
var
data
=
getPageData
()
$
(
"
#curStatus
"
).
val
(
"
登录
"
)
url
=
"
/protocolTools/M_carSimulater_process/login
"
;
url
=
"
/protocolTools/M_carSimulater_process/login
"
;
sendjson
(
data
,
url
);
sendjson
(
data
,
url
);
}
}
//点火
//点火
function
fire
(){
function
fire
(){
var
carId
=
$
(
"
#carId
"
).
val
()
var
data
=
getPageData
()
var
WATER_CODE
=
$
(
"
#WATER_CODE
"
).
val
()
var
durTime
=
$
(
"
#durTime
"
).
val
()
var
gpsLine
=
$
(
"
#selectGPSLine
"
).
val
()
var
data
=
{};
data
[
"
carId
"
]
=
carId
data
[
"
WATER_CODE
"
]
=
WATER_CODE
data
[
"
durTime
"
]
=
durTime
data
[
"
gpsLine
"
]
=
gpsLine
url
=
"
/protocolTools/M_carSimulater_process/fire
"
;
url
=
"
/protocolTools/M_carSimulater_process/fire
"
;
send
(
data
,
url
);
send
json
(
data
,
url
);
$
(
"
#curStatus
"
).
val
(
"
点火
"
)
$
(
"
#curStatus
"
).
val
(
"
点火
"
)
}
}
//行驶
//行驶
function
startTravel
(){
function
startTravel
(){
var
carId
=
$
(
"
#carId
"
).
val
()
var
data
=
getPageData
()
var
WATER_CODE
=
$
(
"
#WATER_CODE
"
).
val
()
var
durTime
=
$
(
"
#durTime
"
).
val
()
var
gpsLine
=
$
(
"
#selectGPSLine
"
).
val
()
var
data
=
{};
data
[
"
carId
"
]
=
carId
data
[
"
WATER_CODE
"
]
=
WATER_CODE
data
[
"
durTime
"
]
=
durTime
data
[
"
gpsLine
"
]
=
gpsLine
url
=
"
/protocolTools/M_carSimulater_process/startTravel
"
;
url
=
"
/protocolTools/M_carSimulater_process/startTravel
"
;
send
(
data
,
url
);
send
json
(
data
,
url
);
$
(
"
#curStatus
"
).
val
(
"
行驶
"
)
$
(
"
#curStatus
"
).
val
(
"
行驶
"
)
}
}
//停止行驶
//停止行驶
...
@@ -190,17 +190,9 @@ function stopTravel(){
...
@@ -190,17 +190,9 @@ function stopTravel(){
}
}
//熄火
//熄火
function
unFire
(){
function
unFire
(){
var
carId
=
$
(
"
#carId
"
).
val
()
var
data
=
getPageData
()
var
WATER_CODE
=
$
(
"
#WATER_CODE
"
).
val
()
var
durTime
=
$
(
"
#durTime
"
).
val
()
var
gpsLine
=
$
(
"
#selectGPSLine
"
).
val
()
var
data
=
{};
data
[
"
carId
"
]
=
carId
data
[
"
WATER_CODE
"
]
=
WATER_CODE
data
[
"
durTime
"
]
=
durTime
data
[
"
gpsLine
"
]
=
gpsLine
url
=
"
/protocolTools/M_carSimulater_process/unFire
"
;
url
=
"
/protocolTools/M_carSimulater_process/unFire
"
;
send
(
data
,
url
);
send
json
(
data
,
url
);
$
(
"
#curStatus
"
).
val
(
"
熄火
"
)
$
(
"
#curStatus
"
).
val
(
"
熄火
"
)
}
}
//断开连接
//断开连接
...
...
views/protocolTools/M_carSimulater_process.py
View file @
d57114d3
...
@@ -52,7 +52,9 @@ def porcessSocketSetting():
...
@@ -52,7 +52,9 @@ def porcessSocketSetting():
##########################################
##########################################
@
M_carSimulater_process
.
route
(
"/createConect"
,
methods
=
[
'POST'
])
@
M_carSimulater_process
.
route
(
"/createConect"
,
methods
=
[
'POST'
])
def
createConect
():
def
createConect
():
timeout
=
int
(
request
.
form
.
get
(
"timeout"
))
params
=
request
.
get_data
()
params
=
json
.
loads
(
params
.
decode
(
"utf-8"
))
timeout
=
int
(
params
[
"timeout"
])
data
=
{}
data
=
{}
try
:
try
:
conf_R
=
ConfigParser
()
conf_R
=
ConfigParser
()
...
@@ -69,6 +71,7 @@ def createConect():
...
@@ -69,6 +71,7 @@ def createConect():
service
=
ProtocolSimulaterService
()
service
=
ProtocolSimulaterService
()
service
.
setSocket
(
cliSocket
)
service
.
setSocket
(
cliSocket
)
service
.
setTimeout
(
timeout
)
service
.
setTimeout
(
timeout
)
service
.
setData
(
params
)
service
.
setSocket
(
cliSocket
)
service
.
setSocket
(
cliSocket
)
service
.
startWebsocketService
()
service
.
startWebsocketService
()
connects
[
0
][
"service"
]
=
service
connects
[
0
][
"service"
]
=
service
...
@@ -118,9 +121,11 @@ def login():
...
@@ -118,9 +121,11 @@ def login():
##########################################
##########################################
@
M_carSimulater_process
.
route
(
"/fire"
,
methods
=
[
'POST'
])
@
M_carSimulater_process
.
route
(
"/fire"
,
methods
=
[
'POST'
])
def
fire
():
def
fire
():
durTime
=
int
(
request
.
form
.
get
(
"durTime"
))
params
=
request
.
get_data
()
gpsLine
=
request
.
form
.
get
(
"gpsLine"
)
params
=
json
.
loads
(
params
.
decode
(
"utf-8"
))
carId
=
request
.
form
.
get
(
"carId"
)
durTime
=
int
(
params
[
"durTime"
])
gpsLine
=
params
[
"gpsLine"
]
carId
=
params
[
"carId"
]
data
=
{}
data
=
{}
try
:
try
:
service
=
connects
[
0
][
"service"
]
service
=
connects
[
0
][
"service"
]
...
@@ -141,8 +146,10 @@ def fire():
...
@@ -141,8 +146,10 @@ def fire():
##########################################
##########################################
@
M_carSimulater_process
.
route
(
"/startTravel"
,
methods
=
[
'POST'
])
@
M_carSimulater_process
.
route
(
"/startTravel"
,
methods
=
[
'POST'
])
def
startTravel
():
def
startTravel
():
durTime
=
int
(
request
.
form
.
get
(
"durTime"
))
params
=
request
.
get_data
()
gpsLine
=
request
.
form
.
get
(
"gpsLine"
)
params
=
json
.
loads
(
params
.
decode
(
"utf-8"
))
durTime
=
int
(
params
[
"durTime"
])
gpsLine
=
params
[
"gpsLine"
]
data
=
{}
data
=
{}
try
:
try
:
service
=
connects
[
0
][
"service"
]
service
=
connects
[
0
][
"service"
]
...
@@ -182,8 +189,10 @@ def stopTravel():
...
@@ -182,8 +189,10 @@ def stopTravel():
##########################################
##########################################
@
M_carSimulater_process
.
route
(
"/unFire"
,
methods
=
[
'POST'
])
@
M_carSimulater_process
.
route
(
"/unFire"
,
methods
=
[
'POST'
])
def
unFire
():
def
unFire
():
gpsLine
=
request
.
form
.
get
(
"gpsLine"
)
params
=
request
.
get_data
()
carId
=
request
.
form
.
get
(
"carId"
)
params
=
json
.
loads
(
params
.
decode
(
"utf-8"
))
gpsLine
=
params
[
"gpsLine"
]
carId
=
params
[
"carId"
]
data
=
{}
data
=
{}
try
:
try
:
connects
[
0
][
"service"
]
.
setGpsLine
(
gpsLine
)
connects
[
0
][
"service"
]
.
setGpsLine
(
gpsLine
)
...
...
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