Commit 997b7fc0 authored by liyuanhong's avatar liyuanhong

车安优图形模拟器故障码功能开发完成

parent 6be4db2f
......@@ -30,7 +30,7 @@ class DataUpstreamTransport_msg(MessageBase):
return msg
# 生成一条完整的消息,针对图形界面,可传递参数
def generateMsg_GUI(self,msgID="0100",phoneNum="13146201119",msgWaterCode=1,encryptionType=0,subPkg=0,msgType="F3",data={"infoTime":"2020-02-06 11:31:56"}):
def generateMsg_GUI(self,msgID="0900",phoneNum="13146201119",msgWaterCode=1,encryptionType=0,subPkg=0,msgType="F3",data={"infoTime":"2020-02-06 11:31:56"}):
msg = ""
msgBody = self.getMsgBody_GUI(msgType,data)
msgHeader = self.getMsgHeader_GUI(msgID, phoneNum, msgWaterCode, encryptionType, subPkg,msgBody)
......
......@@ -83,8 +83,6 @@ class MessageSimulaterService():
def getGpsLineIndex(self):
return self.gpsLineIndex
#设置套接字
def setSocket(self,data):
self.socket = data
......
......@@ -194,6 +194,29 @@
</div>
</div>
</div>
<div style="display: block; width: 100%; border-width: 1px; border-style: solid; border-color: darkgray; border-radius: 10px; padding: 2px; margin-top: 5px;">
<h5><b>其他操作:</b>
<span style="border-width:1px;border-style:solid;border-color:darkgray;border-radius:10px;padding:1px 10px;">
<label><input name="other" type="radio" value="0" checked="checked" onclick="isShowOtherCtrArea(this)"/>隐藏</label>
<label style="margin-left:10px;"><input name="other" type="radio" value="1" onclick="isShowOtherCtrArea(this)"/>显示</label>
</span>
</h5>
<div id="otherCtl_area" style="display:none;">
<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>
<ul class="protocol_content" style="padding:0px;">
<li style="width:210px;"><label>故障码个数:</label><input id="troubleCodeNums" type="text" class="form-control" value="0" style="width:100px;" ></li>
<li><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></li>
<li><button type="button" class="btn btn-primary" style="margin-left:10px;" onclick="sendTroubleCode()">发送故障码</button></li>
</ul>
</div>
</div>
</div>
<div style="width:100%;padding-bottom:60px;border-bottom: 1px solid #eee;">
<h3>日志:</h3>
<textarea id="showFeedback" style="width:100%;padding:5px;padding-bottom:60px;" rows="10"></textarea>
......@@ -1062,6 +1085,31 @@ function changeSurplusOil(){
var url = "http://" + host + "/messageTools/M_simulater_process/changeSurplusOil";
sendHttpMsg(data,url);
}
// -------------------------------- 其他操作js代码-------------------------------------------
function isShowOtherCtrArea(e){
var value = $(e).val()
if(value == "0"){
$("#otherCtl_area").css("display","none")
}else{
$("#otherCtl_area").css("display","block")
}
}
//发送故障码
function sendTroubleCode(){
var data = {}
var carId = $("#phoneNum").val()
var troubleCodeNums = $("#troubleCodeNums").val();
var systemId = $("#systemId").val();
data["carId"] = carId;
data["troubleCodeNums"] = troubleCodeNums;
data["systemId"] = systemId;
data["session"] = {}
var sessionId = $("#curSession").val()
data["session"]["sessionId"] = sessionId
var host = window.location.host;
var url = "http://" + host + "/messageTools/M_simulater_process/porcessTroubleCodeMsg";
sendHttpMsg(data,url);
}
</script>
{% endblock %}
\ No newline at end of file
......@@ -8,6 +8,7 @@ from configparser import ConfigParser
import json
import traceback
from lib.protocol.message.DataUpstreamTransport_msg import DataUpstreamTransport_msg
from lib.protocol.message.Location_msg import Location_msg
from lib.socket.ClientSocket import ClientSocket
from lib.socket.service.MessageSimulaterService import MessageSimulaterService
......@@ -1318,4 +1319,49 @@ def changeSurplusOil():
traceback.print_exc()
data["status"] = "4003"
data["message"] = "Error: 改变剩余油量失败!"
return Response(json.dumps(data), mimetype='application/json')
\ No newline at end of file
return Response(json.dumps(data), mimetype='application/json')
#--------------------------------------- 其他操作逻辑 ---------------------------------------
##########################################
# 【接口类型】处理发送的故障码报文
##########################################
@M_simulater_process.route("/porcessTroubleCodeMsg",methods=['POST'])
def porcessTroubleCodeMsg():
params = request.get_data()
params = json.loads(params.decode("utf-8"))
sessionId = params["session"]["sessionId"]
carId = params["carId"]
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:
timeStamp = time.time()
timeArray = time.localtime(timeStamp)
curTime = time.strftime("%Y-%m-%d %H:%M:%S", timeArray)
msgWaterCode = service.getSn()
latitude = float(service.getCurLatitude())
longitude = float(service.getCurLongtitude())
nums = int(params["troubleCodeNums"])
systemId = params["systemId"]
info = {}
info["infoTime"] = curTime
info["latitude"] = latitude
info["longitude"] = longitude
info["troubleCodeNums"] = nums
info["systemId"] = systemId
obj = DataUpstreamTransport_msg()
msg = obj.generateMsg_GUI(phoneNum=carId,msgWaterCode=msgWaterCode,msgType="F2",data=info)
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