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
d7eb491b
Commit
d7eb491b
authored
Apr 03, 2020
by
liyuanhong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
完成了汽车行驶功能
parent
546db7bf
Changes
7
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
57 additions
and
28 deletions
+57
-28
data/protocolTools/GPSLines/2_大坪到南滨路钟楼.json
data/protocolTools/GPSLines/2_大坪到南滨路钟楼.json
+0
-0
data/protocolTools/GPSLines/4_测试轨迹.json
data/protocolTools/GPSLines/4_测试轨迹.json
+0
-0
data/protocolTools/GPSLines/5_先涛的车轨迹.txt
data/protocolTools/GPSLines/5_先涛的车轨迹.txt
+0
-0
lib/protocol/m300/OBDCAN_protocol_m300.py
lib/protocol/m300/OBDCAN_protocol_m300.py
+1
-1
lib/protocol/report/GPSReport_protocol.py
lib/protocol/report/GPSReport_protocol.py
+1
-1
lib/protocol/report/OBDReport_CAN_protocol.py
lib/protocol/report/OBDReport_CAN_protocol.py
+5
-1
lib/socket/service/ProtocolSimulaterService.py
lib/socket/service/ProtocolSimulaterService.py
+50
-25
No files found.
data/protocolTools/GPSLines/2_大坪到南滨路钟楼.json
0 → 100644
View file @
d7eb491b
This diff is collapsed.
Click to expand it.
data/protocolTools/GPSLines/4_测试轨迹.json
0 → 100644
View file @
d7eb491b
This diff is collapsed.
Click to expand it.
data/protocolTools/GPSLines/5_先涛的车轨迹.txt
0 → 100644
View file @
d7eb491b
This diff is collapsed.
Click to expand it.
lib/protocol/m300/OBDCAN_protocol_m300.py
View file @
d7eb491b
...
@@ -36,7 +36,7 @@ class OBDCAN_protocol_m300(M300Base):
...
@@ -36,7 +36,7 @@ class OBDCAN_protocol_m300(M300Base):
#################################################
#################################################
def
generateMsg
(
self
):
def
generateMsg
(
self
):
msg
=
self
.
IDENTIFY
msg
=
self
.
IDENTIFY
FUNID
=
"000
4
"
#功能id
FUNID
=
"000
3
"
#功能id
waterCode
=
self
.
waterCode
#消息流水号
waterCode
=
self
.
waterCode
#消息流水号
DEV_ID
=
self
.
devid2hexString
(
self
.
DEV_ID
)
#设备id
DEV_ID
=
self
.
devid2hexString
(
self
.
DEV_ID
)
#设备id
msgBody
=
self
.
getMsgBody
()
# 消息体
msgBody
=
self
.
getMsgBody
()
# 消息体
...
...
lib/protocol/report/GPSReport_protocol.py
View file @
d7eb491b
...
@@ -13,7 +13,7 @@ from lib.protocol.report.ProtocolBase import ProtocolBase
...
@@ -13,7 +13,7 @@ from lib.protocol.report.ProtocolBase import ProtocolBase
'''
'''
class
GPSReport_protocol
(
ProtocolBase
):
class
GPSReport_protocol
(
ProtocolBase
):
def
__init__
(
self
,
msgCount
=
1
,
WATER_CODE
=
1000
,
DEV_ID
=
"M121501010001"
,
UTCTime
=
"2020-01-09 18:19:38"
,
latitude
=
40.22077
,
longitude
=
116.23128
,
speed
=
60
.9
,
directionAngle
=
80.8
,
elevation
=
2999.9
,
positionStar
=
3
,
Pdop
=
0.3
,
Hdop
=
0.4
,
Vdop
=
0.5
,
statusBit
=
175
,
valtage
=
36.9
,
OBDSpeed
=
60.9
,
engineSpeed
=
3000
,
GPSTotalMileage
=
12800
,
totalOil
=
100000
,
totalTime
=
2020002
,
GPSTimestamp
=
1578565178
):
def
__init__
(
self
,
msgCount
=
1
,
WATER_CODE
=
1000
,
DEV_ID
=
"M121501010001"
,
UTCTime
=
"2020-01-09 18:19:38"
,
latitude
=
40.22077
,
longitude
=
116.23128
,
speed
=
60
,
directionAngle
=
80.8
,
elevation
=
2999.9
,
positionStar
=
3
,
Pdop
=
0.3
,
Hdop
=
0.4
,
Vdop
=
0.5
,
statusBit
=
175
,
valtage
=
36.9
,
OBDSpeed
=
60.9
,
engineSpeed
=
3000
,
GPSTotalMileage
=
12800
,
totalOil
=
100000
,
totalTime
=
2020002
,
GPSTimestamp
=
1578565178
):
super
()
.
__init__
()
super
()
.
__init__
()
self
.
msgCount
=
int
(
msgCount
)
# 设置默认要发送的GPS数据包个数
self
.
msgCount
=
int
(
msgCount
)
# 设置默认要发送的GPS数据包个数
...
...
lib/protocol/report/OBDReport_CAN_protocol.py
View file @
d7eb491b
...
@@ -9,7 +9,7 @@ from lib.protocol.report.ProtocolBase import ProtocolBase
...
@@ -9,7 +9,7 @@ from lib.protocol.report.ProtocolBase import ProtocolBase
class
OBDReport_CAN_protocol
(
ProtocolBase
):
class
OBDReport_CAN_protocol
(
ProtocolBase
):
def
__init__
(
self
,
msgCount
=
1
,
WATER_CODE
=
1000
,
DEV_ID
=
"M121501010001"
,
infoTime
=
"2020-01-10 16:29:19"
,
dataFlowCode
=
"ffffffffff"
,
protocolType
=
"0101"
,
fireStatus
=
1
,
ACCStatus
=
1
,
voltage
=
36.06
,
troubleLightStatus
=
0
,
toubleCodeCount
=
0
,
engineSpeed
=
4000
,
speed
=
60
,
meterMileage
=
128500
,
mileageStatisticsStyle
=
"01"
,
totalMileage
=
4129040
,
troubleMileage
=
500
,
totalOilExpend
=
3500
,
surplusOil
=
505
,
totalRunTime
=
50000000
,
totalEngineTime
=
5000
,
airIntoAisleTemperture
=
42
,
coolingLiquidTemperture
=
38
,
envTemperture
=
68
,
ariIntoPress
=
20
,
oilPressure
=
550
,
atmosphericPressure
=
120
,
airFlow
=
3600
,
valveLocationSensor
=
4000
,
acceleratorLocation
=
50
,
engineLoad
=
55
,
fuelTrim
=
34
,
fireAngle
=
800
,
B1S1oxygenSensorVoltage
=
18
,
B1S2oxygenSensorVoltage
=
20
,
B1S1oxygenSensorElectricity
=
13000
,
B1S2oxygenSensorElectricity
=
13200
,
momentOilExpend
=
15
,
meterOilExpend
=
20000
,
engineAbsoluteLoad
=
32
,
steeringWheelAngle
=
10
,
torquePercentage
=
31
,
gearsLocation
=
1
,
GPSSpeed
=
72.4
,
GPSMileage
=
380000
):
def
__init__
(
self
,
msgCount
=
1
,
WATER_CODE
=
1000
,
DEV_ID
=
"M121501010001"
,
infoTime
=
"2020-01-10 16:29:19"
,
dataFlowCode
=
"ffffffffff"
,
protocolType
=
"0101"
,
fireStatus
=
1
,
ACCStatus
=
1
,
voltage
=
12
,
troubleLightStatus
=
0
,
toubleCodeCount
=
0
,
engineSpeed
=
4000
,
speed
=
60
,
meterMileage
=
128500
,
mileageStatisticsStyle
=
"01"
,
totalMileage
=
4129040
,
troubleMileage
=
500
,
totalOilExpend
=
3500
,
surplusOil
=
505
,
totalRunTime
=
50000000
,
totalEngineTime
=
5000
,
airIntoAisleTemperture
=
42
,
coolingLiquidTemperture
=
38
,
envTemperture
=
68
,
ariIntoPress
=
20
,
oilPressure
=
550
,
atmosphericPressure
=
120
,
airFlow
=
3600
,
valveLocationSensor
=
4000
,
acceleratorLocation
=
50
,
engineLoad
=
55
,
fuelTrim
=
34
,
fireAngle
=
800
,
B1S1oxygenSensorVoltage
=
18
,
B1S2oxygenSensorVoltage
=
20
,
B1S1oxygenSensorElectricity
=
13000
,
B1S2oxygenSensorElectricity
=
13200
,
momentOilExpend
=
15
,
meterOilExpend
=
20000
,
engineAbsoluteLoad
=
32
,
steeringWheelAngle
=
10
,
torquePercentage
=
31
,
gearsLocation
=
1
,
GPSSpeed
=
72.4
,
GPSMileage
=
380000
):
pass
pass
self
.
msgCount
=
int
(
msgCount
)
# 设置默认要发送的数据包个数
self
.
msgCount
=
int
(
msgCount
)
# 设置默认要发送的数据包个数
...
@@ -59,6 +59,8 @@ class OBDReport_CAN_protocol(ProtocolBase):
...
@@ -59,6 +59,8 @@ class OBDReport_CAN_protocol(ProtocolBase):
self
.
GPSSpeed
=
float
(
GPSSpeed
)
# 设置GPS车速
self
.
GPSSpeed
=
float
(
GPSSpeed
)
# 设置GPS车速
self
.
GPSMileage
=
int
(
GPSMileage
)
# 设置GPS里程
self
.
GPSMileage
=
int
(
GPSMileage
)
# 设置GPS里程
def
setInfoTime
(
self
,
data
):
self
.
infoTime
=
data
def
setFireStatus
(
self
,
data
):
#点火状态
def
setFireStatus
(
self
,
data
):
#点火状态
self
.
fireStatus
=
data
self
.
fireStatus
=
data
def
setACCStatus
(
self
,
data
):
#ACC状态
def
setACCStatus
(
self
,
data
):
#ACC状态
...
@@ -77,6 +79,8 @@ class OBDReport_CAN_protocol(ProtocolBase):
...
@@ -77,6 +79,8 @@ class OBDReport_CAN_protocol(ProtocolBase):
self
.
totalOilExpend
=
data
self
.
totalOilExpend
=
data
def
setSurplusOil
(
self
,
data
):
#剩余油量
def
setSurplusOil
(
self
,
data
):
#剩余油量
self
.
surplusOil
=
data
self
.
surplusOil
=
data
def
setTotalRunTime
(
self
,
data
):
#车辆总运行时间
self
.
totalRunTime
=
data
#####################################################
#####################################################
...
...
lib/socket/service/ProtocolSimulaterService.py
View file @
d7eb491b
...
@@ -29,11 +29,9 @@ class ProtocolSimulaterService():
...
@@ -29,11 +29,9 @@ class ProtocolSimulaterService():
self
.
gpsLineIndex
=
0
#GPS 轨迹索引
self
.
gpsLineIndex
=
0
#GPS 轨迹索引
self
.
travelStatus
=
0
#0,表示为行驶,1表示开始行驶
self
.
travelStatus
=
0
#0,表示为行驶,1表示开始行驶
self
.
carId
=
""
#车机号
self
.
carId
=
""
#车机号
self
.
OBDdata
=
[
#定义要发送的obd数据
self
.
sn
=
0
#消息流水号
{
"fireStatus"
:
1
,
"ACCStatus"
:
0
,
"engineSpeed"
:
300
,
"speed"
:
0
,
"meterMileage"
:
6000
,
"totailMileage"
:
600
,
"totalOilExpen"
:
30
},
# 定义要发送的obd数据
{
"fireStatus"
:
1
,
"ACCStatus"
:
0
,
"engineSpeed"
:
300
,
"speed"
:
0
,
"meterMileage"
:
6000
,
"totailMileage"
:
600
,
"totalOilExpen"
:
30
},
self
.
OBDdata
=
{
"fireStatus"
:
1
,
"ACCStatus"
:
0
,
"engineSpeed"
:
300
,
"speed"
:
0
,
"meterMileage"
:
6000
,
"totailMileage"
:
600
,
"totalOilExpen"
:
30
,
"totalRunTime"
:
10
}
{
"fireStatus"
:
1
,
"ACCStatus"
:
0
,
"engineSpeed"
:
300
,
"speed"
:
0
,
"meterMileage"
:
6000
,
"totailMileage"
:
600
,
"totalOilExpen"
:
30
},
]
self
.
OBDdataIndex
=
0
#发发送OBD数据的索引
self
.
OBDdataIndex
=
0
#发发送OBD数据的索引
#设置套接字
#设置套接字
...
@@ -71,20 +69,32 @@ class ProtocolSimulaterService():
...
@@ -71,20 +69,32 @@ class ProtocolSimulaterService():
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
):
OBDMsg
=
self
.
genOBDMsg
()
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"
]
=
60
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
[
"totalOilExpen"
]
=
self
.
OBDdata
[
"totalOilExpen"
]
+
int
((
self
.
sendDur
*
(
self
.
OBDdata
[
"speed"
]
*
1000
/
3600
))
*
(
1000
/
(
15
*
1000
)))
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
self
.
gpsLineIndex
=
self
.
gpsLineIndex
+
1
elif
self
.
gpsLineIndex
==
len
(
self
.
gpsLine
):
elif
self
.
gpsLineIndex
==
len
(
self
.
gpsLine
):
self
.
stopTravel
()
self
.
websocket
.
send
(
"gps轨迹跑完,自动停止行驶!"
)
self
.
websocket
.
send
(
"gps轨迹跑完,自动停止行驶!"
)
if
OBDMsg
!=
""
:
if
OBDMsg
!=
""
:
self
.
sendMsg
(
OBDMsg
)
self
.
sendMsg
(
OBDMsg
)
self
.
sn
=
self
.
sn
+
1
type
=
self
.
getMsgFunId
(
OBDMsg
)
type
=
self
.
getMsgFunId
(
OBDMsg
)
info
=
type
+
">>>>:"
+
OBDMsg
info
=
type
+
">>>>:"
+
OBDMsg
self
.
websocket
.
send
(
info
)
self
.
websocket
.
send
(
info
)
if
gpsMsg
!=
""
:
sleep
(
0.1
)
sleep
(
0.1
)
self
.
sendMsg
(
gpsMsg
)
self
.
sendMsg
(
gpsMsg
)
self
.
sn
=
self
.
sn
+
1
type
=
self
.
getMsgFunId
(
gpsMsg
)
type
=
self
.
getMsgFunId
(
gpsMsg
)
info
=
type
+
">>>>:"
+
gpsMsg
info
=
type
+
">>>>:"
+
gpsMsg
self
.
websocket
.
send
(
info
)
self
.
websocket
.
send
(
info
)
...
@@ -166,16 +176,19 @@ class ProtocolSimulaterService():
...
@@ -166,16 +176,19 @@ class ProtocolSimulaterService():
if
msgFunId
==
"8205"
:
if
msgFunId
==
"8205"
:
msg
=
Common_response
(
resId
=
"8205"
)
.
generateCommonMsg
()
msg
=
Common_response
(
resId
=
"8205"
)
.
generateCommonMsg
()
self
.
sendMsg
(
msg
)
self
.
sendMsg
(
msg
)
self
.
sn
=
self
.
sn
+
1
type
=
self
.
getMsgFunId
(
msg
)
type
=
self
.
getMsgFunId
(
msg
)
self
.
websocket
.
send
(
type
+
">>>>设置GPSR通信参数应答:"
+
msg
)
self
.
websocket
.
send
(
type
+
">>>>设置GPSR通信参数应答:"
+
msg
)
elif
msgFunId
==
"8206"
:
elif
msgFunId
==
"8206"
:
msg
=
Common_response
(
resId
=
"8206"
)
.
generateCommonMsg
()
msg
=
Common_response
(
resId
=
"8206"
)
.
generateCommonMsg
()
self
.
sendMsg
(
msg
)
self
.
sendMsg
(
msg
)
self
.
sn
=
self
.
sn
+
1
type
=
self
.
getMsgFunId
(
msg
)
type
=
self
.
getMsgFunId
(
msg
)
self
.
websocket
.
send
(
type
+
">>>>设置车辆OBD适配信息应答:"
+
msg
)
self
.
websocket
.
send
(
type
+
">>>>设置车辆OBD适配信息应答:"
+
msg
)
elif
msgFunId
==
"8300"
:
elif
msgFunId
==
"8300"
:
msg
=
Update_response
()
.
generateUpdateMsg
()
msg
=
Update_response
()
.
generateUpdateMsg
()
self
.
sendMsg
(
msg
)
self
.
sendMsg
(
msg
)
self
.
sn
=
self
.
sn
+
1
type
=
self
.
getMsgFunId
(
msg
)
type
=
self
.
getMsgFunId
(
msg
)
self
.
websocket
.
send
(
type
+
">>>>升级_平台通知终端远程升级应答:"
+
msg
)
self
.
websocket
.
send
(
type
+
">>>>升级_平台通知终端远程升级应答:"
+
msg
)
...
@@ -188,29 +201,35 @@ class ProtocolSimulaterService():
...
@@ -188,29 +201,35 @@ class ProtocolSimulaterService():
#点火,发送点火事件
#点火,发送点火事件
def
fireOn
(
self
):
def
fireOn
(
self
):
fireOnEventObj
=
EventReport_protocol
(
DEV_ID
=
self
.
carId
)
fireOnEventObj
=
EventReport_protocol
(
DEV_ID
=
self
.
carId
,
WATER_CODE
=
self
.
sn
)
gpsData
=
self
.
genGPSData
(
self
.
gpsLine
[
0
][
"lat"
],
self
.
gpsLine
[
0
][
"lng"
])
gpsData
=
self
.
genGPSData
(
self
.
gpsLine
[
0
][
"lat"
],
self
.
gpsLine
[
0
][
"lng"
])
fireOnEventObj
.
setGPSPkg
(
gpsData
)
fireOnEventObj
.
setGPSPkg
(
gpsData
)
fireOnEventObj
.
setEventType
(
"0010"
)
fireOnEventObj
.
setEventType
(
"0010"
)
firOnEventMsg
=
fireOnEventObj
.
generateEventMsg
()
firOnEventMsg
=
fireOnEventObj
.
generateEventMsg
()
type
=
self
.
getMsgFunId
(
firOnEventMsg
)
type
=
self
.
getMsgFunId
(
firOnEventMsg
)
self
.
sendMsg
(
firOnEventMsg
)
self
.
sendMsg
(
firOnEventMsg
)
self
.
sn
=
self
.
sn
+
1
self
.
websocket
.
send
(
type
+
">>>>:"
+
firOnEventMsg
)
self
.
websocket
.
send
(
type
+
">>>>:"
+
firOnEventMsg
)
sleep
(
0.1
)
sleep
(
0.1
)
gpsMsg
=
self
.
genGPSMsg
(
self
.
gpsLine
[
0
][
"lat"
],
self
.
gpsLine
[
0
][
"lng"
])
gpsMsg
=
self
.
genGPSMsg
(
self
.
gpsLine
[
0
][
"lat"
],
self
.
gpsLine
[
0
][
"lng"
])
type
=
self
.
getMsgFunId
(
gpsMsg
)
type
=
self
.
getMsgFunId
(
gpsMsg
)
self
.
sendMsg
(
gpsMsg
)
self
.
sendMsg
(
gpsMsg
)
self
.
sn
=
self
.
sn
+
1
self
.
websocket
.
send
(
type
+
">>>>:"
+
gpsMsg
)
self
.
websocket
.
send
(
type
+
">>>>:"
+
gpsMsg
)
sleep
(
0.1
)
sleep
(
0.1
)
OBDMsg
=
self
.
genOBDMsg
()
OBDMsg
=
self
.
genOBDMsg
()
type
=
self
.
getMsgFunId
(
OBDMsg
)
type
=
self
.
getMsgFunId
(
OBDMsg
)
self
.
sendMsg
(
OBDMsg
)
self
.
sendMsg
(
OBDMsg
)
self
.
sn
=
self
.
sn
+
1
self
.
websocket
.
send
(
type
+
">>>>:"
+
OBDMsg
)
self
.
websocket
.
send
(
type
+
">>>>:"
+
OBDMsg
)
# 熄火,发送熄火事件
# 熄火,发送熄火事件
def
fireOff
(
self
):
def
fireOff
(
self
):
gpsLineIndex
=
self
.
gpsLineIndex
if
gpsLineIndex
>=
len
(
self
.
gpsLine
):
gpsLineIndex
=
gpsLineIndex
-
1
fireOffEventObj
=
EventReport_protocol
(
DEV_ID
=
self
.
carId
)
fireOffEventObj
=
EventReport_protocol
(
DEV_ID
=
self
.
carId
)
gpsData
=
self
.
genGPSData
(
self
.
gpsLine
[
self
.
gpsLineIndex
][
"lat"
],
self
.
gpsLine
[
self
.
gpsLineIndex
][
"lng"
])
gpsData
=
self
.
genGPSData
(
self
.
gpsLine
[
gpsLineIndex
][
"lat"
],
self
.
gpsLine
[
gpsLineIndex
][
"lng"
])
fireOffEventObj
.
setGPSPkg
(
gpsData
)
fireOffEventObj
.
setGPSPkg
(
gpsData
)
fireOffEventObj
.
setEventType
(
"0011"
)
fireOffEventObj
.
setEventType
(
"0011"
)
fireOffEventMsg
=
fireOffEventObj
.
generateEventMsg
()
fireOffEventMsg
=
fireOffEventObj
.
generateEventMsg
()
...
@@ -218,14 +237,15 @@ class ProtocolSimulaterService():
...
@@ -218,14 +237,15 @@ class ProtocolSimulaterService():
self
.
sendMsg
(
fireOffEventMsg
)
self
.
sendMsg
(
fireOffEventMsg
)
self
.
websocket
.
send
(
type
+
">>>>:"
+
fireOffEventMsg
)
self
.
websocket
.
send
(
type
+
">>>>:"
+
fireOffEventMsg
)
sleep
(
0.1
)
sleep
(
0.1
)
gpsMsg
=
self
.
genGPSMsg
(
self
.
gpsLine
[
self
.
gpsLineIndex
][
"lat"
],
self
.
gpsLine
[
self
.
gpsLineIndex
][
"lng"
])
gpsMsg
=
self
.
genGPSMsg
(
self
.
gpsLine
[
gpsLineIndex
][
"lat"
],
self
.
gpsLine
[
gpsLineIndex
][
"lng"
])
type
=
self
.
getMsgFunId
(
gpsMsg
)
type
=
self
.
getMsgFunId
(
gpsMsg
)
self
.
sendMsg
(
gpsMsg
)
self
.
sendMsg
(
gpsMsg
)
self
.
sn
=
self
.
sn
+
1
self
.
websocket
.
send
(
type
+
">>>>:"
+
gpsMsg
)
self
.
websocket
.
send
(
type
+
">>>>:"
+
gpsMsg
)
#根据特定参数,生成GPS消息
#根据特定参数,生成GPS消息
def
genGPSMsg
(
self
,
latitude
,
longtitude
):
def
genGPSMsg
(
self
,
latitude
,
longtitude
):
gpsObj
=
GPSReport_protocol
(
DEV_ID
=
self
.
carId
)
gpsObj
=
GPSReport_protocol
(
DEV_ID
=
self
.
carId
,
WATER_CODE
=
self
.
sn
)
gpsObj
.
setLatitude
(
latitude
)
gpsObj
.
setLatitude
(
latitude
)
gpsObj
.
setLongitude
(
longtitude
)
gpsObj
.
setLongitude
(
longtitude
)
timeS
=
int
(
time
.
time
())
-
8
*
3600
timeS
=
int
(
time
.
time
())
-
8
*
3600
...
@@ -237,7 +257,7 @@ class ProtocolSimulaterService():
...
@@ -237,7 +257,7 @@ class ProtocolSimulaterService():
return
msg
return
msg
#根据特定参数,生成GPS消息体,不包含消息头
#根据特定参数,生成GPS消息体,不包含消息头
def
genGPSData
(
self
,
latitude
,
longtitude
):
def
genGPSData
(
self
,
latitude
,
longtitude
):
gpsObj
=
GPSReport_protocol
(
DEV_ID
=
self
.
carId
)
gpsObj
=
GPSReport_protocol
(
DEV_ID
=
self
.
carId
,
WATER_CODE
=
self
.
sn
)
gpsObj
.
setLatitude
(
latitude
)
gpsObj
.
setLatitude
(
latitude
)
gpsObj
.
setLongitude
(
longtitude
)
gpsObj
.
setLongitude
(
longtitude
)
timeS
=
int
(
time
.
time
())
-
8
*
3600
timeS
=
int
(
time
.
time
())
-
8
*
3600
...
@@ -250,15 +270,20 @@ class ProtocolSimulaterService():
...
@@ -250,15 +270,20 @@ class ProtocolSimulaterService():
# 根据特定参数,生成OBD CAN消息
# 根据特定参数,生成OBD CAN消息
def
genOBDMsg
(
self
,
fireStatus
=
1
,
ACCStatus
=
0
,
engineSpeed
=
300
,
speed
=
0
,
meterMileage
=
6000
,
\
def
genOBDMsg
(
self
,
fireStatus
=
1
,
ACCStatus
=
0
,
engineSpeed
=
300
,
speed
=
0
,
meterMileage
=
6000
,
\
totailMileage
=
600
,
totalOilExpend
=
30
):
totailMileage
=
600
,
totalOilExpend
=
30
,
totalRunTime
=
10
):
OBDObj
=
OBDReport_CAN_protocol
(
DEV_ID
=
self
.
carId
)
OBDObj
=
OBDReport_CAN_protocol
(
DEV_ID
=
self
.
carId
,
WATER_CODE
=
self
.
sn
)
OBDObj
.
setFireStatus
(
1
)
timeS
=
int
(
time
.
time
())
-
8
*
3600
OBDObj
.
setACCStatus
(
0
)
timeArray
=
time
.
localtime
(
timeS
)
OBDObj
.
setEngineSpeed
(
300
)
UTCTime
=
time
.
strftime
(
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
,
timeArray
)
OBDObj
.
setSpeed
(
0
)
OBDObj
.
setInfoTime
(
UTCTime
)
OBDObj
.
setMeterMileage
(
600
)
OBDObj
.
setFireStatus
(
fireStatus
)
OBDObj
.
setTotalMileage
(
600
)
OBDObj
.
setACCStatus
(
ACCStatus
)
OBDObj
.
setTotalOilExpend
(
30
)
OBDObj
.
setEngineSpeed
(
engineSpeed
)
# 设置发动机转速
OBDObj
.
setSpeed
(
speed
)
# 设置车辆速度
OBDObj
.
setMeterMileage
(
meterMileage
)
# 设置仪表里程值
OBDObj
.
setTotalMileage
(
totailMileage
)
# 设置总里程值
OBDObj
.
setTotalOilExpend
(
totalOilExpend
)
# 设置总耗油量
OBDObj
.
setTotalRunTime
(
totalRunTime
)
# 设置车辆运行时间
msg
=
OBDObj
.
generateOBDReportCANMsg
()
msg
=
OBDObj
.
generateOBDReportCANMsg
()
return
msg
return
msg
...
...
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