Commit 8b0ba6dd authored by liyuanhong's avatar liyuanhong

完成了新硬件版本上报和OBD消息的修改项

parent 75a557c2
......@@ -30,12 +30,11 @@ class TerminalVersionInfo_msg(MessageBase):
def generateMsg_GUI(self,msgID="0205",phoneNum="13146201119",msgWaterCode=1,encryptionType=0,subPkg=0, \
softwareVersion="KZP200_V201001", softwareVersionDate="2020-02-10", CPUId="CPU-12345678",GMSType="GMS-TYPE-123456", \
GMS_IMEI="GMS_IMEI_123456", SIM_IMSI="SIM_13146201119", SIM_ICCID="SIM_ICCID13146201119",carType=22, VIN="VIN_1234567891234", \
totalMileage=389000, totalOilExpend=420000
):
totalMileage=389000, totalOilExpend=420000,displacement=1500,oilDensity=80):
msg = ""
msgHeader = self.getMsgHeader_GUI(msgID,phoneNum,msgWaterCode,encryptionType,subPkg)
msgBody = self.getMsgBody_GUI(softwareVersion,softwareVersionDate,CPUId,GMSType,GMS_IMEI,SIM_IMSI,SIM_ICCID,carType,VIN,\
totalMileage,totalOilExpend)
totalMileage,totalOilExpend,displacement,oilDensity)
checkCode = self.getCheckCode(msgHeader + msgBody)
msg = msg + self.IDENTIFY
info = msgHeader + msgBody + checkCode
......@@ -62,11 +61,13 @@ class TerminalVersionInfo_msg(MessageBase):
VIN = "VIN_" + self.getRandomStr(13,"0123456789")
totalMileage = self.getRandomNum(30000,6000000)
totalOilExpend = self.getRandomNum(30000,6000000)
displacement = self.getRandomNum(500,3000)
oilDensity = self.getRandomNum(80,500)
msg = ""
msgHeader = self.getMsgHeader_GUI(msgID, phoneNum, msgWaterCode, encryptionType, subPkg)
msgBody = self.getMsgBody_GUI(softwareVersion, softwareVersionDate, CPUId, GMSType, GMS_IMEI, SIM_IMSI,
SIM_ICCID, carType, VIN, \
totalMileage, totalOilExpend)
totalMileage, totalOilExpend,displacement,oilDensity)
checkCode = self.getCheckCode(msgHeader + msgBody)
msg = msg + self.IDENTIFY
info = msgHeader + msgBody + checkCode
......@@ -92,16 +93,18 @@ class TerminalVersionInfo_msg(MessageBase):
VIN = self.GBKString2Hex("VIN_1234567891234") #汽车 VIN 码
totalMileage = self.int2hexStringByBytes(389000,4) #装上终端后车辆累计总里程或车辆仪表里程(单位米)
totalOilExpend = self.int2hexStringByBytes(420000,4) #装上终端后车辆累计总耗油量(ml)
displacement = self.int2hexStringByBytes(1500,2) #排量
oilDensity = self.int2hexStringByBytes(92,2) #油品密度
msg = msg + softwareVersion + softwareVersionDate + CPUId + GSMType + GSM_IMEI
msg = msg + SIM_IMSI + SIM_ICCID + carType + VIN + totalMileage
msg = msg + totalOilExpend
msg = msg + totalOilExpend + displacement + oilDensity
return msg
# 生成一条完整的消息,针对图形界面,可传递参数
def getMsgBody_GUI(self,softwareVersion="KZP200_V201001",softwareVersionDate="2020-02-10",CPUId="CPU-12345678",GMSType="GMS-TYPE-123456",\
GMS_IMEI="GMS_IMEI_123456",SIM_IMSI="SIM_13146201119",SIM_ICCID="SIM_ICCID13146201119",carType=22,VIN="VIN_1234567891234",\
totalMileage=389000,totalOilExpend=420000):
totalMileage=389000,totalOilExpend=420000,displacement=1500,oilDensity=92):
msg = ""
softwareVersion = self.GBKString2Hex(softwareVersion) #软件版本号
softwareVersionDate = self.GBKString2Hex(softwareVersionDate) #终端版本日期
......@@ -114,10 +117,12 @@ class TerminalVersionInfo_msg(MessageBase):
VIN = self.GBKString2Hex(VIN) #汽车 VIN 码
totalMileage = self.int2hexStringByBytes(totalMileage,4) #装上终端后车辆累计总里程或车辆仪表里程(单位米)
totalOilExpend = self.int2hexStringByBytes(totalOilExpend,4) #装上终端后车辆累计总耗油量(ml)
displacement = self.int2hexStringByBytes(displacement,2) #排量
oilDensity = self.int2hexStringByBytes(oilDensity,2) #油密度
msg = msg + softwareVersion + softwareVersionDate + CPUId + GMSType + GMS_IMEI
msg = msg + SIM_IMSI + SIM_ICCID + carType + VIN + totalMileage
msg = msg + totalOilExpend
msg = msg + totalOilExpend + displacement + oilDensity
return msg
#######################################################
......
......@@ -68,13 +68,19 @@ class SaloonCarOBD_data(MessageBase):
coolingLiquidLocation = "6706" + self.int2hexStringByBytes(2) + self.int2hexStringByBytes(65,2)
#续航里程 0.1 km ; 显示值为上传值/10
enduranceMileage = "6707" + self.int2hexStringByBytes(4) + self.int2hexStringByBytes(382,4)
#仪表里程
dashboardMileage = "6708" + self.int2hexStringByBytes(4) + self.int2hexStringByBytes(3500,4)
#车辆总运行时间
runTotalTime = "6709" + self.int2hexStringByBytes(4) + self.int2hexStringByBytes(7200000,4)
#总耗油量
totalOilExpend = "670a" + self.int2hexStringByBytes(4) + self.int2hexStringByBytes(3700000,4)
data = data + engineSpeed + carSpeed + surplusOil + coolingLiquidTemperature + airInletTemperature
data = data + intakeManifoldPressure + atmosphericPressure + envTemperature + acceleratorLocation + oilPressure
data = data + troubleCodeStatus + troubleCodeNum + airFlow + valveLocation + engineRunTime
data = data + troubleMileage + calculateLoadValue + fuelTrim + fireAngle + frontBrakeBlockAbrasion
data = data + backBrakeBlockAbrasion + brakeFluidLocation + engineOilLocation + tirePressureAlarm + coolingLiquidLocation
data = data + enduranceMileage
data = data + enduranceMileage + dashboardMileage + runTotalTime + totalOilExpend
return data
def generateSaloonCarOBDData_GUI(self,data):
dataHex = ""
......@@ -130,12 +136,18 @@ class SaloonCarOBD_data(MessageBase):
coolingLiquidLocation = "6706" + self.int2hexStringByBytes(2) + self.int2hexStringByBytes(int(data["coolingLiquidLocation"]),2)
#续航里程 0.1 km ; 显示值为上传值/10
enduranceMileage = "6707" + self.int2hexStringByBytes(4) + self.int2hexStringByBytes(int(data["enduranceMileage"]),4)
#仪表里程
dashboardMileage = "6708" + self.int2hexStringByBytes(4) + self.int2hexStringByBytes(int(data["dashboardMileage"]),4)
#车辆总运行时间
runTotalTime = "6709" + self.int2hexStringByBytes(4) + self.int2hexStringByBytes(int(data["runTotalTime"]),4)
#总耗油量
totalOilExpend = "670a" + self.int2hexStringByBytes(4) + self.int2hexStringByBytes(int(data["totalOilExpend"]),4)
dataHex = dataHex + engineSpeed + carSpeed + surplusOil + coolingLiquidTemperature + airInletTemperature
dataHex = dataHex + intakeManifoldPressure + atmosphericPressure + envTemperature + acceleratorLocation + oilPressure
dataHex = dataHex + troubleCodeStatus + troubleCodeNum + airFlow + valveLocation + engineRunTime
dataHex = dataHex + troubleMileage + calculateLoadValue + fuelTrim + fireAngle + frontBrakeBlockAbrasion
dataHex = dataHex + backBrakeBlockAbrasion + brakeFluidLocation + engineOilLocation + tirePressureAlarm + coolingLiquidLocation
dataHex = dataHex + enduranceMileage
dataHex = dataHex + enduranceMileage + dashboardMileage + runTotalTime + totalOilExpend
return dataHex
def generateSaloonCarOBDData_random(self):
data = ""
......@@ -191,13 +203,19 @@ class SaloonCarOBD_data(MessageBase):
coolingLiquidLocation = "6706" + self.int2hexStringByBytes(2) + self.int2hexStringByBytes(self.getRandomNum(0,65435),2)
#续航里程 0.1 km ; 显示值为上传值/10
enduranceMileage = "6707" + self.int2hexStringByBytes(4) + self.int2hexStringByBytes(self.getRandomNum(0,2147483648),4)
#仪表里程
dashboardMileage = "6708" + self.int2hexStringByBytes(4) + self.int2hexStringByBytes(self.getRandomNum(0,3500),4)
#车辆总运行时间
runTotalTime = "6709" + self.int2hexStringByBytes(4) + self.int2hexStringByBytes(self.getRandomNum(0,7200000),4)
#总耗油量
totalOilExpend = "670a" + self.int2hexStringByBytes(4) + self.int2hexStringByBytes(self.getRandomNum(0,3700000),4)
data = data + engineSpeed + carSpeed + surplusOil + coolingLiquidTemperature + airInletTemperature
data = data + intakeManifoldPressure + atmosphericPressure + envTemperature + acceleratorLocation + oilPressure
data = data + troubleCodeStatus + troubleCodeNum + airFlow + valveLocation + engineRunTime
data = data + troubleMileage + calculateLoadValue + fuelTrim + fireAngle + frontBrakeBlockAbrasion
data = data + backBrakeBlockAbrasion + brakeFluidLocation + engineOilLocation + tirePressureAlarm + coolingLiquidLocation
data = data + enduranceMileage
data = data + enduranceMileage + dashboardMileage + runTotalTime + totalOilExpend
return data
#####################################################
......
......@@ -75,11 +75,13 @@ class PlatefromVersionInfo_res(ResponseBase):
plateformCurrentTime = self.getBCD2GMTTime(body[:12]) #平台当前时间
carId = self.hexString2int(body[12:16]) #车型id
displacement = self.hexString2int(body[16:20]) #排量
isUpdate = body[20:] #是否升级,0x55 升级,其他不升级
isUpdate = body[20:22] #是否升级,0x55 升级,其他不升级
oilDensity = self.hexString2int(body[22:]) #油密度
json_body["plateformCurrentTime"] = plateformCurrentTime
json_body["carId"] = carId
json_body["displacement"] = displacement
json_body["isUpdate"] = isUpdate
json_body["oilDensity"] = oilDensity
return json_body
#######################################################
......
......@@ -624,6 +624,9 @@
<option value="1" selected="selected">存在胎压失压 </option></select></li>
<li><label>冷却液液位:</label><input id="coolingLiquidLocation" type="text" class="form-control" value="505"></li>
<li><label>续航里程:</label><input id="enduranceMileage" type="text" class="form-control" value="505"></li>
<li><label>仪表里程:</label><input id="dashboardMileage" type="text" class="form-control" value="3500"></li>
<li><label style="word-break:break-all;font-size:10px;">车辆总运行时间:</label><input id="runTotalTime" type="text" class="form-control" value="7200000"></li>
<li><label>总耗油量:</label><input id="totalOilExpend" type="text" class="form-control" value="3700000"></li>
</ul>
</div>
<div id="div_ext_FA" style="display:none;width:100%;border-width:1px;border-style:solid;border-color:darkgray;border-radius:10px;padding:2px;margin-top:5px;padding-left:10px;padding-right:10px;">
......@@ -1182,6 +1185,9 @@ function getExtra_EB(){
var tirePressureAlarm = $("#tirePressureAlarm").val();
var coolingLiquidLocation = $("#coolingLiquidLocation").val();
var enduranceMileage = $("#enduranceMileage").val();
var dashboardMileage = $("#dashboardMileage").val();
var runTotalTime = $("#runTotalTime").val();
var totalOilExpend = $("#totalOilExpend").val();
data["engineSpeed"] = engineSpeed;
data["carSpeed"] = carSpeed;
......@@ -1209,6 +1215,9 @@ function getExtra_EB(){
data["tirePressureAlarm"] = tirePressureAlarm;
data["coolingLiquidLocation"] = coolingLiquidLocation;
data["enduranceMileage"] = enduranceMileage;
data["dashboardMileage"] = dashboardMileage;
data["runTotalTime"] = runTotalTime;
data["totalOilExpend"] = totalOilExpend;
return data;
}
......
......@@ -30,6 +30,8 @@
<li><label style="word-break:break-all;font-size:12px;">汽车VIN码:</label><input id="VIN" type="text" class="form-control" value="VIN_1234567891234"></li>
<li><label style="word-break:break-all;font-size:12px;">装上终端后车辆累计总里程:</label><input id="totalMileage" type="text" class="form-control" value="389000"></li>
<li><label style="word-break:break-all;font-size:12px;">装上终端后车辆累计总耗油:</label><input id="totalOilExpend" type="text" class="form-control" value="420000"></li>
<li><label style="word-break:break-all;font-size:12px;">排量:</label><input id="displacement" type="text" class="form-control" value="1500"></li>
<li><label style="word-break:break-all;font-size:12px;">油密度:</label><input id="oilDensity" type="text" class="form-control" value="92"></li>
</ul>
<H3 style="border-bottom: 1px solid #eee;">控制:</H3>
<div style="width:100%;padding:5px;margin-top:10px;">
......@@ -67,6 +69,8 @@ $("#sendMsgBtn").click(function(){
var VIN = $("#VIN").val();
var totalMileage = $("#totalMileage").val();
var totalOilExpend = $("#totalOilExpend").val();
var displacement = $("#displacement").val();
var oilDensity = $("#oilDensity").val();
var data = {};
data["msgID"] = msgID;
......@@ -87,6 +91,8 @@ $("#sendMsgBtn").click(function(){
data["VIN"] = VIN;
data["totalMileage"] = totalMileage;
data["totalOilExpend"] = totalOilExpend;
data["displacement"] = displacement;
data["oilDensity"] = oilDensity;
var host = window.location.host;
$("#showFeedback").val("")
......
......@@ -142,12 +142,14 @@ def porcessTerminalVersionInfoUploadMsg():
VIN = request.form.get("VIN")
totalMileage = int(request.form.get("totalMileage"))
totalOilExpend = int(request.form.get("totalOilExpend"))
displacement = int(request.form.get("displacement"))
oilDensity = int(request.form.get("oilDensity"))
data = {}
if (msgID == None or phoneNum == None or msgWaterCode == None or encryptionType == None or subPkg == None \
or pkgCounts == None or softwareVersion == None or softwareVersionDate == None or CPUId == None or \
GMSType == None or GMS_IMEI == None or SIM_IMSI == None or SIM_ICCID == None or carType == None \
or VIN == None or totalMileage == None or totalOilExpend == None):
or VIN == None or totalMileage == None or totalOilExpend == None or displacement == None or oilDensity == None):
data["status"] = "4003"
data["message"] = "Info: 请检查是否传入了空数据!"
return Response(json.dumps(data), mimetype='application/json')
......@@ -160,7 +162,7 @@ def porcessTerminalVersionInfoUploadMsg():
terminalVersionInfoObj = TerminalVersionInfo_msg()
msg = terminalVersionInfoObj.generateMsg_GUI(msgID,phoneNum,msgWaterCode,encryptionType,subPkg,softwareVersion,\
softwareVersionDate,CPUId,GMSType,GMS_IMEI,SIM_IMSI,SIM_ICCID,carType,VIN,\
totalMileage,totalOilExpend)
totalMileage,totalOilExpend,displacement,oilDensity)
cliSocket.send(msg)
socRecv_1 = cliSocket.receive()
socRecv_2 = str(socRecv_1)
......@@ -169,7 +171,7 @@ def porcessTerminalVersionInfoUploadMsg():
data["message"] = "Sucess: "
data["original"] = msg
data["result"] = socRecv_2
msgP = PlatformCommon_res(socRecv_1)
msgP = PlatefromVersionInfo_res(socRecv_1)
data["resultH"] = msgP.getOriginalMsg()
data["parse"] = json.loads(msgP.getMsg())
except BaseException as e:
......@@ -470,24 +472,6 @@ def porcessDataUpstreamTransportMsg_F4():
def porcessLocationMsg():
params = request.get_data()
params = json.loads(params.decode("utf-8"))
# msgID = params["msgID"]
# phoneNum = params["phoneNum"]
# msgWaterCode = params["msgWaterCode"]
# encryptionType = params["encryptionType"]
# subPkg = params["subPkg"]
# pkgCounts = params["pkgCounts"]
# ########### 地理位置基础信息 #############
# baseInfo = params["baseInfo"]
# alarmFlag = baseInfo["alarmFlag"]
# status = baseInfo["status"]
# latitude = baseInfo["latitude"]
# longtitude = baseInfo["longtitude"]
# elevation = baseInfo["elevation"]
# speed = baseInfo["speed"]
# directionAngle = baseInfo["directionAngle"]
# infoTime = baseInfo["infoTime"]
# ########### 地理位置附加信息 #############
# extraInfo = params["extraInfo"]
data = {}
if (hasJsonDataIsNone(params)):
data["status"] = "4003"
......
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