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
cc9ab483
Commit
cc9ab483
authored
May 29, 2020
by
liyuanhong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
M300模拟器开发完成
parent
910ca259
Changes
12
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
1118 additions
and
310 deletions
+1118
-310
data/m300Tools/carData/M202003060518.json
data/m300Tools/carData/M202003060518.json
+1
-0
data/protocolTools/carData/M202003060520.json
data/protocolTools/carData/M202003060520.json
+1
-1
lib/protocol/m300/Alarm_protocol_m300.py
lib/protocol/m300/Alarm_protocol_m300.py
+3
-1
lib/protocol/m300/OBDCAN_protocol_m300.py
lib/protocol/m300/OBDCAN_protocol_m300.py
+2
-2
lib/socket/service/M300SimulaterDataService.py
lib/socket/service/M300SimulaterDataService.py
+0
-47
lib/socket/service/M300SimulaterService.py
lib/socket/service/M300SimulaterService.py
+561
-0
lib/socket/service/MessageSimulaterService.py
lib/socket/service/MessageSimulaterService.py
+1
-1
lib/socket/service/ProtocolSimulaterService.py
lib/socket/service/ProtocolSimulaterService.py
+6
-6
templates/m300Tools/report/M_m300Simulater_page.html
templates/m300Tools/report/M_m300Simulater_page.html
+128
-247
views/m300Tools/M_m300Simulater_process.py
views/m300Tools/M_m300Simulater_process.py
+411
-1
views/messageTools/M_simulater_process.py
views/messageTools/M_simulater_process.py
+2
-2
views/protocolTools/M_carSimulater_process.py
views/protocolTools/M_carSimulater_process.py
+2
-2
No files found.
data/m300Tools/carData/M202003060518.json
0 → 100644
View file @
cc9ab483
{
"time"
:
{
"dateTime"
:
"2020-05-29 18:06:43"
,
"date"
:
"2020-05-29"
,
"time"
:
"18:06:43"
},
"curDayTravel"
:
{
"todayTotalMilleage"
:
166
,
"todayTotalOil"
:
16
,
"todayTotalTime"
:
10
,
"theMilleage"
:
166
,
"theOil"
:
16
,
"theTime"
:
10
},
"travelData"
:
{
"totalMilleage"
:
166
,
"totalOil"
:
16
,
"totalTime"
:
10
}}
\ No newline at end of file
data/protocolTools/carData/M202003060520.json
View file @
cc9ab483
{
"time"
:
{
"dateTime"
:
"2020-05-28 10:09:51"
,
"date"
:
"2020-05-28"
,
"time"
:
"10:09:51"
},
"curDayTravel"
:
{
"todayTotalMilleage"
:
5491
,
"todayTotalOil"
:
421
,
"todayTotalTime"
:
338
,
"theMilleage"
:
1497
,
"theOil"
:
102
,
"theTime"
:
93
},
"travelData"
:
{
"totalMilleage"
:
341804
,
"totalOil"
:
32099
,
"totalTime"
:
20303
},
"event"
:
{
"threeRapid"
:
{
"totalRapidlyAccelerate"
:
19
,
"totalSharpSlowdown"
:
18
,
"totalSharpTurn"
:
17
}}}
{
"time"
:
{
"dateTime"
:
"2020-05-29 14:34:14"
,
"date"
:
"2020-05-29"
,
"time"
:
"14:34:14"
},
"curDayTravel"
:
{
"todayTotalMilleage"
:
1469
,
"todayTotalOil"
:
134
,
"todayTotalTime"
:
89
,
"theMilleage"
:
307
,
"theOil"
:
22
,
"theTime"
:
19
},
"travelData"
:
{
"totalMilleage"
:
343273
,
"totalOil"
:
32233
,
"totalTime"
:
20392
},
"event"
:
{
"threeRapid"
:
{
"totalRapidlyAccelerate"
:
19
,
"totalSharpSlowdown"
:
18
,
"totalSharpTurn"
:
17
}}}
\ No newline at end of file
\ No newline at end of file
lib/protocol/m300/Alarm_protocol_m300.py
View file @
cc9ab483
...
@@ -21,10 +21,12 @@ class Alarm_protocol_m300(M300Base):
...
@@ -21,10 +21,12 @@ class Alarm_protocol_m300(M300Base):
self
.
GSMPkg
=
"0000000000"
self
.
GSMPkg
=
"0000000000"
self
.
CANStatus
=
"ffffffffffffffffffff00000000000000000000"
self
.
CANStatus
=
"ffffffffffffffffffff00000000000000000000"
else
:
else
:
self
.
waterCode
=
data
[
"waterCode"
]
self
.
DEV_ID
=
data
[
"DEV_ID"
]
self
.
alarm
=
data
[
"alarm"
]
GPSData
=
data
[
"GPSData"
]
GPSData
=
data
[
"GPSData"
]
GSMData
=
data
[
"GSMData"
]
GSMData
=
data
[
"GSMData"
]
OBDData
=
data
[
"OBDCANData"
]
OBDData
=
data
[
"OBDCANData"
]
self
.
alarm
=
data
[
"alarm"
]
self
.
GPSPkg
=
GPS_protocol_m300
(
dateInfo
=
GPSData
[
"dateInfo"
],
latitude
=
float
(
GPSData
[
"latitude"
]),
longitude
=
float
(
GPSData
[
"longitude"
])
\
self
.
GPSPkg
=
GPS_protocol_m300
(
dateInfo
=
GPSData
[
"dateInfo"
],
latitude
=
float
(
GPSData
[
"latitude"
]),
longitude
=
float
(
GPSData
[
"longitude"
])
\
,
positionStar
=
int
(
GPSData
[
"positionStar"
]),
speed
=
float
(
GPSData
[
"speed"
]),
direction
=
float
(
GPSData
[
"direction"
]),
\
,
positionStar
=
int
(
GPSData
[
"positionStar"
]),
speed
=
float
(
GPSData
[
"speed"
]),
direction
=
float
(
GPSData
[
"direction"
]),
\
altitude
=
float
(
GPSData
[
"altitude"
]),
ACCStatus
=
int
(
GPSData
[
"ACCStatus"
]),
valtage
=
float
(
GPSData
[
"valtage"
]),
OBDSpeed
=
float
(
GPSData
[
"OBDSpeed"
]),
\
altitude
=
float
(
GPSData
[
"altitude"
]),
ACCStatus
=
int
(
GPSData
[
"ACCStatus"
]),
valtage
=
float
(
GPSData
[
"valtage"
]),
OBDSpeed
=
float
(
GPSData
[
"OBDSpeed"
]),
\
...
...
lib/protocol/m300/OBDCAN_protocol_m300.py
View file @
cc9ab483
...
@@ -66,9 +66,9 @@ class OBDCAN_protocol_m300(M300Base):
...
@@ -66,9 +66,9 @@ class OBDCAN_protocol_m300(M300Base):
self
.
timeInfo
=
data
self
.
timeInfo
=
data
def
setAccstatus
(
self
,
data
):
def
setAccstatus
(
self
,
data
):
if
data
==
1
:
if
data
==
1
:
return
self
.
safeStatus
|
1
self
.
safeStatus
=
self
.
safeStatus
|
1
elif
data
==
0
:
elif
data
==
0
:
return
self
.
safeStatus
&
~
1
self
.
safeStatus
=
self
.
safeStatus
&
~
1
def
setEngineSpeed
(
self
,
data
):
def
setEngineSpeed
(
self
,
data
):
self
.
engineSpeed
=
data
self
.
engineSpeed
=
data
def
setSpeed
(
self
,
data
):
def
setSpeed
(
self
,
data
):
...
...
lib/socket/service/M300SimulaterDataService.py
View file @
cc9ab483
...
@@ -43,28 +43,6 @@ class M300SimulaterDataService():
...
@@ -43,28 +43,6 @@ class M300SimulaterDataService():
data
[
"travelData"
][
"totalMilleage"
]
=
0
#行驶总里程
data
[
"travelData"
][
"totalMilleage"
]
=
0
#行驶总里程
data
[
"travelData"
][
"totalOil"
]
=
0
#行驶总油耗
data
[
"travelData"
][
"totalOil"
]
=
0
#行驶总油耗
data
[
"travelData"
][
"totalTime"
]
=
0
#行驶总时间
data
[
"travelData"
][
"totalTime"
]
=
0
#行驶总时间
data
[
"event"
]
=
{}
data
[
"event"
][
"threeRapid"
]
=
{}
#急加速,急减速,急转弯基本数据
data
[
"event"
][
"threeRapid"
][
"totalRapidlyAccelerate"
]
=
0
#急加速总次数
data
[
"event"
][
"threeRapid"
][
"totalSharpSlowdown"
]
=
0
#急减速总次数
data
[
"event"
][
"threeRapid"
][
"totalSharpTurn"
]
=
0
#急转弯总次数
return
data
####################################################
# 修复默认数据模板
# 用于在升级模拟器的时候,对增加的字段进行初始化
####################################################
def
fixDataTemplate
(
self
,
data
):
if
not
"event"
in
data
:
data
[
"event"
]
=
{}
data
[
"event"
][
"threeRapid"
]
=
{}
data
[
"event"
][
"threeRapid"
][
"totalRapidlyAccelerate"
]
=
0
# 急加速总次数
data
[
"event"
][
"threeRapid"
][
"totalSharpSlowdown"
]
=
0
# 急减速总次数
data
[
"event"
][
"threeRapid"
][
"totalSharpTurn"
]
=
0
# 急转弯总次数
if
not
"threeRapid"
in
data
[
"event"
]:
data
[
"event"
][
"threeRapid"
]
=
{}
data
[
"event"
][
"threeRapid"
][
"totalRapidlyAccelerate"
]
=
0
#急加速总次数
data
[
"event"
][
"threeRapid"
][
"totalSharpSlowdown"
]
=
0
#急减速总次数
data
[
"event"
][
"threeRapid"
][
"totalSharpTurn"
]
=
0
#急转弯总次数
return
data
return
data
#设今日行驶总里程,同时写入文件
#设今日行驶总里程,同时写入文件
...
@@ -106,31 +84,6 @@ class M300SimulaterDataService():
...
@@ -106,31 +84,6 @@ class M300SimulaterDataService():
self
.
data
[
"travelData"
][
"totalTime"
]
=
data
self
.
data
[
"travelData"
][
"totalTime"
]
=
data
self
.
writeToFile
(
self
.
path
+
self
.
fileName
,
self
.
data
)
self
.
writeToFile
(
self
.
path
+
self
.
fileName
,
self
.
data
)
#设置急加速总次数,同时写入文件
def
setTotalRapidlyAccelerateCount
(
self
,
data
):
if
not
"event"
in
data
:
data
[
"event"
]
=
{}
if
not
"threeRapid"
in
data
[
"event"
]:
data
[
"event"
][
"threeRapid"
]
=
{}
data
[
"event"
][
"threeRapid"
][
"totalRapidlyAccelerate"
]
=
data
self
.
writeToFile
(
self
.
path
+
self
.
fileName
,
self
.
data
)
# 设置急减速总次数,同时写入文件
def
setTotalSharpSlowdown
(
self
,
data
):
if
not
"event"
in
data
:
data
[
"event"
]
=
{}
if
not
"threeRapid"
in
data
[
"event"
]:
data
[
"event"
][
"threeRapid"
]
=
{}
data
[
"event"
][
"threeRapid"
][
"totalSharpSlowdown"
]
=
data
self
.
writeToFile
(
self
.
path
+
self
.
fileName
,
self
.
data
)
# 设置急转弯总次数,同时写入文件
def
setTotalSharpTurn
(
self
,
data
):
if
not
"event"
in
data
:
data
[
"event"
]
=
{}
if
not
"threeRapid"
in
data
[
"event"
]:
data
[
"event"
][
"threeRapid"
]
=
{}
data
[
"event"
][
"threeRapid"
][
"totalSharpTurn"
]
=
data
self
.
writeToFile
(
self
.
path
+
self
.
fileName
,
self
.
data
)
#设今日日期时间
#设今日日期时间
def
setDateTime2file
(
self
,
data
):
def
setDateTime2file
(
self
,
data
):
self
.
data
[
"time"
][
"dateTime"
]
=
data
self
.
data
[
"time"
][
"dateTime"
]
=
data
...
...
lib/socket/service/M300SimulaterService.py
0 → 100644
View file @
cc9ab483
This diff is collapsed.
Click to expand it.
lib/socket/service/MessageSimulaterService.py
View file @
cc9ab483
...
@@ -106,7 +106,7 @@ class MessageSimulaterService():
...
@@ -106,7 +106,7 @@ class MessageSimulaterService():
def
revMsg
(
self
):
def
revMsg
(
self
):
self
.
socket
.
setTimeOut
(
self
.
timeout
)
self
.
socket
.
setTimeOut
(
self
.
timeout
)
return
self
.
socket
.
receive
()
return
self
.
socket
.
receive
()
#websocket向网页发送消息
,可指定消息的描述类型
#websocket向网页发送消息
def
serviceSendMsg
(
self
,
msg
):
def
serviceSendMsg
(
self
,
msg
):
self
.
sendMsg
(
msg
)
self
.
sendMsg
(
msg
)
type
=
self
.
getMsgFunId
(
msg
)
type
=
self
.
getMsgFunId
(
msg
)
...
...
lib/socket/service/ProtocolSimulaterService.py
View file @
cc9ab483
...
@@ -447,12 +447,12 @@ class ProtocolSimulaterService():
...
@@ -447,12 +447,12 @@ class ProtocolSimulaterService():
self
.
sn
=
self
.
sn
+
1
self
.
sn
=
self
.
sn
+
1
self
.
websocket
.
sendMsgToClient
(
type
+
">>>>:"
+
msg
,
self
.
websocketId
)
self
.
websocket
.
sendMsgToClient
(
type
+
">>>>:"
+
msg
,
self
.
websocketId
)
sleep
(
0.1
)
#
sleep(0.1)
gpsMsg
=
self
.
genGPSMsg
(
self
.
gpsLine
[
gpsLineIndex
][
"lat"
],
self
.
gpsLine
[
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.sn = self.sn + 1
self
.
websocket
.
sendMsgToClient
(
type
+
">>>>:"
+
gpsMsg
,
self
.
websocketId
)
#
self.websocket.sendMsgToClient(type + ">>>>:" + gpsMsg,self.websocketId)
#根据特定参数,生成GPS消息
#根据特定参数,生成GPS消息
def
genGPSMsg
(
self
,
latitude
,
longtitude
,
direct
=
0
):
def
genGPSMsg
(
self
,
latitude
,
longtitude
,
direct
=
0
):
...
...
templates/m300Tools/report/M_m300Simulater_page.html
View file @
cc9ab483
This diff is collapsed.
Click to expand it.
views/m300Tools/M_m300Simulater_process.py
View file @
cc9ab483
This diff is collapsed.
Click to expand it.
views/messageTools/M_simulater_process.py
View file @
cc9ab483
...
@@ -278,11 +278,11 @@ def fileUplad():
...
@@ -278,11 +278,11 @@ def fileUplad():
f
=
request
.
files
.
get
(
'file'
)
f
=
request
.
files
.
get
(
'file'
)
file_content
=
f
.
read
()
file_content
=
f
.
read
()
try
:
try
:
file_content
=
file_content
.
decode
(
"utf-8"
)
file_content
=
file_content
.
decode
(
"utf-8"
)
.
replace
(
"
\n
"
,
""
)
except
BaseException
as
e
:
except
BaseException
as
e
:
pass
pass
try
:
try
:
file_content
=
file_content
.
decode
(
"gbk"
)
file_content
=
file_content
.
decode
(
"gbk"
)
.
replace
(
"
\n
"
,
""
)
except
BaseException
as
e
:
except
BaseException
as
e
:
pass
pass
maxPrefix
=
int
(
fileUtil
.
getMaxPrefixFilePre
(
"data/messageTools/GPSLines"
))
maxPrefix
=
int
(
fileUtil
.
getMaxPrefixFilePre
(
"data/messageTools/GPSLines"
))
...
...
views/protocolTools/M_carSimulater_process.py
View file @
cc9ab483
...
@@ -307,11 +307,11 @@ def fileUplad():
...
@@ -307,11 +307,11 @@ def fileUplad():
f
=
request
.
files
.
get
(
'file'
)
f
=
request
.
files
.
get
(
'file'
)
file_content
=
f
.
read
()
file_content
=
f
.
read
()
try
:
try
:
file_content
=
file_content
.
decode
(
"utf-8"
)
file_content
=
file_content
.
decode
(
"utf-8"
)
.
replace
(
"
\n
"
,
""
)
except
BaseException
as
e
:
except
BaseException
as
e
:
pass
pass
try
:
try
:
file_content
=
file_content
.
decode
(
"gbk"
)
file_content
=
file_content
.
decode
(
"gbk"
)
.
replace
(
"
\n
"
,
""
)
except
BaseException
as
e
:
except
BaseException
as
e
:
pass
pass
maxPrefix
=
int
(
fileUtil
.
getMaxPrefixFilePre
(
"data/protocolTools/GPSLines"
))
maxPrefix
=
int
(
fileUtil
.
getMaxPrefixFilePre
(
"data/protocolTools/GPSLines"
))
...
...
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