Commit ddaf3a31 authored by liyuanhong's avatar liyuanhong

增加了m300测试页面的点击进入

parent 29757da2
......@@ -32,7 +32,7 @@ port = 9008
# msg = TroubleReport_protocol().generateTroubleMsg() #终端上报故障码数据包
# msg = EventReport_protocol().generateEventMsg()
# msg = VersionReport_protocol().generateVersionMsg() #终端上报版本信息数据包
msg = SleepReport_protocol().generateSleepMsg()
msg = SleepReport_protocol().generateSleepMsg() #终端休眠数据包
print(msg)
BUF_SIZE = 1024
......
......@@ -8,6 +8,8 @@ from views.protocolTools.M_carSimulater_view import M_carSimulater_view
from views.protocolTools.M_carSimulater_process import M_carSimulater_process
from views.protocolTools.test_view import test_view
from views.m300Tools.P_m300Protocol_view import P_m300Protocol_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
......@@ -22,6 +24,8 @@ app.register_blueprint(M_carSimulater_view,url_prefix = "/protocolTools/M_carSim
app.register_blueprint(M_carSimulater_process,url_prefix = "/protocolTools/M_carSimulater_process")
app.register_blueprint(test_view,url_prefix = "/protocolTools/test_view")
app.register_blueprint(P_m300Protocol_view,url_prefix = "/m300Tools/P_m300Protocol_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")
......
......@@ -7,11 +7,7 @@ function swichTap(e){
$(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"){
$(location).attr('href', "http://" + window.location.host + "/tab2/login");
}else if(id == "otherTab"){
$(location).attr('href', "http://" + window.location.host + "/other");
}else if(id == "m300Tools"){
$(location).attr('href', "http://" + window.location.host + "/m300Tools/P_m300Protocol_view/P_heartBeat_m300_page");
}
}
/**
*protocols 页面顶部的协议切换
*/
function m300ProtocolManTab(e){
var url = window.location.href;
var id = $(e).attr("id");
if(id == "P_heartBeat_m300_msg"){
$(location).attr('href', "http://" + window.location.host + "/m300Tools/P_m300Protocol_view/P_heartBeat_m300_page");
}else if(id == "userDefined_protocol"){
$(location).attr('href', "http://" + window.location.host + "/protocolTools/protocolReport_view/userDefined_protocol_page");
}else{
alert(id)
}
}
......@@ -20,7 +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">M500协议工具</a></li>
<li role="presentation" {% if arg.path[0]=="m300" %} class="active" {% endif %}><a onclick="swichTap(this)" id="m300">M300协议工具</a></li>
<li role="presentation" {% if arg.path[0]=="m300Tools" %} class="active" {% endif %}><a onclick="swichTap(this)" id="m300Tools">M300协议工具</a></li>
<li role="presentation" {% if arg.path[0]=="messageTools" %} class="active" {% endif %}><a onclick="swichTap(this)" id="messageTools">新硬件消息工具</a></li>
</ul>
</div>
......
{% extends "base.html" %}
{% block title %}m300消息工具{% 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 == "m300_msg_send"){
$(location).attr('href', "http://" + window.location.host + "/m300Tools/P_m300Protocol_view/P_heartBeat_m300_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="m300_msg_send" onclick="swichLeftTab(this)"><a {% if arg.path[1]=="P_m300Protocol_view" %} class="active_left_tab" {% endif %}><span class="glyphicon glyphicon-list-alt" aria-hidden="true"></span> m300单消息发送<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 "m300Tools/index.html" %}
{% block title %}heartBeat_msg{% endblock %}
{% block content_01 %}
<script src="../../static/js/m300Tools/m300.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: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="P_heartBeat_m300_msg" {% if arg.path[2]=="P_heartBeat_m300_page" %} class="link-tab" {% endif %} onclick="m300ProtocolManTab(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" disabled="disabled" 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="subPkg" class="form-control" onchange="hasSubPkg()">
<option value="0"></option>
<option value="8192"></option>
</select>
<label id="subPkg_label" style="color:grey;">分包个数:</label><input disabled="disabled" id="pkgCounts" type="text" class="form-control" value="0" style="width:60px;">
</div>
<H3 style="border-bottom: 1px solid #eee;">设置心跳消息内容:</H3>
<ul class="protocol_content" style="padding:0px;">
<label style="color:red;width:130px;">心跳消息无消息体...</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 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["msgID"] = msgID;
data["phoneNum"] = phoneNum;
data["msgWaterCode"] = msgWaterCode;
data["encryptionType"] = encryptionType;
data["subPkg"] = subPkg;
data["pkgCounts"] = pkgCounts;
var host = window.location.host;
$("#showFeedback").val("")
$.ajax({
url:"http://" + host + "/messageTools/message_process/porcessHeartBeatMsg",
type:"post",
data:data,
dataType:"json",
success:function(data){
if(data.status == 200){
//window.location.reload()
var theShow = "原始数据: " + data.original + "\n";
theShow = theShow + "收到数据: " + data.result + "\n";
theShow = theShow + "收到数据16进制: " + data.resultH + "\n";
theShow = theShow + "解析数据: " + JSON.stringify(data.parse) + "\n";
$("#showFeedback").val(theShow)
}else{
$("#showFeedback").val(data.message)
alert(data.message);
}
}
});
});
function hasSubPkg(){
value = $("#subPkg").val()
if(value == "8192"){
$("#subPkg_label").css("color","black")
$("#pkgCounts").removeAttr("disabled")
}else{
$("#subPkg_label").css("color","grey")
$("#pkgCounts").attr("disabled","disabled")
}
}
</script>
{% endblock %}
</div>
{% endblock %}
\ No newline at end of file
......@@ -2,9 +2,14 @@
{% block title %}heartBeat_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>
<span>
<label>超时时间(秒):</label><input id="timeout" type="text" class="form-control" style="width:100px;" value="10">
</span>
</div>
<H3 style="border-bottom: 1px solid #eee;">输入消息内容:</H3>
<div style="width:100%;padding:5px;margin-top:10px;">
<textarea id="msg" style="width:100%;padding:5px;" rows="5"></textarea>
<textarea id="msg" style="width:100%;padding:5px;" rows="4"></textarea>
</div>
<H3 style="border-bottom: 1px solid #eee;">控制:</H3>
<div style="width:100%;padding:5px;margin-top:10px;">
......@@ -12,7 +17,7 @@
</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>
<textarea id="showFeedback" style="width:100%;padding:5px;" rows="6"></textarea>
</div>
</div>
......@@ -21,9 +26,11 @@
//发送心跳数据包
$("#sendMsgBtn").click(function(){
var msg = $("#msg").val();
var timeout = $("#timeout").val();
var data = {};
data["msg"] = msg;
data["timeout"] = timeout
var host = window.location.host;
$("#showFeedback").val("")
......
#coding:utf-8
from configparser import ConfigParser
from flask import Blueprint, render_template ,request
import re
P_m300Protocol_view = Blueprint('P_m300Protocol_view', __name__)
##########################################
# 【视图类型】访问侧车机模拟器页面
##########################################
@P_m300Protocol_view.route('/P_heartBeat_m300_page')
def P_heartBeat_m300_page():
#获取请求的路劲
url = request.url
reqPath = re.findall("http://(.*)$",url)[0]
reqPath = re.findall("/(.*)$", reqPath)[0]
arg = {}
path = "m300Tools/report/P_heartBeat_m300_page.html"
arg["path"] = reqPath.split("/")
return render_template(path,arg=arg)
\ No newline at end of file
......@@ -24,6 +24,7 @@ protocolReport_process = Blueprint('protocolReport_process', __name__)
@protocolReport_process.route("/porcessUserdefinedMsg",methods=['POST'])
def porcessUserdefinedMsg():
msg = request.form.get("msg")
timeout = int(request.form.get("timeout"))
data = {}
if (msg == None):
......@@ -37,7 +38,7 @@ def porcessUserdefinedMsg():
cliSocket = ClientSocket(conf_R.get("socket", "host"),conf_R.getint("socket", "port"))
cliSocket.connect()
cliSocket.send(msg)
cliSocket.setTimeOut(500)
cliSocket.setTimeOut(timeout)
socRecv = cliSocket.receive()
socRecvo = str(socRecv)
cliSocket.close()
......
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