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
d54f9b19
Commit
d54f9b19
authored
May 11, 2020
by
liyuanhong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
完成M500 故障码报文图形界面
parent
517b34c9
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
164 additions
and
2 deletions
+164
-2
data/protocolTools/carData/M202003060050.json
data/protocolTools/carData/M202003060050.json
+1
-0
data/protocolTools/carData/M202003060200.json
data/protocolTools/carData/M202003060200.json
+1
-0
data/protocolTools/carData/M202003060520.json
data/protocolTools/carData/M202003060520.json
+1
-0
lib/protocol/report/TroubleCodeReport_protocol.py
lib/protocol/report/TroubleCodeReport_protocol.py
+2
-2
static/js/protocolTools/protocols.js
static/js/protocolTools/protocols.js
+2
-0
templates/protocolTools/report/GPS_protocol_page.html
templates/protocolTools/report/GPS_protocol_page.html
+1
-0
templates/protocolTools/report/troubleCode_protocol_page.html
...lates/protocolTools/report/troubleCode_protocol_page.html
+102
-0
views/protocolTools/protocolReport_process.py
views/protocolTools/protocolReport_process.py
+40
-0
views/protocolTools/protocolReport_view.py
views/protocolTools/protocolReport_view.py
+14
-0
No files found.
data/protocolTools/carData/M202003060050.json
0 → 100644
View file @
d54f9b19
{
"time"
:
{
"dateTime"
:
"2020-04-27 15:39:02"
,
"date"
:
"2020-04-27"
,
"time"
:
"15:39:02"
},
"curDayTravel"
:
{
"todayTotalMilleage"
:
2627
,
"todayTotalOil"
:
212
,
"todayTotalTime"
:
161
,
"theMilleage"
:
1411
,
"theOil"
:
136
,
"theTime"
:
85
},
"travelData"
:
{
"totalMilleage"
:
2627
,
"totalOil"
:
212
,
"totalTime"
:
161
}}
\ No newline at end of file
data/protocolTools/carData/M202003060200.json
0 → 100644
View file @
d54f9b19
{
"time"
:
{
"dateTime"
:
"2020-04-27 14:44:04"
,
"date"
:
"2020-04-27"
,
"time"
:
"14:44:04"
},
"curDayTravel"
:
{
"todayTotalMilleage"
:
913
,
"todayTotalOil"
:
88
,
"todayTotalTime"
:
55
,
"theMilleage"
:
913
,
"theOil"
:
88
,
"theTime"
:
55
},
"travelData"
:
{
"totalMilleage"
:
913
,
"totalOil"
:
88
,
"totalTime"
:
55
}}
\ No newline at end of file
data/protocolTools/carData/M202003060520.json
0 → 100644
View file @
d54f9b19
{
"time"
:
{
"dateTime"
:
"2020-05-11 10:59:13"
,
"date"
:
"2020-05-11"
,
"time"
:
"10:59:13"
},
"curDayTravel"
:
{
"todayTotalMilleage"
:
8549
,
"todayTotalOil"
:
824
,
"todayTotalTime"
:
515
,
"theMilleage"
:
830
,
"theOil"
:
80
,
"theTime"
:
50
},
"travelData"
:
{
"totalMilleage"
:
158616
,
"totalOil"
:
15025
,
"totalTime"
:
9286
},
"event"
:
{
"threeRapid"
:
{
"totalRapidlyAccelerate"
:
8
,
"totalSharpSlowdown"
:
6
,
"totalSharpTurn"
:
9
}}}
\ No newline at end of file
lib/protocol/report/TroubleCodeReport_protocol.py
View file @
d54f9b19
...
@@ -14,9 +14,9 @@ class TroubleCode_protocol(ProtocolBase):
...
@@ -14,9 +14,9 @@ class TroubleCode_protocol(ProtocolBase):
self
.
DEV_ID
=
DEV_ID
# 设置默认设备id
self
.
DEV_ID
=
DEV_ID
# 设置默认设备id
self
.
UTCTime
=
UTCTime
# 设置默认UTC时间
self
.
UTCTime
=
UTCTime
# 设置默认UTC时间
self
.
troubleCodeNum
=
troubleCodeNum
# 故障码个数
self
.
troubleCodeNum
=
int
(
troubleCodeNum
)
# 故障码个数
self
.
troubleCode
=
troubleCode
# 故障码内容
self
.
troubleCode
=
troubleCode
# 故障码内容
self
.
MILStatus
=
MILStatus
# MIL状态
self
.
MILStatus
=
int
(
MILStatus
)
# MIL状态
#####################################################
#####################################################
# 生成故障码消息
# 生成故障码消息
...
...
static/js/protocolTools/protocols.js
View file @
d54f9b19
...
@@ -20,6 +20,8 @@ function protocolManTab(e){
...
@@ -20,6 +20,8 @@ function protocolManTab(e){
$
(
location
).
attr
(
'
href
'
,
"
http://
"
+
window
.
location
.
host
+
"
/protocolTools/protocolReport_view/voltageData_protocol_page
"
);
$
(
location
).
attr
(
'
href
'
,
"
http://
"
+
window
.
location
.
host
+
"
/protocolTools/protocolReport_view/voltageData_protocol_page
"
);
}
else
if
(
id
==
"
event_protocol
"
){
}
else
if
(
id
==
"
event_protocol
"
){
$
(
location
).
attr
(
'
href
'
,
"
http://
"
+
window
.
location
.
host
+
"
/protocolTools/protocolReport_view/event_protocol_page
"
);
$
(
location
).
attr
(
'
href
'
,
"
http://
"
+
window
.
location
.
host
+
"
/protocolTools/protocolReport_view/event_protocol_page
"
);
}
else
if
(
id
==
"
troubleCode_protocol
"
){
$
(
location
).
attr
(
'
href
'
,
"
http://
"
+
window
.
location
.
host
+
"
/protocolTools/protocolReport_view/troubleCode_protocol_page
"
);
}
else
{
}
else
{
alert
(
id
)
alert
(
id
)
}
}
...
...
templates/protocolTools/report/GPS_protocol_page.html
View file @
d54f9b19
...
@@ -39,6 +39,7 @@
...
@@ -39,6 +39,7 @@
<li
role=
"presentation"
><a
id=
"securityStatus_protocol"
{%
if
arg.path[2]=
="securityStatus_protocol_page"
%}
class=
"link-tab"
{%
endif
%}
onclick=
"protocolManTab(this)"
>
安防状态报文
</b></a></li>
<li
role=
"presentation"
><a
id=
"securityStatus_protocol"
{%
if
arg.path[2]=
="securityStatus_protocol_page"
%}
class=
"link-tab"
{%
endif
%}
onclick=
"protocolManTab(this)"
>
安防状态报文
</b></a></li>
<li
role=
"presentation"
><a
id=
"voltageData_protocol"
{%
if
arg.path[2]=
="voltageData_protocol_page"
%}
class=
"link-tab"
{%
endif
%}
onclick=
"protocolManTab(this)"
>
电瓶电压采样报文
</b></a></li>
<li
role=
"presentation"
><a
id=
"voltageData_protocol"
{%
if
arg.path[2]=
="voltageData_protocol_page"
%}
class=
"link-tab"
{%
endif
%}
onclick=
"protocolManTab(this)"
>
电瓶电压采样报文
</b></a></li>
<li
role=
"presentation"
><a
id=
"event_protocol"
{%
if
arg.path[2]=
="event_protocol_page"
%}
class=
"link-tab"
{%
endif
%}
onclick=
"protocolManTab(this)"
>
事件报文
</b></a></li>
<li
role=
"presentation"
><a
id=
"event_protocol"
{%
if
arg.path[2]=
="event_protocol_page"
%}
class=
"link-tab"
{%
endif
%}
onclick=
"protocolManTab(this)"
>
事件报文
</b></a></li>
<li
role=
"presentation"
><a
id=
"troubleCode_protocol"
{%
if
arg.path[2]=
="troubleCode_protocol_page"
%}
class=
"link-tab"
{%
endif
%}
onclick=
"protocolManTab(this)"
>
故障码报文
</b></a></li>
</ul>
</ul>
{% endblock %}
{% endblock %}
{% block content_1 %}
{% block content_1 %}
...
...
templates/protocolTools/report/troubleCode_protocol_page.html
0 → 100644
View file @
d54f9b19
{% extends "protocolTools/report/GPS_protocol_page.html" %}
{% block title %}troubleCode_protocol{% endblock %}
{% block content_1 %}
<div
id=
"container3"
style=
"width:100%;min-height:750px;float:left;_background:green;margin-top:10px;_border-top: 1px solid #eee;"
>
<div
style=
"width:100%;_background:green;padding:5px;padding-top:0px;"
>
<h3
style=
"border-bottom: 1px solid #eee;"
>
设置协议头:
</h3>
<label>
消息流水号:
</label><input
id=
"WATER_CODE"
type=
"text"
class=
"form-control"
value=
"0003"
style=
"width:100px;"
>
<label
style=
"margin-left:10px;"
>
车机号:
</label><input
id=
"DEV_ID"
type=
"text"
class=
"form-control"
value=
"M121501010001"
>
</div>
<H3
style=
"border-bottom: 1px solid #eee;"
>
设置电压上报消息内容:
</H3>
<ul
class=
"protocol_content"
style=
"padding:0px;"
>
<li><label>
时间:
</label><input
id=
"curTime"
type=
"text"
class=
"form-control"
value=
"2020-1-20 16:24:36"
></li>
<li
style=
"width:170px;"
><label>
故障码个数:
</label><input
style=
"width:80px;"
id=
"troubleCodeNum"
type=
"text"
class=
"form-control"
value=
"1"
></li>
<li><label>
故障码类型:
</label><select
id=
"systemId"
class=
"form-control"
>
<option
value=
"00"
>
发动机故障码
</option>
<option
value=
"01"
>
变速箱故障码
</option>
<option
value=
"02"
>
ABS 故障码
</option>
<option
value=
"03"
>
安全气囊故障码
</option>
</select></li>
<li><label>
故障码状态:
</label><select
id=
"status"
class=
"form-control"
>
<option
value=
"0"
>
未解决
</option>
<option
value=
"1"
>
已解决
</option>
</select></li>
<li><label>
MIL状态:
</label><select
id=
"MILStatus"
class=
"form-control"
>
<option
value=
"0"
>
ON
</option>
<option
value=
"1"
>
OFF
</option>
</select></li>
</ul>
<H3
style=
"border-bottom: 1px solid #eee;"
>
控制:
</H3>
<div
style=
"width:100%;padding:5px;margin-top:10px;"
>
<button
type=
"button"
class=
"btn btn-primary"
id=
"sendMsgBtn"
>
发送消息
</button>
</div>
<H3
style=
"border-bottom: 1px solid #eee;"
>
返回信息:
</H3>
<div
style=
"width:100%;padding:5px;margin-top:10px;"
>
<textarea
id=
"showFeedback"
style=
"width:100%;padding:5px;"
rows=
"8"
></textarea>
</div>
</div>
<script>
//发送电瓶采样数据包
$
(
"
#sendMsgBtn
"
).
click
(
function
(){
var
WATER_CODE
=
$
(
"
#WATER_CODE
"
).
val
();
var
DEV_ID
=
$
(
"
#DEV_ID
"
).
val
();
var
curTime
=
$
(
"
#curTime
"
).
val
();
var
timestampTemp
=
DateToTimestamp
(
curTime
)
curTime
=
formatDate
(
parseInt
(
timestampTemp
)
-
8
*
3600
*
1000
)
var
troubleCodeNum
=
parseInt
(
$
(
"
#troubleCodeNum
"
).
val
())
var
systemId
=
$
(
"
#systemId
"
).
val
()
var
status
=
$
(
"
#status
"
).
val
()
var
troubleCode
=
[]
for
(
var
i
=
0
;
i
<
troubleCodeNum
;
i
++
){
var
temp
=
{}
temp
[
"
systemId
"
]
=
systemId
temp
[
"
content1
"
]
=
"
00
"
temp
[
"
content2
"
]
=
"
0
"
+
(
i
+
1
)
temp
[
"
status
"
]
=
status
troubleCode
.
push
(
temp
)
}
var
MILStatus
=
$
(
"
#MILStatus
"
).
val
()
var
data
=
{};
data
[
"
WATER_CODE
"
]
=
WATER_CODE
;
data
[
"
DEV_ID
"
]
=
DEV_ID
;
data
[
"
curTime
"
]
=
curTime
;
data
[
"
troubleCodeNum
"
]
=
troubleCodeNum
;
data
[
"
troubleCode
"
]
=
troubleCode
;
data
[
"
MILStatus
"
]
=
MILStatus
;
var
host
=
window
.
location
.
host
;
$
(
"
#showFeedback
"
).
val
(
""
)
$
.
ajax
({
url
:
"
http://
"
+
host
+
"
/protocolTools/protocolReport_process/porcessTroubleCodeMsg
"
,
type
:
"
post
"
,
data
:
JSON
.
stringify
(
data
),
contentType
:
"
application/json
"
,
dataType
:
"
json
"
,
success
:
function
(
data
){
if
(
data
.
status
==
200
){
//window.location.reload()
msg
=
"
发送消息:
"
+
data
.
msgSend
+
"
\n
"
msg
=
msg
+
"
收到消息:
"
+
data
.
result
+
"
\n
"
msg
=
msg
+
"
收到消息16进制:
"
+
data
.
rev
+
"
\n
"
msg
=
msg
+
"
收到消息解析结果:
"
+
JSON
.
stringify
(
data
.
orgRev
)
+
"
\n
"
$
(
"
#showFeedback
"
).
val
(
msg
)
}
else
{
$
(
"
#showFeedback
"
).
val
(
data
.
message
)
alert
(
data
.
message
);
}
}
});
});
//设置当前时间到UTC时间输入框
(
function
(){
var
curTime
=
getCurTime
();
$
(
"
#curTime
"
).
val
(
curTime
);
})();
</script>
{% endblock %}
\ No newline at end of file
views/protocolTools/protocolReport_process.py
View file @
d54f9b19
...
@@ -9,6 +9,7 @@ from lib.protocol.report.LoginReport_protocol import LoginReport_protocol
...
@@ -9,6 +9,7 @@ from lib.protocol.report.LoginReport_protocol import LoginReport_protocol
from
lib.protocol.report.GPSReport_protocol
import
GPSReport_protocol
from
lib.protocol.report.GPSReport_protocol
import
GPSReport_protocol
from
lib.protocol.report.OBDReport_CAN_protocol
import
OBDReport_CAN_protocol
from
lib.protocol.report.OBDReport_CAN_protocol
import
OBDReport_CAN_protocol
from
lib.protocol.report.SecurityStatusReport_protocol
import
SecurityStatusReport_protocol
from
lib.protocol.report.SecurityStatusReport_protocol
import
SecurityStatusReport_protocol
from
lib.protocol.report.TroubleCodeReport_protocol
import
TroubleCode_protocol
from
lib.protocol.report.VoltageDataReport_protocol
import
VoltageDataReport_protocol
from
lib.protocol.report.VoltageDataReport_protocol
import
VoltageDataReport_protocol
from
lib.protocol.reportPlateform.Common_res
import
Common_res
from
lib.protocol.reportPlateform.Common_res
import
Common_res
from
lib.protocol.reportPlateform.Login_res
import
Login_res
from
lib.protocol.reportPlateform.Login_res
import
Login_res
...
@@ -412,6 +413,45 @@ def porcessEventMsg():
...
@@ -412,6 +413,45 @@ def porcessEventMsg():
data
[
"message"
]
=
"Error: 处理失败!"
data
[
"message"
]
=
"Error: 处理失败!"
return
Response
(
json
.
dumps
(
data
),
mimetype
=
'application/json'
)
return
Response
(
json
.
dumps
(
data
),
mimetype
=
'application/json'
)
##########################################
# 【接口类型】处理发送的故障码报文
##########################################
@
protocolReport_process
.
route
(
"/porcessTroubleCodeMsg"
,
methods
=
[
'POST'
])
def
porcessTroubleCodeMsg
():
params
=
request
.
get_data
()
params
=
json
.
loads
(
params
.
decode
(
"utf-8"
))
data
=
{}
if
(
hasJsonDataIsNone
(
params
)):
data
[
"status"
]
=
"4003"
data
[
"message"
]
=
"Info: 请检查是否传入了空数据!"
return
Response
(
json
.
dumps
(
data
),
mimetype
=
'application/json'
)
else
:
try
:
conf_R
=
ConfigParser
()
conf_R
.
read
(
"config/protocolTools/protocolTools.conf"
)
cliSocket
=
ClientSocket
(
conf_R
.
get
(
"socket"
,
"host"
),
conf_R
.
getint
(
"socket"
,
"port"
))
cliSocket
.
connect
()
protocolObj
=
TroubleCode_protocol
(
WATER_CODE
=
params
[
"WATER_CODE"
],
DEV_ID
=
params
[
"DEV_ID"
],
\
UTCTime
=
params
[
"curTime"
],
troubleCodeNum
=
params
[
"troubleCodeNum"
],
troubleCode
=
params
[
"troubleCode"
],
\
MILStatus
=
params
[
"MILStatus"
])
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"
]
=
data
[
"orgRev"
]
=
json
.
loads
(
Common_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'
)
...
...
views/protocolTools/protocolReport_view.py
View file @
d54f9b19
...
@@ -120,4 +120,18 @@ def event_protocol_page():
...
@@ -120,4 +120,18 @@ def event_protocol_page():
arg
=
{}
arg
=
{}
path
=
"protocolTools/report/event_protocol_page.html"
path
=
"protocolTools/report/event_protocol_page.html"
arg
[
"path"
]
=
reqPath
.
split
(
"/"
)
arg
[
"path"
]
=
reqPath
.
split
(
"/"
)
return
render_template
(
path
,
arg
=
arg
)
##########################################
# 【视图类型】访问终端上报故障码报文发送页面
##########################################
@
protocolReport_view
.
route
(
'/troubleCode_protocol_page'
)
def
troubleCode_protocol_page
():
#获取请求的路劲
url
=
request
.
url
reqPath
=
re
.
findall
(
"http://(.*)$"
,
url
)[
0
]
reqPath
=
re
.
findall
(
"/(.*)$"
,
reqPath
)[
0
]
arg
=
{}
path
=
"protocolTools/report/troubleCode_protocol_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