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
a6cf06dd
Commit
a6cf06dd
authored
Sep 24, 2020
by
liyuanhong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加了控制是否发送OBD消息的功能
parent
5f953db0
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
190 additions
and
109 deletions
+190
-109
data/protocolTools/sendMsg/genBigPkg.py
data/protocolTools/sendMsg/genBigPkg.py
+120
-104
lib/socket/service/ProtocolSimulaterService.py
lib/socket/service/ProtocolSimulaterService.py
+9
-5
templates/protocolTools/report/M_carSimulater_page.html
templates/protocolTools/report/M_carSimulater_page.html
+32
-0
views/protocolTools/M_carSimulater_process.py
views/protocolTools/M_carSimulater_process.py
+29
-0
No files found.
data/protocolTools/sendMsg/genBigPkg.py
View file @
a6cf06dd
# coding: utf-8
# coding: utf-8
import
binascii
import
binascii
import
socket
import
socket
import
time
import
os
din
=
"M20200
3060520
"
din
=
"M20200
8270021
"
#####################################################
#####################################################
# 数字转换为16进制字符串
# 数字转换为16进制字符串
#####################################################
#####################################################
...
@@ -81,123 +83,135 @@ def rightPad(inputStr, strLen):
...
@@ -81,123 +83,135 @@ def rightPad(inputStr, strLen):
##############################################################################
##############################################################################
def
getEventPkg
():
def
getEventPkg
():
with
open
(
"event.txt"
,
"r"
,
encoding
=
"utf-8"
)
as
fi
:
if
os
.
path
.
exists
(
'event.txt'
):
content
=
fi
.
readlines
()
with
open
(
"event.txt"
,
"r"
,
encoding
=
"utf-8"
)
as
fi
:
pkg
=
""
content
=
fi
.
readlines
()
msgs
=
[]
pkg
=
""
pkgCounts
=
0
msgs
=
[]
for
i
in
content
:
pkgCounts
=
0
onePkg
=
i
[
21
:]
.
replace
(
"
\n
"
,
""
)
for
i
in
content
:
onePkg
=
onePkg
[
30
:][:
-
4
]
onePkg
=
i
[
21
:]
.
replace
(
"
\n
"
,
""
)
onePkg
=
onePkg
[
2
:]
onePkg
=
onePkg
[
30
:][:
-
4
]
pkg
=
pkg
+
onePkg
onePkg
=
onePkg
[
2
:]
pkgCounts
=
pkgCounts
+
1
pkg
=
pkg
+
onePkg
if
len
(
pkg
)
>
2000
:
pkgCounts
=
pkgCounts
+
1
pkgCounts
=
int2hexStringByBytes
(
pkgCounts
)
if
len
(
pkg
)
>
2000
:
HEADER
=
"4040"
pkgCounts
=
int2hexStringByBytes
(
pkgCounts
)
WATER_CODE
=
int2hexStringByBytes
(
1
,
2
)
HEADER
=
"4040"
DEV_ID
=
devid2hexString
(
din
)
WATER_CODE
=
int2hexStringByBytes
(
1
,
2
)
FUN_ID
=
"0021"
DEV_ID
=
devid2hexString
(
din
)
LENGTH
=
int2hexStringByBytes
(
int
(
len
(
WATER_CODE
+
DEV_ID
+
FUN_ID
+
pkgCounts
+
pkg
)
/
2
),
2
)
FUN_ID
=
"0021"
CHECK_CODE
=
crc16
(
HEADER
+
LENGTH
+
WATER_CODE
+
DEV_ID
+
FUN_ID
+
pkgCounts
+
pkg
)
LENGTH
=
int2hexStringByBytes
(
int
(
len
(
WATER_CODE
+
DEV_ID
+
FUN_ID
+
pkgCounts
+
pkg
)
/
2
),
2
)
msg
=
HEADER
+
LENGTH
+
WATER_CODE
+
DEV_ID
+
FUN_ID
+
pkgCounts
+
pkg
+
CHECK_CODE
CHECK_CODE
=
crc16
(
HEADER
+
LENGTH
+
WATER_CODE
+
DEV_ID
+
FUN_ID
+
pkgCounts
+
pkg
)
msgs
.
append
(
msg
)
msg
=
HEADER
+
LENGTH
+
WATER_CODE
+
DEV_ID
+
FUN_ID
+
pkgCounts
+
pkg
+
CHECK_CODE
pkg
=
""
msgs
.
append
(
msg
)
pkgCounts
=
0
pkg
=
""
pkgCounts
=
int2hexStringByBytes
(
pkgCounts
)
pkgCounts
=
0
HEADER
=
"4040"
pkgCounts
=
int2hexStringByBytes
(
pkgCounts
)
WATER_CODE
=
int2hexStringByBytes
(
1
,
2
)
HEADER
=
"4040"
DEV_ID
=
devid2hexString
(
din
)
WATER_CODE
=
int2hexStringByBytes
(
1
,
2
)
FUN_ID
=
"0021"
DEV_ID
=
devid2hexString
(
din
)
LENGTH
=
int2hexStringByBytes
(
int
(
len
(
WATER_CODE
+
DEV_ID
+
FUN_ID
+
pkgCounts
+
pkg
)
/
2
),
2
)
FUN_ID
=
"0021"
CHECK_CODE
=
crc16
(
HEADER
+
LENGTH
+
WATER_CODE
+
DEV_ID
+
FUN_ID
+
pkgCounts
+
pkg
)
LENGTH
=
int2hexStringByBytes
(
int
(
len
(
WATER_CODE
+
DEV_ID
+
FUN_ID
+
pkgCounts
+
pkg
)
/
2
),
2
)
msg
=
HEADER
+
LENGTH
+
WATER_CODE
+
DEV_ID
+
FUN_ID
+
pkgCounts
+
pkg
+
CHECK_CODE
CHECK_CODE
=
crc16
(
HEADER
+
LENGTH
+
WATER_CODE
+
DEV_ID
+
FUN_ID
+
pkgCounts
+
pkg
)
msgs
.
append
(
msg
)
msg
=
HEADER
+
LENGTH
+
WATER_CODE
+
DEV_ID
+
FUN_ID
+
pkgCounts
+
pkg
+
CHECK_CODE
msgs
.
append
(
msg
)
with
open
(
"event_big.txt"
,
"w"
,
encoding
=
"utf-8"
)
as
fi2
:
with
open
(
"event_big.txt"
,
"w"
,
encoding
=
"utf-8"
)
as
fi2
:
for
txt
in
msgs
:
for
txt
in
msgs
:
fi2
.
write
(
txt
+
"
\n
"
)
fi2
.
write
(
txt
+
"
\n
"
)
return
msgs
return
msgs
else
:
print
(
"event.txt is not exist"
)
return
[
"4040000b00034d1215010100010003f50b"
]
def
getGpsPkg
():
def
getGpsPkg
():
with
open
(
"gps.txt"
,
"r"
,
encoding
=
"utf-8"
)
as
fi
:
if
os
.
path
.
exists
(
'gps.txt'
):
content
=
fi
.
readlines
()
with
open
(
"gps.txt"
,
"r"
,
encoding
=
"utf-8"
)
as
fi
:
pkg
=
""
content
=
fi
.
readlines
()
msgs
=
[]
pkg
=
""
pkgCounts
=
0
msgs
=
[]
for
i
in
content
:
pkgCounts
=
0
onePkg
=
i
[
21
:]
.
replace
(
"
\n
"
,
""
)
for
i
in
content
:
onePkg
=
onePkg
[
30
:][:
-
4
]
onePkg
=
i
[
21
:]
.
replace
(
"
\n
"
,
""
)
onePkg
=
onePkg
[
2
:]
onePkg
=
onePkg
[
30
:][:
-
4
]
pkg
=
pkg
+
onePkg
onePkg
=
onePkg
[
2
:]
pkgCounts
=
pkgCounts
+
1
pkg
=
pkg
+
onePkg
if
len
(
pkg
)
>
2000
:
pkgCounts
=
pkgCounts
+
1
pkgCounts
=
int2hexStringByBytes
(
pkgCounts
)
if
len
(
pkg
)
>
2000
:
HEADER
=
"4040"
pkgCounts
=
int2hexStringByBytes
(
pkgCounts
)
WATER_CODE
=
int2hexStringByBytes
(
1
,
2
)
HEADER
=
"4040"
DEV_ID
=
devid2hexString
(
din
)
WATER_CODE
=
int2hexStringByBytes
(
1
,
2
)
FUN_ID
=
"0010"
DEV_ID
=
devid2hexString
(
din
)
LENGTH
=
int2hexStringByBytes
(
int
(
len
(
WATER_CODE
+
DEV_ID
+
FUN_ID
+
pkgCounts
+
pkg
)
/
2
),
2
)
FUN_ID
=
"0010"
CHECK_CODE
=
crc16
(
HEADER
+
LENGTH
+
WATER_CODE
+
DEV_ID
+
FUN_ID
+
pkgCounts
+
pkg
)
LENGTH
=
int2hexStringByBytes
(
int
(
len
(
WATER_CODE
+
DEV_ID
+
FUN_ID
+
pkgCounts
+
pkg
)
/
2
),
2
)
msg
=
HEADER
+
LENGTH
+
WATER_CODE
+
DEV_ID
+
FUN_ID
+
pkgCounts
+
pkg
+
CHECK_CODE
CHECK_CODE
=
crc16
(
HEADER
+
LENGTH
+
WATER_CODE
+
DEV_ID
+
FUN_ID
+
pkgCounts
+
pkg
)
msgs
.
append
(
msg
)
msg
=
HEADER
+
LENGTH
+
WATER_CODE
+
DEV_ID
+
FUN_ID
+
pkgCounts
+
pkg
+
CHECK_CODE
pkg
=
""
msgs
.
append
(
msg
)
pkgCounts
=
0
pkg
=
""
pkgCounts
=
int2hexStringByBytes
(
pkgCounts
)
pkgCounts
=
0
HEADER
=
"4040"
pkgCounts
=
int2hexStringByBytes
(
pkgCounts
)
WATER_CODE
=
int2hexStringByBytes
(
1
,
2
)
HEADER
=
"4040"
DEV_ID
=
devid2hexString
(
din
)
WATER_CODE
=
int2hexStringByBytes
(
1
,
2
)
FUN_ID
=
"0010"
DEV_ID
=
devid2hexString
(
din
)
LENGTH
=
int2hexStringByBytes
(
int
(
len
(
WATER_CODE
+
DEV_ID
+
FUN_ID
+
pkgCounts
+
pkg
)
/
2
),
2
)
FUN_ID
=
"0010"
CHECK_CODE
=
crc16
(
HEADER
+
LENGTH
+
WATER_CODE
+
DEV_ID
+
FUN_ID
+
pkgCounts
+
pkg
)
LENGTH
=
int2hexStringByBytes
(
int
(
len
(
WATER_CODE
+
DEV_ID
+
FUN_ID
+
pkgCounts
+
pkg
)
/
2
),
2
)
msg
=
HEADER
+
LENGTH
+
WATER_CODE
+
DEV_ID
+
FUN_ID
+
pkgCounts
+
pkg
+
CHECK_CODE
CHECK_CODE
=
crc16
(
HEADER
+
LENGTH
+
WATER_CODE
+
DEV_ID
+
FUN_ID
+
pkgCounts
+
pkg
)
msgs
.
append
(
msg
)
msg
=
HEADER
+
LENGTH
+
WATER_CODE
+
DEV_ID
+
FUN_ID
+
pkgCounts
+
pkg
+
CHECK_CODE
msgs
.
append
(
msg
)
with
open
(
"gps_big.txt"
,
"w"
,
encoding
=
"utf-8"
)
as
fi2
:
with
open
(
"gps_big.txt"
,
"w"
,
encoding
=
"utf-8"
)
as
fi2
:
for
txt
in
msgs
:
for
txt
in
msgs
:
fi2
.
write
(
txt
+
"
\n
"
)
fi2
.
write
(
txt
+
"
\n
"
)
return
msgs
return
msgs
else
:
print
(
"gps.txt is not exist"
)
return
[
"4040000b00034d1215010100010003f50b"
]
def
getObdPkg
():
def
getObdPkg
():
with
open
(
"obd.txt"
,
"r"
,
encoding
=
"utf-8"
)
as
fi
:
if
os
.
path
.
exists
(
'obd.txt'
):
content
=
fi
.
readlines
()
with
open
(
"obd.txt"
,
"r"
,
encoding
=
"utf-8"
)
as
fi
:
pkg
=
""
content
=
fi
.
readlines
()
msgs
=
[]
pkg
=
""
pkgCounts
=
0
msgs
=
[]
for
i
in
content
:
pkgCounts
=
0
onePkg
=
i
[
21
:]
.
replace
(
"
\n
"
,
""
)
for
i
in
content
:
onePkg
=
onePkg
[
30
:][:
-
4
]
onePkg
=
i
[
21
:]
.
replace
(
"
\n
"
,
""
)
onePkg
=
onePkg
[
2
:]
onePkg
=
onePkg
[
30
:][:
-
4
]
print
(
onePkg
)
onePkg
=
onePkg
[
2
:]
pkg
=
pkg
+
onePkg
print
(
onePkg
)
pkgCounts
=
pkgCounts
+
1
pkg
=
pkg
+
onePkg
if
len
(
pkg
)
>
2000
:
pkgCounts
=
pkgCounts
+
1
pkgCounts
=
int2hexStringByBytes
(
pkgCounts
)
if
len
(
pkg
)
>
2000
:
HEADER
=
"4040"
pkgCounts
=
int2hexStringByBytes
(
pkgCounts
)
WATER_CODE
=
int2hexStringByBytes
(
1
,
2
)
HEADER
=
"4040"
DEV_ID
=
devid2hexString
(
din
)
WATER_CODE
=
int2hexStringByBytes
(
1
,
2
)
FUN_ID
=
"0012"
DEV_ID
=
devid2hexString
(
din
)
LENGTH
=
int2hexStringByBytes
(
int
(
len
(
WATER_CODE
+
DEV_ID
+
FUN_ID
+
pkgCounts
+
pkg
)
/
2
),
2
)
FUN_ID
=
"0012"
CHECK_CODE
=
crc16
(
HEADER
+
LENGTH
+
WATER_CODE
+
DEV_ID
+
FUN_ID
+
pkgCounts
+
pkg
)
LENGTH
=
int2hexStringByBytes
(
int
(
len
(
WATER_CODE
+
DEV_ID
+
FUN_ID
+
pkgCounts
+
pkg
)
/
2
),
2
)
msg
=
HEADER
+
LENGTH
+
WATER_CODE
+
DEV_ID
+
FUN_ID
+
pkgCounts
+
pkg
+
CHECK_CODE
CHECK_CODE
=
crc16
(
HEADER
+
LENGTH
+
WATER_CODE
+
DEV_ID
+
FUN_ID
+
pkgCounts
+
pkg
)
msgs
.
append
(
msg
)
msg
=
HEADER
+
LENGTH
+
WATER_CODE
+
DEV_ID
+
FUN_ID
+
pkgCounts
+
pkg
+
CHECK_CODE
pkg
=
""
msgs
.
append
(
msg
)
pkgCounts
=
0
pkg
=
""
pkgCounts
=
int2hexStringByBytes
(
pkgCounts
)
pkgCounts
=
0
HEADER
=
"4040"
pkgCounts
=
int2hexStringByBytes
(
pkgCounts
)
WATER_CODE
=
int2hexStringByBytes
(
1
,
2
)
HEADER
=
"4040"
DEV_ID
=
devid2hexString
(
din
)
WATER_CODE
=
int2hexStringByBytes
(
1
,
2
)
FUN_ID
=
"0012"
DEV_ID
=
devid2hexString
(
din
)
LENGTH
=
int2hexStringByBytes
(
int
(
len
(
WATER_CODE
+
DEV_ID
+
FUN_ID
+
pkgCounts
+
pkg
)
/
2
),
2
)
FUN_ID
=
"0012"
CHECK_CODE
=
crc16
(
HEADER
+
LENGTH
+
WATER_CODE
+
DEV_ID
+
FUN_ID
+
pkgCounts
+
pkg
)
LENGTH
=
int2hexStringByBytes
(
int
(
len
(
WATER_CODE
+
DEV_ID
+
FUN_ID
+
pkgCounts
+
pkg
)
/
2
),
2
)
msg
=
HEADER
+
LENGTH
+
WATER_CODE
+
DEV_ID
+
FUN_ID
+
pkgCounts
+
pkg
+
CHECK_CODE
CHECK_CODE
=
crc16
(
HEADER
+
LENGTH
+
WATER_CODE
+
DEV_ID
+
FUN_ID
+
pkgCounts
+
pkg
)
msgs
.
append
(
msg
)
msg
=
HEADER
+
LENGTH
+
WATER_CODE
+
DEV_ID
+
FUN_ID
+
pkgCounts
+
pkg
+
CHECK_CODE
with
open
(
"obd_big.txt"
,
"w"
,
encoding
=
"utf-8"
)
as
fi2
:
msgs
.
append
(
msg
)
for
txt
in
msgs
:
with
open
(
"obd_big.txt"
,
"w"
,
encoding
=
"utf-8"
)
as
fi2
:
fi2
.
write
(
txt
+
"
\n
"
)
for
txt
in
msgs
:
return
msgs
fi2
.
write
(
txt
+
"
\n
"
)
return
msgs
else
:
print
(
"obd.txt is not exist"
)
return
[
"4040000b00034d1215010100010003f50b"
]
def
getLenOfFile
():
def
getLenOfFile
():
...
@@ -207,8 +221,8 @@ def getLenOfFile():
...
@@ -207,8 +221,8 @@ def getLenOfFile():
def
sendMsg
(
msgs
):
def
sendMsg
(
msgs
):
host
=
"1
0.100.12.32
"
host
=
"1
72.19.7.13
"
port
=
9008
port
=
4
9008
BUF_SIZE
=
1024
BUF_SIZE
=
1024
client
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
client
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
...
@@ -228,8 +242,10 @@ def sendMsg(msgs):
...
@@ -228,8 +242,10 @@ def sendMsg(msgs):
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
msg
=
getEventPkg
()
msg
=
getEventPkg
()
sendMsg
(
msg
)
sendMsg
(
msg
)
time
.
sleep
(
1
)
msg
=
getGpsPkg
()
msg
=
getGpsPkg
()
sendMsg
(
msg
)
sendMsg
(
msg
)
time
.
sleep
(
1
)
msg
=
getObdPkg
()
msg
=
getObdPkg
()
sendMsg
(
msg
)
sendMsg
(
msg
)
...
...
lib/socket/service/ProtocolSimulaterService.py
View file @
a6cf06dd
...
@@ -48,6 +48,7 @@ class ProtocolSimulaterService():
...
@@ -48,6 +48,7 @@ class ProtocolSimulaterService():
self
.
sendType
=
0
self
.
sendType
=
0
self
.
GPSValid
=
1
#用来控制GPS数据是有效还是无效 0:无效 1:有效
self
.
GPSValid
=
1
#用来控制GPS数据是有效还是无效 0:无效 1:有效
self
.
lngLatIsOk
=
1
#用来控制经纬度是否都为0 0:都为0 1:正常
self
.
lngLatIsOk
=
1
#用来控制经纬度是否都为0 0:都为0 1:正常
self
.
hasOBD
=
1
#行驶数据是否包含obd数据 0:否 1:是
# 定义要发送的obd数据
# 定义要发送的obd数据
self
.
OBDdata
=
{
"fireStatus"
:
1
,
"ACCStatus"
:
0
,
"engineSpeed"
:
3000
,
"speed"
:
0
,
"meterMileage"
:
6000
,
"totailMileage"
:
600
,
"totalOilExpen"
:
30
,
"totalRunTime"
:
10
,
"surplusOil"
:
505
}
self
.
OBDdata
=
{
"fireStatus"
:
1
,
"ACCStatus"
:
0
,
"engineSpeed"
:
3000
,
"speed"
:
0
,
"meterMileage"
:
6000
,
"totailMileage"
:
600
,
"totalOilExpen"
:
30
,
"totalRunTime"
:
10
,
"surplusOil"
:
505
}
# 定义初始的obd数据,与上面的OBD数据保持一致,主要用于汽车行驶过程中数据变化量的计算
# 定义初始的obd数据,与上面的OBD数据保持一致,主要用于汽车行驶过程中数据变化量的计算
...
@@ -97,6 +98,8 @@ class ProtocolSimulaterService():
...
@@ -97,6 +98,8 @@ class ProtocolSimulaterService():
self
.
data
[
"other"
][
"valtage"
]
=
data
self
.
data
[
"other"
][
"valtage"
]
=
data
def
setFixPosition
(
self
,
data
):
def
setFixPosition
(
self
,
data
):
self
.
fixPosition
=
data
self
.
fixPosition
=
data
def
setHasOBD
(
self
,
data
):
self
.
hasOBD
=
data
def
getWebsocket
(
self
):
def
getWebsocket
(
self
):
...
@@ -213,11 +216,12 @@ class ProtocolSimulaterService():
...
@@ -213,11 +216,12 @@ class ProtocolSimulaterService():
self
.
carDataObj
.
setTotalTime
(
self
.
carData
[
"travelData"
][
"totalTime"
]
+
self
.
OBDdata
[
"totalRunTime"
]
-
self
.
OBDdataOri
[
"totalRunTime"
])
self
.
carDataObj
.
setTotalTime
(
self
.
carData
[
"travelData"
][
"totalTime"
]
+
self
.
OBDdata
[
"totalRunTime"
]
-
self
.
OBDdataOri
[
"totalRunTime"
])
self
.
OBDdataOri
[
"totalRunTime"
]
=
self
.
OBDdata
[
"totalRunTime"
]
self
.
OBDdataOri
[
"totalRunTime"
]
=
self
.
OBDdata
[
"totalRunTime"
]
if
OBDMsg
!=
""
:
if
OBDMsg
!=
""
:
self
.
sendMsg
(
OBDMsg
)
if
self
.
hasOBD
==
1
:
self
.
sn
=
self
.
sn
+
1
self
.
sendMsg
(
OBDMsg
)
type
=
self
.
getMsgFunId
(
OBDMsg
)
self
.
sn
=
self
.
sn
+
1
info
=
type
+
">>>>:"
+
OBDMsg
type
=
self
.
getMsgFunId
(
OBDMsg
)
self
.
websocket
.
sendMsgToClient
(
info
,
self
.
websocketId
)
info
=
type
+
">>>>:"
+
OBDMsg
self
.
websocket
.
sendMsgToClient
(
info
,
self
.
websocketId
)
if
gpsMsg
!=
""
:
if
gpsMsg
!=
""
:
sleep
(
0.1
)
sleep
(
0.1
)
self
.
sendMsg
(
gpsMsg
)
self
.
sendMsg
(
gpsMsg
)
...
...
templates/protocolTools/report/M_carSimulater_page.html
View file @
a6cf06dd
...
@@ -202,6 +202,7 @@
...
@@ -202,6 +202,7 @@
<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=
"12"
><button
type=
"button"
class=
"btn btn-primary"
onclick=
"changeVoltage()"
>
改变电瓶电压
</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>
<span
style=
"margin-left:10px;display: inline-block;"
><button
title=
"点击后,车机将会在当前位置发送gps和obd数据"
type=
"button"
class=
"btn btn-primary"
onclick=
"fixCurPosition(this)"
>
固定在当前位置
</button></span>
<span
style=
"margin-left:10px;display: inline-block;"
><button
type=
"button"
class=
"btn btn-primary"
onclick=
"setOBDSend(this)"
>
关闭OBD消息
</button></span>
</div>
</div>
</div>
</div>
</div>
</div>
...
@@ -1185,6 +1186,37 @@ function fixCurPosition(e){
...
@@ -1185,6 +1186,37 @@ function fixCurPosition(e){
$
(
e
).
text
(
"
固定在当前位置
"
)
$
(
e
).
text
(
"
固定在当前位置
"
)
}
}
}
}
//控制是否发送OBD消息
function
setOBDSend
(
e
){
var
butTxt
=
$
(
e
).
text
()
if
(
butTxt
==
"
关闭OBD消息
"
){
var
data
=
{}
var
carId
=
$
(
"
#carId
"
).
val
()
data
[
"
carId
"
]
=
carId
data
[
"
hasOBD
"
]
=
0
//会话session数据
data
[
"
session
"
]
=
{}
var
sessionId
=
$
(
"
#curSession
"
).
val
()
data
[
"
session
"
][
"
sessionId
"
]
=
sessionId
url
=
"
/protocolTools/M_carSimulater_process/setOBDSend
"
;
var
host
=
window
.
location
.
host
;
sendjson
(
data
,
url
);
$
(
e
).
text
(
"
恢复OBD消息
"
);
}
else
{
var
data
=
{}
var
carId
=
$
(
"
#carId
"
).
val
()
data
[
"
carId
"
]
=
carId
data
[
"
hasOBD
"
]
=
1
//会话session数据
data
[
"
session
"
]
=
{}
var
sessionId
=
$
(
"
#curSession
"
).
val
()
data
[
"
session
"
][
"
sessionId
"
]
=
sessionId
url
=
"
/protocolTools/M_carSimulater_process/setOBDSend
"
;
var
host
=
window
.
location
.
host
;
sendjson
(
data
,
url
);
$
(
e
).
text
(
"
关闭OBD消息
"
);
}
}
// -------------------------------- 其他操作js代码-------------------------------------------
// -------------------------------- 其他操作js代码-------------------------------------------
//设置隐藏或显示其他操作区域
//设置隐藏或显示其他操作区域
function
isShowOtheroperCtrArea
(
e
){
function
isShowOtheroperCtrArea
(
e
){
...
...
views/protocolTools/M_carSimulater_process.py
View file @
a6cf06dd
...
@@ -1605,6 +1605,35 @@ def fixCurPosition():
...
@@ -1605,6 +1605,35 @@ def fixCurPosition():
data
[
"message"
]
=
"Error: 设置是否固定gps点失败!"
data
[
"message"
]
=
"Error: 设置是否固定gps点失败!"
return
Response
(
json
.
dumps
(
data
),
mimetype
=
'application/json'
)
return
Response
(
json
.
dumps
(
data
),
mimetype
=
'application/json'
)
##########################################
# 【接口类型】行驶过程中是否发送OBD消息
##########################################
@
M_carSimulater_process
.
route
(
"/setOBDSend"
,
methods
=
[
'POST'
])
def
setOBDSend
():
params
=
request
.
get_data
()
params
=
json
.
loads
(
params
.
decode
(
"utf-8"
))
sessionId
=
params
[
"session"
][
"sessionId"
]
hasOBD
=
int
(
params
[
"hasOBD"
])
data
=
{}
if
not
sessionId
in
connects
.
keys
():
data
[
"status"
]
=
"4003"
data
[
"message"
]
=
"Error: 未启动服务,不可设置是否发送OBD消息!"
return
Response
(
json
.
dumps
(
data
),
mimetype
=
'application/json'
)
service
=
connects
[
sessionId
][
"service"
]
try
:
service
.
setHasOBD
(
hasOBD
)
data
[
"status"
]
=
"200"
data
[
"message"
]
=
"设置是否发送OBD消息成功!"
except
BaseException
as
e
:
# 打印异常信息
traceback
.
print_exc
()
data
[
"status"
]
=
"4003"
data
[
"message"
]
=
"Error: 设置是否发送OBD消息失败!"
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