Commit 62c059fa authored by liyuanhong's avatar liyuanhong

车安优模拟器增加了终端拔出报警、怠速过长报警、超速报警、疲劳驾驶、碰撞告警、水温报警、高速空挡滑行事件

parent 46d2a6ac
{"time": {"dateTime": "2020-07-09 11:30:36", "date": "2020-07-09", "time": "11:30:36"}, "curDayTravel": {"todayTotalMilleage": 3091, "todayTotalOil": 196, "todayTotalTime": 193, "theMilleage": 3091, "theOil": 196, "theTime": 193}, "travelData": {"totalMilleage": 111811, "totalOil": 10109, "totalTime": 6851}} {"time": {"dateTime": "2020-07-13 14:17:20", "date": "2020-07-13", "time": "14:17:20"}, "curDayTravel": {"todayTotalMilleage": 166, "todayTotalOil": 16, "todayTotalTime": 10, "theMilleage": 166, "theOil": 16, "theTime": 10}, "travelData": {"totalMilleage": 111977, "totalOil": 10125, "totalTime": 6861}}
\ No newline at end of file \ No newline at end of file
{"time": {"dateTime": "2020-07-10 10:37:16", "date": "2020-07-10", "time": "10:37:16"}, "curDayTravel": {"todayTotalMilleage": 10669, "todayTotalOil": 799, "todayTotalTime": 658, "theMilleage": 1987, "theOil": 127, "theTime": 124}, "travelData": {"totalMilleage": 575093, "totalOil": 52193, "totalTime": 34516}, "event": {"threeRapid": {"totalRapidlyAccelerate": 43, "totalSharpSlowdown": 31, "totalSharpTurn": 34}}} {"time": {"dateTime": "2020-07-10 10:37:16", "date": "2020-07-10", "time": "10:37:16"}, "curDayTravel": {"todayTotalMilleage": 17293, "todayTotalOil": 1213, "todayTotalTime": 1072, "theMilleage": 1952, "theOil": 122, "theTime": 122}, "travelData": {"totalMilleage": 581717, "totalOil": 52607, "totalTime": 34930}, "event": {"threeRapid": {"totalRapidlyAccelerate": 43, "totalSharpSlowdown": 31, "totalSharpTurn": 34}}}
\ No newline at end of file \ No newline at end of file
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
display:block; display:block;
content:" "; content:" ";
} }
.protocol_content li { .protocol_content li {
width:250px; width:250px;
_background:yellow; _background:yellow;
...@@ -23,11 +22,14 @@ ...@@ -23,11 +22,14 @@
margin-top:5px; margin-top:5px;
float:left; float:left;
} }
.protocol_content label{ .protocol_content label{
width:90px; width:90px;
text-align:right; text-align:right;
} }
h1,h2,h3,h4,h5 {
margin-top: 5px;
margin-bottom: 5px;
}
</style> </style>
<div id="container2" style="width:83%;min-height:750px;float:left;_background:grey;margin-top:50px;"> <div id="container2" style="width:83%;min-height:750px;float:left;_background:grey;margin-top:50px;">
{% block content_02 %} {% block content_02 %}
...@@ -135,25 +137,33 @@ ...@@ -135,25 +137,33 @@
<div id="event_area" style="display:none;"> <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;"> <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="insertAlarm_check" onclick="eventSelect(this)" checked />终端插入报警 </label> <label style="padding: 0px 10px;"><input type="checkbox" id="insertAlarm_check" onclick="eventSelect(this)" checked />终端插入报警 </label>
<label style="padding: 0px 10px;"><input type="checkbox" id="pullOutAlarm_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="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="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="idlingSpeedOver_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="overspeed_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="fatigueDriving_check" onclick="eventSelect(this)" checked />疲劳驾驶 </label>
<label style="padding: 0px 10px;"><input type="checkbox" id="waterTemperatureAlarm_check" onclick="eventSelect(this)" checked />水温报警 </label>
<label style="padding: 0px 10px;"><input type="checkbox" id="highSpeedNeutralGear_check" onclick="eventSelect(this)" checked />高速空挡滑行 </label>
<label style="padding: 0px 10px;"><input type="checkbox" id="crashAlarm_check" onclick="eventSelect(this)" checked />碰撞告警 </label>
</div> </div>
<div style="padding:10px;"> <div style="padding:10px;">
<span id="insertAlarm_button" style="display:inline;"><button type="button" class="btn btn-primary" onclick="sendInsertAlarmEvent(this)">终端插入报警</button></label></span> <span id="insertAlarm_button" style="display:inline;"><button type="button" class="btn btn-primary" onclick="sendInsertAlarmEvent(this)">终端插入报警</button></label></span>
<span id="pullOutAlarm_button" style="display:inline;"><button type="button" class="btn btn-primary" onclick="sendpullOutAlarmEvent(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="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="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="idlingSpeedOver_button" style="display:inline;"><button type="button" class="btn btn-primary" onclick="sendIdlingSpeedOverEvent(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="overspeed_button" style="display:inline;"><button type="button" class="btn btn-primary" onclick="sendOverspeedEvent(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="fatigueDriving_button" style="display:inline;"><button type="button" class="btn btn-primary" onclick="sendFatigueDrivingEvent(this)">疲劳驾驶</button></label></span>
<span id="waterTemperatureAlarm_button" style="display:inline;"><button type="button" class="btn btn-primary" onclick="sendWaterTemperatureAlarmEvent(this)">水温报警</button></label></span>
<span id="highSpeedNeutralGear_button" style="display:inline;"><button type="button" class="btn btn-primary" onclick="sendHighSpeedNeutralGearEvent(this)">高速空挡滑行</button></label></span>
<span id="crashAlarm_button" style="display:inline;"><button type="button" class="btn btn-primary" onclick="sendCrashAlarmEvent(this)">碰撞告警</button></label></span>
</div> </div>
</div> </div>
</div> </div>
...@@ -663,6 +673,8 @@ function eventSelect(e){ ...@@ -663,6 +673,8 @@ function eventSelect(e){
if($(e).is(':checked')){ if($(e).is(':checked')){
if($(e).attr("id") == "insertAlarm_check"){ if($(e).attr("id") == "insertAlarm_check"){
$("#insertAlarm_button").css("display","inline") $("#insertAlarm_button").css("display","inline")
}else if($(e).attr("id") == "pullOutAlarm_check"){
$("#pullOutAlarm_button").css("display","inline")
}else if($(e).attr("id") == "lowVoltage_check"){ }else if($(e).attr("id") == "lowVoltage_check"){
$("#lowVoltage_button").css("display","inline") $("#lowVoltage_button").css("display","inline")
}else if($(e).attr("id") == "rapidlyAccelerateEvent_check"){ }else if($(e).attr("id") == "rapidlyAccelerateEvent_check"){
...@@ -677,10 +689,24 @@ function eventSelect(e){ ...@@ -677,10 +689,24 @@ function eventSelect(e){
$("#setUpDefencesEvent_button").css("display","inline") $("#setUpDefencesEvent_button").css("display","inline")
}else if($(e).attr("id") == "setDownDefencesEvent_check"){ }else if($(e).attr("id") == "setDownDefencesEvent_check"){
$("#setDownDefencesEvent_button").css("display","inline") $("#setDownDefencesEvent_button").css("display","inline")
}else if($(e).attr("id") == "idlingSpeedOver_check"){
$("#idlingSpeedOver_button").css("display","inline")
}else if($(e).attr("id") == "overspeed_check"){
$("#overspeed_button").css("display","inline")
}else if($(e).attr("id") == "fatigueDriving_check"){
$("#fatigueDriving_button").css("display","inline")
}else if($(e).attr("id") == "waterTemperatureAlarm_check"){
$("#waterTemperatureAlarm_button").css("display","inline")
}else if($(e).attr("id") == "highSpeedNeutralGear_check"){
$("#highSpeedNeutralGear_button").css("display","inline")
}else if($(e).attr("id") == "crashAlarm_check"){
$("#crashAlarm_button").css("display","inline")
} }
}else{ }else{
if($(e).attr("id") == "insertAlarm_check"){ if($(e).attr("id") == "insertAlarm_check"){
$("#insertAlarm_button").css("display","none") $("#insertAlarm_button").css("display","none")
}else if($(e).attr("id") == "pullOutAlarm_check"){
$("#pullOutAlarm_button").css("display","none")
}else if($(e).attr("id") == "lowVoltage_check"){ }else if($(e).attr("id") == "lowVoltage_check"){
$("#lowVoltage_button").css("display","none") $("#lowVoltage_button").css("display","none")
}else if($(e).attr("id") == "rapidlyAccelerateEvent_check"){ }else if($(e).attr("id") == "rapidlyAccelerateEvent_check"){
...@@ -695,6 +721,18 @@ function eventSelect(e){ ...@@ -695,6 +721,18 @@ function eventSelect(e){
$("#setUpDefencesEvent_button").css("display","none") $("#setUpDefencesEvent_button").css("display","none")
}else if($(e).attr("id") == "setDownDefencesEvent_check"){ }else if($(e).attr("id") == "setDownDefencesEvent_check"){
$("#setDownDefencesEvent_button").css("display","none") $("#setDownDefencesEvent_button").css("display","none")
}else if($(e).attr("id") == "idlingSpeedOver_check"){
$("#idlingSpeedOver_button").css("display","none")
}else if($(e).attr("id") == "overspeed_check"){
$("#overspeed_button").css("display","none")
}else if($(e).attr("id") == "fatigueDriving_check"){
$("#fatigueDriving_button").css("display","none")
}else if($(e).attr("id") == "waterTemperatureAlarm_check"){
$("#waterTemperatureAlarm_button").css("display","none")
}else if($(e).attr("id") == "highSpeedNeutralGear_check"){
$("#highSpeedNeutralGear_button").css("display","none")
}else if($(e).attr("id") == "crashAlarm_check"){
$("#crashAlarm_button").css("display","none")
} }
} }
} }
...@@ -706,6 +744,13 @@ function sendInsertAlarmEvent(){ ...@@ -706,6 +744,13 @@ function sendInsertAlarmEvent(){
var url = "http://" + host + "/messageTools/M_simulater_process/sendTerminalInsertAlarm"; var url = "http://" + host + "/messageTools/M_simulater_process/sendTerminalInsertAlarm";
sendHttpMsg(data,url); sendHttpMsg(data,url);
} }
//发送终端拔出报警
function sendpullOutAlarmEvent(){
var data = getPageData();
var host = window.location.host;
var url = "http://" + host + "/messageTools/M_simulater_process/sendTerminalPullOutAlarm";
sendHttpMsg(data,url);
}
//发送低电压报警 //发送低电压报警
function sendLowVoltageEvent(){ function sendLowVoltageEvent(){
var data = getPageData(); var data = getPageData();
...@@ -742,7 +787,48 @@ function sendRightSharpTurnEvent(){ ...@@ -742,7 +787,48 @@ function sendRightSharpTurnEvent(){
var url = "http://" + host + "/messageTools/M_simulater_process/sendRightSharpTurnEvent"; var url = "http://" + host + "/messageTools/M_simulater_process/sendRightSharpTurnEvent";
sendHttpMsg(data,url); sendHttpMsg(data,url);
} }
//发送怠速过长事件消息
function sendIdlingSpeedOverEvent(){
var data = getPageData();
var host = window.location.host;
var url = "http://" + host + "/messageTools/M_simulater_process/sendIdlingSpeedOverEvent";
sendHttpMsg(data,url);
}
//发送超速报警消息
function sendOverspeedEvent(){
var data = getPageData();
var host = window.location.host;
var url = "http://" + host + "/messageTools/M_simulater_process/sendOverspeedEvent";
sendHttpMsg(data,url);
}
//发送疲劳驾驶消息
function sendFatigueDrivingEvent(){
var data = getPageData();
var host = window.location.host;
var url = "http://" + host + "/messageTools/M_simulater_process/sendFatigueDrivingEvent";
sendHttpMsg(data,url);
}
//发送水温报警消息
function sendWaterTemperatureAlarmEvent(){
var data = getPageData();
var host = window.location.host;
var url = "http://" + host + "/messageTools/M_simulater_process/sendWaterTemperatureEvent";
sendHttpMsg(data,url);
}
//发送高速空挡滑行消息
function sendHighSpeedNeutralGearEvent(){
var data = getPageData();
var host = window.location.host;
var url = "http://" + host + "/messageTools/M_simulater_process/sendHighSpeedNeutralGearEvent";
sendHttpMsg(data,url);
}
//发送碰撞告警消息
function sendCrashAlarmEvent(){
var data = getPageData();
var host = window.location.host;
var url = "http://" + host + "/messageTools/M_simulater_process/sendCrashAlarmEvent";
sendHttpMsg(data,url);
}
// -------------------------------- 实时控制js代码------------------------------------------- // -------------------------------- 实时控制js代码-------------------------------------------
//设置隐藏或显示实时控制区域 //设置隐藏或显示实时控制区域
function isShowRealTimeCtrArea(e){ function isShowRealTimeCtrArea(e){
......
...@@ -404,6 +404,49 @@ def sendTerminalInsertAlarm(): ...@@ -404,6 +404,49 @@ def sendTerminalInsertAlarm():
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("/sendTerminalPullOutAlarm",methods=['POST'])
def sendTerminalPullOutAlarm():
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"]
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": {"terminalPullOut": "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')
########################################## ##########################################
# 【接口类型】发送低电压报警报警事件 # 【接口类型】发送低电压报警报警事件
########################################## ##########################################
...@@ -647,6 +690,283 @@ def sendRightSharpTurnEvent(): ...@@ -647,6 +690,283 @@ def sendRightSharpTurnEvent():
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("/sendIdlingSpeedOverEvent",methods=['POST'])
def sendIdlingSpeedOverEvent():
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"]
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": {"idlingSpeedOver": {"alarmType": "1", "idlingTimeOfDuration": "600",
"idlingOilExpend": "1200", "idlingEngineMaxSpeed": "5000","idlingEngineMinSpeed":"500"}}}}
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("/sendOverspeedEvent",methods=['POST'])
def sendOverspeedEvent():
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"]
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": {"overspeedAlarm": {"alarmType": "1", "averageSpeed": "700",
"maxSpeed": "145", "overspeedDistance": "10000","overspeedTimeOfDuration":"700"}}}}
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("/sendFatigueDrivingEvent",methods=['POST'])
def sendFatigueDrivingEvent():
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"]
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": {"fatigueDriving": {"alarmType": "1", "totalContinueDrivingTime": "10000"}}}}
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("/sendWaterTemperatureEvent",methods=['POST'])
def sendWaterTemperatureEvent():
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"]
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": {"waterTemperatureAlarm": {"alarmType": "1", "averageTemperature": "280",
"maxTemperature": "750", "timeOfDuration": "11000"}}}}
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("/sendHighSpeedNeutralGearEvent",methods=['POST'])
def sendHighSpeedNeutralGearEvent():
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": {"highSpeedNeutralGear": "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("/sendCrashAlarmEvent",methods=['POST'])
def sendCrashAlarmEvent():
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"]
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": {"crashAlarm": "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