Commit 395c00fa authored by liyuanhong's avatar liyuanhong

修改了M500事件 图形界面发消息失败问题

parent 3001f34d
......@@ -17,6 +17,28 @@ class EventClass(ProtocolBase):
def setSecurityData(self,data):
self.securityData = data
# 0001 终端插入报警附带信息
def terminalInsertionAlarmExtraInfo(self,theTime=""):
if theTime != "":
return self.getUTCTimeHex(theTime)
else:
return self.getUTCTimeHex(datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'))
# 0002 终端拔出报警附带信息
def terminalPulloutAlarmExtraInfo(self,theTime=""):
if theTime != "":
return self.getUTCTimeHex(theTime)
else:
return self.getUTCTimeHex(datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'))
# 000F 预点火事件附带信息
def preFiringExtraInfo(self):
bit0 = 1 #1:有点火电压波形,0:无点火电压波形
bit1 = 2 #2:有电压和噪声点火,0:无电压和噪声点火
bit2 = 4 #3:有gps车速和噪声点火,0:无gps车速和噪声点火
data = bit0 + bit1 + bit2
return self.int2hexString(data)
# 0010 点火事件附带信息
def fireExtraInfo(self):
allRapidlyAccelerateCount = self.int2hexStringByBytes(15, 2) # 急加速总次数
......@@ -95,7 +117,23 @@ class EventClass(ProtocolBase):
securityData = SecurityStatusReport_protocol.generateSecurityStatusData() # 安防数据
return securityData
#12 急加速报警附带信息
#0019 SOS报警事件附加信息
def SOSAlarmEtraInfo(self,theTime):
if theTime != "":
return self.getUTCTimeHex(theTime)
else:
return self.getUTCTimeHex(datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'))
#001A 001B 充电事件附带信息
def chargeEtraInfo(self):
SOC = self.int2hexString(0.3 * 100) #乘以100上传,平台除以100处理(显示小于1的小数值)
SOH = self.int2hexString(4 * 100) #乘以100上传,平台除以100处理
voltage = self.int2hexStringByBytes(3.6 * 10,2) #乘以10上传,平台除以10处理
chargeEventCode = self.int2hexString(3) #充电开始报警,和后续的充电结束报警为同一编号
data = SOC + SOH + voltage + chargeEventCode
return data
# 0020 急加速报警附带信息
def rapidlyAccelerateExtraInfo(self):
totalRapidlyAccelerateCount = 100 #急加速总次数
totalSharpSlowdown = 200 #急减速总次数
......@@ -111,7 +149,7 @@ class EventClass(ProtocolBase):
data = totalRapidlyAccelerateCount + totalSharpSlowdown + totalSharpTurn + dataProperty + GPSSampleData + CANSampleData + SENSORSampleData
return data
#13 急减速报警附带信息
# 0021 急减速报警附带信息
def sharpSlowdownExtraInfo(self):
totalRapidlyAccelerateCount = 100 #急加速总次数
totalSharpSlowdown = 200 #急减速总次数
......@@ -127,7 +165,7 @@ class EventClass(ProtocolBase):
data = totalRapidlyAccelerateCount + totalSharpSlowdown + totalSharpTurn + dataProperty + GPSSampleData + CANSampleData + SENSORSampleData
return data
#14 急转弯报警附带信息
# 0022 急转弯报警附带信息
def sharpTurnExtraInfo(self):
totalRapidlyAccelerateCount = 100 #急加速总次数
totalSharpSlowdown = 200 #急减速总次数
......@@ -143,7 +181,7 @@ class EventClass(ProtocolBase):
data = totalRapidlyAccelerateCount + totalSharpSlowdown + totalSharpTurn + dataProperty + GPSSampleData + CANSampleData + SENSORSampleData
return data
#15 碰撞报警附带信息
#0023 碰撞报警附带信息
def collisionAlarmExtraInfo(self):
totalCount = self.int2hexStringByBytes(7,2) #历史碰撞总次数
# 1:表示事件发生时刻,前10秒的事件采样数据;
......@@ -157,7 +195,6 @@ class EventClass(ProtocolBase):
data = totalCount + dataProperty + extraInfo
return data
#16 碰撞报警前后10秒采样数据附带信息
def collisionSamplingData(self):
GPSSampleData = self.GPSDataFromSeconds(10) #GPS 采样点 ,N秒内的GPS采样数据,170个字节
......@@ -176,7 +213,6 @@ class EventClass(ProtocolBase):
return data
#23 GPS采样数据项
def GPSSamplingData(self):
latitude = 40.22077 #纬度
......@@ -232,52 +268,15 @@ class EventClass(ProtocolBase):
data += self.int2hexStringByBytes(30,2) #第1秒内的第1个0.5秒内的平均加速度值
return data
#30 终端插入报警附带信息
def terminalInsertionAlarmExtraInfo(self,theTime=""):
if theTime != "":
return self.getUTCTimeHex(theTime)
else:
return self.getUTCTimeHex(datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'))
#36 预点火事件附带信息
def preFiringExtraInfo(self):
bit0 = 1 #1:有点火电压波形,0:无点火电压波形
bit1 = 2 #2:有电压和噪声点火,0:无电压和噪声点火
bit2 = 4 #3:有gps车速和噪声点火,0:无gps车速和噪声点火
data = bit0 + bit1 + bit2
return self.int2hexString(data)
#39 SOS报警事件附加信息
def SOSAlarmEtraInfo(self,theTime):
if theTime != "":
return self.getUTCTimeHex(theTime)
else:
return self.getUTCTimeHex(datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'))
#41 充电事件附带信息
def chargeEtraInfo(self):
SOC = self.int2hexString(0.3 * 100) #乘以100上传,平台除以100处理(显示小于1的小数值)
SOH = self.int2hexString(4 * 100) #乘以100上传,平台除以100处理
voltage = self.int2hexStringByBytes(3.6 * 10,2) #乘以10上传,平台除以10处理
chargeEventCode = self.int2hexString(3) #充电开始报警,和后续的充电结束报警为同一编号
data = SOC + SOH + voltage + chargeEventCode
return data
#45 终端拔出报警附带信息
def terminalPulloutAlarmExtraInfo(self,theTime=""):
if theTime != "":
return self.getUTCTimeHex(theTime)
else:
return self.getUTCTimeHex(datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'))
#50 低档高速报警附
# 0036 低档高速报警附
def lowGearHighSpeedAlarm(self,alarmType=1,durationTime=10):
alarmTypeHex = self.int2hexStringByBytes(alarmType)
durationTimeHex = self.int2hexStringByBytes(durationTime,2)
data = alarmTypeHex + durationTimeHex
return data
#51 高档低速报警附带信息
# 0037 高档低速报警附带信息
def highGearLowSpeedAlarm(self,alarmType=1,durationTime=10):
alarmTypeHex = self.int2hexStringByBytes(alarmType)
durationTimeHex = self.int2hexStringByBytes(durationTime,2)
......@@ -291,7 +290,7 @@ class EventClass(ProtocolBase):
data += self.int2hexStringByBytes(self.num2signedNum(-50),2) #第1秒内侧倾角[-90, 90],大于0右倾,小于0左倾
return data
#69 剩余油量异常告警附带信息
#004A 剩余油量异常告警附带信息
def surplusOilAlarm(self,surplusOilType=0,value=30):
surplusOilTypeHex = self.int2hexStringByBytes(surplusOilType)
valueHex = self.int2hexStringByBytes(value,2)
......
#encoding:utf-8
'''
定义终端心跳消息
定义平台升级数据包应答消息
'''
from lib.protocol.message.MessageBase import MessageBase
......@@ -96,5 +96,4 @@ class PlateformUpdateRes_msg(MessageBase):
if __name__ == "__main__":
print(TerminalHeartbeat_msg().generateMsg())
print(TerminalHeartbeat_msg().getMsgBodyProperty())
\ No newline at end of file
pass
\ No newline at end of file
......@@ -85,7 +85,9 @@ class EventReport_protocol(ProtocolBase):
for i in range(0,self.msgCount):
data += self.generateEventPkg(self.msgCount,self.generateEventData())
else:
data += self.generateEventData_GUI()
for i in range(0,self.msgCount):
data += self.generateEventPkg(self.msgCount,self.generateEventData_GUI())
# data += self.generateEventData_GUI()
# 消息长度
LENGTH = self.getMsgLength(int(len(WATER_CODE + DEV_ID + FUN_ID + data)/2))
......@@ -206,58 +208,47 @@ class EventReport_protocol(ProtocolBase):
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"]))
theData = eventObj.lowGearHighSpeedAlarm(int(eventData["0037"]["alarmType"]),int(eventData["0037"]["durationTime"]))
data = data + "0037" + self.int2hexStringByBytes(int((len(theData) / 2)), 2) + theData
if ("004A" in eventData.keys()): #高档低速报警
dataNums = dataNums + 1
eventObj = EventClass()
theData = eventObj.surplusOilAlarm(int(eventData["004A"]["surplusOilType"]),int(eventData["004A"]["value"]))
data = data + "004A" + self.int2hexStringByBytes(int((len(theData) / 2)), 2) + theData
dataNumsHex = self.int2hexString(int(dataNums))
data = dataNumsHex +data
return data
......
......@@ -130,9 +130,9 @@ class MessageSimulaterService():
############################# 读取车机的数据 ############################
content = fi.read()
conJson = json.loads(content)
conJson["curDayTravel"]["theMilleage"] = 0 # 今日行驶总里程
conJson["curDayTravel"]["theOil"] = 0 # 今日行驶总油耗
conJson["curDayTravel"]["theTime"] = 0 # 今日行驶总时间
conJson["curDayTravel"]["theMilleage"] = 0 # 本次行驶总里程
conJson["curDayTravel"]["theOil"] = 0 # 本次行驶总油耗
conJson["curDayTravel"]["theTime"] = 0 # 本次行驶总时间
timeStamp = time.time()
timeArray = time.localtime(timeStamp)
dateTimeM = time.strftime("%Y-%m-%d %H:%M:%S", timeArray)
......
......@@ -58,12 +58,20 @@ class ProtocolSimulaterService():
def setWebsocketId(self):
sleep(1)
self.websocketId = self.websocket.getCurrentClientId()
def getWebsocket(self):
return self.websocket
def setWebsocket(self,data):
self.websocket = data
def getWebsocket(self):
return self.websocket
def getGpsLineIndex(self):
return self.gpsLineIndex
def getGpsLine(self):
return self.gpsLine
def getTravelStatus(self):
return self.travelStatus
def sendMsg(self,msg):
self.socket.setTimeOut(self.timeout)
self.socket.send(msg)
......@@ -274,9 +282,9 @@ class ProtocolSimulaterService():
with open("data/protocolTools/carData/" + self.carId + ".json", "r", encoding="utf-8") as fi:
content = fi.read()
conJson = json.loads(content)
conJson["curDayTravel"]["theMilleage"] = 0 # 今日行驶总里程
conJson["curDayTravel"]["theOil"] = 0 # 今日行驶总油耗
conJson["curDayTravel"]["theTime"] = 0 # 今日行驶总时间
conJson["curDayTravel"]["theMilleage"] = 0 # 本次行驶总里程
conJson["curDayTravel"]["theOil"] = 0 # 本次行驶总油耗
conJson["curDayTravel"]["theTime"] = 0 # 本次行驶总时间
timeStamp = time.time()
timeArray = time.localtime(timeStamp)
dateTimeM = time.strftime("%Y-%m-%d %H:%M:%S", timeArray)
......
......@@ -14,6 +14,8 @@ function messageManTab(e){
$(location).attr('href', "http://" + window.location.host + "/messageTools/message_view/dataUpstreamTransport_msg_page");
}else if(id == "location_msg"){
$(location).attr('href', "http://" + window.location.host + "/messageTools/message_view/location_msg_page");
}else if(id == "userDefined_msg"){
$(location).attr('href', "http://" + window.location.host + "/messageTools/message_view/userDefined_msg_page");
}else{
alert(id)
}
......
......@@ -32,6 +32,7 @@
<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="userDefined_msg" {% if arg.path[2]=="userDefined_msg_page" %} class="link-tab" {% endif %} onclick="messageManTab(this)">自定义消息</b></a></li>
<li role="presentation"><a id="terminalHeartBeat_msg" {% if arg.path[2]=="heartBeat_msg_page" %} class="link-tab" {% endif %} onclick="messageManTab(this)">心跳消息</b></a></li>
<li role="presentation"><a id="terminalRegister_msg" {% if arg.path[2]=="terminalRegister_msg_page" %} class="link-tab" {% endif %} onclick="messageManTab(this)">终端注册</b></a></li>
<li role="presentation"><a id="terminalVersionInfoUpload_msg" {% if arg.path[2]=="terminalVersionInfoUpload_msg_page" %} class="link-tab" {% endif %} onclick="messageManTab(this)">终端版本信息上报</b></a></li>
......
{% extends "messageTools/message/heartBeat_msg_page.html" %}
{% block title %}terminalRegister_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;">
<div>
<span>
<label>超时时间(秒):</label><input id="timeout" type="text" class="form-control" style="width:100px;" value="1">
</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="4"></textarea>
</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="6"></textarea>
</div>
</div>
<script>
//发送GPS数据
$("#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("")
$.ajax({
url:"http://" + host + "/messageTools/message_process/porcessUserdefinedMsg",
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
......@@ -115,8 +115,7 @@
<span style="margin-left:20px;"><label>当前状态:</label><input id="curStatus" value="断网" disabled="disabled" class="form-control" style="font-weight: bold;width:85px;color:red;border-width: 1px; border-style: solid; border-color: darkgray; border-radius: 10px;"></span>
<span style="width:80px;padding-left:10px;"><label style="width:70px"><input type="checkbox" id="ignition" onclick="isLogShow(this)"/>隐藏日志</label> </span>
</div>
<!--
<div style="display: block; width: 100%; border-width: 1px; border-style: solid; border-color: darkgray; border-radius: 10px; padding: 2px; margin-top: 5px;">
<!--<div style="display: block; width: 100%; border-width: 1px; border-style: solid; border-color: darkgray; border-radius: 10px; padding: 2px; margin-top: 5px;">
<h5><b>事件发送:</b>
<span style="border-width:1px;border-style:solid;border-color:darkgray;border-radius:10px;padding:1px 10px;">
<label><input name="eventshow" type="radio" value="0" checked="checked" onclick="isShowEventArea(this)"/>隐藏</label>
......@@ -125,7 +124,7 @@
</h5>
<div id="event_area" style="display:none;">
<div style="margin-top:10px;width:100%;border-width:1px;border-style:solid;border-color:darkgray;border-radius:10px;padding:2px;background:skyblue;">
<label style="padding: 0px 10px;"><input type="checkbox" id="aaa" onclick="eventSelect(this)"/>急加速 </label>
<label style="padding: 0px 10px;"><input type="checkbox" id="rapidlyAccelerateEvent_check" onclick="eventSelect(this)"/>急加速 </label>
<label style="padding: 0px 10px;"><input type="checkbox" id="bbb" onclick="eventSelect(this)"/>急减速 </label>
<label style="padding: 0px 10px;"><input type="checkbox" id="ccc" onclick="eventSelect(this)"/>急转弯 </label>
<label style="padding: 0px 10px;"><input type="checkbox" id="0003" onclick="eventSelect(this)"/>汽车电瓶低电压报警 </label>
......@@ -136,10 +135,9 @@
<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;">
<span><label>我的id:</label><input disabled=disabled type="text" id="c" class="form-control" style="display:inline;width:200px;" value=""/></span>
<div style="padding:10px;">
<span id="rapidlyAccelerateEvent_button" style="display:none;"><button id="a" type="button" class="btn btn-primary" onclick="sendRapidlyAccelerateEvent(this)">急加速</button></label></span>
<span><label>在线人数:</label><input disabled=disabled type="text" id="b" class="form-control" style="display:inline;width:80px;" value="1"/></span>
<button id="a" type="button" class="btn btn-primary" onclick="getAllUsers(this)">刷新</button></label>
</div>
</div>
</div>
......@@ -151,12 +149,9 @@
</span>
</h5>
<div id="realTimeCtl_area" style="display:none;">
<span><label>我的id:</label><input disabled=disabled type="text" id="c2" class="form-control" style="display:inline;width:200px;" value=""/></span>
<span><label>在线人数:</label><input disabled=disabled type="text" id="b2" class="form-control" style="display:inline;width:80px;" value="1"/></span>
<button id="a2" type="button" class="btn btn-primary" onclick="getAllUsers(this)">刷新</button></label>
实时控制
</div>
</div>
-->
</div> -->
<div style="width:100%;padding-bottom:60px;border-bottom: 1px solid #eee;">
<h3>日志:</h3>
<textarea id="showFeedback" style="width:100%;padding:5px;padding-bottom:60px;" rows="10"></textarea>
......@@ -633,6 +628,25 @@ function isShowEventArea(e){
}
}
//事件的选择与取消选择
function eventSelect(e){
if($(e).is(':checked')){
if($(e).attr("id") == "rapidlyAccelerateEvent_check"){
$("#rapidlyAccelerateEvent_button").css("display","inline")
}
}else{
if($(e).attr("id") == "rapidlyAccelerateEvent_check"){
$("#rapidlyAccelerateEvent_button").css("display","none")
}
}
}
//发送急加速事件消息
function sendRapidlyAccelerateEvent(){
var data = getPageData()
url = "/protocolTools/M_carSimulater_process/sendRapidlyAccelerateEvent";
sendjson(data,url);
}
</script>
{% endblock %}
......
......@@ -266,27 +266,27 @@
<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>
<option value="0">不存在</option>
</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>
<option value="0">不存在</option>
</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>
<option value="0">不存在</option>
</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>
<option value="0">不存在</option>
</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>
<option value="0">不存在</option>
</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>
<option value="0">不存在</option>
</select></li>
</ul>
</div>
......@@ -299,6 +299,11 @@
<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="0020" onclick="eventSelect(this)"/>急加速 </label>-->
<!-- <label style="padding: 0px 10px;"><input type="checkbox" id="0021" onclick="eventSelect(this)"/>急减速 </label>-->
<!-- <label style="padding: 0px 10px;"><input type="checkbox" id="0022" 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>
......@@ -315,6 +320,36 @@
<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 id="0020_area" style="display:none;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="RA_allRapidlyAccelerateCount" type="text" class="form-control" value="5"></span>
<span><label>急减速总次数:</label><input style="width:80px;" id="RA_allSharpSlowdownCount" type="text" class="form-control" value="6"></span>
<span><label>急转弯总次数:</label><input style="width:80px;" id="RA_allSharpTurn" type="text" class="form-control" value="4"></span>
<span><label>数据属性:</label><select style="width:200px;" id="RA_dataProperty" class="form-control">
<option value="1">前10秒的事件采样数据</option>
<option value="2">后10秒的事件采样数据</option>
</select></span>
</div>
<div id="0021_area" style="display:none;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="SS_allRapidlyAccelerateCount" type="text" class="form-control" value="5"></span>
<span><label>急减速总次数:</label><input style="width:80px;" id="SS_allSharpSlowdownCount" type="text" class="form-control" value="6"></span>
<span><label>急转弯总次数:</label><input style="width:80px;" id="SS_allSharpTurn" type="text" class="form-control" value="4"></span>
<span><label>数据属性:</label><select style="width:200px;" id="SS_dataProperty" class="form-control">
<option value="1">前10秒的事件采样数据</option>
<option value="2">后10秒的事件采样数据</option>
</select></span>
</div>
<div id="0022_area" style="display:none;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="ST_allRapidlyAccelerateCount" type="text" class="form-control" value="5"></span>
<span><label>急减速总次数:</label><input style="width:80px;" id="ST_allSharpSlowdownCount" type="text" class="form-control" value="6"></span>
<span><label>急转弯总次数:</label><input style="width:80px;" id="ST_allSharpTurn" type="text" class="form-control" value="4"></span>
<span><label>数据属性:</label><select style="width:200px;" id="ST_dataProperty" class="form-control">
<option value="1">前10秒的事件采样数据</option>
<option value="2">后10秒的事件采样数据</option>
</select></span>
</div>
<div id="0036_area" style="display:none;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>
......@@ -534,6 +569,17 @@ function getData(){
if($("#0013").is(':checked')){
data["event"]["0013"] = get0013(); //获取撤防事件数据
}
if($("#0020").is(':checked')){
data["event"]["0020"] = get0020(); //获取急加速事件数据
}
if($("#0021").is(':checked')){
data["event"]["0021"] = get0021(); //获取急减速事件数据
}
if($("#0022").is(':checked')){
data["event"]["0022"] = get0022(); //获取急转弯事件数据
}
if($("#0036").is(':checked')){
data["event"]["0036"] = get0036(); //低档高速报警
}
......@@ -566,6 +612,30 @@ function get0012(){ //获取设防事
function get0013(){ //获取撤防事件数据
return {};
}
function get0020(){ //获取急加速事件数据
data = {}
data["allRapidlyAccelerateCount"] = $("#RA_allRapidlyAccelerateCount").val();
data["allSharpSlowdownCount"] = $("#RA_allSharpSlowdownCount").val();
data["allSharpTurn"] = $("#RA_allSharpTurn").val();
data["dataProperty"] = $("#RA_dataProperty").val();
return data
}
function get0021(){ //获取急减速事件数据
data = {}
data["allRapidlyAccelerateCount"] = $("#RA_allRapidlyAccelerateCount").val();
data["allSharpSlowdownCount"] = $("#RA_allSharpSlowdownCount").val();
data["allSharpTurn"] = $("#RA_allSharpTurn").val();
data["dataProperty"] = $("#RA_dataProperty").val();
return data
}
function get0022(){ //获取急转弯事件数据
data = {}
data["allRapidlyAccelerateCount"] = $("#RA_allRapidlyAccelerateCount").val();
data["allSharpSlowdownCount"] = $("#RA_allSharpSlowdownCount").val();
data["allSharpTurn"] = $("#RA_allSharpTurn").val();
data["dataProperty"] = $("#RA_dataProperty").val();
return data
}
function get0036(){ //低档高速报警
data = {};
data["alarmType"] = $("#alarmType_1").val();
......@@ -610,6 +680,12 @@ function eventSelect(e){
$("#0010_area").css("display","block")
}else if($(e).attr("id") == "0011"){
$("#0011_area").css("display","block")
}else if($(e).attr("id") == "0020"){
$("#0020_area").css("display","block")
}else if($(e).attr("id") == "0021"){
$("#0021_area").css("display","block")
}else if($(e).attr("id") == "0022"){
$("#0022_area").css("display","block")
}else if($(e).attr("id") == "0036"){
$("#0036_area").css("display","block")
}else if($(e).attr("id") == "0037"){
......@@ -622,6 +698,12 @@ function eventSelect(e){
$("#0010_area").css("display","none")
}else if($(e).attr("id") == "0011"){
$("#0011_area").css("display","none")
}else if($(e).attr("id") == "0020"){
$("#0020_area").css("display","none")
}else if($(e).attr("id") == "0021"){
$("#0021_area").css("display","none")
}else if($(e).attr("id") == "0022"){
$("#0022_area").css("display","none")
}else if($(e).attr("id") == "0036"){
$("#0036_area").css("display","none")
}else if($(e).attr("id") == "0037"){
......
......@@ -21,6 +21,45 @@ from lib.util.jsonUtil import hasJsonDataIsNone
message_process = Blueprint('message_process', __name__)
##########################################
# 【接口类型】处理发送的自定义报文
##########################################
@message_process.route("/porcessUserdefinedMsg",methods=['POST'])
def porcessUserdefinedMsg():
msg = request.form.get("msg")
timeout = int(request.form.get("timeout"))
data = {}
if (msg == 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()
cliSocket.send(msg)
cliSocket.setTimeOut(timeout)
cliSocket.send(msg)
socRecv_1 = cliSocket.receive()
socRecv_2 = str(socRecv_1)
cliSocket.close()
data["status"] = "200"
data["message"] = "Sucess: "
data["original"] = msg
data["result"] = socRecv_2
msgP = PlatformCommon_res(socRecv_1)
data["resultH"] = msgP.getOriginalMsg()
data["parse"] = json.loads(msgP.getMsg())
except BaseException as e:
# 打印异常信息
traceback.print_exc()
data["status"] = "4003"
data["message"] = "Error: 处理失败!"
return Response(json.dumps(data), mimetype='application/json')
##########################################
# 【接口类型】处理发送的心跳消息
##########################################
......
......@@ -19,6 +19,20 @@ def heartBeat_msg_page():
arg["path"] = reqPath.split("/")
return render_template(path,arg=arg)
##########################################
# 【视图类型】访问用户自定义消息发送页面
##########################################
@message_view.route('/userDefined_msg_page')
def userDefined_msg_page():
#获取请求的路劲
url = request.url
reqPath = re.findall("http://(.*)$",url)[0]
reqPath = re.findall("/(.*)$", reqPath)[0]
arg = {}
path = "messageTools/message/userDefined_msg_page.html"
arg["path"] = reqPath.split("/")
return render_template(path,arg=arg)
##########################################
# 【视图类型】访问终端注册消息发送页面
##########################################
......
......@@ -4,6 +4,8 @@ from time import sleep
from flask import Blueprint ,Response,request,send_from_directory
from configparser import ConfigParser
from lib.protocol.report.EventReport_protocol import EventReport_protocol
from lib.protocol.report.LoginReport_protocol import LoginReport_protocol
from lib.protocol.report.VersionReport_protocol import VersionReport_protocol
from lib.socket.ClientSocket import ClientSocket
......@@ -381,3 +383,32 @@ def getConnects():
data["message"] = "Error: 获取在线人数失败失败!"
return Response(json.dumps(data), mimetype='application/json')
#--------------------------------------- 发送事件逻辑 ---------------------------------------
@M_carSimulater_process.route("/sendRapidlyAccelerateEvent",methods=['POST'])
def sendRapidlyAccelerateEvent():
params = request.get_data()
params = json.loads(params.decode("utf-8"))
sessionId = params["session"]["sessionId"]
data = {}
if not sessionId in connects.keys():
data["status"] = "4003"
data["message"] = "Error: 未启动服务,不可发送急加速事件!"
return Response(json.dumps(data), mimetype='application/json')
service = connects[sessionId]["service"]
travelStatus = service.getTravelStatus() #获取汽车行驶状态
if travelStatus == 0 or travelStatus == 2:
data["status"] = "4003"
data["message"] = "Error: 汽车还未行驶,不可发送急加速事件!"
elif travelStatus == 2:
try:
obj = EventReport_protocol()
msg = obj.generateEventMsg()
data["status"] = "200"
data["message"] = "发送急加速事件成功!"
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
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