Commit f8bf25bc authored by liyuanhong's avatar liyuanhong

完成了M500模拟器设防、撤防、抵挡高速、高档低速、剩余油量异常事件发送

parent 683cb800
......@@ -327,6 +327,7 @@ if __name__ == "__main__":
# print(MessageBase().generateMsg())
print(MessageBase().GBKString2Hex("渝B23CX"))
print(MessageBase().hex2GBKString("d3e54232334358"))
print(MessageBase().hex2GBKString("4c323030414230313032303030312c737a6c696e6779692e716963702e7669702c383838392c537a4c696e6759692c7a373254713246742c4c3230304142303130322e303030312e42494e2c2f2c"))
# print(MessageBase().int2BCD(123456789012345,10))
# print(MessageBase().getRandomNum(3000,5000,[2,4,6,8,10,12],4))
# print(MessageBase().getRandomStr(10))
......
......@@ -7,8 +7,12 @@ from lib.protocol.message.MessageBase import MessageBase
class TerminalCommonMsgRes_msg(MessageBase):
def __init__(self):
def __init__(self,resId="0002",phoneNum=13146201119,resWaterCode="0001",sn=1):
super().__init__() #不执行该方法,无法使用父类里面定义的属性
self.resId = resId
self.phoneNum = phoneNum
self.resWaterCode = resWaterCode
self.sn = sn
pass
#######################################################
......@@ -30,8 +34,8 @@ class TerminalCommonMsgRes_msg(MessageBase):
# 获取消息体
#######################################################
def getMsgBody(self):
resWaterCode = "0001" #对应的平台消息的流水号
msgId = "0001" #消息id,对应的平台消息的 ID
resWaterCode = self.resWaterCode #对应的平台消息的流水号
msgId = self.resId #消息id,对应的平台消息的 ID
reslult = self.int2hexStringByBytes(0) #0:成功/确认;1:失败;2:消息有误;3:不支持
data = ""
msg = data + resWaterCode + msgId + reslult
......@@ -41,10 +45,11 @@ class TerminalCommonMsgRes_msg(MessageBase):
# 获取消息头
#######################################################
def getMsgHeader(self):
msgID = self.int2hexStringByBytes(102,2) #消息id
# msgID = self.int2hexStringByBytes(102,2) #消息id
msgID = "0001" #消息id
msgBodyProperty = self.getMsgBodyProperty(int(len(self.getMsgBody()) / 2)) #消息体属性
phoneNum = self.int2BCD(13146201119) #终端手机号
msgWaterCode = self.int2hexStringByBytes(1,2) #消息流水号
phoneNum = self.int2BCD(int(self.phoneNum)) #终端手机号
msgWaterCode = self.int2hexStringByBytes(self.sn,2) #消息流水号
subPkgContent = "" #消息包封装项
data = msgID + msgBodyProperty + phoneNum + msgWaterCode + subPkgContent
return data
......
......@@ -89,7 +89,7 @@ class MessageSimulaterDataService():
self.data["time"]["dateTime"] = data
self.writeToFile(self.path + self.fileName,self.data)
#设今日日期
def setData2file(self,data):
def setDate2file(self,data):
self.data["time"]["date"] = data
self.writeToFile(self.path + self.fileName,self.data)
#设今日时间
......@@ -131,7 +131,7 @@ class MessageSimulaterDataService():
self.setTodayTodayTotalOil(0)
self.setTodayTodayTotalTime(0)
self.setDateTime2file(dateTimeM)
self.setData2file(dateM)
self.setDate2file(dateM)
self.setTime2file(timeM)
self.data = conJson
......
......@@ -13,6 +13,7 @@ import traceback
from time import sleep
from lib.protocol.message.Location_msg import Location_msg
from lib.protocol.message.TerminalCommonMsgRes_msg import TerminalCommonMsgRes_msg
from lib.protocol.message.TerminalRegister_msg import TerminalRegister_msg
from lib.protocol.message.TerminalVersionInfo_msg import TerminalVersionInfo_msg
from lib.socket.service.MessageSimulaterDataService import MessageSimulaterDataService
......@@ -156,7 +157,7 @@ class MessageSimulaterService():
self.carDataObj.setTodayTodayTotalOil(0)
self.carDataObj.setTodayTodayTotalTime(0)
self.carDataObj.setDateTime2file(dateTimeM)
self.carDataObj.setData2file(dateM)
self.carDataObj.setDate2file(dateM)
self.carDataObj.setTime2file(timeM)
self.OBDdata["extraInfo"]["01"]["extra_01"] = conJson["travelData"]["totalMilleage"]
self.OBDdataOri["extraInfo"]["01"]["extra_01"] = conJson["travelData"]["totalMilleage"]
......@@ -459,27 +460,16 @@ class MessageSimulaterService():
#收到 某些类型的消息后执行回复操作
########################################################
def doResponse(self,msg):
# TODO 收到 某些类型的消息后执行回复操作
pass
# msgFunId = self.getMsgFunId(msg)
# if msgFunId == "8205":
# msg = Common_response(resId="8205").generateCommonMsg()
# self.sendMsg(msg)
# self.sn = self.sn + 1
# type = self.getMsgFunId(msg)
# self.websocket.send(type + ">>>>设置GPSR通信参数应答:" + msg)
# elif msgFunId == "8206":
# msg = Common_response(resId="8206").generateCommonMsg()
# self.sendMsg(msg)
# self.sn = self.sn + 1
# type = self.getMsgFunId(msg)
# self.websocket.send(type + ">>>>设置车辆OBD适配信息应答:" + msg)
# elif msgFunId == "8300":
# msg = Update_response().generateUpdateMsg()
# self.sendMsg(msg)
# self.sn = self.sn + 1
# type = self.getMsgFunId(msg)
# self.websocket.send(type + ">>>>升级_平台通知终端远程升级应答:" + msg)
msgFunId = self.getMsgFunId(msg)
resWaterCode = msg[22:26]
if msgFunId == "8105":
msg = TerminalCommonMsgRes_msg(resId="8105",phoneNum=self.carId,resWaterCode=resWaterCode,sn=self.sn).generateMsg()
self.sendMsg(msg)
self.sn = self.sn + 1
type = self.getMsgFunId(msg)
self.websocket.send(type + ">>>>终端控制消息应答:" + msg)
elif msgFunId == "8206":
pass
#设置GPS轨迹
......
......@@ -124,23 +124,28 @@
</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="lowVoltage_check" onclick="eventSelect(this)"/>汽车电瓶低电压报警 </label>
<label style="padding: 0px 10px;"><input type="checkbox" id="powerOff_check" 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="sharpSlowdownEvent_check" onclick="eventSelect(this)"/>急减速 </label>
<label style="padding: 0px 10px;"><input type="checkbox" id="sharpTurnEvent_check" 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>
<label style="padding: 0px 10px;"><input type="checkbox" id="lowVoltage_check" onclick="eventSelect(this)" checked />汽车电瓶低电压报警 </label>
<label style="padding: 0px 10px;"><input type="checkbox" id="powerOff_check" onclick="eventSelect(this)" checked />终端主电断电报警 </label>
<label style="padding: 0px 10px;"><input type="checkbox" id="rapidlyAccelerateEvent_check" onclick="eventSelect(this)" checked />急加速 </label>
<label style="padding: 0px 10px;"><input type="checkbox" id="sharpSlowdownEvent_check" onclick="eventSelect(this)" checked />急减速 </label>
<label style="padding: 0px 10px;"><input type="checkbox" id="sharpTurnEvent_check" onclick="eventSelect(this)" checked />急转弯 </label>
<label style="padding: 0px 10px;"><input type="checkbox" id="setUpDefencesEvent_check" onclick="eventSelect(this)" checked />设防 </label>
<label style="padding: 0px 10px;"><input type="checkbox" id="setDownDefencesEvent_check" onclick="eventSelect(this)" checked />撤防 </label>
<label style="padding: 0px 10px;"><input type="checkbox" id="lowGearHighSpeed_check" onclick="eventSelect(this)" checked />低档高速报警 </label>
<label style="padding: 0px 10px;"><input type="checkbox" id="highGearLowSpeed_check" onclick="eventSelect(this)" checked />高档低速报警 </label>
<label style="padding: 0px 10px;"><input type="checkbox" id="surplusOil_check" onclick="eventSelect(this)" checked />剩余油量异常告警 </label>
</div>
<div style="padding:10px;">
<span id="lowVoltage_button" style="display:none;"><button type="button" class="btn btn-primary" onclick="sendLowVoltageEvent(this)">汽车电瓶低电压报警</button></label></span>
<span id="powerOff_button" style="display:none;"><button type="button" class="btn btn-primary" onclick="sendPowerOffEvent(this)">终端主电断电报警</button></label></span>
<span id="rapidlyAccelerateEvent_button" style="display:none;"><button type="button" class="btn btn-primary" onclick="sendRapidlyAccelerateEvent(this)">急加速</button></label></span>
<span id="sharpSlowdownEvent_button" style="display:none;"><button type="button" class="btn btn-primary" onclick="sendSharpSlowdownEvent(this)">急减速</button></label></span>
<span id="sharpTurnEvent_button" style="display:none;"><button type="button" class="btn btn-primary" onclick="sendSharpTurnEvent(this)">急转弯</button></label></span>
<span id="lowVoltage_button" style="display:inline;"><button type="button" class="btn btn-primary" onclick="sendLowVoltageEvent(this)">汽车电瓶低电压报警</button></label></span>
<span id="powerOff_button" style="display:inline;"><button type="button" class="btn btn-primary" onclick="sendPowerOffEvent(this)">终端主电断电报警</button></label></span>
<span id="rapidlyAccelerateEvent_button" style="display:inline;"><button type="button" class="btn btn-primary" onclick="sendRapidlyAccelerateEvent(this)">急加速</button></label></span>
<span id="sharpSlowdownEvent_button" style="display:inline;"><button type="button" class="btn btn-primary" onclick="sendSharpSlowdownEvent(this)">急减速</button></label></span>
<span id="sharpTurnEvent_button" style="display:inline;"><button type="button" class="btn btn-primary" onclick="sendSharpTurnEvent(this)">急转弯</button></label></span>
<span id="setUpDefencesEvent_button" style="display:inline;"><button type="button" class="btn btn-primary" onclick="sendSetUpDefencesEvent(this)">设防</button></label></span>
<span id="setDownDefencesEvent_button" style="display:inline;"><button type="button" class="btn btn-primary" onclick="sendSetDownDefencesEvent(this)">撤防</button></label></span>
<span id="lowGearHighSpeed_button" style="display:inline;"><button type="button" class="btn btn-primary" onclick="sendLowGearHighSpeedEvent(this)">低挡高速</button></label></span>
<span id="highGearLowSpeed_button" style="display:inline;"><button type="button" class="btn btn-primary" onclick="sendHighGearLowSpeedEvent(this)">高档低速</button></label></span>
<span id="surplusOil_button" style="display:inline;"><button type="button" class="btn btn-primary" onclick="sendSurplusOilAlarmEvent(this)">剩余油量异常</button></label></span>
</div>
</div>
</div>
......@@ -644,6 +649,16 @@ function eventSelect(e){
$("#sharpSlowdownEvent_button").css("display","inline")
}else if($(e).attr("id") == "sharpTurnEvent_check"){
$("#sharpTurnEvent_button").css("display","inline")
}else if($(e).attr("id") == "setUpDefencesEvent_check"){
$("#setUpDefencesEvent_button").css("display","inline")
}else if($(e).attr("id") == "setDownDefencesEvent_check"){
$("#setDownDefencesEvent_button").css("display","inline")
}else if($(e).attr("id") == "lowGearHighSpeed_check"){
$("#lowGearHighSpeed_button").css("display","inline")
}else if($(e).attr("id") == "highGearLowSpeed_check"){
$("#highGearLowSpeed_button").css("display","inline")
}else if($(e).attr("id") == "surplusOil_check"){
$("#surplusOil_button").css("display","inline")
}
}else{
if($(e).attr("id") == "lowVoltage_check"){
......@@ -656,6 +671,16 @@ function eventSelect(e){
$("#sharpSlowdownEvent_button").css("display","none")
}else if($(e).attr("id") == "sharpTurnEvent_check"){
$("#sharpTurnEvent_button").css("display","none")
}else if($(e).attr("id") == "setUpDefencesEvent_check"){
$("#setUpDefencesEvent_button").css("display","none")
}else if($(e).attr("id") == "setDownDefencesEvent_check"){
$("#setDownDefencesEvent_button").css("display","none")
}else if($(e).attr("id") == "lowGearHighSpeed_check"){
$("#lowGearHighSpeed_button").css("display","none")
}else if($(e).attr("id") == "highGearLowSpeed_check"){
$("#highGearLowSpeed_button").css("display","none")
}else if($(e).attr("id") == "surplusOil_check"){
$("#surplusOil_button").css("display","none")
}
}
}
......@@ -689,6 +714,36 @@ function sendSharpTurnEvent(){
url = "/protocolTools/M_carSimulater_process/sendSharpTurnEvent";
sendjson(data,url);
}
//发送设防事件消息
function sendSetUpDefencesEvent(){
var data = getPageData()
url = "/protocolTools/M_carSimulater_process/sendSetUpDefencesEvent";
sendjson(data,url);
}
//发送撤防事件消息
function sendSetDownDefencesEvent(){
var data = getPageData()
url = "/protocolTools/M_carSimulater_process/sendSetDownDefencesEvent";
sendjson(data,url);
}
//发送低档高速报警事件消息
function sendLowGearHighSpeedEvent(){
var data = getPageData()
url = "/protocolTools/M_carSimulater_process/sendLowGearHighSpeedEvent";
sendjson(data,url);
}
//发送高档低速报警事件消息
function sendHighGearLowSpeedEvent(){
var data = getPageData()
url = "/protocolTools/M_carSimulater_process/sendHighGearLowSpeedEvent";
sendjson(data,url);
}
//发送剩余油量异常告警事件消息
function sendSurplusOilAlarmEvent(){
var data = getPageData()
url = "/protocolTools/M_carSimulater_process/sendSurplusOilAlarmEvent";
sendjson(data,url);
}
</script>
{% endblock %}
......
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