Commit b7797ad1 authored by liyuanhong's avatar liyuanhong

M500 模拟器增加了经纬度设置为0的功能

parent f6a8a2c6
{"time": {"dateTime": "2020-05-18 11:54:49", "date": "2020-05-18", "time": "11:54:49"}, "curDayTravel": {"todayTotalMilleage": 20920, "todayTotalOil": 2020, "todayTotalTime": 1260, "theMilleage": 1000, "theOil": 100, "theTime": 60}, "travelData": {"totalMilleage": 283737, "totalOil": 26847, "totalTime": 16782}, "event": {"threeRapid": {"totalRapidlyAccelerate": 14, "totalSharpSlowdown": 13, "totalSharpTurn": 13}}} {"time": {"dateTime": "2020-05-19 11:09:47", "date": "2020-05-19", "time": "11:09:47"}, "curDayTravel": {"todayTotalMilleage": 6190, "todayTotalOil": 595, "todayTotalTime": 373, "theMilleage": 83, "theOil": 8, "theTime": 5}, "travelData": {"totalMilleage": 289927, "totalOil": 27442, "totalTime": 17155}, "event": {"threeRapid": {"totalRapidlyAccelerate": 14, "totalSharpSlowdown": 13, "totalSharpTurn": 13}}}
\ No newline at end of file \ No newline at end of file
...@@ -45,6 +45,7 @@ class ProtocolSimulaterService(): ...@@ -45,6 +45,7 @@ class ProtocolSimulaterService():
''' '''
self.sendType = 0 self.sendType = 0
self.GPSValid = 1 #用来控制GPS数据是有效还是无效 0:无效 1:有效 self.GPSValid = 1 #用来控制GPS数据是有效还是无效 0:无效 1:有效
self.lngLatIsOk = 1 #用来控制经纬度是否都为0 0:都为0 1:正常
# 定义要发送的obd数据 # 定义要发送的obd数据
self.OBDdata = {"fireStatus":1,"ACCStatus":0,"engineSpeed":300,"speed":0,"meterMileage":6000,"totailMileage":600,"totalOilExpen":30,"totalRunTime":10} self.OBDdata = {"fireStatus":1,"ACCStatus":0,"engineSpeed":300,"speed":0,"meterMileage":6000,"totailMileage":600,"totalOilExpen":30,"totalRunTime":10}
# 定义初始的obd数据,与上面的OBD数据保持一致,主要用于汽车行驶过程中数据变化量的计算 # 定义初始的obd数据,与上面的OBD数据保持一致,主要用于汽车行驶过程中数据变化量的计算
...@@ -82,6 +83,8 @@ class ProtocolSimulaterService(): ...@@ -82,6 +83,8 @@ class ProtocolSimulaterService():
self.sendType = data self.sendType = data
def setGPSValid(self,data): def setGPSValid(self,data):
self.GPSValid = data self.GPSValid = data
def setLngLatIsOk(self,data):
self.lngLatIsOk = data
...@@ -463,6 +466,9 @@ class ProtocolSimulaterService(): ...@@ -463,6 +466,9 @@ class ProtocolSimulaterService():
gpsObj = GPSReport_protocol(DEV_ID=self.carId,WATER_CODE=self.sn) gpsObj = GPSReport_protocol(DEV_ID=self.carId,WATER_CODE=self.sn)
gpsObj.setLatitude(latitude) gpsObj.setLatitude(latitude)
gpsObj.setLongitude(longtitude) gpsObj.setLongitude(longtitude)
if self.lngLatIsOk == 0:
gpsObj.setLatitude(0)
gpsObj.setLongitude(0)
if self.GPSValid == 1: if self.GPSValid == 1:
gpsObj.setGpsValid(1) gpsObj.setGpsValid(1)
elif self.GPSValid == 0: elif self.GPSValid == 0:
...@@ -480,6 +486,9 @@ class ProtocolSimulaterService(): ...@@ -480,6 +486,9 @@ class ProtocolSimulaterService():
gpsObj = GPSReport_protocol(DEV_ID=self.carId,WATER_CODE=self.sn) gpsObj = GPSReport_protocol(DEV_ID=self.carId,WATER_CODE=self.sn)
gpsObj.setLatitude(latitude) gpsObj.setLatitude(latitude)
gpsObj.setLongitude(longtitude) gpsObj.setLongitude(longtitude)
if self.lngLatIsOk == 0:
gpsObj.setLatitude(0)
gpsObj.setLongitude(0)
if self.GPSValid == 1: if self.GPSValid == 1:
gpsObj.setGpsValid(1) gpsObj.setGpsValid(1)
elif self.GPSValid == 0: elif self.GPSValid == 0:
......
...@@ -170,6 +170,10 @@ ...@@ -170,6 +170,10 @@
<label><input name="GPSValie" value="1" type="radio" onclick="changeGPSValid(this)" checked="checked">GPS有效</label> <label><input name="GPSValie" value="1" type="radio" onclick="changeGPSValid(this)" checked="checked">GPS有效</label>
<label style="margin-left:10px;color:red;"><input name="GPSValie" value="0" type="radio" onclick="changeGPSValid(this)">GPS无效</label> <label style="margin-left:10px;color:red;"><input name="GPSValie" value="0" type="radio" onclick="changeGPSValid(this)">GPS无效</label>
</span> </span>
<span style="margin-top:10px;display:inline-block;border-width:1px;border-style:solid;border-color:darkgray;border-radius:10px;padding:1px 10px;margin-left:10px;">
<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>
</span>
</div> </div>
</div> </div>
</div> </div>
...@@ -915,6 +919,20 @@ function changeGPSValid(e){ ...@@ -915,6 +919,20 @@ function changeGPSValid(e){
url = "/protocolTools/M_carSimulater_process/controlGPSValid"; url = "/protocolTools/M_carSimulater_process/controlGPSValid";
sendjson(data,url); sendjson(data,url);
} }
//控制经纬度为0还是正常
function changeLngLatIsOk(e){
var data = {}
var carId = $("#carId").val()
var lngLatIsOk = $(e).val()
data["carId"] = carId
data["lngLatIsOk"] = lngLatIsOk
//会话session数据
data["session"] = {}
var sessionId = $("#curSession").val()
data["session"]["sessionId"] = sessionId
url = "/protocolTools/M_carSimulater_process/controlLngLatIsOk";
sendjson(data,url);
}
</script> </script>
{% endblock %} {% endblock %}
</div> </div>
......
...@@ -1112,3 +1112,30 @@ def controlGPSValid(): ...@@ -1112,3 +1112,30 @@ def controlGPSValid():
data["status"] = "4003" data["status"] = "4003"
data["message"] = "Error: 设置GPS有效信息失败!" data["message"] = "Error: 设置GPS有效信息失败!"
return Response(json.dumps(data), mimetype='application/json') return Response(json.dumps(data), mimetype='application/json')
##########################################
# 【接口类型】控制经纬度是正常,还是为0
##########################################
@M_carSimulater_process.route("/controlLngLatIsOk",methods=['POST'])
def controlLngLatIsOk():
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:
lngLatIsOk = int(params["lngLatIsOk"])
service.setLngLatIsOk(lngLatIsOk)
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