Commit 1f519742 authored by liyuanhong's avatar liyuanhong

M500模拟器故障码功能开发完成

parent 6421fbbd
{"time": {"dateTime": "2020-07-09 16:58:36", "date": "2020-07-09", "time": "16:58:36"}, "curDayTravel": {"todayTotalMilleage": 1162, "todayTotalOil": 112, "todayTotalTime": 70, "theMilleage": 1162, "theOil": 112, "theTime": 70}, "travelData": {"totalMilleage": 564424, "totalOil": 51394, "totalTime": 33858}, "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": 2573, "todayTotalOil": 248, "todayTotalTime": 155, "theMilleage": 581, "theOil": 56, "theTime": 35}, "travelData": {"totalMilleage": 566997, "totalOil": 51642, "totalTime": 34013}, "event": {"threeRapid": {"totalRapidlyAccelerate": 43, "totalSharpSlowdown": 31, "totalSharpTurn": 34}}}
\ No newline at end of file \ No newline at end of file
...@@ -308,12 +308,8 @@ class OBDReport_CAN_protocol(ProtocolBase): ...@@ -308,12 +308,8 @@ class OBDReport_CAN_protocol(ProtocolBase):
# 单位:0.01V # 单位:0.01V
################################################### ###################################################
def getVoltageHex(self,num): def getVoltageHex(self,num):
valtageStr = str(num) valtage = int(num * 100)
valtageStr = valtageStr.replace(".", "") valtageHex = self.int2hexStringByBytes(valtage,2)
while (len(valtageStr) < 4):
valtageStr = "0" + valtageStr
valtageHex = hex(int(valtageStr))
valtageHex = self.leftPad(str(valtageHex)[2:], 4)
return valtageHex return valtageHex
#################################################### ####################################################
......
...@@ -193,7 +193,7 @@ ...@@ -193,7 +193,7 @@
<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> <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;"><label>电瓶电压(v) :</label><input style="width:80px;margin-right:5px;" id="change_voltage" type="text" class="form-control" value="1.2"><button type="button" class="btn btn-primary" onclick="changeVoltage()">改变电瓶电压</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> </div>
</div> </div>
...@@ -205,8 +205,24 @@ ...@@ -205,8 +205,24 @@
</span> </span>
</h5> </h5>
<div id="other_area" style="display:none;"> <div id="other_area" style="display:none;">
<div style="padding:10px;"> <div style="border-width:1px;border-style:solid;border-color:darkgray;border-radius:10px;padding:1px 10px;margin:0px 10px;">
<h5><i><b>故障码上报:</b></i></h5>
<label>故障码个数:</label><input style="width:80px;" id="troubleCodeNum" type="text" class="form-control" value="1">
<label>故障码类型:</label><select id="systemId" class="form-control">
<option value="00">发动机故障码</option>
<option value="01">变速箱故障码</option>
<option value="02">ABS 故障码</option>
<option value="03">安全气囊故障码</option>
</select>
<label>故障码状态:</label><select id="status" class="form-control" style="width:100px;">
<option value="0">未解决</option>
<option value="1">已解决</option>
</select>
<label>MIL状态:</label><select id="MILStatus" class="form-control" style="width:80px;">
<option value="0">ON</option>
<option value="1">OFF</option>
</select>
<button type="button" class="btn btn-primary" onclick="sendTroubleCode()">发送故障码</button>
</div> </div>
</div> </div>
</div> </div>
...@@ -275,7 +291,7 @@ function getPageData(){ ...@@ -275,7 +291,7 @@ function getPageData(){
data["travelData"]["travelLoop"] = travelLoop data["travelData"]["travelLoop"] = travelLoop
//其他默认数据 //其他默认数据
data["other"] = {} data["other"] = {}
var valtage = 1.2 * 100 var valtage = 1.2 * 10
data["other"]["valtage"] = valtage data["other"]["valtage"] = valtage
return data; return data;
} }
...@@ -1092,6 +1108,47 @@ function changeVoltage(){ ...@@ -1092,6 +1108,47 @@ function changeVoltage(){
url = "/protocolTools/M_carSimulater_process/changeValtage"; url = "/protocolTools/M_carSimulater_process/changeValtage";
sendjson(data,url); sendjson(data,url);
} }
// -------------------------------- 其他操作js代码-------------------------------------------
//设置隐藏或显示其他操作区域
function isShowOtheroperCtrArea(e){
var value = $(e).val()
if(value == "0"){
$("#other_area").css("display","none")
}else{
$("#other_area").css("display","block")
}
}
//发送故障码
function sendTroubleCode(){
var data = {}
var carId = $("#carId").val()
data["carId"] = carId
//会话session数据
data["session"] = {}
data["troubleCode"] = {}
var sessionId = $("#curSession").val()
data["session"]["sessionId"] = sessionId
var troubleCodeNum = parseInt($("#troubleCodeNum").val())
var systemId = $("#systemId").val()
var status = $("#status").val()
var troubleCode = []
for(var i = 0;i < troubleCodeNum;i++){
var temp = {}
temp["systemId"] = systemId
temp["content1"] = "00"
temp["content2"] = "0" + (i + 1)
temp["status"] = status
troubleCode.push(temp)
}
var MILStatus = $("#MILStatus").val()
data["troubleCode"]["troubleCodeNum"] = troubleCodeNum;
data["troubleCode"]["troubleCode"] = troubleCode;
data["troubleCode"]["MILStatus"] = MILStatus;
url = "/protocolTools/M_carSimulater_process/porcessTroubleCodeMsg";
sendjson(data,url);
}
</script> </script>
{% endblock %} {% endblock %}
</div> </div>
......
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
<script> <script>
//发送电瓶采样数据包 //发送故障码数据包
$("#sendMsgBtn").click(function(){ $("#sendMsgBtn").click(function(){
var WATER_CODE = $("#WATER_CODE").val(); var WATER_CODE = $("#WATER_CODE").val();
var DEV_ID = $("#DEV_ID").val(); var DEV_ID = $("#DEV_ID").val();
......
#coding:utf-8 #coding:utf-8
import binascii
import os import os
import time import time
from time import sleep from time import sleep
...@@ -8,6 +9,7 @@ from configparser import ConfigParser ...@@ -8,6 +9,7 @@ from configparser import ConfigParser
from lib.protocol.report.EventReport_protocol import EventReport_protocol from lib.protocol.report.EventReport_protocol import EventReport_protocol
from lib.protocol.report.LoginReport_protocol import LoginReport_protocol from lib.protocol.report.LoginReport_protocol import LoginReport_protocol
from lib.protocol.report.TroubleCodeReport_protocol import TroubleCode_protocol
from lib.protocol.report.VersionReport_protocol import VersionReport_protocol from lib.protocol.report.VersionReport_protocol import VersionReport_protocol
from lib.socket.ClientSocket import ClientSocket from lib.socket.ClientSocket import ClientSocket
import json import json
...@@ -1482,6 +1484,45 @@ def changeValtage(): ...@@ -1482,6 +1484,45 @@ def changeValtage():
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("/porcessTroubleCodeMsg",methods=['POST'])
def porcessTroubleCodeMsg():
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:
conf_R = ConfigParser()
conf_R.read("config/protocolTools/protocolTools.conf")
cliSocket = ClientSocket(conf_R.get("socket", "host"),conf_R.getint("socket", "port"))
cliSocket.connect()
timeS = int(time.time()) - 8 * 3600
timeArray = time.localtime(timeS)
UTCTime = time.strftime("%Y-%m-%d %H:%M:%S", timeArray)
sn = service.getSn()
protocolObj = TroubleCode_protocol(WATER_CODE=sn,DEV_ID=params["carId"], \
UTCTime=UTCTime,troubleCodeNum=params["troubleCode"]["troubleCodeNum"],troubleCode=params["troubleCode"]["troubleCode"], \
MILStatus=params["troubleCode"]["MILStatus"])
msg = protocolObj.generateMsg()
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