Commit 2f22a080 authored by liyuanhong's avatar liyuanhong

M500 事件协议图形界面完成80%

parent 836043b1
......@@ -14,7 +14,7 @@ requirements.txt:设置项目需要的依赖库
---
### (二)、安装部署
1、机器上安装了python3 和 pip包管理工具
2、使用 :pip install -r requirement.txt 安装依赖库
2、使用 :pip install -r requirements.txt 安装依赖库
3、python3 run.py 运行项目
4、访问 host:5000 即可进入模拟器页面
......
[socket]
host = 10.100.11.20
port = 9001
host = v.vandyo.cn
port = 9018
......@@ -10,9 +10,12 @@ class EventClass(ProtocolBase):
def __init__(self):
self.GPSPkg = "1401091213260265b86206ed8c70026103280000752f03030405af017102610bb800003200000186a0001ed2a25e16fe3a"
self.BaseStationPkg = "1401140a0c050207e407e607e807ea07ec4eea4eec4eee4ef04efc4efe4f004f024f040024025e07d00007a125000927c60000ea610100"
self.securityData = ""
def setGPSpkg(self,data):
self.GPSPkg = data
def setSecurityData(self,data):
self.securityData = data
# 3 点火事件附带信息
def fireExtraInfo(self):
......@@ -21,7 +24,11 @@ class EventClass(ProtocolBase):
allSharpTurn = self.int2hexStringByBytes(15, 2) # 急转弯总次数
securityObj = SecurityStatusReport_protocol()
securityObj.setGPSPkg(self.GPSPkg)
securityData = securityObj.generateSecurityStatusData() # 安防数据
securityData = ""
if self.securityData == "":
securityData = securityObj.generateSecurityStatusData() # 安防数据
else:
securityData = self.securityData
data = allRapidlyAccelerateCount + allSharpSlowdownCount + allSharpTurn + securityData
return data
......@@ -32,18 +39,35 @@ class EventClass(ProtocolBase):
allSharpTurn = self.int2hexStringByBytes(35,2) #急转弯总次数
securityObj = SecurityStatusReport_protocol()
securityObj.setGPSPkg(self.GPSPkg)
securityData = securityObj.generateSecurityStatusData() #安防数据
securityData = ""
if self.securityData == "":
securityData = securityObj.generateSecurityStatusData() # 安防数据
else:
securityData = self.securityData
data = allRapidlyAccelerateCount + allSharpSlowdownCount + allSharpTurn + securityData
return data
#5 设防事件附带信息
def setUpDefencesExtraInfo(self):
securityData = SecurityStatusReport_protocol.generateSecurityStatusData() # 安防数据
securityObj = SecurityStatusReport_protocol()
securityObj.setGPSPkg(self.GPSPkg)
securityData = ""
if self.securityData == "":
securityData = securityObj.generateSecurityStatusData() # 安防数据
else:
securityData = self.securityData
return securityData
#6 撤防事件附带信息
def setDownDefencesExtraInfo(self):
securityData = SecurityStatusReport_protocol.generateSecurityStatusData() # 安防数据
securityObj = SecurityStatusReport_protocol()
securityObj.setGPSPkg(self.GPSPkg)
securityData = ""
if self.securityData == "":
securityData = securityObj.generateSecurityStatusData() # 安防数据
else:
securityData = self.securityData
return securityData
return securityData
#7 锁车未成功事件附带信息
......
......@@ -4,25 +4,52 @@ import time
from lib.protocol.report.GPSReport_protocol import GPSReport_protocol
from lib.protocol.report.ProtocolBase import ProtocolBase
from lib.protocol.appendix.EventClass import EventClass
from lib.protocol.report.SecurityStatusReport_protocol import SecurityStatusReport_protocol
'''
终端上事件数据包
'''
class EventReport_protocol(ProtocolBase):
def __init__(self,msgCount = 1,WATER_CODE = 26,DEV_ID = "M121501010001",locationType=1,eventType="0036"):
#data = {"WATER_CODE":"0003","DEV_ID":"M121501010001","gpsInfo":{"UTCTime":"2020-04-14 11:03:20","latitude":"40.22077","longitude":"116.23128","speed":"80.8","directionAngle":"80.8","elevation":"2999.9","positionStar":"3","Pdop":"0.3","Hdop":"0.4","Vdop":"0.5","statusBit":162,"valtage":"36.9","OBDSpeed":"60.9","engineSpeed":"3000","GPSTotalMileage":"12800","totalOil":"100000","totalTime":"2020002","GPSTimestamp":"1586833400"},"securityData":{"securityStatus":107,"doorStatus":0,"lockStatus":0,"windowStatus":0,"lightStatus":0,"onoffStatusA":0,"onoffStatusB":112,"dataByte":249},"event":{}}
data = {}
def __init__(self,msgCount = 1,WATER_CODE = 26,DEV_ID = "M121501010001",locationType=1,eventType="0036",data={}):
super().__init__()
self.msgCount = msgCount #数据包个数
self.data = data
if len(data) == 0:
self.msgCount = msgCount #数据包个数
self.WATER_CODE = int(WATER_CODE) #消息流水号
self.DEV_ID = DEV_ID #设备id
self.locationType = int(locationType) # 定位类型
#self.GPSPkg = GPSpkg & BaseStationPkg # GPS包或者基站包
self.GPSPkg = "1401091213260265b86206ed8c70026103280000752f03030405af017102610bb800003200000186a0001ed2a25e16fe3a"
self.BaseStationPkg = "1401140a0c050207e407e607e807ea07ec4eea4eec4eee4ef04efc4efe4f004f024f040024025e07d00007a125000927c60000ea610100"
self.eventType = eventType #事件类别
else:
self.msgCount = 1 # 数据包个数
self.WATER_CODE = int(data["WATER_CODE"]) # 消息流水号
self.DEV_ID = data["DEV_ID"] # 设备id
self.WATER_CODE = int(WATER_CODE); #消息流水号
self.DEV_ID = DEV_ID #设备id
self.locationType = 1 # 定位类型
gpsInfo = data["gpsInfo"]
self.gpsInfo = gpsInfo
securityData = data["securityData"]
self.securityData = securityData
event = data["event"]
self.event = event
self.GPSPkg = GPSReport_protocol(1,self.WATER_CODE,self.DEV_ID,gpsInfo["UTCTime"],gpsInfo["latitude"],gpsInfo["longitude"] \
,gpsInfo["speed"],gpsInfo["directionAngle"],gpsInfo["elevation"],gpsInfo["positionStar"],gpsInfo["Pdop"] \
,gpsInfo["Hdop"],gpsInfo["Vdop"],gpsInfo["statusBit"],gpsInfo["valtage"],gpsInfo["OBDSpeed"],gpsInfo["engineSpeed"] \
,gpsInfo["GPSTotalMileage"],gpsInfo["totalOil"],gpsInfo["totalTime"],gpsInfo["GPSTimestamp"]).generateGpsData()
self.locationType = int(locationType) # 定位类型
#self.GPSPkg = GPSpkg & BaseStationPkg # GPS包或者基站包
self.GPSPkg = "1401091213260265b86206ed8c70026103280000752f03030405af017102610bb800003200000186a0001ed2a25e16fe3a"
self.BaseStationPkg = "1401140a0c050207e407e607e807ea07ec4eea4eec4eee4ef04efc4efe4f004f024f040024025e07d00007a125000927c60000ea610100"
self.eventType = eventType #事件类别
self.securityPkg = SecurityStatusReport_protocol(1,self.WATER_CODE,self.DEV_ID,1,self.GPSPkg,"ffffffffffffffffffff" \
,securityData["securityStatus"],securityData["doorStatus"],securityData["lockStatus"] \
,securityData["windowStatus"],securityData["lightStatus"],securityData["onoffStatusA"] \
,securityData["onoffStatusB"],securityData["dataByte"]).generateSecurityStatusData()
self.BaseStationPkg = "1401140a0c050207e407e607e807ea07ec4eea4eec4eee4ef04efc4efe4f004f024f040024025e07d00007a125000927c60000ea610100"
def setLatitude(self,data):
self.latitude = data
......@@ -38,7 +65,6 @@ class EventReport_protocol(ProtocolBase):
self.BaseStationPkg = data
#####################################################
# 生成事件信息消息
#####################################################
......@@ -55,8 +81,11 @@ class EventReport_protocol(ProtocolBase):
FUN_ID = "0021"
#数据段
data = ""
for i in range(0,self.msgCount):
data += self.generateEventPkg(self.msgCount,self.generateEventData())
if len(self.data) == 0:
for i in range(0,self.msgCount):
data += self.generateEventPkg(self.msgCount,self.generateEventData())
else:
data += self.generateEventData_GUI()
# 消息长度
LENGTH = self.getMsgLength(int(len(WATER_CODE + DEV_ID + FUN_ID + data)/2))
......@@ -95,9 +124,19 @@ class EventReport_protocol(ProtocolBase):
eventType = self.eventType
extraInfo = self.getExtraData(eventType) #附带信息
extraInfoLen = self.int2hexStringByBytes(int((len(extraInfo) / 2)),2) #附带信息长度
data = locationType + locationData + eventType + extraInfoLen + extraInfo
return data
def generateEventData_GUI(self):
data = ""
locationType = self.int2hexString(self.locationType) #定位类型
locationData = "" #GPS包或基站包
if self.locationType == 1:
locationData = self.GPSPkg
elif self.locationType == 2:
locationData = self.BaseStationPkg
eventData = self.getExtraData_GUI(self.event)
data = locationType + locationData + eventData
return data
#####################################################
# 获取附带信息
......@@ -160,3 +199,65 @@ class EventReport_protocol(ProtocolBase):
elif eventType == "004A": #剩余油量异常告警
return EventClass().surplusOilAlarm()
#####################################################
# 获取附带信息(针对图形界面)
#####################################################
def getExtraData_GUI(self,eventData):
data = ""
dataNums = 0
if("0003" in eventData.keys()): #汽车电瓶低电压报警
dataNums = dataNums + 1
theData = ""
data = data + "0003" + self.int2hexStringByBytes(int((len(theData) / 2)),2) + theData
if ("0004" in eventData.keys()): #终端主电断电报警
dataNums = dataNums + 1
theData = ""
data = data + "0004" + self.int2hexStringByBytes(int((len(theData) / 2)), 2) + theData
if ("0010" in eventData.keys()): #汽车点火上报
dataNums = dataNums + 1
eventObj = EventClass()
eventObj.setGPSpkg(self.GPSPkg)
eventObj.setSecurityData(self.securityPkg)
theData = eventObj.fireExtraInfo()
data = data + "0010" + self.int2hexStringByBytes(int((len(theData) / 2)), 2) + theData
if ("0011" in eventData.keys()): #汽车熄火上报
dataNums = dataNums + 1
eventObj = EventClass()
eventObj.setGPSpkg(self.GPSPkg)
eventObj.setSecurityData(self.securityPkg)
theData = eventObj.fireExtraInfo()
data = data + "0011" + self.int2hexStringByBytes(int((len(theData) / 2)), 2) + theData
if ("0012" in eventData.keys()): #汽车设防上报
dataNums = dataNums + 1
eventObj = EventClass()
eventObj.setGPSpkg(self.GPSPkg)
eventObj.setSecurityData(self.securityPkg)
theData = eventObj.setUpDefencesExtraInfo()
data = data + "0012" + self.int2hexStringByBytes(int((len(theData) / 2)), 2) + theData
if ("0013" in eventData.keys()): #汽车撤防上报
dataNums = dataNums + 1
eventObj = EventClass()
eventObj.setGPSpkg(self.GPSPkg)
eventObj.setSecurityData(self.securityPkg)
theData = eventObj.setDownDefencesExtraInfo()
data = data + "0013" + self.int2hexStringByBytes(int((len(theData) / 2)), 2) + theData
if ("0036" in eventData.keys()): #低档高速报警
dataNums = dataNums + 1
eventObj = EventClass()
theData = eventObj.lowGearHighSpeedAlarm(int(eventData["0036"]["alarmType"]),int(eventData["0036"]["durationTime"]))
data = data + "0036" + self.int2hexStringByBytes(int((len(theData) / 2)), 2) + theData
if ("0037" in eventData.keys()): #高档低速报警
dataNums = dataNums + 1
eventObj = EventClass()
theData = eventObj.lowGearHighSpeedAlarm(int(eventData["0036"]["alarmType"]),int(eventData["0036"]["durationTime"]))
data = data + "0037" + self.int2hexStringByBytes(int((len(theData) / 2)), 2) + theData
print(data)
dataNumsHex = self.int2hexString(int(dataNums))
data = dataNumsHex +data
return data
if __name__ == "__main__":
data = {"a":1,"b":2,"c":{"d":3}}
data = {}
print(len(data))
\ No newline at end of file
......@@ -40,11 +40,11 @@ port = 9008
# msg = SecurityStatusReport_protocol().generateSecurityStatusMsg() #终端上报安防状态协议
# msg = BaseStationReport_protocol().generateBaseStationMsg() #终端上报基站定位协议
# msg = TroubleReport_protocol().generateTroubleMsg() #终端上报故障码数据包
# msg = EventReport_protocol().generateEventMsg() #终端上报事件数据包
msg = EventReport_protocol().generateEventMsg() #终端上报事件数据包
# msg = VersionReport_protocol().generateVersionMsg() #终端上报版本信息数据包
# msg = SleepReport_protocol().generateSleepMsg() #终端休眠数据包
# msg = CommonReport_protocol().generateCommonMsg() #通用应答消息
msg = VoltageDataReport_protocol().generateMsg() #终端上报电瓶电压采样数据
# msg = VoltageDataReport_protocol().generateMsg() #终端上报电瓶电压采样数据
print(msg)
BUF_SIZE = 1024
......
......@@ -15,6 +15,8 @@ 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.messageTools.M_simulater_view import M_simulater_view
from views.messageTools.M_simulater_process import M_simulater_process
app = Flask(__name__)
app.register_blueprint(setting_view,url_prefix = "/protocolTools/setting_view")
......@@ -32,6 +34,8 @@ app.register_blueprint(msgSetting_view,url_prefix = "/messageTools/msgSetting_vi
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(M_simulater_view,url_prefix = "/messageTools/M_simulater_view")
app.register_blueprint(M_simulater_process,url_prefix = "/messageTools/M_simulater_process")
@app.route('/')
def hello():
......
/**
*模拟器 页面顶部的Tab切换
*/
function simulaterManTab(e){
var url = window.location.href;
var id = $(e).attr("id");
if(id == "car_simulater_tab"){
$(location).attr('href', "http://" + window.location.host + "/messageTools/M_simulater_view/M_simulater_page");
}else if(id == "car_simulaterSetting_tab"){
$(location).attr('href', "http://" + window.location.host + "/messageTools/M_simulater_view/M_simulaterSetting_page");
}else{
alert(id)
}
}
\ No newline at end of file
......@@ -18,6 +18,8 @@ function protocolManTab(e){
$(location).attr('href', "http://" + window.location.host + "/protocolTools/protocolReport_view/securityStatus_protocol_page");
}else if(id == "voltageData_protocol"){
$(location).attr('href', "http://" + window.location.host + "/protocolTools/protocolReport_view/voltageData_protocol_page");
}else if(id == "event_protocol"){
$(location).attr('href', "http://" + window.location.host + "/protocolTools/protocolReport_view/event_protocol_page");
}else{
alert(id)
}
......
......@@ -23,10 +23,8 @@
$(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"){
$(location).attr('href', "http://" + window.location.host + "/tab1/icon");
}else if(id == "car_simulater"){
$(location).attr('href', "http://" + window.location.host + "/messageTools/M_simulater_view/M_simulater_page");
}
}
</script>
......@@ -38,7 +36,7 @@
<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>
<li id="car_simulater" onclick="swichLeftTab(this)"><a {% if arg.path[1]=="M_simulater_view" %} class="active_left_tab" {% endif %}><span class="glyphicon glyphicon-hand-right" aria-hidden="true"></span></span> 车机模拟器</a></li>
</ul>
</div>
{% endblock %}
......
{% extends "messageTools/message/M_simulater_page.html" %}
{% block title %}heartBeat_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;">
<H3 style="border-bottom: 1px solid #eee;">设置操作界面</H3>
</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 %}
\ No newline at end of file
{% extends "messageTools/index.html" %}
{% block title %}heartBeat_msg{% endblock %}
{% block content_01 %}
<script src="../../static/js/messageTools/simulater.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="car_simulaterSetting_tab" {% if arg.path[2]=="M_simulaterSetting_page" %} class="link-tab" {% endif %} onclick="simulaterManTab(this)">设置</b></a></li>
<li role="presentation"><a id="car_simulater_tab" {% if arg.path[2]=="M_simulater_page" %} class="link-tab" {% endif %} onclick="simulaterManTab(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;">
<H3 style="border-bottom: 1px solid #eee;">模拟器操作界面</H3>
</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
......@@ -43,10 +43,10 @@
<ul class="nav nav-sidebar" style="margin-top:20px;">
<li id="car_simulater" onclick="swichLeftTab(this)"><a {% if arg.path[1]=="M_carSimulater_view" %} class="active_left_tab" {% endif %}><span class="glyphicon glyphicon-hand-right" aria-hidden="true"></span> 车辆行为模拟</a></li>
</ul>
<ul class="nav nav-sidebar" style="margin-top:20px;">
<li id="test" onclick="swichLeftTab(this)"><a {% if arg.path[1]=="test_view" %} class="active_left_tab" {% endif %}><span class="glyphicon glyphicon-text-size" aria-hidden="true"></span> 测试页面</a></li>
<li><a><span class="glyphicon glyphicon-eye-open" aria-hidden="true"></span> 其他页面</a></li>
</ul>
<!-- <ul class="nav nav-sidebar" style="margin-top:20px;">-->
<!-- <li id="test" onclick="swichLeftTab(this)"><a {% if arg.path[1]=="test_view" %} class="active_left_tab" {% endif %}><span class="glyphicon glyphicon-text-size" aria-hidden="true"></span> 测试页面</a></li>-->
<!-- <li><a><span class="glyphicon glyphicon-eye-open" aria-hidden="true"></span> 其他页面</a></li>-->
<!-- </ul>-->
</div>
{% endblock %}
......
......@@ -38,6 +38,7 @@
<li role="presentation"><a id="OBD_CAN_protocol" {% if arg.path[2]=="OBD_CAN_protocol_page" %} class="link-tab" {% endif %} onclick="protocolManTab(this)">OBD-CAN报文</b></a></li>
<li role="presentation"><a id="securityStatus_protocol" {% if arg.path[2]=="securityStatus_protocol_page" %} class="link-tab" {% endif %} onclick="protocolManTab(this)">安防状态报文</b></a></li>
<li role="presentation"><a id="voltageData_protocol" {% if arg.path[2]=="voltageData_protocol_page" %} class="link-tab" {% endif %} onclick="protocolManTab(this)">电瓶电压采样报文</b></a></li>
<li role="presentation"><a id="event_protocol" {% if arg.path[2]=="event_protocol_page" %} class="link-tab" {% endif %} onclick="protocolManTab(this)">事件报文</b></a></li>
</ul>
{% endblock %}
{% block content_1 %}
......
{% extends "protocolTools/report/GPS_protocol_page.html" %}
{% block title %}event_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 style="width:100%;_background:green;padding:5px;padding-top:0px;">
<h3 style="border-bottom: 1px solid #eee;">设置协议头:</h3>
<label>消息流水号:</label><input id="WATER_CODE" type="text" class="form-control" value="0003" style="width:100px;">
<label style="margin-left:10px;">车机号:</label><input id="DEV_ID" type="text" class="form-control" value="M121501010001">
</div>
<H3 style="border-bottom: 1px solid #eee;">设置事件消息内容:</H3>
<div style="width:100%;border-width:1px;border-style:solid;border-color:darkgray;border-radius:10px;padding:2px;_background:skyblue;">
<h5><b>设置事件携带的GPS数据包:</b>
<span style="border-width:1px;border-style:solid;border-color:darkgray;border-radius:10px;padding:1px 10px;">
<label><input name="gps" type="radio" value="0" checked="checked" onclick="isShowGspArea(this)"/>隐藏</label>
<label><input name="gps" type="radio" value="1" onclick="isShowGspArea(this)"/>显示</label>
</span>
</h5>
<div style="display:none;" id="gps_area">
<ul class="protocol_content" style="padding:0px;">
<li><label>UTC时间:</label><input id="UTCTime" type="text" class="form-control" value="2020-1-20 16:24:36"></li>
<li><label>纬度:</label><input id="latitude" type="text" class="form-control" value="40.22077"></li>
<li><label>经度:</label><input id="longitude" type="text" class="form-control" value="116.23128"></li>
<!-- <li style="width:480px;height:40px;"><label>速度:</label>0&nbsp;&nbsp;<input type="range" min="0" max="100" value="70" style="width:280px;display:inline;"/> 100 &nbsp;&nbsp;值:<span id="speedValShow">33</span></li>-->
<li style="width:500px;"><label>速度:</label><input id="speed" type="text" class="form-control" value="80.8">&nbsp;&nbsp;<p style="display:inline;font-size:12px;">单位 0.1 km/h,取值范围10.0~240.0</p></li>
<li><label>方向角:</label><input id="directionAngle" type="text" class="form-control" value="80.8"></li>
<li><label>海拔:</label><input id="elevation" type="text" class="form-control" value="2999.9"></li>
<li><label>定位星数:</label><input id="positionStar" type="text" class="form-control" value="3"></li>
<li><label>PDOP精度:</label><input id="Pdop" type="text" class="form-control" value="0.3"></li>
<li><label>HDOP精度:</label><input id="Hdop" type="text" class="form-control" value="0.4"></li>
<li><label>VDOP精度:</label><input id="Vdop" type="text" class="form-control" value="0.5"></li>
<li style="width:100%;">
<h5><b>状态位:</b></h5>
<label style="font-size:12px;">当前定位是否有效:</label><select id="isLocationValid" class="form-control" style="width:100px;">
<option value="1">有效</option>
<option value="0">无效</option>
</select>
<label style="font-size:12px;">当前定位模式:</label><select id="locationMode" class="form-control" style="width:170px;">
<option value="0">自动模式</option>
<option value="2">单GPS模式</option>
<option value="4">单BDS模式</option>
<option value="6">GPS+BDS双模式</option>
</select>
<label style="font-size:12px;">定位类型:</label><select id="locationType" class="form-control" style="width:100px;">
<option value="32">2D定位</option>
<option value="48">3D定位</option>
</select>
<label style="font-size:12px;">统计里程模式:</label><select id="staticMileageMode" class="form-control" style="width:150px;">
<option value="0">GPS统计里程</option>
<option value="64">OBD统计里程</option>
</select>
<label style="font-size:12px;">车辆点熄火状态:</label><select id="fireStatus" class="form-control" style="width:100px;">
<option value="0">熄火</option>
<option value="128" selected="selected">点火</option>
</select>
</li>
<li><label>电瓶电压:</label><input id="valtage" type="text" class="form-control" value="36.9"></li>
<li><label>OBD车速速:</label><input id="OBDSpeed" type="text" class="form-control" value="60.9"></li>
<li><label>发动机转速:</label><input id="engineSpeed" type="text" class="form-control" value="3000"></li>
<li><label>累计里程:</label><input id="GPSTotalMileage" type="text" class="form-control" value="12800"></li>
<li><label>累计油耗:</label><input id="totalOil" type="text" class="form-control" value="100000"></li>
<li><label style="font-size:10px;">累计行驶时间:</label><input id="totalTime" type="text" class="form-control" value="2020002"></li>
<li><label style="font-size:10px;">GPS信息时间戳:</label><input id="GPSTimestamp" type="text" class="form-control"></li>
</ul>
</div>
</div>
<div style="margin-top:10px;width:100%;border-width:1px;border-style:solid;border-color:darkgray;border-radius:10px;padding:2px;_background:skyblue;">
<h5><b>设置事件携带的安防数据包(有些事件需要携带):</b>
<span style="border-width:1px;border-style:solid;border-color:darkgray;border-radius:10px;padding:1px 10px;">
<label><input name="security" type="radio" value="0" checked="checked" onclick="isShowSecurityArea(this)"/>隐藏</label>
<label><input name="security" type="radio" value="1" onclick="isShowSecurityArea(this)"/>显示</label>
</span>
</h5>
<div style="display:none;" id="security_area">
<h5>安全状态:</h5>
<ul class="protocol_content" style="padding:0px;">
<li style="width:175px;"><label>ACC状态:</label><select style="width:80px;" id="accStatus" class="form-control">
<option value="1"></option>
<option value="0"></option>
</select></li>
<li style="width:175px;"><label style="word-break:break-all;font-size:12px;">设防撤防状态:</label><select style="width:80px;" id="defenseStatus" class="form-control">
<option value="2">设防</option>
<option value="0">撤防</option>
</select></li>
<li style="width:175px;"><label>脚刹状态:</label><select style="width:80px;" id="brakeStatus" class="form-control">
<option value="4">踩下</option>
<option value="0" selected="selected">松开</option>
</select></li>
<li style="width:175px;"><label>是否踩油门:</label><select style="width:80px;" id="acceleratorStatus" class="form-control">
<option value="8">踩下</option>
<option value="0">松开</option>
</select></li>
<li style="width:175px;"><label>手刹状态:</label><select style="width:80px;" id="handBrakeStatus" class="form-control">
<option value="16">拉起</option>
<option value="0" selected="selected">松开</option>
</select></li>
<li style="width:175px;"><label style="word-break:break-all;font-size:12px;">主驾驶安全带:</label><select style="width:80px;" id="mainSafetyBelt" class="form-control">
<option value="32">插入</option>
<option value="0">松开</option>
</select></li>
<li style="width:175px;"><label style="word-break:break-all;font-size:12px;">副驾驶安全带:</label><select style="width:80px;" id="subSafetyBelt" class="form-control">
<option value="64">插入</option>
<option value="0">松开</option>
</select></li>
</ul>
<h5>门状态:</h5>
<ul class="protocol_content" style="padding:0px;">
<li style="width:175px;"><label>左前门:</label><select style="width:80px;" id="lfDoorStatus" class="form-control">
<option value="1"></option>
<option value="0" selected="selected"></option>
</select></li>
<li style="width:175px;"><label>右前门:</label><select style="width:80px;" id="rfDoorStatus" class="form-control">
<option value="2"></option>
<option value="0" selected="selected"></option>
</select></li>
<li style="width:175px;"><label>左后门:</label><select style="width:80px;" id="lbDoorStatus" class="form-control">
<option value="4"></option>
<option value="0" selected="selected"></option>
</select></li>
<li style="width:175px;"><label>右后门:</label><select style="width:80px;" id="rbDoorStatus" class="form-control">
<option value="8"></option>
<option value="0" selected="selected"></option>
</select></li>
<li style="width:175px;"><label>后备箱:</label><select style="width:80px;" id="trunk" class="form-control">
<option value="16"></option>
<option value="0" selected="selected"></option>
</select></li>
<li style="width:175px;"><label>发送机盖:</label><select style="width:80px;" id="enginCover" class="form-control">
<option value="32"></option>
<option value="0" selected="selected"></option>
</select></li>
</ul>
<h5>锁状态:</h5>
<ul class="protocol_content" style="padding:0px;">
<li style="width:175px;"><label style="word-break:break-all;font-size:12px;">左前门锁状态:</label><select style="width:80px;" id="lfDoorLockStatus" class="form-control">
<option value="1"></option>
<option value="0" selected="selected"></option>
</select></li>
<li style="width:175px;"><label style="word-break:break-all;font-size:12px;">右前门锁状态:</label><select style="width:80px;" id="rfDoorLockStatus" class="form-control">
<option value="2"></option>
<option value="0" selected="selected"></option>
</select></li>
<li style="width:175px;"><label style="word-break:break-all;font-size:12px;">左后门锁状态:</label><select style="width:80px;" id="lbDoorLockStatus" class="form-control">
<option value="4"></option>
<option value="0" selected="selected"></option>
</select></li>
<li style="width:175px;"><label style="word-break:break-all;font-size:12px;">右后门锁状态:</label><select style="width:80px;" id="rbDoorLockStatus" class="form-control">
<option value="8"></option>
<option value="0" selected="selected"></option>
</select></li>
</ul>
<h5>窗户状态:</h5>
<ul class="protocol_content" style="padding:0px;">
<li style="width:175px;"><label>左前窗:</label><select style="width:80px;" id="lfWindowStatus" class="form-control">
<option value="1"></option>
<option value="0" selected="selected"></option>
</select></li>
<li style="width:175px;"><label>右前窗:</label><select style="width:80px;" id="rfWindowStatus" class="form-control">
<option value="2"></option>
<option value="0" selected="selected"></option>
</select></li>
<li style="width:175px;"><label>左后窗:</label><select style="width:80px;" id="lbWindowStatus" class="form-control">
<option value="4"></option>
<option value="0" selected="selected"></option>
</select></li>
<li style="width:175px;"><label>右后窗:</label><select style="width:80px;" id="rbWindowStatus" class="form-control">
<option value="8"></option>
<option value="0" selected="selected"></option>
</select></li>
<li style="width:175px;"><label>天窗开关:</label><select style="width:80px;" id="topWindowStatus" class="form-control">
<option value="16"></option>
<option value="0" selected="selected"></option>
</select></li>
<li style="width:175px;"><label>左转向灯:</label><select style="width:80px;" id="lTurnLight" class="form-control">
<option value="32"></option>
<option value="0" selected="selected"></option>
</select></li>
<li style="width:175px;"><label>右转向灯:</label><select style="width:80px;" id="rTurnLight" class="form-control">
<option value="64"></option>
<option value="0" selected="selected"></option>
</select></li>
<li style="width:175px;"><label>阅读灯:</label><select style="width:80px;" id="readLight" class="form-control">
<option value="128"></option>
<option value="0" selected="selected"></option>
</select></li>
</ul>
<h5>灯光状态:</h5>
<ul class="protocol_content" style="padding:0px;">
<li style="width:175px;"><label>近光灯:</label><select style="width:80px;" id="lowHeadlight" class="form-control">
<option value="1"></option>
<option value="0" selected="selected"></option>
</select></li>
<li style="width:175px;"><label>远光灯:</label><select style="width:80px;" id="highHeadlight" class="form-control">
<option value="2"></option>
<option value="0" selected="selected"></option>
</select></li>
<li style="width:175px;"><label>前雾灯:</label><select style="width:80px;" id="ffogLight" class="form-control">
<option value="4"></option>
<option value="0" selected="selected"></option>
</select></li>
<li style="width:175px;"><label>后雾灯:</label><select style="width:80px;" id="bfogLight" class="form-control">
<option value="8"></option>
<option value="0" selected="selected"></option>
</select></li>
<li style="width:175px;"><label>危险灯:</label><select style="width:80px;" id="dangerLight" class="form-control">
<option value="16"></option>
<option value="0" selected="selected"></option>
</select></li>
<li style="width:175px;"><label>倒车灯:</label><select style="width:80px;" id="backCarLight" class="form-control">
<option value="32"></option>
<option value="0" selected="selected"></option>
</select></li>
<li style="width:175px;"><label>auto灯:</label><select style="width:80px;" id="autoLight" class="form-control">
<option value="64"></option>
<option value="0" selected="selected"></option>
</select></li>
<li style="width:175px;"><label>示宽灯:</label><select style="width:80px;" id="widthLight" class="form-control">
<option value="128"></option>
<option value="0" selected="selected"></option>
</select></li>
</ul>
<h5>开关状态A:</h5>
<ul class="protocol_content" style="padding:0px;">
<li style="width:175px;"><label>机油报警:</label><select style="width:80px;" id="machineOilWarning" class="form-control">
<option value="1"></option>
<option value="0" selected="selected"></option>
</select></li>
<li style="width:175px;"><label>燃油报警:</label><select style="width:80px;" id="oilWarning" class="form-control">
<option value="2"></option>
<option value="0" selected="selected"></option>
</select></li>
<li style="width:175px;"><label>雨刷报警:</label><select style="width:80px;" id="wiperWarning" class="form-control">
<option value="4"></option>
<option value="0" selected="selected"></option>
</select></li>
<li style="width:175px;"><label>喇叭报警:</label><select style="width:80px;" id="loudsspeakerWaring" class="form-control">
<option value="8"></option>
<option value="0" selected="selected"></option>
</select></li>
<li style="width:175px;"><label>空调:</label><select style="width:80px;" id="airConditionerWaring" class="form-control">
<option value="16"></option>
<option value="0" selected="selected"></option>
</select></li>
<li style="width:175px;"><label>后视镜状态:</label><select style="width:80px;" id="backMirrorWaring" class="form-control">
<option value="32"></option>
<option value="0" selected="selected"></option>
</select></li>
</ul>
<h5>开关状态B:</h5>
<ul class="protocol_content" style="padding:0px;">
<li style="width:175px;"><label>档位:</label><select style="width:80px;" id="gears" class="form-control">
<option value="0">P</option>
<option value="16">R</option>
<option value="32">N</option>
<option value="48">D</option>
<option value="64">1挡</option>
<option value="80">2挡</option>
<option value="96">3挡</option>
<option value="112" selected="selected">4挡</option>
<option value="128">5挡</option>
<option value="144">6挡</option>
<option value="160">M挡</option>
<option value="176">S挡</option>
</select></li>
</ul>
<h5>数据字节:</h5>
<ul class="protocol_content" style="padding:0px;">
<li style="width:175px;"><label>V1N1:</label><select style="width:80px;" id="V1N1" class="form-control">
<option value="1">存在</option>
<option value="0">不存在</option>n>
</select></li>
<li style="width:175px;"><label>总线总里程:</label><select style="width:80px;" id="busTotalMileage" class="form-control">
<option value="8">存在</option>
<option value="0">不存在</option>n>
</select></li>
<li style="width:175px;"><label>仪表数据:</label><select style="width:80px;" id="meterData" class="form-control">
<option value="16">存在</option>
<option value="0">不存在</option>n>
</select></li>
<li style="width:175px;"><label>发送机转速:</label><select style="width:80px;" id="security_engineSpeed" class="form-control">
<option value="32">存在</option>
<option value="0">不存在</option>n>
</select></li>
<li style="width:175px;"><label>车辆速度:</label><select style="width:80px;" id="security_speed" class="form-control">
<option value="64">存在</option>
<option value="0">不存在</option>n>
</select></li>
<li style="width:175px;"><label>剩余油量:</label><select style="width:80px;" id="surplusOil" class="form-control">
<option value="128">存在</option>
<option value="0">不存在</option>n>
</select></li>
</ul>
</div>
</div>
<div style="margin-top:10px;width:100%;border-width:1px;border-style:solid;border-color:darkgray;border-radius:10px;padding:2px;background:skyblue;">
<h5><b>选择要上报的事件:</b></h5>
<label style="padding: 0px 10px;"><input type="checkbox" id="0003" onclick="eventSelect(this)"/>汽车电瓶低电压报警 </label>
<label style="padding: 0px 10px;"><input type="checkbox" id="0004" onclick="eventSelect(this)"/>终端主电断电报警 </label>
<label style="padding: 0px 10px;"><input type="checkbox" id="0010" onclick="eventSelect(this)"/>点火 </label>
<label style="padding: 0px 10px;"><input type="checkbox" id="0011" onclick="eventSelect(this)"/>熄火 </label>
<label style="padding: 0px 10px;"><input type="checkbox" id="0012" onclick="eventSelect(this)"/>设防 </label>
<label style="padding: 0px 10px;"><input type="checkbox" id="0013" onclick="eventSelect(this)"/>撤防 </label>
<label style="padding: 0px 10px;"><input type="checkbox" id="0036" onclick="eventSelect(this)"/>低档高速报警 </label>
<label style="padding: 0px 10px;"><input type="checkbox" id="0037" onclick="eventSelect(this)"/>高档低速报警 </label>
<label style="padding: 0px 10px;"><input type="checkbox" id="004A" onclick="eventSelect(this)"/>剩余油量异常告警 </label>
</div>
<div style="margin-top:10px;width:100%;border-width:1px;border-style:solid;border-color:darkgray;border-radius:10px;padding:2px;_background:skyblue;">
<h5><b>点火事件:</b></h5>
<span><label>急加速总次数:</label><input style="width:80px;" id="fire_allRapidlyAccelerateCount" type="text" class="form-control" value="5"></span>
<span><label>急减速总次数:</label><input style="width:80px;" id="fire_allSharpSlowdownCount" type="text" class="form-control" value="6"></span>
<span><label>急转弯总次数:</label><input style="width:80px;" id="fire_allSharpTurn" type="text" class="form-control" value="4"></span>
</div>
<div style="margin-top:10px;width:100%;border-width:1px;border-style:solid;border-color:darkgray;border-radius:10px;padding:2px;_background:skyblue;">
<h5><b>熄火事件:</b></h5>
<span><label>急加速总次数:</label><input style="width:80px;" id="misfire_allRapidlyAccelerateCount" type="text" class="form-control" value="5"></span>
<span><label>急减速总次数:</label><input style="width:80px;" id="misfire_allSharpSlowdownCount" type="text" class="form-control" value="6"></span>
<span><label>急转弯总次数:</label><input style="width:80px;" id="misfire_allSharpTurn" type="text" class="form-control" value="4"></span>
</div>
<div style="margin-top:10px;width:100%;border-width:1px;border-style:solid;border-color:darkgray;border-radius:10px;padding:2px;_background:skyblue;">
<h5><b>低档高速报警:</b></h5>
<span><label>报警属性:</label>
<select id="alarmType_1" class="form-control" style="width:120px;">
<option value="1">报警触发</option>
<option value="0">报警结束</option>
</select>
</span>
<span><label>持续时间(秒):</label><input style="width:80px;" id="durationTime_1" type="text" class="form-control" value="6"></span>
</div>
<div style="margin-top:10px;width:100%;border-width:1px;border-style:solid;border-color:darkgray;border-radius:10px;padding:2px;_background:skyblue;">
<h5><b>高档低速报警:</b></h5>
<span><label>报警属性:</label>
<select id="alarmType_2" class="form-control" style="width:120px;">
<option value="1">报警触发</option>
<option value="0">报警结束</option>
</select>
</span>
<span><label>持续时间(秒):</label><input style="width:80px;" id="durationTime_2" type="text" class="form-control" value="6"></span>
</div>
<div style="margin-top:10px;width:100%;border-width:1px;border-style:solid;border-color:darkgray;border-radius:10px;padding:2px;_background:skyblue;">
<h5><b>剩余油量异常告警附:</b></h5>
<span><label>剩余油量单位:</label>
<select id="surplusOilType" class="form-control" style="width:120px;">
<option value="1">升(L)</option>
<option value="0">百分比(%)</option>
</select>
</span>
<span><label>异常值:</label><input style="width:80px;" id="surplusOil_value" type="text" class="form-control" value="6"></span>
</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="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>
//发送电瓶采样数据包
$("#sendMsgBtn").click(function(){
var data = getData();
var host = window.location.host;
$("#showFeedback").val("");
$.ajax({
url:"http://" + host + "/protocolTools/protocolReport_process/porcessEventMsg",
type:"post",
data:JSON.stringify(data),
contentType:"application/json",
dataType:"json",
success:function(data){
if(data.status == 200){
//window.location.reload()
msg = "发送消息:" + data.msgSend + "\n"
msg = msg + "收到消息:" + data.result + "\n"
msg = msg + "收到消息16进制:" + data.rev + "\n"
msg = msg + "收到消息解析结果:" + JSON.stringify(data.orgRev) + "\n"
$("#showFeedback").val(msg)
}else{
$("#showFeedback").val(data.message);
alert(data.message);
}
}
});
});
//获取GPS数据
function getGPSData(){
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 isLocationValid = parseInt($("#isLocationValid").val());
var locationMode = parseInt($("#isLocationValid").val());
var locationType = parseInt($("#locationType").val());
var staticMileageMode = parseInt($("#staticMileageMode").val());
var fireStatus = parseInt($("#fireStatus").val());
var statusBit = isLocationValid + locationMode + locationType + staticMileageMode + fireStatus
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["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;
return data;
}
//获取安防数据
function getSecurityData(){
var accStatus = parseInt($("#accStatus").val());
var defenseStatus = parseInt($("#defenseStatus").val());
var brakeStatus = parseInt($("#brakeStatus").val());
var acceleratorStatus = parseInt($("#acceleratorStatus").val());
var handBrakeStatus = parseInt($("#handBrakeStatus").val());
var mainSafetyBelt = parseInt($("#mainSafetyBelt").val());
var subSafetyBelt = parseInt($("#subSafetyBelt").val());
var securityStatus = accStatus + defenseStatus + brakeStatus + acceleratorStatus + handBrakeStatus + mainSafetyBelt + subSafetyBelt
var lfDoorStatus = parseInt($("#lfDoorStatus").val());
var rfDoorStatus = parseInt($("#rfDoorStatus").val());
var lbDoorStatus = parseInt($("#lbDoorStatus").val());
var rbDoorStatus = parseInt($("#rbDoorStatus").val());
var trunk = parseInt($("#trunk").val());
var enginCover = parseInt($("#enginCover").val());
var doorStatus = lfDoorStatus + rfDoorStatus + lbDoorStatus + rbDoorStatus + trunk + enginCover
var lfDoorLockStatus = parseInt($("#lfDoorLockStatus").val());
var rfDoorLockStatus = parseInt($("#rfDoorLockStatus").val());
var lbDoorLockStatus = parseInt($("#lbDoorLockStatus").val());
var rbDoorLockStatus = parseInt($("#rbDoorLockStatus").val());
var lockStatus = lfDoorLockStatus + rfDoorLockStatus + lbDoorLockStatus + rbDoorLockStatus
var lfWindowStatus = parseInt($("#lfWindowStatus").val());
var rfWindowStatus = parseInt($("#rfWindowStatus").val());
var lbWindowStatus = parseInt($("#lbWindowStatus").val());
var rbWindowStatus = parseInt($("#rbWindowStatus").val());
var topWindowStatus = parseInt($("#topWindowStatus").val());
var lTurnLight = parseInt($("#lTurnLight").val());
var rTurnLight = parseInt($("#rTurnLight").val());
var readLight = parseInt($("#readLight").val());
var windowStatus = lfWindowStatus + rfWindowStatus + lbWindowStatus + rbWindowStatus + topWindowStatus + lTurnLight + rTurnLight + readLight
var lowHeadlight = parseInt($("#lowHeadlight").val());
var highHeadlight = parseInt($("#highHeadlight").val());
var ffogLight = parseInt($("#ffogLight").val());
var bfogLight = parseInt($("#bfogLight").val());
var dangerLight = parseInt($("#dangerLight").val());
var backCarLight = parseInt($("#backCarLight").val());
var autoLight = parseInt($("#autoLight").val());
var widthLight = parseInt($("#widthLight").val());
var lightStatus = lowHeadlight + highHeadlight + ffogLight + bfogLight + dangerLight + backCarLight + autoLight + widthLight
var machineOilWarning = parseInt($("#machineOilWarning").val());
var oilWarning = parseInt($("#oilWarning").val());
var wiperWarning = parseInt($("#wiperWarning").val());
var loudsspeakerWaring = parseInt($("#loudsspeakerWaring").val());
var airConditionerWaring = parseInt($("#airConditionerWaring").val());
var backMirrorWaring = parseInt($("#backMirrorWaring").val());
var onoffStatusA = machineOilWarning + oilWarning + wiperWarning + loudsspeakerWaring + airConditionerWaring + backMirrorWaring + backMirrorWaring
var gears = parseInt($("#gears").val());
var onoffStatusB = gears
var V1N1 = parseInt($("#V1N1").val());
var busTotalMileage = parseInt($("#busTotalMileage").val());
var meterData = parseInt($("#meterData").val());
var engineSpeed = parseInt($("#security_engineSpeed").val());
var speed = parseInt($("#security_speed").val());
var surplusOil = parseInt($("#surplusOil").val());
var dataByte = V1N1 + busTotalMileage + meterData + engineSpeed + speed + surplusOil
var data = {};
data["securityStatus"] = securityStatus
data["doorStatus"] = doorStatus
data["lockStatus"] = lockStatus
data["windowStatus"] = windowStatus
data["lightStatus"] = lightStatus
data["onoffStatusA"] = onoffStatusA
data["onoffStatusB"] = onoffStatusB
data["dataByte"] = dataByte
return data
}
//获取页面数据
function getData(){
var WATER_CODE = $("#WATER_CODE").val();
var DEV_ID = $("#DEV_ID").val();
var data = {};
data["WATER_CODE"] = WATER_CODE;
data["DEV_ID"] = DEV_ID;
data["gpsInfo"] = getGPSData();
data["securityData"] = getSecurityData()
data["event"] = {};
if($("#0003").is(':checked')){
data["event"]["0003"] = {}; //汽车电瓶低电压报警
}
if($("#0004").is(':checked')){
data["event"]["0004"] = {}; //终端主电断电报警
}
if($("#0010").is(':checked')){
data["event"]["0010"] = get0010(); //获取点火事件数据
}
if($("#0011").is(':checked')){
data["event"]["0011"] = get0011(); //获取熄火事件数据
}
if($("#0012").is(':checked')){
data["event"]["0012"] = get0012(); //获取设防事件数据
}
if($("#0013").is(':checked')){
data["event"]["0013"] = get0013(); //获取撤防事件数据
}
if($("#0036").is(':checked')){
data["event"]["0036"] = get0036(); //低档高速报警
}
if($("#0037").is(':checked')){
data["event"]["0037"] = get0037(); //高档低速报警
}
if($("#004A").is(':checked')){
data["event"]["004A"] = get004A(); //剩余油量异常告警
}
return data;
}
function get0010(){ //获取点火事件数据
data = {};
data["allRapidlyAccelerateCount"] = $("#fire_allRapidlyAccelerateCount").val();
data["allSharpSlowdownCount"] = $("#fire_allSharpSlowdownCount").val();
data["allSharpTurn"] = $("#fire_allSharpTurn").val();
return data;
}
function get0011(){ //获取熄火事件数据
data = {};
data["allRapidlyAccelerateCount"] = $("#misfire_allRapidlyAccelerateCount").val();
data["allSharpSlowdownCount"] = $("#misfire_allSharpSlowdownCount").val();
data["allSharpTurn"] = $("#misfire_allSharpTurn").val();
return data;
}
function get0012(){ //获取设防事件数据
return {};
}
function get0013(){ //获取撤防事件数据
return {};
}
function get0036(){ //低档高速报警
data = {};
data["alarmType"] = $("#alarmType_1").val();
data["durationTime"] = $("#durationTime_1").val();
return data;
}
function get0037(){ //高档低速报警
data = {};
data["alarmType"] = $("#alarmType_2").val();
data["durationTime"] = $("#durationTime_2").val();
return data;
}
function get004A(){ //剩余油量异常告警
return {};
}
//gps区域的隐藏与显示
function isShowGspArea(e){
var val = $(e).val()
if(val == "0"){
$("#gps_area").css("display","none")
}else{
$("#gps_area").css("display","block")
}
}
//安防数据的隐藏于显示
function isShowSecurityArea(e){
var val = $(e).val()
if(val == "0"){
$("#security_area").css("display","none")
}else{
$("#security_area").css("display","block")
}
}
//事件多选按钮的处理事项
function eventSelect(){
}
//设置当前时间到UTC时间输入框
(function(){
var curTime = getCurTime();
$("#UTCTime").val(curTime);
})();
//设置当前时间戳到GPS信息时间戳输入框
(function(){
var curTimestamp = getCutTimestamp();
$("#GPSTimestamp").val(curTimestamp);
})();
</script>
{% endblock %}
\ No newline at end of file
......@@ -7,7 +7,7 @@
<label>消息流水号:</label><input id="WATER_CODE" type="text" class="form-control" value="0003" style="width:100px;">
<label style="margin-left:10px;">车机号:</label><input id="DEV_ID" type="text" class="form-control" value="M121501010001">
</div>
<H3 style="border-bottom: 1px solid #eee;">设置心跳消息内容:</H3>
<H3 style="border-bottom: 1px solid #eee;">设置电压上报消息内容:</H3>
<ul class="protocol_content" style="padding:0px;">
<li style="width:170px"><label>采样个数:</label><input style="width:80px;" id="sampleNums" type="text" class="form-control" value="2"></li>
<li><label style="font-size:10px;">采样开始时间:</label><input id="curTime" type="text" class="form-control" value=""></li>
......
#coding:utf-8
import os
from time import sleep
from flask import Blueprint ,Response,request,send_from_directory
from configparser import ConfigParser
import json
import traceback
M_simulater_process = Blueprint('M_simulater_process', __name__)
connects = [] #用来保存连接的信息
##########################################
# 【接口类型】设置socket信息
##########################################
@M_simulater_process.route("/porcessSocketSetting",methods=['POST'])
def porcessSocketSetting():
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/protocolTools/carSimulater.conf")
conf_W = conf_R
conf_W["socket"]["host"] = host
conf_W["socket"]["port"] = port
with open("config/protocolTools/carSimulater.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')
\ No newline at end of file
#coding:utf-8
from flask import Blueprint, render_template ,request
import re
M_simulater_view = Blueprint('M_simulater_view', __name__)
##########################################
# 【视图类型】访问模拟器页面
##########################################
@M_simulater_view.route('/M_simulater_page')
def M_simulater_page():
#获取请求的路劲
url = request.url
reqPath = re.findall("http://(.*)$",url)[0]
reqPath = re.findall("/(.*)$", reqPath)[0]
arg = {}
path = "messageTools/message/M_simulater_page.html"
arg["path"] = reqPath.split("/")
return render_template(path,arg=arg)
##########################################
# 【视图类型】访问模拟器设置页面
##########################################
@M_simulater_view.route('/M_simulaterSetting_page')
def M_simulaterSetting_page():
#获取请求的路劲
url = request.url
reqPath = re.findall("http://(.*)$",url)[0]
reqPath = re.findall("/(.*)$", reqPath)[0]
arg = {}
path = "messageTools/message/M_simulaterSetting_page.html"
arg["path"] = reqPath.split("/")
return render_template(path,arg=arg)
\ No newline at end of file
......@@ -3,6 +3,7 @@
from flask import Blueprint ,Response,request
from configparser import ConfigParser
from lib.protocol.report.EventReport_protocol import EventReport_protocol
from lib.protocol.report.HeartBeatReport_protocol import HeartBeatReport_protocol
from lib.protocol.report.LoginReport_protocol import LoginReport_protocol
from lib.protocol.report.GPSReport_protocol import GPSReport_protocol
......@@ -175,7 +176,6 @@ def porcessGPSMsg():
return Response(json.dumps(data), mimetype='application/json')
else:
try:
# cliSocket = ClientSocket("183.230.194.65",8712)
# d读取config文件
conf_R = ConfigParser()
conf_R.read("config/protocolTools/protocolTools.conf")
......@@ -375,7 +375,42 @@ def porcessVoltageDataMsg():
data["message"] = "Error: 处理失败!"
return Response(json.dumps(data), mimetype='application/json')
##########################################
# 【接口类型】处理发送的事件报文
##########################################
@protocolReport_process.route("/porcessEventMsg",methods=['POST'])
def porcessEventMsg():
params = request.get_data()
params = json.loads(params.decode("utf-8"))
data = {}
if (hasJsonDataIsNone(params)):
data["status"] = "4003"
data["message"] = "Info: 请检查是否传入了空数据!"
return Response(json.dumps(data), mimetype='application/json')
else:
try:
conf_R = ConfigParser()
conf_R.read("config/protocolTools/protocolTools.conf")
cliSocket = ClientSocket(conf_R.get("socket", "host"),conf_R.getint("socket", "port"))
cliSocket.connect()
protocolObj = EventReport_protocol(data=params)
msg = protocolObj.generateEventMsg()
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"] = data["orgRev"] = json.loads(Common_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')
......
......@@ -94,7 +94,7 @@ def securityStatus_protocol_page():
##########################################
# 【视图类型】访问终端上报安防状态协议报文发送页面
# 【视图类型】访问终端上报电瓶电压协议报文发送页面
##########################################
@protocolReport_view.route('/voltageData_protocol_page')
def voltageData_protocol_page():
......@@ -106,3 +106,18 @@ def voltageData_protocol_page():
path = "protocolTools/report/voltageData_protocol_page.html"
arg["path"] = reqPath.split("/")
return render_template(path,arg=arg)
##########################################
# 【视图类型】访问终端上报事件协议报文发送页面
##########################################
@protocolReport_view.route('/event_protocol_page')
def event_protocol_page():
#获取请求的路劲
url = request.url
reqPath = re.findall("http://(.*)$",url)[0]
reqPath = re.findall("/(.*)$", reqPath)[0]
arg = {}
path = "protocolTools/report/event_protocol_page.html"
arg["path"] = reqPath.split("/")
return render_template(path,arg=arg)
\ No newline at end of file
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