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
d3f73f3a
Commit
d3f73f3a
authored
Apr 09, 2020
by
liyuanhong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
M300 GPS 图形操作界面开发完成
parent
8b0ba6dd
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
229 additions
and
16 deletions
+229
-16
lib/protocol/m300/GPS_protocol_m300.py
lib/protocol/m300/GPS_protocol_m300.py
+14
-13
static/js/m300Tools/m300.js
static/js/m300Tools/m300.js
+2
-1
templates/m300Tools/report/P_GPS_m300_page.html
templates/m300Tools/report/P_GPS_m300_page.html
+139
-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
+58
-1
views/m300Tools/P_m300Protocol_view.py
views/m300Tools/P_m300Protocol_view.py
+15
-1
No files found.
lib/protocol/m300/GPS_protocol_m300.py
View file @
d3f73f3a
...
...
@@ -50,19 +50,20 @@ class GPS_protocol_m300(M300Base):
# 获取消息体
#################################################
def
getMsgBody
(
self
):
dateInfo
=
self
.
getDateInfo
(
self
.
dateInfo
)
#日期
dateInfo
=
self
.
getDateInfo
(
self
.
dateInfo
)
#日期
latitude
=
self
.
int2hexStringByBytes
(
int
(
self
.
latitude
*
1000000
),
4
)
#维度
longitude
=
self
.
int2hexStringByBytes
(
int
(
self
.
longitude
*
1000000
),
4
)
#经度
positionStar
=
self
.
int2hexStringByBytes
(
self
.
positionStar
)
#定位星数
speed
=
self
.
int2hexStringByBytes
(
int
(
self
.
speed
*
10
),
2
)
#速度
direction
=
self
.
int2hexStringByBytes
(
int
(
self
.
direction
*
10
),
2
)
#方向角
altitude
=
self
.
int2hexStringByBytes
(
int
(
self
.
altitude
*
10
),
4
)
#海拔高度
ACCStatus
=
self
.
int2hexStringByBytes
(
self
.
ACCStatus
)
#ACC状态
valtage
=
self
.
int2hexStringByBytes
(
int
(
self
.
valtage
*
10
),
2
)
#汽车电瓶电压
OBDSpeed
=
self
.
int2hexStringByBytes
(
int
(
self
.
OBDSpeed
*
10
),
2
)
#汽车OBD速度
valid
=
self
.
getValid
()
#GPS定位是否有效
tripMark
=
self
.
int2hexStringByBytes
(
self
.
tripMark
,
2
)
#驾驶循环标签
reserve
=
self
.
reserve
#保留字段
longitude
=
self
.
int2hexStringByBytes
(
int
(
self
.
longitude
*
1000000
),
4
)
#经度
positionStar
=
self
.
int2hexStringByBytes
(
self
.
positionStar
)
#定位星数
speed
=
self
.
int2hexStringByBytes
(
int
(
self
.
speed
*
10
),
2
)
#速度
direction
=
self
.
int2hexStringByBytes
(
int
(
self
.
direction
*
10
),
2
)
#方向角
altitude
=
self
.
int2hexStringByBytes
(
int
(
self
.
altitude
*
10
),
4
)
#海拔高度
ACCStatus
=
self
.
int2hexStringByBytes
(
self
.
ACCStatus
)
#ACC状态
valtage
=
self
.
int2hexStringByBytes
(
int
(
self
.
valtage
*
10
),
2
)
#汽车电瓶电压
OBDSpeed
=
self
.
int2hexStringByBytes
(
int
(
self
.
OBDSpeed
*
10
),
2
)
#汽车OBD速度
# valid = self.getValid() #GPS定位是否有效
valid
=
self
.
int2hexStringByBytes
(
self
.
valid
)
# GPS定位是否有效
tripMark
=
self
.
int2hexStringByBytes
(
self
.
tripMark
,
2
)
#驾驶循环标签
reserve
=
self
.
reserve
#保留字段
data
=
dateInfo
+
latitude
+
longitude
+
positionStar
+
speed
data
=
data
+
direction
+
altitude
+
ACCStatus
+
valtage
+
OBDSpeed
data
=
data
+
valid
+
tripMark
+
reserve
...
...
@@ -81,7 +82,7 @@ class GPS_protocol_m300(M300Base):
def
getValid
(
self
):
isGPSValid
=
1
#Gps是否当前定位有效数据 1/0 是/否
isFixMod
=
0
#车机是否处于修车模式 12
1
8/0 是/否
isFixMod
=
0
#车机是否处于修车模式 128/0 是/否
data
=
isGPSValid
+
isFixMod
dataHex
=
self
.
int2hexStringByBytes
(
data
)
return
dataHex
...
...
static/js/m300Tools/m300.js
View file @
d3f73f3a
...
...
@@ -12,10 +12,11 @@ function m300ProtocolManTab(e){
$
(
location
).
attr
(
'
href
'
,
"
http://
"
+
window
.
location
.
host
+
"
/m300Tools/P_m300Protocol_view/P_login_m300_page
"
);
}
else
if
(
id
==
"
P_version_m300_msg
"
){
$
(
location
).
attr
(
'
href
'
,
"
http://
"
+
window
.
location
.
host
+
"
/m300Tools/P_m300Protocol_view/P_version_m300_page
"
);
}
else
if
(
id
==
"
P_GPS_m300_msg
"
){
$
(
location
).
attr
(
'
href
'
,
"
http://
"
+
window
.
location
.
host
+
"
/m300Tools/P_m300Protocol_view/P_GPS_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
{
alert
(
id
)
}
}
templates/m300Tools/report/P_GPS_m300_page.html
0 → 100644
View file @
d3f73f3a
{% extends "m300Tools/report/P_heartBeat_m300_page.html" %}
{% block title %}GPS_msg{% 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>
功能ID:
</label><input
id=
"FUNID"
type=
"text"
class=
"form-control"
disabled=
"disabled"
value=
"0007"
style=
"width:80px;"
>
<label>
消息序列号:
</label><input
id=
"waterCode"
type=
"text"
class=
"form-control"
value=
"1"
style=
"width:60px;"
>
<label>
设备ID:
</label><input
id=
"DEV_ID"
type=
"text"
class=
"form-control"
value=
"M202004070000"
style=
"width:150px;"
>
<label>
是否加密:
</label><select
style=
"width:100px;"
id=
"encryptionType"
class=
"form-control"
>
<option
value=
"0"
>
不加密
</option>
<option
value=
"1024"
>
加密
</option>
</select>
</div>
<H3
style=
"border-bottom: 1px solid #eee;"
>
设置心跳消息内容:
</H3>
<ul
class=
"protocol_content"
style=
"padding:0px;"
>
<li><label>
日期:
</label><input
id=
"dateInfo"
type=
"text"
class=
"form-control"
value=
""
></li>
<li
style=
"width:495px;"
><label>
维度:
</label><sapn>
<input
id=
"latitude"
type=
"text"
class=
"form-control"
value=
"40.22077"
>
<select
style=
"width:80px;"
id=
"latitudeType"
class=
"form-control"
>
<option
value=
"0"
>
北纬
</option>
<option
value=
"1"
>
南纬
</option></select>
</sapn></li>
<li
style=
"width:495px;"
><label>
经度:
</label><sapn>
<input
id=
"longitude"
type=
"text"
class=
"form-control"
value=
"116.23128"
>
<select
style=
"width:80px;"
id=
"longitudeType"
class=
"form-control"
>
<option
value=
"0"
>
东经
</option>
<option
value=
"1"
>
西经
</option></select>
</sapn></li>
<li><label>
定位星数:
</label><input
id=
"positionStar"
type=
"text"
class=
"form-control"
value=
"2"
></li>
<li><label>
速度:
</label><input
id=
"speed"
type=
"text"
class=
"form-control"
value=
"66.0"
></li>
<li><label>
方向角:
</label><input
id=
"direction"
type=
"text"
class=
"form-control"
value=
"55.3"
></li>
<li><label>
海拔高度:
</label><input
id=
"altitude"
type=
"text"
class=
"form-control"
value=
"11.0"
></li>
<li><label>
ACC状态:
</label><select
style=
"width:155px;"
id=
"ACCStatus"
class=
"form-control"
>
<option
value=
"0"
>
关
</option>
<option
value=
"1"
selected=
"selected"
>
开
</option></select></li>
<li><label
style=
"word-break:break-all;font-size:10px;"
>
汽车电瓶电压:
</label><input
id=
"valtage"
type=
"text"
class=
"form-control"
value=
"36.0"
></li>
<li><label
style=
"word-break:break-all;font-size:10px;"
>
汽车OBD速度:
</label><input
id=
"OBDSpeed"
type=
"text"
class=
"form-control"
value=
"66.4"
></li>
<li><label
style=
"word-break:break-all;font-size:10px;"
>
GPS定位是否有效:
</label><select
style=
"width:155px;"
id=
"valid_1"
class=
"form-control"
>
<option
value=
"0"
>
否
</option>
<option
value=
"1"
selected=
"selected"
>
是
</option></select></li>
<li><label
style=
"word-break:break-all;font-size:10px;"
>
车机是否处于修车模式:
</label><select
style=
"width:155px;"
id=
"valid_2"
class=
"form-control"
>
<option
value=
"0"
>
否
</option>
<option
value=
"128"
>
是
</option></select></li>
<li><label
style=
"word-break:break-all;font-size:10px;"
>
驾驶循环标签:
</label><input
id=
"tripMark"
type=
"text"
class=
"form-control"
value=
"0"
></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>
//发送GPS数据
$
(
"
#sendMsgBtn
"
).
click
(
function
(){
var
FUNID
=
$
(
"
#FUNID
"
).
val
();
var
waterCode
=
$
(
"
#waterCode
"
).
val
();
var
DEV_ID
=
$
(
"
#DEV_ID
"
).
val
();
var
encryptionType
=
$
(
"
#encryptionType
"
).
val
();
var
dateInfo
=
$
(
"
#dateInfo
"
).
val
();
var
latitude
=
parseFloat
(
$
(
"
#latitude
"
).
val
());
var
latitudeType
=
parseInt
(
$
(
"
#latitudeType
"
).
val
());
if
(
latitudeType
==
1
){
latitude
=
latitude
+
2147483648
/
1000000
}
var
longitude
=
parseFloat
(
$
(
"
#longitude
"
).
val
());
var
longitudeType
=
parseInt
(
$
(
"
#longitudeType
"
).
val
());
if
(
longitudeType
==
1
){
longitude
=
longitude
+
2147483648
/
1000000
}
var
positionStar
=
$
(
"
#positionStar
"
).
val
();
var
speed
=
$
(
"
#speed
"
).
val
();
var
direction
=
$
(
"
#direction
"
).
val
();
var
altitude
=
$
(
"
#altitude
"
).
val
();
var
ACCStatus
=
$
(
"
#ACCStatus
"
).
val
();
var
valtage
=
$
(
"
#valtage
"
).
val
();
var
OBDSpeed
=
$
(
"
#OBDSpeed
"
).
val
();
var
valid_1
=
parseInt
(
$
(
"
#valid_1
"
).
val
());
var
valid_2
=
parseInt
(
$
(
"
#valid_2
"
).
val
());
var
valid
=
valid_1
+
valid_2
var
tripMark
=
$
(
"
#tripMark
"
).
val
();
var
data
=
{};
data
[
"
FUNID
"
]
=
FUNID
;
data
[
"
waterCode
"
]
=
waterCode
;
data
[
"
DEV_ID
"
]
=
DEV_ID
;
data
[
"
encryptionType
"
]
=
encryptionType
;
data
[
"
dateInfo
"
]
=
dateInfo
;
data
[
"
latitude
"
]
=
latitude
;
data
[
"
longitude
"
]
=
longitude
;
data
[
"
positionStar
"
]
=
positionStar
;
data
[
"
speed
"
]
=
speed
;
data
[
"
direction
"
]
=
direction
;
data
[
"
altitude
"
]
=
altitude
;
data
[
"
ACCStatus
"
]
=
ACCStatus
;
data
[
"
valtage
"
]
=
valtage
;
data
[
"
OBDSpeed
"
]
=
OBDSpeed
;
data
[
"
valid
"
]
=
valid
;
data
[
"
tripMark
"
]
=
tripMark
;
var
host
=
window
.
location
.
host
;
$
(
"
#showFeedback
"
).
val
(
""
)
$
.
ajax
({
url
:
"
http://
"
+
host
+
"
/m300Tools/P_m300Protocol_process/porcessGPSMsg
"
,
type
:
"
post
"
,
data
:
data
,
dataType
:
"
json
"
,
success
:
function
(
data
){
if
(
data
.
status
==
200
){
//window.location.reload()
var
theShow
=
"
原始数据:
"
+
data
.
msgSend
+
"
\n
"
;
theShow
=
theShow
+
"
收到数据:
"
+
data
.
result
+
"
\n
"
;
theShow
=
theShow
+
"
收到数据16进制:
"
+
data
.
rev
+
"
\n
"
;
theShow
=
theShow
+
"
解析数据:
"
+
JSON
.
stringify
(
data
.
orgRev
)
+
"
\n
"
;
$
(
"
#showFeedback
"
).
val
(
theShow
)
}
else
{
$
(
"
#showFeedback
"
).
val
(
data
.
message
)
alert
(
data
.
message
);
}
}
});
});
//设置当前时间到UTC时间输入框
(
function
(){
var
curTime
=
getCurTime
();
$
(
"
#dateInfo
"
).
val
(
curTime
);
})();
</script>
{% endblock %}
\ No newline at end of file
templates/m300Tools/report/P_heartBeat_m300_page.html
View file @
d3f73f3a
...
...
@@ -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_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_GPS_m300_msg"
{%
if
arg.path[2]=
="P_GPS_m300_page"
%}
class=
"link-tab"
{%
endif
%}
onclick=
"m300ProtocolManTab(this)"
>
GPS消息
</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>
{% endblock %}
...
...
views/m300Tools/P_m300Protocol_process.py
View file @
d3f73f3a
...
...
@@ -3,13 +3,13 @@
from
flask
import
Blueprint
,
Response
,
request
from
configparser
import
ConfigParser
from
lib.protocol.m300.GPS_protocol_m300
import
GPS_protocol_m300
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.OBDCAN_protocol_m300
import
OBDCAN_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.M300Login_res
import
M300Login_res
from
lib.protocol.reportPlateform.Common_res
import
Common_res
from
lib.socket.ClientSocket
import
ClientSocket
import
json
...
...
@@ -180,6 +180,63 @@ def porcessVersionMsg():
data
[
"message"
]
=
"Error: 处理失败!"
return
Response
(
json
.
dumps
(
data
),
mimetype
=
'application/json'
)
##########################################
# 【接口类型】处理发送的GPS信息上报报文
##########################################
@
P_m300Protocol_process
.
route
(
"/porcessGPSMsg"
,
methods
=
[
'POST'
])
def
porcessGPSMsg
():
FUNID
=
request
.
form
.
get
(
"FUNID"
)
waterCode
=
int
(
request
.
form
.
get
(
"waterCode"
))
DEV_ID
=
request
.
form
.
get
(
"DEV_ID"
)
encryptionType
=
int
(
request
.
form
.
get
(
"encryptionType"
))
dateInfo
=
request
.
form
.
get
(
"dateInfo"
)
latitude
=
float
(
request
.
form
.
get
(
"latitude"
))
longitude
=
float
(
request
.
form
.
get
(
"longitude"
))
positionStar
=
int
(
request
.
form
.
get
(
"positionStar"
))
speed
=
float
(
request
.
form
.
get
(
"speed"
))
direction
=
float
(
request
.
form
.
get
(
"direction"
))
altitude
=
float
(
request
.
form
.
get
(
"altitude"
))
ACCStatus
=
int
(
request
.
form
.
get
(
"ACCStatus"
))
valtage
=
float
(
request
.
form
.
get
(
"valtage"
))
OBDSpeed
=
float
(
request
.
form
.
get
(
"OBDSpeed"
))
valid
=
int
(
request
.
form
.
get
(
"valid"
))
tripMark
=
int
(
request
.
form
.
get
(
"tripMark"
))
data
=
{}
if
(
waterCode
==
None
or
DEV_ID
==
None
or
encryptionType
==
None
or
dateInfo
==
None
or
latitude
==
None
or
longitude
==
None
\
or
positionStar
==
None
or
speed
==
None
or
direction
==
None
or
altitude
==
None
or
ACCStatus
==
None
or
valtage
==
None
\
or
OBDSpeed
==
None
or
valid
==
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
=
GPS_protocol_m300
(
waterCode
=
waterCode
,
DEV_ID
=
DEV_ID
,
encryptionType
=
encryptionType
,
dateInfo
=
dateInfo
\
,
latitude
=
latitude
,
longitude
=
longitude
,
positionStar
=
positionStar
,
speed
=
speed
,
direction
=
direction
,
altitude
=
altitude
\
,
ACCStatus
=
ACCStatus
,
valtage
=
valtage
,
OBDSpeed
=
OBDSpeed
,
valid
=
valid
,
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'
)
##########################################
# 【接口类型】处理发送的OBD CAN 信息上报报文
##########################################
...
...
views/m300Tools/P_m300Protocol_view.py
View file @
d3f73f3a
...
...
@@ -69,7 +69,21 @@ def P_version_m300_page():
return
render_template
(
path
,
arg
=
arg
)
##########################################
# 【视图类型】访问版本协议页面
# 【视图类型】访问 GPS 协议页面
##########################################
@
P_m300Protocol_view
.
route
(
'/P_GPS_m300_page'
)
def
P_GPS_m300_page
():
#获取请求的路劲
url
=
request
.
url
reqPath
=
re
.
findall
(
"http://(.*)$"
,
url
)[
0
]
reqPath
=
re
.
findall
(
"/(.*)$"
,
reqPath
)[
0
]
arg
=
{}
path
=
"m300Tools/report/P_GPS_m300_page.html"
arg
[
"path"
]
=
reqPath
.
split
(
"/"
)
return
render_template
(
path
,
arg
=
arg
)
##########################################
# 【视图类型】访问OBD CAN协议页面
##########################################
@
P_m300Protocol_view
.
route
(
'/P_CAN_m300_page'
)
def
P_CAN_m300_page
():
...
...
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