Commit 511139a1 authored by 李远洪's avatar 李远洪

心跳消息发送页面初步开发

parent 17b36517
......@@ -33,10 +33,14 @@ class MessageBase(Base):
#######################################################
def getMsgHeader(self):
msgID = self.int2hexStringByBytes(102,2) #消息id
msgBodyProperty = self.getMsgBodyProperty() #消息体属性
subPkg = 0
msgBodyProperty = self.getMsgBodyProperty(subPkg=subPkg) #消息体属性
phoneNum = self.int2BCD(13146201118) #终端手机号
msgWaterCode = self.int2hexStringByBytes(1) #消息流水号
subPkgContent = "" #消息包封装项s
if subPkg != 8192:
subPkgContent = "" #消息包封装项
else:
subPkgContent = self.getMsgPackage()
data = msgID + msgBodyProperty + phoneNum + msgWaterCode + subPkgContent
return data
......@@ -52,6 +56,19 @@ class MessageBase(Base):
dataHex = self.int2hexStringByBytes(data,2)
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):
data = self.int2BCD(int(data))
return data
if __name__ == "__main__":
# print(MessageBase().str2Hex("uvwxyz"))
# print(MessageBase().str2Ascsii("uvwxyz"))
......
......@@ -39,10 +39,14 @@ class TerminalHeartbeat_msg(MessageBase):
def getMsgHeader(self):
# msgID = self.int2hexStringByBytes(102,2) #消息id
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) #终端手机号
msgWaterCode = self.int2hexStringByBytes(1,2) #消息流水号
if subPkg != 8192:
subPkgContent = "" #消息包封装项
else:
subPkgContent = self.getMsgPackage()
data = msgID + msgBodyProperty + phoneNum + msgWaterCode + subPkgContent
return data
......
......@@ -5,6 +5,8 @@ from views.protocolTools.setting_process import setting_process
from views.protocolTools.protocolReport_view import protocolReport_view
from views.protocolTools.protocolReport_process import protocolReport_process
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.icon import icon
from views.tab2.login import login
......@@ -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_process,url_prefix = "/protocolTools/protocolReport_process")
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(icon,url_prefix = "/tab1/icon")
app.register_blueprint(login,url_prefix = "/tab2/login")
......
......@@ -5,6 +5,8 @@ function swichTap(e){
var id = $(e).attr("id")
if(id == "protocolTools"){
$(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"){
$(location).attr('href', "http://" + window.location.host + "/tab1/style");
}else if(id == "tab2"){
......
......@@ -20,6 +20,7 @@
<div style="width: 70%;margin: 0 auto">
<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]=="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]=="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>
......
{% 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
{% 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
#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)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment