Commit b8688e5f authored by liyuanhong's avatar liyuanhong

车安优模拟器改变剩余油量、改变电瓶电压、改变发动机转速功能

parent 3cd2b654
{"time": {"dateTime": "2020-07-13 14:17:20", "date": "2020-07-13", "time": "14:17:20"}, "curDayTravel": {"todayTotalMilleage": 4044, "todayTotalOil": 264, "todayTotalTime": 252, "theMilleage": 630, "theOil": 45, "theTime": 39}, "travelData": {"totalMilleage": 115855, "totalOil": 10373, "totalTime": 7103}}
\ No newline at end of file
{"time": {"dateTime": "2020-07-14 11:09:33", "date": "2020-07-14", "time": "11:09:33"}, "curDayTravel": {"todayTotalMilleage": 3852, "todayTotalOil": 297, "todayTotalTime": 237, "theMilleage": 422, "theOil": 32, "theTime": 26}, "travelData": {"totalMilleage": 119707, "totalOil": 10670, "totalTime": 7340}}
\ No newline at end of file
......@@ -46,6 +46,7 @@ class MessageSimulaterService():
"pkgCounts": "0", "baseInfo": {"alarmFlag": 0, "status": 262402, "latitude": 29.569133, "longtitude": 106.586571,
"elevation": "521", "speed": "66", "directionAngle": "59",
"infoTime": "2020-04-23 13:15:37"}, "extraInfo": {"01": {"extra_01": "20202020"},
"EA": {"0012": {"dataId_0012": "36"}},
"EB": {"6010": "2", "6014": "0", "6040": "44", "6050": "76", "6070": "89", "6100": "505", "6110": "51",
"6210": "4508", "6330": "28", "6460": "65", "6490": "32", "6701": "0", "6702": "0", "6703": "1",
"6704": "505", "6705": "1", "6706": "505", "6707": "505", "6708": "3500", "6709": "7200000",
......@@ -56,6 +57,7 @@ class MessageSimulaterService():
"pkgCounts": "0", "baseInfo": {"alarmFlag": 0, "status": 262402, "latitude": 29.569133, "longtitude": 106.586571,
"elevation": "521", "speed": "66", "directionAngle": "59",
"infoTime": "2020-04-23 13:15:37"}, "extraInfo": {"01": {"extra_01": "20202020"},
"EA": {"0012": {"dataId_0012": "36"}},
"EB": {"6010": "2", "6014": "0", "6040": "44", "6050": "76", "6070": "89", "6100": "505", "6110": "51",
"6210": "4508", "6330": "28", "6460": "65", "6490": "32", "6701": "0", "6702": "0", "6703": "1",
"6704": "505", "6705": "1", "6706": "505", "6707": "505", "6708": "3500", "6709": "7200000",
......@@ -110,6 +112,12 @@ class MessageSimulaterService():
self.travelDirection = data
def setFixCurPosition(self,data):
self.fixCurPosition = data
def setVotage(self,data):
self.data["travelData"]["votage"] = data
def setEngineSpeed(self,data):
self.data["travelData"]["engineSpeed"] = data
def setSurplusOil(self,data):
self.data["travelData"]["surplusOil"] = data
def sendMsg(self,msg):
self.socket.setTimeOut(self.timeout)
......@@ -299,7 +307,9 @@ class MessageSimulaterService():
self.OBDdata["baseInfo"]["latitude"] = self.gpsLine[self.gpsLineIndex]["lat"]
self.OBDdata["baseInfo"]["longtitude"] = self.gpsLine[self.gpsLineIndex]["lng"]
self.OBDdata["baseInfo"]["directionAngle"] = self.getDirAngle()
self.OBDdata["extraInfo"]["EB"]["60C0"] = 3000 # 发动机转速
self.OBDdata["extraInfo"]["EA"]["0012"]["dataId_0012"] = int(self.data["travelData"]["votage"]) # 电瓶电压
self.OBDdata["extraInfo"]["EB"]["60C0"] = int(self.data["travelData"]["engineSpeed"]) # 发动机转速
self.OBDdata["extraInfo"]["EB"]["62f0"] = int(self.data["travelData"]["surplusOil"]) # 剩余油量
speed = int(self.data["travelData"]["carSpeed"])
oilExpend = int(self.data["travelData"]["oilExpend"])
self.OBDdata["extraInfo"]["EB"]["60D0"] = speed # 车速
......@@ -357,7 +367,10 @@ class MessageSimulaterService():
self.OBDdata["baseInfo"]["latitude"] = self.gpsLine[self.gpsLineIndex]["lat"]
self.OBDdata["baseInfo"]["longtitude"] = self.gpsLine[self.gpsLineIndex]["lng"]
self.OBDdata["baseInfo"]["directionAngle"] = self.getDirAngle()
self.OBDdata["extraInfo"]["EB"]["60C0"] = 3000 # 发动机转速
# self.OBDdata["extraInfo"]["EB"]["60C0"] = 3000 # 发动机转速
self.OBDdata["extraInfo"]["EA"]["0012"]["dataId_0012"] = int(self.data["travelData"]["votage"]) # 电瓶电压
self.OBDdata["extraInfo"]["EB"]["60C0"] = int(self.data["travelData"]["engineSpeed"]) # 发动机转速
self.OBDdata["extraInfo"]["EB"]["62f0"] = int(self.data["travelData"]["surplusOil"]) # 剩余油量
speed = int(self.data["travelData"]["carSpeed"])
oilExpend = int(self.data["travelData"]["oilExpend"])
self.OBDdata["extraInfo"]["EB"]["60D0"] = speed # 车速
......
......@@ -181,6 +181,9 @@
<span style="margin-left:10px"><label>上报间隔(秒):</label><input style="width:80px;margin-right:5px;" id="change_durTime" type="text" class="form-control" value="5"><button type="button" class="btn btn-primary" onclick="changeDurTime()">改变上报间隔</button></span>
<span style="margin-left:10px;display: inline-block;"><button type="button" class="btn btn-primary" onclick="changeTravelDirection()">反向行驶</button></span>
<span style="margin-left:10px;display: inline-block;"><button type="button" class="btn btn-primary" onclick="fixCurPosition(this)">固定在当前位置</button></span>
<span style="margin-left:10px;display: inline-block;"><label>剩余油量(%):</label><input style="width:80px;margin-right:5px;" id="change_surplusOil" type="text" class="form-control" value="50.5"><button type="button" class="btn btn-primary" onclick="changeSurplusOil()">改变剩余油量</button></span>
<span style="margin-left:10px;display: inline-block;"><label>发动机转速:</label><input style="width:80px;margin-right:5px;" id="change_engineSpeed" type="text" class="form-control" value="3000"><button type="button" class="btn btn-primary" onclick="changeEngineSpeed()">改变发动机转速</button></span>
<span style="margin-left:10px;display: inline-block;"><label>电瓶电压(v) :</label><input style="width:80px;margin-right:5px;" id="change_voltage" type="text" class="form-control" value="12"><button type="button" class="btn btn-primary" onclick="changeVoltage()">改变电瓶电压</button></span>
</div>
</div>
</div>
......@@ -438,9 +441,15 @@ function getPageData(){
var carSpeed = $("#carSpeed").val()
var oilExpend = $("#oilExpend").val()
var travelLoop = $("#travelLoop").val()
var votage = 120
var surplusOil = 505
var engineSpeed = 3000
data["travelData"]["carSpeed"] = carSpeed
data["travelData"]["oilExpend"] = oilExpend
data["travelData"]["travelLoop"] = travelLoop
data["travelData"]["votage"] = votage
data["travelData"]["surplusOil"] = surplusOil
data["travelData"]["engineSpeed"] = engineSpeed
return data;
}
//控制登录数据区域的显示与隐藏
......@@ -929,7 +938,7 @@ function changeTravelDirection(){
var url = "http://" + host + "/messageTools/M_simulater_process/changeTravelDirection";
sendHttpMsg(data,url);
}
//固定于取消固定gps发送点
function fixCurPosition(e){
var butTxt = $(e).text()
if(butTxt == "固定在当前位置"){
......@@ -960,6 +969,51 @@ function fixCurPosition(e){
$(e).text("固定在当前位置")
}
}
//改变电瓶电压
function changeVoltage(){
var data = {}
var carId = $("#phoneNum").val()
var votage = parseFloat($("#change_voltage").val()) * 10
data["carId"] = carId
data["votage"] = votage
//会话session数据
data["session"] = {}
var sessionId = $("#curSession").val()
data["session"]["sessionId"] = sessionId
var host = window.location.host;
var url = "http://" + host + "/messageTools/M_simulater_process/changeVotage";
sendHttpMsg(data,url);
}
//改变发动机转速
function changeEngineSpeed(){
var data = {}
var carId = $("#phoneNum").val()
var engineSpeed = $("#change_engineSpeed").val()
data["carId"] = carId
data["engineSpeed"] = engineSpeed
//会话session数据
data["session"] = {}
var sessionId = $("#curSession").val()
data["session"]["sessionId"] = sessionId
var host = window.location.host;
var url = "http://" + host + "/messageTools/M_simulater_process/changeEngineSpeed";
sendHttpMsg(data,url);
}
//改变剩余油量
function changeSurplusOil(){
var data = {}
var carId = $("#phoneNum").val()
var surplusOil = parseFloat($("#change_surplusOil").val()) * 10
data["carId"] = carId
data["surplusOil"] = surplusOil
//会话session数据
data["session"] = {}
var sessionId = $("#curSession").val()
data["session"]["sessionId"] = sessionId
var host = window.location.host;
var url = "http://" + host + "/messageTools/M_simulater_process/changeSurplusOil";
sendHttpMsg(data,url);
}
</script>
{% endblock %}
\ No newline at end of file
......@@ -1157,3 +1157,96 @@ def fixCurPosition():
data["status"] = "4003"
data["message"] = "Error: 固定gps点失败!"
return Response(json.dumps(data), mimetype='application/json')
##########################################
# 【接口类型】改变电瓶电压
##########################################
@M_simulater_process.route("/changeVotage",methods=['POST'])
def changeVotage():
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:
service.setVotage(params["votage"])
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("/changeEngineSpeed",methods=['POST'])
def changeEngineSpeed():
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:
service.setEngineSpeed(params["engineSpeed"])
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("/changeSurplusOil",methods=['POST'])
def changeSurplusOil():
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:
service.setSurplusOil(params["surplusOil"])
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