Commit bd8a4961 authored by liyuanhong's avatar liyuanhong

M500模拟器增加了改变行驶方向的功能

parent ef9207fd
...@@ -90,6 +90,8 @@ class ProtocolSimulaterService(): ...@@ -90,6 +90,8 @@ class ProtocolSimulaterService():
self.GPSValid = data self.GPSValid = data
def setLngLatIsOk(self,data): def setLngLatIsOk(self,data):
self.lngLatIsOk = data self.lngLatIsOk = data
def setTravelDirection(self,data):
self.travelDirection = data
...@@ -105,6 +107,8 @@ class ProtocolSimulaterService(): ...@@ -105,6 +107,8 @@ class ProtocolSimulaterService():
return self.sn return self.sn
def getCarData(self): def getCarData(self):
return self.carData return self.carData
def getTravelDirection(self):
return self.travelDirection
####################################################### #######################################################
# type 为0表示正常发送,type为1表示数据写入本地 # type 为0表示正常发送,type为1表示数据写入本地
...@@ -160,9 +164,14 @@ class ProtocolSimulaterService(): ...@@ -160,9 +164,14 @@ class ProtocolSimulaterService():
self.gpsLineIndex = self.gpsLineIndex - 1 #反向行驶 self.gpsLineIndex = self.gpsLineIndex - 1 #反向行驶
elif self.gpsLineIndex == len(self.gpsLine) or self.gpsLineIndex == -1: #如果反向行驶和反向行驶刚好跑完 elif self.gpsLineIndex == len(self.gpsLine) or self.gpsLineIndex == -1: #如果反向行驶和反向行驶刚好跑完
if int(self.data["travelData"]["travelLoop"]) == 0: #没有设置循环行驶 if int(self.data["travelData"]["travelLoop"]) == 0: #没有设置循环行驶
if self.travelDirection == 0:
self.gpsLineIndex = self.gpsLineIndex - 1 self.gpsLineIndex = self.gpsLineIndex - 1
self.stopTravel() self.stopTravel()
self.websocket.sendMsgToClient("gps轨迹跑完,自动停止行驶!",self.websocketId) self.websocket.sendMsgToClient("gps轨迹跑完,自动停止行驶!",self.websocketId)
else:
self.gpsLineIndex = self.gpsLineIndex + 1
self.stopTravel()
self.websocket.sendMsgToClient("gps轨迹跑完,自动停止行驶!", self.websocketId)
else: #设置了循环行驶 else: #设置了循环行驶
if self.travelDirection == 0: if self.travelDirection == 0:
self.gpsLineIndex = self.gpsLineIndex - 1 self.gpsLineIndex = self.gpsLineIndex - 1
......
...@@ -185,6 +185,7 @@ ...@@ -185,6 +185,7 @@
<label><input name="lngLatIsOk" value="1" type="radio" onclick="changeLngLatIsOk(this)" checked="checked">经纬度正常</label> <label><input name="lngLatIsOk" value="1" type="radio" onclick="changeLngLatIsOk(this)" checked="checked">经纬度正常</label>
<label style="margin-left:10px;color:red;"><input name="lngLatIsOk" value="0" type="radio" onclick="changeLngLatIsOk(this)">经纬度为0</label> <label style="margin-left:10px;color:red;"><input name="lngLatIsOk" value="0" type="radio" onclick="changeLngLatIsOk(this)">经纬度为0</label>
</span> </span>
<span style="margin-left:10px;display: inline-block;"><button type="button" class="btn btn-primary" onclick="changeTravelDirection()">改变行驶方向</button></span>
</div> </div>
</div> </div>
</div> </div>
...@@ -1000,6 +1001,18 @@ function changeLngLatIsOk(e){ ...@@ -1000,6 +1001,18 @@ function changeLngLatIsOk(e){
url = "/protocolTools/M_carSimulater_process/controlLngLatIsOk"; url = "/protocolTools/M_carSimulater_process/controlLngLatIsOk";
sendjson(data,url); sendjson(data,url);
} }
//改变行驶方向
function changeTravelDirection(){
var data = {}
var carId = $("#carId").val()
data["carId"] = carId
//会话session数据
data["session"] = {}
var sessionId = $("#curSession").val()
data["session"]["sessionId"] = sessionId
url = "/protocolTools/M_carSimulater_process/changeTravelDirection";
sendjson(data,url);
}
</script> </script>
{% endblock %} {% endblock %}
</div> </div>
......
...@@ -1337,3 +1337,39 @@ def controlLngLatIsOk(): ...@@ -1337,3 +1337,39 @@ def controlLngLatIsOk():
data["status"] = "4003" data["status"] = "4003"
data["message"] = "Error: 设置经纬度值失败!" data["message"] = "Error: 设置经纬度值失败!"
return Response(json.dumps(data), mimetype='application/json') return Response(json.dumps(data), mimetype='application/json')
##########################################
# 【接口类型】改变行驶方向
##########################################
@M_carSimulater_process.route("/changeTravelDirection",methods=['POST'])
def changeTravelDirection():
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:
travelDirection = service.getTravelDirection()
if travelDirection == 0:
service.setTravelDirection(1)
else:
service.setTravelDirection(0)
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