Commit ea864fb4 authored by 李远洪's avatar 李远洪

完成了心跳消息页面开发以及消息设置页面的开发

parent 511139a1
[socket]
host = 10.100.9.17
port = 9001
......@@ -6,7 +6,12 @@ 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.msgSetting_view import msgSetting_view
from views.messageTools.msgSetting_process import msgSetting_process
from views.messageTools.message_view import message_view
from views.messageTools.message_process import message_process
from views.tab1.style import style
from views.tab1.icon import icon
from views.tab2.login import login
......@@ -20,7 +25,11 @@ app.register_blueprint(protocolReport_view,url_prefix = "/protocolTools/protocol
app.register_blueprint(protocolReport_process,url_prefix = "/protocolTools/protocolReport_process")
app.register_blueprint(test_view,url_prefix = "/protocolTools/test_view")
app.register_blueprint(msgSetting_view,url_prefix = "/messageTools/msgSetting_view")
app.register_blueprint(msgSetting_process,url_prefix = "/messageTools/msgSetting_process")
app.register_blueprint(message_view,url_prefix = "/messageTools/message_view")
app.register_blueprint(message_process,url_prefix = "/messageTools/message_process")
app.register_blueprint(style,url_prefix = "/tab1/style")
app.register_blueprint(icon,url_prefix = "/tab1/icon")
app.register_blueprint(login,url_prefix = "/tab2/login")
......
/**
*setting 页面顶部的协议切换
*/
function settingManTab(e){
var url = window.location.href;
var id = $(e).attr("id");
if(id == "msgSetting"){
$(location).attr('href', "http://" + window.location.host + "/messageTools/msgSetting_view/msgSetting_page");
}else if(id == "style_labels1"){
$(location).attr('href', "http://" + window.location.host + "/tab1/style/labels");
}else{
alert(id)
}
}
\ No newline at end of file
......@@ -20,9 +20,9 @@
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");
$(location).attr('href', "http://" + window.location.host + "/messageTools/msgSetting_view/msgSetting_page");
}else if(id == "msg_send"){
$(location).attr('href', "http://" + window.location.host + "/messageTools/message_view/heartBeat_msg_page");
}else if(id == "test"){
$(location).attr('href', "http://" + window.location.host + "/protocolTools/test_view/test_page");
}else if(id == "icon"){
......@@ -34,8 +34,8 @@
{% 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>
<li id="setting" onclick="swichLeftTab(this)"><a {% if arg.path[1]=="msgSetting_view" %} class="active_left_tab" {% endif %}><span class="glyphicon glyphicon-cog" aria-hidden="true"></span> 系统设置</a></li>
<li id="msg_send" 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>
......
......@@ -42,11 +42,11 @@
<option value="0">不加密</option>
<option value="1024">加密</option>
</select>
<label>有无分包:</label><select style="width:80px;" id="brakeStatus" class="form-control">
<label>有无分包:</label><select style="width:80px;" id="subPkg" 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;">
<label id="subPkg_label" style="color:grey;">分包个数:</label><input disabled="disabled" id="pkgCounts" 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;">
......@@ -67,63 +67,38 @@
<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 msgID = $("#msgID").val();
var phoneNum = $("#phoneNum").val();
var msgWaterCode = $("#msgWaterCode").val();
var encryptionType = $("#encryptionType").val();
var subPkg = $("#subPkg").val();
var pkgCounts = ""
if (subPkg != "8192"){
pkgCounts = "0"
}else{
pkgCounts = $("#pkgCounts").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;
data["msgID"] = msgID;
data["phoneNum"] = phoneNum;
data["msgWaterCode"] = msgWaterCode;
data["encryptionType"] = encryptionType;
data["subPkg"] = subPkg;
data["pkgCounts"] = pkgCounts;
var host = window.location.host;
$.ajax({
url:"http://" + host + "/protocolTools/protocolReport_process/porcessGPSMsg",
url:"http://" + host + "/messageTools/message_process/porcessHeartBeatMsg",
type:"post",
data:data,
dataType:"json",
success:function(data){
if(data.status == 200){
//window.location.reload()
$("#showFeedback").val(data.result)
var theShow = "原始数据: " + data.result + "\n"
theShow = theShow + "解析数据: " + JSON.stringify(data.parse) + "\n"
$("#showFeedback").val(theShow)
}else{
$("#showFeedback").val(data.message)
alert(data.message);
......@@ -131,18 +106,6 @@
}
});
});
//设置当前时间到UTC时间输入框
(function(){
var curTime = getCurTime();
$("#UTCTime").val(curTime);
})();
//设置当前时间戳到GPS信息时间戳输入框
(function(){
var curTimestamp = getCutTimestamp();
$("#GPSTimestamp").val(curTimestamp);
})();
</script>
{% endblock %}
</div>
......
{% extends "messageTools/index.html" %}
{% block title %}msgSetting{% endblock %}
{% block content_01 %}
<script src="../../static/js/messageTools/setting.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;
}
.protocol_content label{
width:90px;
text-align:right;
}
</style>
<div id="container2" style="width:82%;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="msgSetting" {% if arg.path[2]=="msgSetting_page" %} class="link-tab" {% endif %} onclick="settingManTab(this)">socket设置</b></a></li>
<li role="presentation"><a id="style_index1" {% if arg.path[2]=="1" %} class="link-tab" {% endif %} onclick="settingManTab(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>主机地址:</label><input id="host" type="text" class="form-control" value="{{ arg['socket']['host']}}">
<label style="margin-left:10px;">端口:</label><input id="port" type="text" class="form-control" value="{{ arg['socket']['port']}}" style="width:100px;">
</div>
<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="saveSetting">保存设置</button>
</div>
</div>
<script>
//保存设置数据
$("#saveSetting").click(function(){
var host = $("#host").val();
var port = $("#port").val();
var data = {};
data["host"] = host;
data["port"] = port;
var host = window.location.host;
$.ajax({
url:"http://" + host + "/messageTools/msgSetting_process/msgSocketSetting",
type:"post",
data:data,
dataType:"json",
success:function(data){
if(data.status == 200){
window.location.reload()
}else{
$("#showFeedback").val(data.message)
alert(data.message);
}
}
});
});
</script>
{% endblock %}
</div>
{% endblock %}
\ No newline at end of file
#coding:utf-8
from flask import Blueprint ,Response,request
from configparser import ConfigParser
from lib.protocol.message.TerminalHeartbeat_msg import TerminalHeartbeat_msg
from lib.protocol.messageRes.PlatformCommon_res import PlatformCommon_res
from lib.protocol.report.HeartBeatReport_protocol import HeartBeatReport_protocol
from lib.socket.ClientSocket import ClientSocket
import json
import traceback
import binascii
message_process = Blueprint('message_process', __name__)
##########################################
# 【接口类型】处理发送的心跳消息
##########################################
@message_process.route("/porcessHeartBeatMsg",methods=['POST'])
def porcessHeartBeatMsg():
msgID = request.form.get("msgID")
phoneNum = request.form.get("phoneNum")
msgWaterCode = request.form.get("msgWaterCode")
encryptionType = request.form.get("encryptionType")
subPkg = request.form.get("subPkg")
pkgCounts = request.form.get("pkgCounts")
data = {}
if (msgID == None or phoneNum == None or msgWaterCode == None or encryptionType == None or subPkg == None or pkgCounts == None):
data["status"] = "4003"
data["message"] = "Info: 请检查是否传入了空数据!"
return Response(json.dumps(data), mimetype='application/json')
else:
try:
conf_R = ConfigParser()
conf_R.read("config/messageTools/messageTools.conf")
cliSocket = ClientSocket(conf_R.get("socket", "host"),conf_R.getint("socket", "port"))
cliSocket.connect()
heartBeatmsgObj = TerminalHeartbeat_msg()
msg = heartBeatmsgObj.generateMsg()
cliSocket.send(msg)
socRecv_1 = cliSocket.receive()
socRecv_2 = str(socRecv_1)
cliSocket.close()
data["status"] = "200"
data["message"] = "Sucess: "
data["result"] = socRecv_2
data["parse"] = PlatformCommon_res(socRecv_1).getMsg()
except BaseException as e:
# 打印异常信息
traceback.print_exc()
data["status"] = "4003"
data["message"] = "Error: 处理失败!"
return Response(json.dumps(data), mimetype='application/json')
\ No newline at end of file
#coding:utf-8
from flask import Blueprint ,Response,request
from configparser import ConfigParser
import json
import traceback
msgSetting_process = Blueprint('msgSetting_process', __name__)
##########################################
# 【接口类型】处理发送的GPS上报报文
##########################################
@msgSetting_process.route("/msgSocketSetting",methods=['POST'])
def msgSocketSetting():
host = request.form.get("host")
port = request.form.get("port")
data = {}
if (host == None or port == None):
data["status"] = "4003"
data["message"] = "Info: 请检查是否传入了空数据!"
return Response(json.dumps(data), mimetype='application/json')
else:
try:
# d读取config文件
conf_R = ConfigParser()
conf_R.read("config/messageTools/messageTools.conf")
conf_W = conf_R
conf_W["socket"]["host"] = host
conf_W["socket"]["port"] = port
with open("config/messageTools/messageTools.conf", "w") as fi:
conf_W.write(fi)
data["status"] = "200"
data["message"] = "Sucess: "
except BaseException as e:
# 打印异常信息
traceback.print_exc()
data["status"] = "4003"
data["message"] = "Error: 处理失败!"
return Response(json.dumps(data), mimetype='application/json')
#coding:utf-8
from configparser import ConfigParser
from flask import Blueprint, render_template ,request
import re
msgSetting_view = Blueprint('msgSetting_view', __name__)
##########################################
# 【视图类型】访问心跳消息发送页面
##########################################
@msgSetting_view.route('/msgSetting_page')
def msgSetting_page():
#获取请求的路劲
url = request.url
reqPath = re.findall("http://(.*)$",url)[0]
reqPath = re.findall("/(.*)$", reqPath)[0]
arg = {}
path = "messageTools/setting/msgSetting_page.html"
arg["path"] = reqPath.split("/")
# 读取config文件
arg["socket"] = {}
conf_R = ConfigParser()
conf_R.read("config/messageTools/messageTools.conf")
arg["socket"]["host"] = conf_R.get("socket", "host")
arg["socket"]["port"] = conf_R.getint("socket", "port")
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