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
75a557c2
Commit
75a557c2
authored
Apr 08, 2020
by
liyuanhong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
m300 OBD图形操作界面开发完成
parent
87690cca
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
551 additions
and
4 deletions
+551
-4
lib/protocol/m300/OBDCAN_protocol_m300.py
lib/protocol/m300/OBDCAN_protocol_m300.py
+3
-3
static/js/m300Tools/m300.js
static/js/m300Tools/m300.js
+2
-0
templates/m300Tools/report/P_CAN_m300_page.html
templates/m300Tools/report/P_CAN_m300_page.html
+437
-0
templates/m300Tools/report/P_heartBeat_m300_page.html
templates/m300Tools/report/P_heartBeat_m300_page.html
+1
-0
views/m300Tools/P_m300Protocol_process.py
views/m300Tools/P_m300Protocol_process.py
+94
-1
views/m300Tools/P_m300Protocol_view.py
views/m300Tools/P_m300Protocol_view.py
+14
-0
No files found.
lib/protocol/m300/OBDCAN_protocol_m300.py
View file @
75a557c2
...
@@ -13,7 +13,7 @@ class OBDCAN_protocol_m300(M300Base):
...
@@ -13,7 +13,7 @@ class OBDCAN_protocol_m300(M300Base):
,
troubleCodeNum
=
2
,
engineSpeed
=
3000
,
speed
=
60
,
airInletTemperature
=
88
,
coolingLiquidTemperature
=
76
,
envTemperature
=
65
\
,
troubleCodeNum
=
2
,
engineSpeed
=
3000
,
speed
=
60
,
airInletTemperature
=
88
,
coolingLiquidTemperature
=
76
,
envTemperature
=
65
\
,
intakeManifoldPressure
=
20
,
oilPressure
=
276
,
atmosphericPressure
=
28
,
airFlow
=
550
,
valveLocation
=
51
,
acceleratorLocation
=
32
\
,
intakeManifoldPressure
=
20
,
oilPressure
=
276
,
atmosphericPressure
=
28
,
airFlow
=
550
,
valveLocation
=
51
,
acceleratorLocation
=
32
\
,
engineRunTime
=
370
,
troubleMileage
=
4508
,
surplusOil
=
801
,
engineLoad
=
52
,
fuelTrim
=
89
,
fireAngle
=
154
,
dashboardTotailMilleage
=
3000
\
,
engineRunTime
=
370
,
troubleMileage
=
4508
,
surplusOil
=
801
,
engineLoad
=
52
,
fuelTrim
=
89
,
fireAngle
=
154
,
dashboardTotailMilleage
=
3000
\
,
carTotalRunTime
=
360
,):
,
carTotalRunTime
=
360
,
tripMark
=
"0000"
):
super
()
.
__init__
()
# 不执行该方法,无法使用父类里面定义的属性
super
()
.
__init__
()
# 不执行该方法,无法使用父类里面定义的属性
self
.
waterCode
=
waterCode
#消息流水号
self
.
waterCode
=
waterCode
#消息流水号
self
.
DEV_ID
=
DEV_ID
#设备Id
self
.
DEV_ID
=
DEV_ID
#设备Id
...
@@ -60,7 +60,7 @@ class OBDCAN_protocol_m300(M300Base):
...
@@ -60,7 +60,7 @@ class OBDCAN_protocol_m300(M300Base):
self
.
dashboardTotailMilleage
=
dashboardTotailMilleage
#仪表总里程
self
.
dashboardTotailMilleage
=
dashboardTotailMilleage
#仪表总里程
self
.
carTotalRunTime
=
carTotalRunTime
#车辆总运行时间
self
.
carTotalRunTime
=
carTotalRunTime
#车辆总运行时间
self
.
retail
=
"00000000000000000000"
self
.
retail
=
"00000000000000000000"
self
.
tripMark
=
"0000"
#
驾驶循环标签
self
.
tripMark
=
tripMark
#
驾驶循环标签
#################################################
#################################################
...
@@ -234,7 +234,7 @@ class OBDCAN_protocol_m300(M300Base):
...
@@ -234,7 +234,7 @@ class OBDCAN_protocol_m300(M300Base):
dashboardData
=
0
#仪表数据,16:存在 0:不存在
dashboardData
=
0
#仪表数据,16:存在 0:不存在
engineSpeed
=
0
#发动机转速,32:存在 0:不存在
engineSpeed
=
0
#发动机转速,32:存在 0:不存在
carSpeed
=
0
#车辆速度,64:存在 0:不存在
carSpeed
=
0
#车辆速度,64:存在 0:不存在
surplueOil
=
0
#剩余油量,
64
:存在 0:不存在
surplueOil
=
0
#剩余油量,
128
:存在 0:不存在
val
=
V1N1
+
retain1
+
retain2
+
busMileage
+
dashboardData
+
engineSpeed
+
carSpeed
+
surplueOil
val
=
V1N1
+
retain1
+
retain2
+
busMileage
+
dashboardData
+
engineSpeed
+
carSpeed
+
surplueOil
hexData
=
self
.
int2hexStringByBytes
(
val
)
hexData
=
self
.
int2hexStringByBytes
(
val
)
return
hexData
return
hexData
...
...
static/js/m300Tools/m300.js
View file @
75a557c2
...
@@ -12,6 +12,8 @@ function m300ProtocolManTab(e){
...
@@ -12,6 +12,8 @@ function m300ProtocolManTab(e){
$
(
location
).
attr
(
'
href
'
,
"
http://
"
+
window
.
location
.
host
+
"
/m300Tools/P_m300Protocol_view/P_login_m300_page
"
);
$
(
location
).
attr
(
'
href
'
,
"
http://
"
+
window
.
location
.
host
+
"
/m300Tools/P_m300Protocol_view/P_login_m300_page
"
);
}
else
if
(
id
==
"
P_version_m300_msg
"
){
}
else
if
(
id
==
"
P_version_m300_msg
"
){
$
(
location
).
attr
(
'
href
'
,
"
http://
"
+
window
.
location
.
host
+
"
/m300Tools/P_m300Protocol_view/P_version_m300_page
"
);
$
(
location
).
attr
(
'
href
'
,
"
http://
"
+
window
.
location
.
host
+
"
/m300Tools/P_m300Protocol_view/P_version_m300_page
"
);
}
else
if
(
id
==
"
P_CAN_m300_msg
"
){
$
(
location
).
attr
(
'
href
'
,
"
http://
"
+
window
.
location
.
host
+
"
/m300Tools/P_m300Protocol_view/P_CAN_m300_page
"
);
}
else
{
}
else
{
alert
(
id
)
alert
(
id
)
}
}
...
...
templates/m300Tools/report/P_CAN_m300_page.html
0 → 100644
View file @
75a557c2
This diff is collapsed.
Click to expand it.
templates/m300Tools/report/P_heartBeat_m300_page.html
View file @
75a557c2
...
@@ -36,6 +36,7 @@
...
@@ -36,6 +36,7 @@
<li
role=
"presentation"
><a
id=
"P_heartBeat_m300_msg"
{%
if
arg.path[2]=
="P_heartBeat_m300_page"
%}
class=
"link-tab"
{%
endif
%}
onclick=
"m300ProtocolManTab(this)"
>
心跳消息
</b></a></li>
<li
role=
"presentation"
><a
id=
"P_heartBeat_m300_msg"
{%
if
arg.path[2]=
="P_heartBeat_m300_page"
%}
class=
"link-tab"
{%
endif
%}
onclick=
"m300ProtocolManTab(this)"
>
心跳消息
</b></a></li>
<li
role=
"presentation"
><a
id=
"P_login_m300_msg"
{%
if
arg.path[2]=
="P_login_m300_page"
%}
class=
"link-tab"
{%
endif
%}
onclick=
"m300ProtocolManTab(this)"
>
登录消息
</b></a></li>
<li
role=
"presentation"
><a
id=
"P_login_m300_msg"
{%
if
arg.path[2]=
="P_login_m300_page"
%}
class=
"link-tab"
{%
endif
%}
onclick=
"m300ProtocolManTab(this)"
>
登录消息
</b></a></li>
<li
role=
"presentation"
><a
id=
"P_version_m300_msg"
{%
if
arg.path[2]=
="P_version_m300_page"
%}
class=
"link-tab"
{%
endif
%}
onclick=
"m300ProtocolManTab(this)"
>
版本消息
</b></a></li>
<li
role=
"presentation"
><a
id=
"P_version_m300_msg"
{%
if
arg.path[2]=
="P_version_m300_page"
%}
class=
"link-tab"
{%
endif
%}
onclick=
"m300ProtocolManTab(this)"
>
版本消息
</b></a></li>
<li
role=
"presentation"
><a
id=
"P_CAN_m300_msg"
{%
if
arg.path[2]=
="P_CAN_m300_page"
%}
class=
"link-tab"
{%
endif
%}
onclick=
"m300ProtocolManTab(this)"
>
CAN消息
</b></a></li>
</ul>
</ul>
{% endblock %}
{% endblock %}
{% block content_1 %}
{% block content_1 %}
...
...
views/m300Tools/P_m300Protocol_process.py
View file @
75a557c2
...
@@ -5,6 +5,7 @@ from configparser import ConfigParser
...
@@ -5,6 +5,7 @@ from configparser import ConfigParser
from
lib.protocol.m300.Heartbeat_protocol_300
import
Heartbeat_protocol_300
from
lib.protocol.m300.Heartbeat_protocol_300
import
Heartbeat_protocol_300
from
lib.protocol.m300.Login_protocol_m300
import
Login_protocol_m300
from
lib.protocol.m300.Login_protocol_m300
import
Login_protocol_m300
from
lib.protocol.m300.OBDCAN_protocol_m300
import
OBDCAN_protocol_m300
from
lib.protocol.m300.VersionInfo_protocol_m300
import
VersionInfo_protocol_m300
from
lib.protocol.m300.VersionInfo_protocol_m300
import
VersionInfo_protocol_m300
from
lib.protocol.m300Plateform.M300Common_res
import
M300Common_res
from
lib.protocol.m300Plateform.M300Common_res
import
M300Common_res
from
lib.protocol.m300Plateform.M300Login_res
import
M300Login_res
from
lib.protocol.m300Plateform.M300Login_res
import
M300Login_res
...
@@ -130,7 +131,7 @@ def porcessLoginMsg():
...
@@ -130,7 +131,7 @@ def porcessLoginMsg():
return
Response
(
json
.
dumps
(
data
),
mimetype
=
'application/json'
)
return
Response
(
json
.
dumps
(
data
),
mimetype
=
'application/json'
)
##########################################
##########################################
# 【接口类型】处理发送的
登录
上报报文
# 【接口类型】处理发送的
版本信息
上报报文
##########################################
##########################################
@
P_m300Protocol_process
.
route
(
"/porcessVersionMsg"
,
methods
=
[
'POST'
])
@
P_m300Protocol_process
.
route
(
"/porcessVersionMsg"
,
methods
=
[
'POST'
])
def
porcessVersionMsg
():
def
porcessVersionMsg
():
...
@@ -177,4 +178,96 @@ def porcessVersionMsg():
...
@@ -177,4 +178,96 @@ def porcessVersionMsg():
traceback
.
print_exc
()
traceback
.
print_exc
()
data
[
"status"
]
=
"4003"
data
[
"status"
]
=
"4003"
data
[
"message"
]
=
"Error: 处理失败!"
data
[
"message"
]
=
"Error: 处理失败!"
return
Response
(
json
.
dumps
(
data
),
mimetype
=
'application/json'
)
##########################################
# 【接口类型】处理发送的OBD CAN 信息上报报文
##########################################
@
P_m300Protocol_process
.
route
(
"/porcessCANMsg"
,
methods
=
[
'POST'
])
def
porcessCANMsg
():
FUNID
=
request
.
form
.
get
(
"FUNID"
)
waterCode
=
int
(
request
.
form
.
get
(
"waterCode"
))
DEV_ID
=
request
.
form
.
get
(
"DEV_ID"
)
encryptionType
=
int
(
request
.
form
.
get
(
"encryptionType"
))
timeInfo
=
request
.
form
.
get
(
"timeInfo"
)
prototolType
=
request
.
form
.
get
(
"prototolType"
)
statusMask
=
request
.
form
.
get
(
"statusMask"
)
safeStatus
=
int
(
request
.
form
.
get
(
"safeStatus"
))
doorStatus
=
int
(
request
.
form
.
get
(
"doorStatus"
))
lockStatus
=
int
(
request
.
form
.
get
(
"lockStatus"
))
windowStatus
=
int
(
request
.
form
.
get
(
"windowStatus"
))
lightStatus
=
int
(
request
.
form
.
get
(
"lightStatus"
))
swichStatusA
=
int
(
request
.
form
.
get
(
"swichStatusA"
))
swichStatusB
=
int
(
request
.
form
.
get
(
"swichStatusB"
))
dataBit
=
int
(
request
.
form
.
get
(
"dataBit"
))
dataFlowMask
=
request
.
form
.
get
(
"dataFlowMask"
)
votage
=
int
(
request
.
form
.
get
(
"votage"
))
totalMilleageType
=
int
(
request
.
form
.
get
(
"totalMilleageType"
))
totalMilleage
=
int
(
request
.
form
.
get
(
"totalMilleage"
))
totalOil
=
int
(
request
.
form
.
get
(
"totalOil"
))
troubleLightStatus
=
int
(
request
.
form
.
get
(
"troubleLightStatus"
))
troubleCodeNum
=
int
(
request
.
form
.
get
(
"troubleCodeNum"
))
engineSpeed
=
int
(
request
.
form
.
get
(
"engineSpeed"
))
speed
=
int
(
request
.
form
.
get
(
"speed"
))
airInletTemperature
=
int
(
request
.
form
.
get
(
"airInletTemperature"
))
coolingLiquidTemperature
=
int
(
request
.
form
.
get
(
"coolingLiquidTemperature"
))
envTemperature
=
int
(
request
.
form
.
get
(
"envTemperature"
))
intakeManifoldPressure
=
int
(
request
.
form
.
get
(
"intakeManifoldPressure"
))
oilPressure
=
int
(
request
.
form
.
get
(
"oilPressure"
))
atmosphericPressure
=
int
(
request
.
form
.
get
(
"atmosphericPressure"
))
airFlow
=
int
(
request
.
form
.
get
(
"airFlow"
))
valveLocation
=
int
(
request
.
form
.
get
(
"valveLocation"
))
acceleratorLocation
=
int
(
request
.
form
.
get
(
"acceleratorLocation"
))
engineRunTime
=
int
(
request
.
form
.
get
(
"engineRunTime"
))
troubleMileage
=
int
(
request
.
form
.
get
(
"troubleMileage"
))
surplusOil
=
int
(
request
.
form
.
get
(
"surplusOil"
))
engineLoad
=
int
(
request
.
form
.
get
(
"engineLoad"
))
fuelTrim
=
int
(
request
.
form
.
get
(
"fuelTrim"
))
fireAngle
=
int
(
request
.
form
.
get
(
"fireAngle"
))
dashboardTotailMilleage
=
int
(
request
.
form
.
get
(
"dashboardTotailMilleage"
))
carTotalRunTime
=
int
(
request
.
form
.
get
(
"carTotalRunTime"
))
tripMark
=
request
.
form
.
get
(
"tripMark"
)
data
=
{}
if
(
waterCode
==
None
or
DEV_ID
==
None
or
encryptionType
==
None
or
timeInfo
==
None
or
prototolType
==
None
or
statusMask
==
None
\
or
safeStatus
==
None
or
doorStatus
==
None
or
lockStatus
==
None
or
windowStatus
==
None
or
lightStatus
==
None
or
swichStatusA
==
None
\
or
swichStatusB
==
None
or
dataBit
==
None
or
dataFlowMask
==
None
or
votage
==
None
or
totalMilleageType
==
None
or
totalMilleage
==
None
\
or
totalOil
==
None
or
troubleLightStatus
==
None
or
troubleCodeNum
==
None
or
engineSpeed
==
None
or
speed
==
None
or
airInletTemperature
==
None
\
or
coolingLiquidTemperature
==
None
or
envTemperature
==
None
or
intakeManifoldPressure
==
None
or
oilPressure
==
None
or
atmosphericPressure
==
None
or
airFlow
==
None
\
or
valveLocation
==
None
or
acceleratorLocation
==
None
or
engineRunTime
==
None
or
troubleMileage
==
None
or
surplusOil
==
None
or
engineLoad
==
None
\
or
fuelTrim
==
None
or
fireAngle
==
None
or
dashboardTotailMilleage
==
None
or
carTotalRunTime
==
None
or
tripMark
==
None
):
data
[
"status"
]
=
"4003"
data
[
"message"
]
=
"Info: 请检查是否传入了空数据!"
return
Response
(
json
.
dumps
(
data
),
mimetype
=
'application/json'
)
else
:
try
:
conf_R
=
ConfigParser
()
conf_R
.
read
(
"config/m300Tools/m300Tools.conf"
)
cliSocket
=
ClientSocket
(
conf_R
.
get
(
"socket"
,
"host"
),
conf_R
.
getint
(
"socket"
,
"port"
))
cliSocket
.
connect
()
protocolObj
=
OBDCAN_protocol_m300
(
waterCode
=
waterCode
,
DEV_ID
=
DEV_ID
,
encryptionType
=
encryptionType
,
timeInfo
=
timeInfo
,
prototolType
=
prototolType
,
statusMask
=
statusMask
\
,
safeStatus
=
safeStatus
,
doorStatus
=
doorStatus
,
lockStatus
=
lockStatus
,
windowStatus
=
windowStatus
,
lightStatus
=
lightStatus
,
swichStatusA
=
swichStatusA
\
,
swichStatusB
=
swichStatusB
,
dataBit
=
dataBit
,
dataFlowMask
=
dataFlowMask
,
votage
=
votage
,
totalMilleageType
=
totalMilleageType
,
totalMilleage
=
totalMilleage
\
,
totalOil
=
totalOil
,
troubleLightStatus
=
troubleLightStatus
,
troubleCodeNum
=
troubleCodeNum
,
engineSpeed
=
engineSpeed
,
speed
=
speed
,
airInletTemperature
=
airInletTemperature
\
,
coolingLiquidTemperature
=
coolingLiquidTemperature
,
envTemperature
=
envTemperature
,
intakeManifoldPressure
=
intakeManifoldPressure
,
oilPressure
=
oilPressure
\
,
atmosphericPressure
=
atmosphericPressure
,
airFlow
=
airFlow
,
valveLocation
=
valveLocation
,
acceleratorLocation
=
acceleratorLocation
,
engineRunTime
=
engineRunTime
,
troubleMileage
=
troubleMileage
,
surplusOil
=
surplusOil
,
engineLoad
=
engineLoad
,
fuelTrim
=
fuelTrim
,
fireAngle
=
fireAngle
,
dashboardTotailMilleage
=
dashboardTotailMilleage
\
,
carTotalRunTime
=
carTotalRunTime
,
tripMark
=
tripMark
)
msg
=
protocolObj
.
generateMsg
()
cliSocket
.
send
(
msg
)
socRecv
=
cliSocket
.
receive
()
socRecvo
=
str
(
socRecv
)
cliSocket
.
close
()
data
[
"status"
]
=
"200"
data
[
"message"
]
=
"Sucess: "
data
[
"msgSend"
]
=
msg
data
[
"result"
]
=
socRecvo
data
[
"rev"
]
=
str
(
binascii
.
b2a_hex
(
socRecv
))[
2
:][:
-
1
]
data
[
"orgRev"
]
=
json
.
loads
(
M300Common_res
(
data
[
"rev"
])
.
getMsg
())
except
BaseException
as
e
:
# 打印异常信息
traceback
.
print_exc
()
data
[
"status"
]
=
"4003"
data
[
"message"
]
=
"Error: 处理失败!"
return
Response
(
json
.
dumps
(
data
),
mimetype
=
'application/json'
)
return
Response
(
json
.
dumps
(
data
),
mimetype
=
'application/json'
)
\ No newline at end of file
views/m300Tools/P_m300Protocol_view.py
View file @
75a557c2
...
@@ -66,4 +66,18 @@ def P_version_m300_page():
...
@@ -66,4 +66,18 @@ def P_version_m300_page():
arg
=
{}
arg
=
{}
path
=
"m300Tools/report/P_version_m300_page.html"
path
=
"m300Tools/report/P_version_m300_page.html"
arg
[
"path"
]
=
reqPath
.
split
(
"/"
)
arg
[
"path"
]
=
reqPath
.
split
(
"/"
)
return
render_template
(
path
,
arg
=
arg
)
##########################################
# 【视图类型】访问版本协议页面
##########################################
@
P_m300Protocol_view
.
route
(
'/P_CAN_m300_page'
)
def
P_CAN_m300_page
():
#获取请求的路劲
url
=
request
.
url
reqPath
=
re
.
findall
(
"http://(.*)$"
,
url
)[
0
]
reqPath
=
re
.
findall
(
"/(.*)$"
,
reqPath
)[
0
]
arg
=
{}
path
=
"m300Tools/report/P_CAN_m300_page.html"
arg
[
"path"
]
=
reqPath
.
split
(
"/"
)
return
render_template
(
path
,
arg
=
arg
)
return
render_template
(
path
,
arg
=
arg
)
\ No newline at end of file
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