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
fc54f847
Commit
fc54f847
authored
May 14, 2020
by
liyuanhong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改了点熄火,三急事件次数写死的bug
parent
cc33f022
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
92 additions
and
35 deletions
+92
-35
lib/protocol/appendix/EventClass.py
lib/protocol/appendix/EventClass.py
+8
-8
lib/protocol/report/EventReport_protocol.py
lib/protocol/report/EventReport_protocol.py
+2
-2
lib/socket/service/ProtocolSimulaterService.py
lib/socket/service/ProtocolSimulaterService.py
+72
-17
lib/socket/service/websocket_service.py
lib/socket/service/websocket_service.py
+4
-2
views/protocolTools/M_carSimulater_process.py
views/protocolTools/M_carSimulater_process.py
+6
-6
No files found.
lib/protocol/appendix/EventClass.py
View file @
fc54f847
...
...
@@ -40,10 +40,10 @@ class EventClass(ProtocolBase):
return
self
.
int2hexString
(
data
)
# 0010 点火事件附带信息
def
fireExtraInfo
(
self
):
allRapidlyAccelerateCount
=
self
.
int2hexStringByBytes
(
15
,
2
)
# 急加速总次数
allSharpSlowdownCount
=
self
.
int2hexStringByBytes
(
15
,
2
)
# 急减速总次数
allSharpTurn
=
self
.
int2hexStringByBytes
(
15
,
2
)
# 急转弯总次数
def
fireExtraInfo
(
self
,
allRapidlyAccelerateCount
=
15
,
allSharpSlowdownCount
=
15
,
allSharpTurn
=
15
):
allRapidlyAccelerateCount
=
self
.
int2hexStringByBytes
(
allRapidlyAccelerateCount
,
2
)
# 急加速总次数
allSharpSlowdownCount
=
self
.
int2hexStringByBytes
(
allSharpSlowdownCount
,
2
)
# 急减速总次数
allSharpTurn
=
self
.
int2hexStringByBytes
(
allSharpTurn
,
2
)
# 急转弯总次数
securityObj
=
SecurityStatusReport_protocol
()
securityObj
.
setGPSPkg
(
self
.
GPSPkg
)
securityData
=
""
...
...
@@ -55,10 +55,10 @@ class EventClass(ProtocolBase):
return
data
# 0011 熄火事件附带信息
def
misFireExtraInfo
(
self
):
allRapidlyAccelerateCount
=
self
.
int2hexStringByBytes
(
100
,
2
)
#急加速总次数
allSharpSlowdownCount
=
self
.
int2hexStringByBytes
(
101
,
2
)
#急减速总次数
allSharpTurn
=
self
.
int2hexStringByBytes
(
35
,
2
)
#急转弯总次数
def
misFireExtraInfo
(
self
,
allRapidlyAccelerateCount
=
15
,
allSharpSlowdownCount
=
15
,
allSharpTurn
=
15
):
allRapidlyAccelerateCount
=
self
.
int2hexStringByBytes
(
allRapidlyAccelerateCount
,
2
)
#急加速总次数
allSharpSlowdownCount
=
self
.
int2hexStringByBytes
(
allSharpSlowdownCount
,
2
)
#急减速总次数
allSharpTurn
=
self
.
int2hexStringByBytes
(
allSharpTurn
,
2
)
#急转弯总次数
securityObj
=
SecurityStatusReport_protocol
()
securityObj
.
setGPSPkg
(
self
.
GPSPkg
)
securityData
=
""
...
...
lib/protocol/report/EventReport_protocol.py
View file @
fc54f847
...
...
@@ -216,13 +216,13 @@ class EventReport_protocol(ProtocolBase):
eventObj
=
EventClass
()
eventObj
.
setGPSpkg
(
self
.
GPSPkg
)
eventObj
.
setSecurityData
(
self
.
securityPkg
)
theData
=
eventObj
.
fireExtraInfo
()
theData
=
eventObj
.
fireExtraInfo
(
int
(
eventData
[
"0010"
][
"allRapidlyAccelerateCount"
]),
int
(
eventData
[
"0010"
][
"allSharpSlowdownCount"
]),
int
(
eventData
[
"0010"
][
"allSharpTurn"
])
)
data
=
data
+
"0010"
+
self
.
int2hexStringByBytes
(
int
((
len
(
theData
)
/
2
)),
2
)
+
theData
if
(
"0011"
in
eventData
.
keys
()):
#汽车熄火上报
eventObj
=
EventClass
()
eventObj
.
setGPSpkg
(
self
.
GPSPkg
)
eventObj
.
setSecurityData
(
self
.
securityPkg
)
theData
=
eventObj
.
fireExtraInfo
(
)
theData
=
eventObj
.
misFireExtraInfo
(
int
(
eventData
[
"0011"
][
"allRapidlyAccelerateCount"
]),
int
(
eventData
[
"0011"
][
"allSharpSlowdownCount"
]),
int
(
eventData
[
"0011"
][
"allSharpTurn"
])
)
data
=
data
+
"0011"
+
self
.
int2hexStringByBytes
(
int
((
len
(
theData
)
/
2
)),
2
)
+
theData
if
(
"0012"
in
eventData
.
keys
()):
#汽车设防上报
eventObj
=
EventClass
()
...
...
lib/socket/service/ProtocolSimulaterService.py
View file @
fc54f847
...
...
@@ -61,7 +61,7 @@ class ProtocolSimulaterService():
def
setData
(
self
,
data
):
self
.
data
=
data
def
setWebsocketId
(
self
):
sleep
(
1
)
sleep
(
0.
1
)
self
.
websocketId
=
self
.
websocket
.
getCurrentClientId
()
def
setWebsocket
(
self
,
data
):
self
.
websocket
=
data
...
...
@@ -356,15 +356,42 @@ class ProtocolSimulaterService():
self
.
OBDdata
[
"totalRunTime"
]
=
conJson
[
"travelData"
][
"totalTime"
]
self
.
OBDdataOri
[
"totalRunTime"
]
=
conJson
[
"travelData"
][
"totalTime"
]
self
.
carData
=
self
.
carDataObj
.
fixDataTemplate
(
conJson
)
fireOnEventObj
=
EventReport_protocol
(
DEV_ID
=
self
.
carId
,
WATER_CODE
=
self
.
sn
)
gpsData
=
self
.
genGPSData
(
self
.
gpsLine
[
0
][
"lat"
],
self
.
gpsLine
[
0
][
"lng"
])
fireOnEventObj
.
setGPSPkg
(
gpsData
)
fireOnEventObj
.
setEventType
(
"0010"
)
firOnEventMsg
=
fireOnEventObj
.
generateEventMsg
()
type
=
self
.
getMsgFunId
(
firOnEventMsg
)
self
.
sendMsg
(
firOnEventMsg
)
# fireOnEventObj = EventReport_protocol(DEV_ID=self.carId,WATER_CODE=self.sn)
# gpsData = self.genGPSData(self.gpsLine[0]["lat"], self.gpsLine[0]["lng"])
# fireOnEventObj.setGPSPkg(gpsData)
# fireOnEventObj.setEventType("0010")
# firOnEventMsg = fireOnEventObj.generateEventMsg()
# type = self.getMsgFunId(firOnEventMsg)
# self.sendMsg(firOnEventMsg)
# self.sn = self.sn + 1
# self.websocket.sendMsgToClient(type + ">>>>:" + firOnEventMsg,self.websocketId)
jdata
=
{
"WATER_CODE"
:
"0003"
,
"DEV_ID"
:
"M121501010001"
,
"gpsInfo"
:
{
"UTCTime"
:
"2020-04-30 14:59:33"
,
"latitude"
:
"40.22077"
,
"longitude"
:
"116.23128"
,
"speed"
:
"80.8"
,
"directionAngle"
:
"80.8"
,
"elevation"
:
"2999.9"
,
"positionStar"
:
"3"
,
"Pdop"
:
"0.3"
,
"Hdop"
:
"0.4"
,
"Vdop"
:
"0.5"
,
"statusBit"
:
162
,
"valtage"
:
"36.9"
,
"OBDSpeed"
:
"60.9"
,
"engineSpeed"
:
"3000"
,
"GPSTotalMileage"
:
"12800"
,
"totalOil"
:
"100000"
,
"totalTime"
:
"2020002"
,
"GPSTimestamp"
:
"1588229973"
},
"securityData"
:
{
"securityStatus"
:
107
,
"doorStatus"
:
0
,
"lockStatus"
:
0
,
"windowStatus"
:
0
,
"lightStatus"
:
0
,
"onoffStatusA"
:
0
,
"onoffStatusB"
:
112
,
"dataByte"
:
249
},
"event"
:
{
"0010"
:
{
"allRapidlyAccelerateCount"
:
"5"
,
"allSharpSlowdownCount"
:
"6"
,
"allSharpTurn"
:
"4"
,
"dataProperty"
:
"1"
}}}
jdata
[
"event"
][
"0010"
][
"allRapidlyAccelerateCount"
]
=
self
.
carData
[
"event"
][
"threeRapid"
][
"totalRapidlyAccelerate"
]
jdata
[
"event"
][
"0010"
][
"allSharpSlowdownCount"
]
=
self
.
carData
[
"event"
][
"threeRapid"
][
"totalSharpSlowdown"
]
jdata
[
"event"
][
"0010"
][
"allSharpTurn"
]
=
self
.
carData
[
"event"
][
"threeRapid"
][
"totalSharpTurn"
]
jdata
[
"DEV_ID"
]
=
self
.
carId
obj
=
EventReport_protocol
(
data
=
jdata
)
gpsData
=
self
.
genGPSData2
()
obj
.
setGPSPkg
(
gpsData
)
obj
.
setEventType
(
"0010"
)
msg
=
obj
.
generateEventMsg
()
type
=
self
.
getMsgFunId
(
msg
)
self
.
sendMsg
(
msg
)
self
.
sn
=
self
.
sn
+
1
self
.
websocket
.
sendMsgToClient
(
type
+
">>>>:"
+
firOnEventMsg
,
self
.
websocketId
)
self
.
websocket
.
sendMsgToClient
(
type
+
">>>>:"
+
msg
,
self
.
websocketId
)
sleep
(
0.1
)
gpsMsg
=
self
.
genGPSMsg
(
self
.
gpsLine
[
0
][
"lat"
],
self
.
gpsLine
[
0
][
"lng"
])
type
=
self
.
getMsgFunId
(
gpsMsg
)
...
...
@@ -385,14 +412,42 @@ class ProtocolSimulaterService():
gpsLineIndex
=
self
.
gpsLineIndex
if
gpsLineIndex
>=
len
(
self
.
gpsLine
):
gpsLineIndex
=
gpsLineIndex
-
1
fireOffEventObj
=
EventReport_protocol
(
DEV_ID
=
self
.
carId
)
gpsData
=
self
.
genGPSData
(
self
.
gpsLine
[
gpsLineIndex
][
"lat"
],
self
.
gpsLine
[
gpsLineIndex
][
"lng"
])
fireOffEventObj
.
setGPSPkg
(
gpsData
)
fireOffEventObj
.
setEventType
(
"0011"
)
fireOffEventMsg
=
fireOffEventObj
.
generateEventMsg
()
type
=
self
.
getMsgFunId
(
fireOffEventMsg
)
self
.
sendMsg
(
fireOffEventMsg
)
self
.
websocket
.
sendMsgToClient
(
type
+
">>>>:"
+
fireOffEventMsg
,
self
.
websocketId
)
# fireOffEventObj = EventReport_protocol(DEV_ID=self.carId)
# gpsData = self.genGPSData(self.gpsLine[gpsLineIndex]["lat"],self.gpsLine[gpsLineIndex]["lng"])
# fireOffEventObj.setGPSPkg(gpsData)
# fireOffEventObj.setEventType("0011")
# fireOffEventMsg = fireOffEventObj.generateEventMsg()
# type = self.getMsgFunId(fireOffEventMsg)
# self.sendMsg(fireOffEventMsg)
# self.sn = self.sn + 1
# self.websocket.sendMsgToClient(type + ">>>>:" + fireOffEventMsg,self.websocketId)
jdata
=
{
"WATER_CODE"
:
"0003"
,
"DEV_ID"
:
"M121501010001"
,
"gpsInfo"
:
{
"UTCTime"
:
"2020-04-30 14:59:33"
,
"latitude"
:
"40.22077"
,
"longitude"
:
"116.23128"
,
"speed"
:
"80.8"
,
"directionAngle"
:
"80.8"
,
"elevation"
:
"2999.9"
,
"positionStar"
:
"3"
,
"Pdop"
:
"0.3"
,
"Hdop"
:
"0.4"
,
"Vdop"
:
"0.5"
,
"statusBit"
:
162
,
"valtage"
:
"36.9"
,
"OBDSpeed"
:
"60.9"
,
"engineSpeed"
:
"3000"
,
"GPSTotalMileage"
:
"12800"
,
"totalOil"
:
"100000"
,
"totalTime"
:
"2020002"
,
"GPSTimestamp"
:
"1588229973"
},
"securityData"
:
{
"securityStatus"
:
107
,
"doorStatus"
:
0
,
"lockStatus"
:
0
,
"windowStatus"
:
0
,
"lightStatus"
:
0
,
"onoffStatusA"
:
0
,
"onoffStatusB"
:
112
,
"dataByte"
:
249
},
"event"
:
{
"0011"
:
{
"allRapidlyAccelerateCount"
:
"5"
,
"allSharpSlowdownCount"
:
"6"
,
"allSharpTurn"
:
"4"
,
"dataProperty"
:
"1"
}}}
jdata
[
"event"
][
"0011"
][
"allRapidlyAccelerateCount"
]
=
self
.
carData
[
"event"
][
"threeRapid"
][
"totalRapidlyAccelerate"
]
jdata
[
"event"
][
"0011"
][
"allSharpSlowdownCount"
]
=
self
.
carData
[
"event"
][
"threeRapid"
][
"totalSharpSlowdown"
]
jdata
[
"event"
][
"0011"
][
"allSharpTurn"
]
=
self
.
carData
[
"event"
][
"threeRapid"
][
"totalSharpTurn"
]
jdata
[
"DEV_ID"
]
=
self
.
carId
obj
=
EventReport_protocol
(
data
=
jdata
)
gpsData
=
self
.
genGPSData2
()
obj
.
setGPSPkg
(
gpsData
)
obj
.
setEventType
(
"0011"
)
msg
=
obj
.
generateEventMsg
()
type
=
self
.
getMsgFunId
(
msg
)
self
.
sendMsg
(
msg
)
self
.
sn
=
self
.
sn
+
1
self
.
websocket
.
sendMsgToClient
(
type
+
">>>>:"
+
msg
,
self
.
websocketId
)
sleep
(
0.1
)
gpsMsg
=
self
.
genGPSMsg
(
self
.
gpsLine
[
gpsLineIndex
][
"lat"
],
self
.
gpsLine
[
gpsLineIndex
][
"lng"
])
type
=
self
.
getMsgFunId
(
gpsMsg
)
...
...
lib/socket/service/websocket_service.py
View file @
fc54f847
...
...
@@ -3,6 +3,7 @@ import json
import
logging
import
threading
import
time
import
traceback
from
time
import
sleep
from
lib.socket.SocketBase
import
SocketBase
...
...
@@ -90,8 +91,8 @@ class Websocket_service(SocketBase):
#给指定客户端发送消息
def
sendMsgToClient
(
self
,
msg
,
clientId
):
print
(
self
.
clients
)
print
(
self
.
server
)
#
print(self.clients)
#
print(self.server)
data
=
{}
data
[
"code"
]
=
"0002"
data
[
"client"
]
=
self
.
currentClient
...
...
@@ -100,6 +101,7 @@ class Websocket_service(SocketBase):
self
.
server
.
send_message
(
self
.
clients
[
clientId
],
data
)
if
__name__
==
"__main__"
:
w
=
Websocket_service
()
w
.
setHost
(
"127.0.0.1"
)
...
...
views/protocolTools/M_carSimulater_process.py
View file @
fc54f847
...
...
@@ -505,6 +505,8 @@ def sendRapidlyAccelerateEvent():
"0020"
:
{
"allRapidlyAccelerateCount"
:
"5"
,
"allSharpSlowdownCount"
:
"6"
,
"allSharpTurn"
:
"4"
,
"dataProperty"
:
"1"
}}}
carData
=
service
.
getCarData
()
carData
[
"event"
][
"threeRapid"
][
"totalRapidlyAccelerate"
]
=
carData
[
"event"
][
"threeRapid"
][
"totalRapidlyAccelerate"
]
+
1
service
.
setCarData
(
carData
)
jdata
[
"event"
][
"0020"
][
"allRapidlyAccelerateCount"
]
=
carData
[
"event"
][
"threeRapid"
][
"totalRapidlyAccelerate"
]
jdata
[
"event"
][
"0020"
][
"allSharpSlowdownCount"
]
=
carData
[
"event"
][
"threeRapid"
][
"totalSharpSlowdown"
]
jdata
[
"event"
][
"0020"
][
"allSharpTurn"
]
=
carData
[
"event"
][
"threeRapid"
][
"totalSharpTurn"
]
...
...
@@ -516,8 +518,6 @@ def sendRapidlyAccelerateEvent():
msg
=
obj
.
generateEventMsg
()
service
.
serviceSendMsg
(
msg
,
"急加速事件"
)
service
.
setSn
(
service
.
getSn
()
+
1
)
carData
[
"event"
][
"threeRapid"
][
"totalRapidlyAccelerate"
]
=
carData
[
"event"
][
"threeRapid"
][
"totalRapidlyAccelerate"
]
+
1
service
.
setCarData
(
carData
)
data
[
"status"
]
=
"200"
data
[
"message"
]
=
"发送急加速事件成功!"
except
BaseException
as
e
:
...
...
@@ -559,6 +559,8 @@ def sendSharpSlowdownEvent():
"0021"
:
{
"allRapidlyAccelerateCount"
:
"5"
,
"allSharpSlowdownCount"
:
"6"
,
"allSharpTurn"
:
"4"
,
"dataProperty"
:
"1"
}}}
carData
=
service
.
getCarData
()
carData
[
"event"
][
"threeRapid"
][
"totalSharpSlowdown"
]
=
carData
[
"event"
][
"threeRapid"
][
"totalSharpSlowdown"
]
+
1
service
.
setCarData
(
carData
)
jdata
[
"event"
][
"0021"
][
"allRapidlyAccelerateCount"
]
=
carData
[
"event"
][
"threeRapid"
][
"totalRapidlyAccelerate"
]
jdata
[
"event"
][
"0021"
][
"allSharpSlowdownCount"
]
=
carData
[
"event"
][
"threeRapid"
][
"totalSharpSlowdown"
]
jdata
[
"event"
][
"0021"
][
"allSharpTurn"
]
=
carData
[
"event"
][
"threeRapid"
][
"totalSharpTurn"
]
...
...
@@ -570,8 +572,6 @@ def sendSharpSlowdownEvent():
msg
=
obj
.
generateEventMsg
()
service
.
serviceSendMsg
(
msg
,
"急减速事件"
)
service
.
setSn
(
service
.
getSn
()
+
1
)
carData
[
"event"
][
"threeRapid"
][
"totalSharpSlowdown"
]
=
carData
[
"event"
][
"threeRapid"
][
"totalSharpSlowdown"
]
+
1
service
.
setCarData
(
carData
)
data
[
"status"
]
=
"200"
data
[
"message"
]
=
"发送急减速事件成功!"
except
BaseException
as
e
:
...
...
@@ -613,6 +613,8 @@ def sendSharpTurnEvent():
"0022"
:
{
"allRapidlyAccelerateCount"
:
"5"
,
"allSharpSlowdownCount"
:
"6"
,
"allSharpTurn"
:
"4"
,
"direction"
:
"0"
,
"dataProperty"
:
"1"
}}}
carData
=
service
.
getCarData
()
carData
[
"event"
][
"threeRapid"
][
"totalSharpTurn"
]
=
carData
[
"event"
][
"threeRapid"
][
"totalSharpTurn"
]
+
1
service
.
setCarData
(
carData
)
jdata
[
"event"
][
"0022"
][
"allRapidlyAccelerateCount"
]
=
carData
[
"event"
][
"threeRapid"
][
"totalRapidlyAccelerate"
]
jdata
[
"event"
][
"0022"
][
"allSharpSlowdownCount"
]
=
carData
[
"event"
][
"threeRapid"
][
"totalSharpSlowdown"
]
jdata
[
"event"
][
"0022"
][
"allSharpTurn"
]
=
carData
[
"event"
][
"threeRapid"
][
"totalSharpTurn"
]
...
...
@@ -624,8 +626,6 @@ def sendSharpTurnEvent():
msg
=
obj
.
generateEventMsg
()
service
.
serviceSendMsg
(
msg
,
"急转弯事件"
)
service
.
setSn
(
service
.
getSn
()
+
1
)
carData
[
"event"
][
"threeRapid"
][
"totalSharpTurn"
]
=
carData
[
"event"
][
"threeRapid"
][
"totalSharpTurn"
]
+
1
service
.
setCarData
(
carData
)
data
[
"status"
]
=
"200"
data
[
"message"
]
=
"发送急转弯事件成功!"
except
BaseException
as
e
:
...
...
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