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
511139a1
Commit
511139a1
authored
Feb 07, 2020
by
李远洪
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
心跳消息发送页面初步开发
parent
17b36517
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
253 additions
and
4 deletions
+253
-4
lib/protocol/message/MessageBase.py
lib/protocol/message/MessageBase.py
+21
-2
lib/protocol/message/TerminalHeartbeat_msg.py
lib/protocol/message/TerminalHeartbeat_msg.py
+6
-2
run.py
run.py
+4
-0
static/js/index.js
static/js/index.js
+2
-0
templates/base.html
templates/base.html
+1
-0
templates/messageTools/index.html
templates/messageTools/index.html
+50
-0
templates/messageTools/message/heartBeat_msg_page.html
templates/messageTools/message/heartBeat_msg_page.html
+149
-0
views/messageTools/message_process.py
views/messageTools/message_process.py
+0
-0
views/messageTools/message_view.py
views/messageTools/message_view.py
+20
-0
No files found.
lib/protocol/message/MessageBase.py
View file @
511139a1
...
@@ -33,10 +33,14 @@ class MessageBase(Base):
...
@@ -33,10 +33,14 @@ class MessageBase(Base):
#######################################################
#######################################################
def
getMsgHeader
(
self
):
def
getMsgHeader
(
self
):
msgID
=
self
.
int2hexStringByBytes
(
102
,
2
)
#消息id
msgID
=
self
.
int2hexStringByBytes
(
102
,
2
)
#消息id
msgBodyProperty
=
self
.
getMsgBodyProperty
()
#消息体属性
subPkg
=
0
msgBodyProperty
=
self
.
getMsgBodyProperty
(
subPkg
=
subPkg
)
#消息体属性
phoneNum
=
self
.
int2BCD
(
13146201118
)
#终端手机号
phoneNum
=
self
.
int2BCD
(
13146201118
)
#终端手机号
msgWaterCode
=
self
.
int2hexStringByBytes
(
1
)
#消息流水号
msgWaterCode
=
self
.
int2hexStringByBytes
(
1
)
#消息流水号
subPkgContent
=
""
#消息包封装项s
if
subPkg
!=
8192
:
subPkgContent
=
""
#消息包封装项
else
:
subPkgContent
=
self
.
getMsgPackage
()
data
=
msgID
+
msgBodyProperty
+
phoneNum
+
msgWaterCode
+
subPkgContent
data
=
msgID
+
msgBodyProperty
+
phoneNum
+
msgWaterCode
+
subPkgContent
return
data
return
data
...
@@ -52,6 +56,19 @@ class MessageBase(Base):
...
@@ -52,6 +56,19 @@ class MessageBase(Base):
dataHex
=
self
.
int2hexStringByBytes
(
data
,
2
)
dataHex
=
self
.
int2hexStringByBytes
(
data
,
2
)
return
dataHex
return
dataHex
#获取消息封装项
def
getMsgPackage
(
self
):
pkgCounts
=
2
#消息报包总数
pkgCountsHex
=
self
.
int2hexStringByBytes
(
2
,
2
)
pkgNumsHex
=
""
for
i
in
range
(
0
,
pkgCounts
):
pkgNum
=
i
pkgNumHex
=
self
.
int2hexStringByBytes
(
pkgNum
,
2
)
pkgNumsHex
=
pkgNumsHex
+
pkgNumHex
msgPackage
=
pkgCountsHex
+
pkgNumsHex
return
msgPackage
#######################################################
#######################################################
# 获取消息体
# 获取消息体
...
@@ -139,6 +156,8 @@ class MessageBase(Base):
...
@@ -139,6 +156,8 @@ class MessageBase(Base):
data
=
self
.
int2BCD
(
int
(
data
))
data
=
self
.
int2BCD
(
int
(
data
))
return
data
return
data
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
# print(MessageBase().str2Hex("uvwxyz"))
# print(MessageBase().str2Hex("uvwxyz"))
# print(MessageBase().str2Ascsii("uvwxyz"))
# print(MessageBase().str2Ascsii("uvwxyz"))
...
...
lib/protocol/message/TerminalHeartbeat_msg.py
View file @
511139a1
...
@@ -39,10 +39,14 @@ class TerminalHeartbeat_msg(MessageBase):
...
@@ -39,10 +39,14 @@ class TerminalHeartbeat_msg(MessageBase):
def
getMsgHeader
(
self
):
def
getMsgHeader
(
self
):
# msgID = self.int2hexStringByBytes(102,2) #消息id
# msgID = self.int2hexStringByBytes(102,2) #消息id
msgID
=
"0002"
msgID
=
"0002"
msgBodyProperty
=
self
.
getMsgBodyProperty
(
int
(
len
(
self
.
getMsgBody
())
/
2
))
#消息体属性
subPkg
=
0
msgBodyProperty
=
self
.
getMsgBodyProperty
(
msgBodyLen
=
int
(
len
(
self
.
getMsgBody
())
/
2
),
subPkg
=
subPkg
)
#消息体属性
phoneNum
=
self
.
int2BCD
(
13146201119
)
#终端手机号
phoneNum
=
self
.
int2BCD
(
13146201119
)
#终端手机号
msgWaterCode
=
self
.
int2hexStringByBytes
(
1
,
2
)
#消息流水号
msgWaterCode
=
self
.
int2hexStringByBytes
(
1
,
2
)
#消息流水号
subPkgContent
=
""
#消息包封装项
if
subPkg
!=
8192
:
subPkgContent
=
""
#消息包封装项
else
:
subPkgContent
=
self
.
getMsgPackage
()
data
=
msgID
+
msgBodyProperty
+
phoneNum
+
msgWaterCode
+
subPkgContent
data
=
msgID
+
msgBodyProperty
+
phoneNum
+
msgWaterCode
+
subPkgContent
return
data
return
data
...
...
run.py
View file @
511139a1
...
@@ -5,6 +5,8 @@ from views.protocolTools.setting_process import setting_process
...
@@ -5,6 +5,8 @@ from views.protocolTools.setting_process import setting_process
from
views.protocolTools.protocolReport_view
import
protocolReport_view
from
views.protocolTools.protocolReport_view
import
protocolReport_view
from
views.protocolTools.protocolReport_process
import
protocolReport_process
from
views.protocolTools.protocolReport_process
import
protocolReport_process
from
views.protocolTools.test_view
import
test_view
from
views.protocolTools.test_view
import
test_view
from
views.messageTools.message_view
import
message_view
from
views.tab1.style
import
style
from
views.tab1.style
import
style
from
views.tab1.icon
import
icon
from
views.tab1.icon
import
icon
from
views.tab2.login
import
login
from
views.tab2.login
import
login
...
@@ -17,6 +19,8 @@ app.register_blueprint(setting_process,url_prefix = "/protocolTools/setting_proc
...
@@ -17,6 +19,8 @@ app.register_blueprint(setting_process,url_prefix = "/protocolTools/setting_proc
app
.
register_blueprint
(
protocolReport_view
,
url_prefix
=
"/protocolTools/protocolReport_view"
)
app
.
register_blueprint
(
protocolReport_view
,
url_prefix
=
"/protocolTools/protocolReport_view"
)
app
.
register_blueprint
(
protocolReport_process
,
url_prefix
=
"/protocolTools/protocolReport_process"
)
app
.
register_blueprint
(
protocolReport_process
,
url_prefix
=
"/protocolTools/protocolReport_process"
)
app
.
register_blueprint
(
test_view
,
url_prefix
=
"/protocolTools/test_view"
)
app
.
register_blueprint
(
test_view
,
url_prefix
=
"/protocolTools/test_view"
)
app
.
register_blueprint
(
message_view
,
url_prefix
=
"/messageTools/message_view"
)
app
.
register_blueprint
(
style
,
url_prefix
=
"/tab1/style"
)
app
.
register_blueprint
(
style
,
url_prefix
=
"/tab1/style"
)
app
.
register_blueprint
(
icon
,
url_prefix
=
"/tab1/icon"
)
app
.
register_blueprint
(
icon
,
url_prefix
=
"/tab1/icon"
)
app
.
register_blueprint
(
login
,
url_prefix
=
"/tab2/login"
)
app
.
register_blueprint
(
login
,
url_prefix
=
"/tab2/login"
)
...
...
static/js/index.js
View file @
511139a1
...
@@ -5,6 +5,8 @@ function swichTap(e){
...
@@ -5,6 +5,8 @@ function swichTap(e){
var
id
=
$
(
e
).
attr
(
"
id
"
)
var
id
=
$
(
e
).
attr
(
"
id
"
)
if
(
id
==
"
protocolTools
"
){
if
(
id
==
"
protocolTools
"
){
$
(
location
).
attr
(
'
href
'
,
"
http://
"
+
window
.
location
.
host
+
"
/protocolTools/protocolReport_view/GPS_protocol_page
"
);
$
(
location
).
attr
(
'
href
'
,
"
http://
"
+
window
.
location
.
host
+
"
/protocolTools/protocolReport_view/GPS_protocol_page
"
);
}
else
if
(
id
==
"
messageTools
"
){
$
(
location
).
attr
(
'
href
'
,
"
http://
"
+
window
.
location
.
host
+
"
/messageTools/message_view/heartBeat_msg_page
"
);
}
else
if
(
id
==
"
tab1
"
){
}
else
if
(
id
==
"
tab1
"
){
$
(
location
).
attr
(
'
href
'
,
"
http://
"
+
window
.
location
.
host
+
"
/tab1/style
"
);
$
(
location
).
attr
(
'
href
'
,
"
http://
"
+
window
.
location
.
host
+
"
/tab1/style
"
);
}
else
if
(
id
==
"
tab2
"
){
}
else
if
(
id
==
"
tab2
"
){
...
...
templates/base.html
View file @
511139a1
...
@@ -20,6 +20,7 @@
...
@@ -20,6 +20,7 @@
<div
style=
"width: 70%;margin: 0 auto"
>
<div
style=
"width: 70%;margin: 0 auto"
>
<ul
class=
"nav nav-tabs"
style=
"font-size:18px;"
>
<ul
class=
"nav nav-tabs"
style=
"font-size:18px;"
>
<li
role=
"presentation"
{%
if
arg.path[0]=
="protocolTools"
%}
class=
"active"
{%
endif
%}
><a
onclick=
"swichTap(this)"
id=
"protocolTools"
>
协议工具
</a></li>
<li
role=
"presentation"
{%
if
arg.path[0]=
="protocolTools"
%}
class=
"active"
{%
endif
%}
><a
onclick=
"swichTap(this)"
id=
"protocolTools"
>
协议工具
</a></li>
<li
role=
"presentation"
{%
if
arg.path[0]=
="messageTools"
%}
class=
"active"
{%
endif
%}
><a
onclick=
"swichTap(this)"
id=
"messageTools"
>
消息工具
</a></li>
<li
role=
"presentation"
{%
if
arg.path[0]=
="tab1"
%}
class=
"active"
{%
endif
%}
><a
onclick=
"swichTap(this)"
id=
"tab1"
>
案例
</a></li>
<li
role=
"presentation"
{%
if
arg.path[0]=
="tab1"
%}
class=
"active"
{%
endif
%}
><a
onclick=
"swichTap(this)"
id=
"tab1"
>
案例
</a></li>
<li
role=
"presentation"
{%
if
arg.path[0]=
="tab2"
%}
class=
"active"
{%
endif
%}
><a
onclick=
"swichTap(this)"
id=
"tab2"
>
演示页面
</a></li>
<li
role=
"presentation"
{%
if
arg.path[0]=
="tab2"
%}
class=
"active"
{%
endif
%}
><a
onclick=
"swichTap(this)"
id=
"tab2"
>
演示页面
</a></li>
<li
role=
"presentation"
{%
if
arg.path[0]=
="other"
%}
class=
"active"
{%
endif
%}
><a
onclick=
"swichTap(this)"
id=
"otherTab"
>
其他
</a></li>
<li
role=
"presentation"
{%
if
arg.path[0]=
="other"
%}
class=
"active"
{%
endif
%}
><a
onclick=
"swichTap(this)"
id=
"otherTab"
>
其他
</a></li>
...
...
templates/messageTools/index.html
0 → 100644
View file @
511139a1
{% extends "base.html" %}
{% block title %}消息工具{% endblock %}
{% block content %}
<style
type=
"text/css"
>
.link-tab
{
background-color
:
#e4e2dd
;
}
.active_left_tab
{
background-color
:
#428BCA
;
color
:
white
;
}
.table
>
thead
>
tr
>
th
,
.table
>
tbody
>
tr
>
td
{
_background-color
:
red
;
}
</style>
<!-- 切换左边的tab -->
<script
type=
"text/javascript"
>
function
swichLeftTab
(
e
){
var
id
=
$
(
e
).
attr
(
"
id
"
)
if
(
id
==
"
setting
"
){
$
(
location
).
attr
(
'
href
'
,
"
http://
"
+
window
.
location
.
host
+
"
/protocolTools/setting_view/socketSetting_page
"
);
}
else
if
(
id
==
"
protocols_report
"
){
$
(
location
).
attr
(
'
href
'
,
"
http://
"
+
window
.
location
.
host
+
"
/protocolTools/protocolReport_view/GPS_protocol_page
"
);
}
else
if
(
id
==
"
test
"
){
$
(
location
).
attr
(
'
href
'
,
"
http://
"
+
window
.
location
.
host
+
"
/protocolTools/test_view/test_page
"
);
}
else
if
(
id
==
"
icon
"
){
$
(
location
).
attr
(
'
href
'
,
"
http://
"
+
window
.
location
.
host
+
"
/tab1/icon
"
);
}
}
</script>
<!-- 左侧导航添加为可继承模块 -->
{% block leftNav %}
<div
id=
"container1"
class=
"col-sm-3 col-md-2 sidebar"
style=
"margin-top:50px;width:15%;padding:0px;margin-right:15px;"
>
<ul
class=
"nav nav-sidebar"
>
<li
id=
"setting"
onclick=
"swichLeftTab(this)"
><a
{%
if
arg.path[1]=
="setting_view"
%}
class=
"active_left_tab"
{%
endif
%}
><span
class=
"glyphicon glyphicon-cog"
aria-hidden=
"true"
></span>
系统设置
</a></li>
<li
id=
"protocols_report"
onclick=
"swichLeftTab(this)"
><a
{%
if
arg.path[1]=
="message_view"
%}
class=
"active_left_tab"
{%
endif
%}
><span
class=
"glyphicon glyphicon-list-alt"
aria-hidden=
"true"
></span>
终端消息发送
<span
class=
"sr-only"
></span></a></li>
</ul>
<ul
class=
"nav nav-sidebar"
style=
"margin-top:20px;"
>
<li><a><span
class=
"glyphicon glyphicon-eye-open"
aria-hidden=
"true"
></span>
其他页面
</a></li>
</ul>
</div>
{% endblock %}
{% block content_01 %}
<!-- 右边内容区域 -->
{% endblock %}
{% endblock %}
</div>
\ No newline at end of file
templates/messageTools/message/heartBeat_msg_page.html
0 → 100644
View file @
511139a1
{% extends "messageTools/index.html" %}
{% block title %}heartBeat_msg{% endblock %}
{% block content_01 %}
<script
src=
"../../static/js/protocolTools/protocols.js"
></script>
<style>
.nav-pills
li
{
margin-bottom
:
5px
;
}
.form-control
{
display
:
inline
;
width
:
160px
;
}
.protocol_content
:after
{
clear
:
both
;
display
:
block
;
content
:
" "
;
}
.protocol_content
li
{
width
:
250px
;
_background
:
yellow
;
list-style
:
none
;
margin-top
:
5px
;
float
:
left
;
}
</style>
<div
id=
"container2"
style=
"width:83%;min-height:750px;float:left;_background:grey;margin-top:50px;"
>
{% block content_02 %}
<ul
class=
"nav nav-pills"
style=
"font-size:14px;"
>
<li
role=
"presentation"
><a
id=
"heartBeat_protocol"
{%
if
arg.path[2]=
="heartBeat_msg_page"
%}
class=
"link-tab"
{%
endif
%}
onclick=
"protocolManTab(this)"
>
心跳消息
</b></a></li>
<li
role=
"presentation"
><a
id=
"style_index2"
{%
if
arg.path[2]=
="2"
%}
class=
"link-tab"
{%
endif
%}
onclick=
"protocolManTab(this)"
>
其他报文
</b></a></li>
</ul>
{% 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=
"msgID"
type=
"text"
class=
"form-control"
value=
"0002"
style=
"width:80px;"
>
<label>
终端手机号:
</label><input
id=
"phoneNum"
type=
"text"
class=
"form-control"
value=
"13146201119"
style=
"width:150px;"
>
<label>
消息流水号:
</label><input
id=
"msgWaterCode"
type=
"text"
class=
"form-control"
value=
"1"
style=
"width:60px;"
>
<label>
是否加密:
</label><select
style=
"width:100px;"
id=
"encryptionType"
class=
"form-control"
>
<option
value=
"0"
>
不加密
</option>
<option
value=
"1024"
>
加密
</option>
</select>
<label>
有无分包:
</label><select
style=
"width:80px;"
id=
"brakeStatus"
class=
"form-control"
>
<option
value=
"0"
>
无
</option>
<option
value=
"8192"
>
有
</option>
</select>
<label
id=
"subPkg_label"
style=
"color:grey;"
>
分包个数:
</label><input
disabled=
"disabled"
id=
"subPkg"
type=
"text"
class=
"form-control"
value=
"2"
style=
"width:60px;"
>
</div>
<H3
style=
"border-bottom: 1px solid #eee;"
>
设置心跳消息内容:
</H3>
<ul
class=
"protocol_content"
style=
"padding:0px;"
>
<label
style=
"color:red;"
>
心跳消息无消息体...
</label>
</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
WATER_CODE
=
$
(
"
#WATER_CODE
"
).
val
();
var
DEV_ID
=
$
(
"
#DEV_ID
"
).
val
();
var
msgCount
=
$
(
"
#msgCount
"
).
val
();
var
UTCTime
=
$
(
"
#UTCTime
"
).
val
();
var
latitude
=
$
(
"
#latitude
"
).
val
();
var
longitude
=
$
(
"
#longitude
"
).
val
();
var
speed
=
$
(
"
#speed
"
).
val
();
var
directionAngle
=
$
(
"
#directionAngle
"
).
val
();
var
elevation
=
$
(
"
#elevation
"
).
val
();
var
positionStar
=
$
(
"
#positionStar
"
).
val
();
var
Pdop
=
$
(
"
#Pdop
"
).
val
();
var
Hdop
=
$
(
"
#Hdop
"
).
val
();
var
Vdop
=
$
(
"
#Vdop
"
).
val
();
var
statusBit
=
$
(
"
#statusBit
"
).
val
();
var
valtage
=
$
(
"
#valtage
"
).
val
();
var
OBDSpeed
=
$
(
"
#OBDSpeed
"
).
val
();
var
engineSpeed
=
$
(
"
#engineSpeed
"
).
val
();
var
GPSTotalMileage
=
$
(
"
#GPSTotalMileage
"
).
val
();
var
totalOil
=
$
(
"
#totalOil
"
).
val
();
var
totalTime
=
$
(
"
#totalTime
"
).
val
();
var
GPSTimestamp
=
$
(
"
#GPSTimestamp
"
).
val
();
var
data
=
{};
data
[
"
WATER_CODE
"
]
=
WATER_CODE
;
data
[
"
DEV_ID
"
]
=
DEV_ID
;
data
[
"
msgCount
"
]
=
msgCount
;
data
[
"
UTCTime
"
]
=
UTCTime
;
data
[
"
latitude
"
]
=
latitude
;
data
[
"
longitude
"
]
=
longitude
;
data
[
"
speed
"
]
=
speed
;
data
[
"
directionAngle
"
]
=
directionAngle
;
data
[
"
elevation
"
]
=
elevation
;
data
[
"
positionStar
"
]
=
positionStar
;
data
[
"
Pdop
"
]
=
Pdop
;
data
[
"
Hdop
"
]
=
Hdop
;
data
[
"
Vdop
"
]
=
Vdop
;
data
[
"
statusBit
"
]
=
statusBit
;
data
[
"
valtage
"
]
=
valtage
;
data
[
"
OBDSpeed
"
]
=
OBDSpeed
;
data
[
"
engineSpeed
"
]
=
engineSpeed
;
data
[
"
GPSTotalMileage
"
]
=
GPSTotalMileage
;
data
[
"
totalOil
"
]
=
totalOil
;
data
[
"
totalTime
"
]
=
totalTime
;
data
[
"
GPSTimestamp
"
]
=
GPSTimestamp
;
var
host
=
window
.
location
.
host
;
$
.
ajax
({
url
:
"
http://
"
+
host
+
"
/protocolTools/protocolReport_process/porcessGPSMsg
"
,
type
:
"
post
"
,
data
:
data
,
dataType
:
"
json
"
,
success
:
function
(
data
){
if
(
data
.
status
==
200
){
//window.location.reload()
$
(
"
#showFeedback
"
).
val
(
data
.
result
)
}
else
{
$
(
"
#showFeedback
"
).
val
(
data
.
message
)
alert
(
data
.
message
);
}
}
});
});
//设置当前时间到UTC时间输入框
(
function
(){
var
curTime
=
getCurTime
();
$
(
"
#UTCTime
"
).
val
(
curTime
);
})();
//设置当前时间戳到GPS信息时间戳输入框
(
function
(){
var
curTimestamp
=
getCutTimestamp
();
$
(
"
#GPSTimestamp
"
).
val
(
curTimestamp
);
})();
</script>
{% endblock %}
</div>
{% endblock %}
\ No newline at end of file
views/messageTools/message_process.py
0 → 100644
View file @
511139a1
views/messageTools/message_view.py
0 → 100644
View file @
511139a1
#coding:utf-8
from
flask
import
Blueprint
,
render_template
,
request
import
re
message_view
=
Blueprint
(
'message_view'
,
__name__
)
##########################################
# 【视图类型】访问心跳消息发送页面
##########################################
@
message_view
.
route
(
'/heartBeat_msg_page'
)
def
heartBeat_msg_page
():
#获取请求的路劲
url
=
request
.
url
reqPath
=
re
.
findall
(
"http://(.*)$"
,
url
)[
0
]
reqPath
=
re
.
findall
(
"/(.*)$"
,
reqPath
)[
0
]
arg
=
{}
path
=
"messageTools/message/heartBeat_msg_page.html"
arg
[
"path"
]
=
reqPath
.
split
(
"/"
)
return
render_template
(
path
,
arg
=
arg
)
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