Commit 0939bd4a authored by liyuanhong's avatar liyuanhong

车安优模拟器完成急左转弯和急右转弯事件开发

parent cc9ab483
{"time": {"dateTime": "2020-05-28 14:37:12", "date": "2020-05-28", "time": "14:37:12"}, "curDayTravel": {"todayTotalMilleage": 17121, "todayTotalOil": 1719, "todayTotalTime": 1016, "theMilleage": 4687, "theOil": 407, "theTime": 198}, "travelData": {"totalMilleage": 23629, "totalOil": 2227, "totalTime": 1416}} {"time": {"dateTime": "2020-06-01 11:23:40", "date": "2020-06-01", "time": "11:23:40"}, "curDayTravel": {"todayTotalMilleage": 1472, "todayTotalOil": 92, "todayTotalTime": 92, "theMilleage": 656, "theOil": 41, "theTime": 41}, "travelData": {"totalMilleage": 25101, "totalOil": 2319, "totalTime": 1508}}
\ No newline at end of file \ No newline at end of file
...@@ -45,9 +45,10 @@ class AlarmEvent_data(MessageBase): ...@@ -45,9 +45,10 @@ class AlarmEvent_data(MessageBase):
illegalFire = "0110" + self.int2hexStringByBytes(0) #非法点火 illegalFire = "0110" + self.int2hexStringByBytes(0) #非法点火
rapidAccelerateAlarm = "0111" + self.int2hexStringByBytes(0) #急加速报警 rapidAccelerateAlarm = "0111" + self.int2hexStringByBytes(0) #急加速报警
sharpSlowdownAlarm = "0112" + self.int2hexStringByBytes(0) #急减速报警 sharpSlowdownAlarm = "0112" + self.int2hexStringByBytes(0) #急减速报警
sharpBendAlarm = "0113" + self.int2hexStringByBytes(0) #急拐弯报警 sharpBendAlarm = "0113" + self.int2hexStringByBytes(0) #急拐弯报警
crashAlarm = "0114" + self.int2hexStringByBytes(0) #碰撞报警 crashAlarm = "0114" + self.int2hexStringByBytes(0) #碰撞报警
rapidChangeLines = "0115" + self.int2hexStringByBytes(0) #急变道报警 rapidChangeLines = "0115" + self.int2hexStringByBytes(0) #急变道报警
sharpRightBendAlarm = "0117" + self.int2hexStringByBytes(0) #急右拐弯报警
data = ignition data = ignition
...@@ -141,7 +142,7 @@ class AlarmEvent_data(MessageBase): ...@@ -141,7 +142,7 @@ class AlarmEvent_data(MessageBase):
sharpSlowdownAlarm = "0112" + self.int2hexStringByBytes(0) #急减速报警 sharpSlowdownAlarm = "0112" + self.int2hexStringByBytes(0) #急减速报警
dataHex = dataHex + sharpSlowdownAlarm dataHex = dataHex + sharpSlowdownAlarm
if ("sharpBendAlarm" in data.keys()): if ("sharpBendAlarm" in data.keys()):
sharpBendAlarm = "0113" + self.int2hexStringByBytes(0) #急拐弯报警 sharpBendAlarm = "0113" + self.int2hexStringByBytes(0) #急拐弯报警
dataHex = dataHex + sharpBendAlarm dataHex = dataHex + sharpBendAlarm
if ("crashAlarm" in data.keys()): if ("crashAlarm" in data.keys()):
crashAlarm = "0114" + self.int2hexStringByBytes(0) #碰撞报警 crashAlarm = "0114" + self.int2hexStringByBytes(0) #碰撞报警
...@@ -149,6 +150,9 @@ class AlarmEvent_data(MessageBase): ...@@ -149,6 +150,9 @@ class AlarmEvent_data(MessageBase):
if ("rapidChangeLines" in data.keys()): if ("rapidChangeLines" in data.keys()):
rapidChangeLines = "0115" + self.int2hexStringByBytes(0) #急变道报警 rapidChangeLines = "0115" + self.int2hexStringByBytes(0) #急变道报警
dataHex = dataHex + rapidChangeLines dataHex = dataHex + rapidChangeLines
if ("sharpRightBendAlarm" in data.keys()):
sharpBendAlarm = "0117" + self.int2hexStringByBytes(0) #急右拐弯报警
dataHex = dataHex + sharpBendAlarm
return dataHex return dataHex
# 创建报警事件数据,数据随机产生 # 创建报警事件数据,数据随机产生
...@@ -183,9 +187,10 @@ class AlarmEvent_data(MessageBase): ...@@ -183,9 +187,10 @@ class AlarmEvent_data(MessageBase):
illegalFire = "0110" + self.int2hexStringByBytes(0) #非法点火 illegalFire = "0110" + self.int2hexStringByBytes(0) #非法点火
rapidAccelerateAlarm = "0111" + self.int2hexStringByBytes(0) #急加速报警 rapidAccelerateAlarm = "0111" + self.int2hexStringByBytes(0) #急加速报警
sharpSlowdownAlarm = "0112" + self.int2hexStringByBytes(0) #急减速报警 sharpSlowdownAlarm = "0112" + self.int2hexStringByBytes(0) #急减速报警
sharpBendAlarm = "0113" + self.int2hexStringByBytes(0) #急拐弯报警 sharpBendAlarm = "0113" + self.int2hexStringByBytes(0) #急拐弯报警
crashAlarm = "0114" + self.int2hexStringByBytes(0) #碰撞报警 crashAlarm = "0114" + self.int2hexStringByBytes(0) #碰撞报警
rapidChangeLines = "0115" + self.int2hexStringByBytes(0) #急变道报警 rapidChangeLines = "0115" + self.int2hexStringByBytes(0) #急变道报警
sharpRightBendAlarm = "0117" + self.int2hexStringByBytes(0) #急右拐弯报警
arr = [] arr = []
arr.append(ignition) arr.append(ignition)
...@@ -216,7 +221,8 @@ class AlarmEvent_data(MessageBase): ...@@ -216,7 +221,8 @@ class AlarmEvent_data(MessageBase):
arr.append(sharpBendAlarm) arr.append(sharpBendAlarm)
arr.append(crashAlarm) arr.append(crashAlarm)
arr.append(rapidChangeLines) arr.append(rapidChangeLines)
mult = self.getRandomNum(0, 28) arr.append(sharpRightBendAlarm)
mult = self.getRandomNum(0, 29)
temp = [] temp = []
for i in range(0, mult): for i in range(0, mult):
con = self.getRandomNum(intArr=arr, mult=1) con = self.getRandomNum(intArr=arr, mult=1)
......
...@@ -138,7 +138,8 @@ ...@@ -138,7 +138,8 @@
<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="lowVoltage_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="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="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="sharpTurnEvent_check" onclick="eventSelect(this)" checked />急左转弯 </label>
<label style="padding: 0px 10px;"><input type="checkbox" id="sharpRightTurnEvent_check" onclick="eventSelect(this)" checked />急右转弯 </label>
<!-- <label style="padding: 0px 10px;"><input type="checkbox" id="collisionAlarmEvent_check" onclick="eventSelect(this)" checked />碰撞报警 </label>--> <!-- <label style="padding: 0px 10px;"><input type="checkbox" id="collisionAlarmEvent_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="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="setDownDefencesEvent_check" onclick="eventSelect(this)" checked />撤防 </label>-->
...@@ -148,7 +149,8 @@ ...@@ -148,7 +149,8 @@
<span id="lowVoltage_button" style="display:inline;"><button type="button" class="btn btn-primary" onclick="sendLowVoltageEvent(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="rapidlyAccelerateEvent_button" style="display:inline;"><button type="button" class="btn btn-primary" onclick="sendRapidlyAccelerateEvent(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="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="sharpTurnEvent_button" style="display:inline;"><button type="button" class="btn btn-primary" onclick="sendSharpTurnEvent(this)">急左转弯</button></label></span>
<span id="sharpRightTurnEvent_button" style="display:inline;"><button type="button" class="btn btn-primary" onclick="sendRightSharpTurnEvent(this)">急右转弯</button></label></span>
<!-- <span id="collisionAlarmEvent_button" style="display:inline;"><button type="button" class="btn btn-primary" onclick="sendCollisionAlarmEvent(this)">碰撞报警</button></label></span>--> <!-- <span id="collisionAlarmEvent_button" style="display:inline;"><button type="button" class="btn btn-primary" onclick="sendCollisionAlarmEvent(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="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="setDownDefencesEvent_button" style="display:inline;"><button type="button" class="btn btn-primary" onclick="sendSetDownDefencesEvent(this)">撤防</button></label></span>-->
...@@ -724,6 +726,21 @@ function sendSharpSlowdownEvent(){ ...@@ -724,6 +726,21 @@ function sendSharpSlowdownEvent(){
var url = "http://" + host + "/messageTools/M_simulater_process/sendSharpSlowdownAlarm"; var url = "http://" + host + "/messageTools/M_simulater_process/sendSharpSlowdownAlarm";
sendHttpMsg(data,url); sendHttpMsg(data,url);
} }
//发送急左转弯事件消息
function sendSharpTurnEvent(){
var data = getPageData();
var host = window.location.host;
var url = "http://" + host + "/messageTools/M_simulater_process/sendSharpTurnEvent";
sendHttpMsg(data,url);
}
//发送急右转弯事件消息
function sendRightSharpTurnEvent(){
var data = getPageData();
var host = window.location.host;
var url = "http://" + host + "/messageTools/M_simulater_process/sendRightSharpTurnEvent";
sendHttpMsg(data,url);
}
// -------------------------------- 实时控制js代码------------------------------------------- // -------------------------------- 实时控制js代码-------------------------------------------
//设置隐藏或显示实时控制区域 //设置隐藏或显示实时控制区域
......
...@@ -546,6 +546,106 @@ def sendSharpSlowdownAlarm(): ...@@ -546,6 +546,106 @@ def sendSharpSlowdownAlarm():
data["message"] = "Error: 发送急减速事件失败!" data["message"] = "Error: 发送急减速事件失败!"
return Response(json.dumps(data), mimetype='application/json') return Response(json.dumps(data), mimetype='application/json')
##########################################
# 【接口类型】发送急左转弯事件
##########################################
@M_simulater_process.route("/sendSharpTurnEvent",methods=['POST'])
def sendSharpTurnEvent():
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 == 1:
try:
jdata = {"msgID": "0200", "phoneNum": "13146201119", "msgWaterCode": "1", "encryptionType": "0",
"subPkg": "0",
"pkgCounts": "0",
"baseInfo": {"alarmFlag": 0, "status": 262402, "latitude": 29.40268, "longtitude": 106.54041,
"elevation": "521", "speed": "66", "directionAngle": "59",
"infoTime": "2020-05-28 14:20:04"},
"extraInfo": {"FA": {"sharpBendAlarm": "on"}}}
timeStamp = time.time()
timeArray = time.localtime(timeStamp)
curTime = time.strftime("%Y-%m-%d %H:%M:%S", timeArray)
jdata["phoneNum"] = params["phoneNum"]
jdata["msgWaterCode"] = service.getSn()
jdata["baseInfo"]["infoTime"] = curTime
jdata["baseInfo"]["latitude"] = service.getCurLatitude()
jdata["baseInfo"]["longtitude"] = service.getCurLongtitude()
jdata["baseInfo"]["directionAngle"] = service.getDirAngle()
msgObj = Location_msg()
msg = msgObj.generateMsg_GUI(jdata)
service.serviceSendMsg(msg)
service.setSn(service.getSn() + 1)
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')
##########################################
# 【接口类型】发送急右转弯事件
##########################################
@M_simulater_process.route("/sendRightSharpTurnEvent",methods=['POST'])
def sendRightSharpTurnEvent():
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 == 1:
try:
jdata = {"msgID": "0200", "phoneNum": "13146201119", "msgWaterCode": "1", "encryptionType": "0",
"subPkg": "0",
"pkgCounts": "0",
"baseInfo": {"alarmFlag": 0, "status": 262402, "latitude": 29.40268, "longtitude": 106.54041,
"elevation": "521", "speed": "66", "directionAngle": "59",
"infoTime": "2020-05-28 14:20:04"},
"extraInfo": {"FA": {"sharpRightBendAlarm": "on"}}}
timeStamp = time.time()
timeArray = time.localtime(timeStamp)
curTime = time.strftime("%Y-%m-%d %H:%M:%S", timeArray)
jdata["phoneNum"] = params["phoneNum"]
jdata["msgWaterCode"] = service.getSn()
jdata["baseInfo"]["infoTime"] = curTime
jdata["baseInfo"]["latitude"] = service.getCurLatitude()
jdata["baseInfo"]["longtitude"] = service.getCurLongtitude()
jdata["baseInfo"]["directionAngle"] = service.getDirAngle()
msgObj = Location_msg()
msg = msgObj.generateMsg_GUI(jdata)
service.serviceSendMsg(msg)
service.setSn(service.getSn() + 1)
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')
#--------------------------------------- 实时控制逻辑 --------------------------------------- #--------------------------------------- 实时控制逻辑 ---------------------------------------
########################################## ##########################################
# 【接口类型】改变车速 # 【接口类型】改变车速
......
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