Commit 6f1aebda authored by liyuanhong's avatar liyuanhong

完成OBD随机数据生成方法

parent 189f96aa
#模拟程序说明文档 # 模拟程序说明文档
####(一)、框架结构说明 #### (一)、框架结构说明
\ No newline at end of file \ No newline at end of file
...@@ -6,6 +6,8 @@ import threading ...@@ -6,6 +6,8 @@ import threading
import time import time
from lib.multiThread.ThreadBase import ThreadBase from lib.multiThread.ThreadBase import ThreadBase
from lib.protocol.message.Location_msg import Location_msg
from lib.protocol.message.TerminalRegister_msg import TerminalRegister_msg
class SendMultMsgThread(): class SendMultMsgThread():
...@@ -84,7 +86,13 @@ class SendMultMsgThread(): ...@@ -84,7 +86,13 @@ class SendMultMsgThread():
timeStart = int(time.time() * 1000) timeStart = int(time.time() * 1000)
for i in range(0,self.threadCount): for i in range(0,self.threadCount):
threadName = "thread" + str(i) threadName = "thread" + str(i)
theThread = threading.Thread(target=self.sendMsg,args=(self.msg,threadName,))
# theThread = threading.Thread(target=self.sendMsg, args=("7e0002000001314620111800065b7e",threadName,)) # 数据写死,心跳
# theThread = threading.Thread(target=self.sendMsg,args=("7e0200010908597573774756702ed057ac0016fb16010f4f5208e98691021700400024951202144709EA6600010400000000000204001e7c1f0003050A0001f400000405020001d4c000050400057d0240000604000119400007040007530000100c0004006403f203f203f203f2001114ffffffffffffffffffff00200000000000000000001202002400130106001D0101310160e07e", threadName,)) # 数据写死
theThread = threading.Thread(target=self.sendMsg, \
args=(TerminalRegister_msg().generateMsg_random(), threadName,)) #终端注册
# theThread = threading.Thread(target=self.sendMsg, \
# args=(Location_msg().generateMsg_random(), threadName,)) #地理位置
threadInfo = {} threadInfo = {}
threadInfo["name"] = threadName threadInfo["name"] = threadName
threadInfo["status"] = 0 threadInfo["status"] = 0
...@@ -92,11 +100,12 @@ class SendMultMsgThread(): ...@@ -92,11 +100,12 @@ class SendMultMsgThread():
theThread.start() theThread.start()
timeEnd = int(time.time() * 1000) timeEnd = int(time.time() * 1000)
timeExpend = timeEnd - timeStart timeExpend = timeEnd - timeStart
time.sleep(3)
print("耗时:" + str(timeExpend) + " 毫秒") print("耗时:" + str(timeExpend) + " 毫秒")
print("并发数据每秒发送:" + str(int(self.threadCount / (timeExpend / 1000)))) print("并发数据每秒发送:" + str(int(self.threadCount / (timeExpend / 1000))))
time.sleep(2)
print("平均响应时间:" + str(self.totalTime / self.threadCount) + "毫秒") print("平均响应时间:" + str(self.totalTime / self.threadCount) + "毫秒")
print("响应失败个数:" + str(self.failThreadCount)) print("发送总数:" + str(self.threadCount))
print("响应失败数:" + str(self.failThreadCount))
self.writeToFile("../../data/threadDetails.json",self.threadArr) self.writeToFile("../../data/threadDetails.json",self.threadArr)
# print(json.dumps( self.threadArr)) # print(json.dumps( self.threadArr))
...@@ -109,8 +118,8 @@ class SendMultMsgThread(): ...@@ -109,8 +118,8 @@ class SendMultMsgThread():
if __name__ == "__main__": if __name__ == "__main__":
t = SendMultMsgThread(msg="") t = SendMultMsgThread()
t.setMsg("7e0002000001314620111800065b7e") # t.setMsg("7e0002000001314620111800065b7e")
# t.setMsg("7e020001020131462011190001fffc7fff001c010401c0a6380659ad7a02090042003b200204185704310102EA6600010400000000000204001e7c1f0003050A0001f400000405020001d4c000050400057d0240000604000119400007040007530000100c0004006403f203f203f203f2001114ffffffffffffffffffff00200000000000000000001202002400130106001D0101EB7960C0020bb860D0013c62f00203216050014c60F0015860B001146330011c646001416490012060A00201146014010160100102610002022661100201f561F0020e746210040000119c6040012c60700200e660E00203206701010067020100670301016704024e20670502000067060200416707040000017d02097e") # t.setMsg("7e020001020131462011190001fffc7fff001c010401c0a6380659ad7a02090042003b200204185704310102EA6600010400000000000204001e7c1f0003050A0001f400000405020001d4c000050400057d0240000604000119400007040007530000100c0004006403f203f203f203f2001114ffffffffffffffffffff00200000000000000000001202002400130106001D0101EB7960C0020bb860D0013c62f00203216050014c60F0015860B001146330011c646001416490012060A00201146014010160100102610002022661100201f561F0020e746210040000119c6040012c60700200e660E00203206701010067020100670301016704024e20670502000067060200416707040000017d02097e")
t.startThread() t.startThread()
......
...@@ -188,7 +188,8 @@ class Location_msg(MessageBase): ...@@ -188,7 +188,8 @@ class Location_msg(MessageBase):
#油量,WORD,1/10L,对应车上油量表读数 #油量,WORD,1/10L,对应车上油量表读数
extra_02 = "02" + self.int2hexStringByBytes(2) + self.int2hexStringByBytes(self.getRandomNum(0,65535),2) extra_02 = "02" + self.int2hexStringByBytes(2) + self.int2hexStringByBytes(self.getRandomNum(0,65535),2)
#超速报警附加信息 #超速报警附加信息
extra_11 = "11" + self.int2hexStringByBytes(int(len(self.getOverSpeedAlarmExtraInfo_random()) / 2)) + self.getOverSpeedAlarmExtraInfo_random() data_11 = self.getOverSpeedAlarmExtraInfo_random()
extra_11 = "11" + self.int2hexStringByBytes(int(len(data_11) / 2)) + data_11
#进出区域/路线报警附加信息见 #进出区域/路线报警附加信息见
extra_12 = "12" + self.int2hexStringByBytes(6) + self.getInOutAreaAlarmExtraInfo_random() extra_12 = "12" + self.int2hexStringByBytes(6) + self.getInOutAreaAlarmExtraInfo_random()
#路段行驶时间不足/过长报警附加信息见 #路段行驶时间不足/过长报警附加信息见
...@@ -199,10 +200,12 @@ class Location_msg(MessageBase): ...@@ -199,10 +200,12 @@ class Location_msg(MessageBase):
extra_30 = "30" + self.int2hexStringByBytes(1) + self.int2hexStringByBytes(self.getRandomNum(0,255)) extra_30 = "30" + self.int2hexStringByBytes(1) + self.int2hexStringByBytes(self.getRandomNum(0,255))
#BYTE,GNSS 定位卫星数 #BYTE,GNSS 定位卫星数
extra_31 = "31" + self.int2hexStringByBytes(1) + self.int2hexStringByBytes(self.getRandomNum(0,255)) extra_31 = "31" + self.int2hexStringByBytes(1) + self.int2hexStringByBytes(self.getRandomNum(0,255))
data_EA = self.getBaseDataList_random()
#基础数据项列表 #基础数据项列表
extra_EA = "EA" + self.int2hexStringByBytes(int(len(self.getBaseDataList()) / 2)) + self.getBaseDataList() extra_EA = "EA" + self.int2hexStringByBytes(int(len(data_EA) / 2)) + data_EA
#轿车 OBD 数据流 #轿车 OBD 数据流
extra_EB = "EB" + self.int2hexStringByBytes(int(len(SaloonCarOBD_data().generateSaloonCarOBDData()) / 2)) + SaloonCarOBD_data().generateSaloonCarOBDData() data_EB = SaloonCarOBD_data().generateSaloonCarOBDData_random()
extra_EB = "EB" + self.int2hexStringByBytes(int(len(data_EB) / 2)) + data_EB
#货车 OBD 数据流 #货车 OBD 数据流
# extra_EC = "EC" + self.int2hexStringByBytes(int(len(TruckCarOBD_data().generateTruckCarOBD_data()) / 2)) + TruckCarOBD_data().generateTruckCarOBD_data() # extra_EC = "EC" + self.int2hexStringByBytes(int(len(TruckCarOBD_data().generateTruckCarOBD_data()) / 2)) + TruckCarOBD_data().generateTruckCarOBD_data()
#新能源 OBD 数据流 #新能源 OBD 数据流
...@@ -210,7 +213,8 @@ class Location_msg(MessageBase): ...@@ -210,7 +213,8 @@ class Location_msg(MessageBase):
#外设数据项列表 #外设数据项列表
# extra_EE = "EE" + self.int2hexStringByBytes(int(len(Circum_data().generateCircum_data()) / 2)) + Circum_data().generateCircum_data() # extra_EE = "EE" + self.int2hexStringByBytes(int(len(Circum_data().generateCircum_data()) / 2)) + Circum_data().generateCircum_data()
#报警事件 ID 数据项列表 #报警事件 ID 数据项列表
extra_FA = "FA" + self.int2hexStringByBytes(int(len(AlarmEvent_data().generateAlarmEvent_data()) / 2)) + AlarmEvent_data().generateAlarmEvent_data() data_FA = AlarmEvent_data().generateAlarmEvent_data_random()
extra_FA = "FA" + self.int2hexStringByBytes(int(len(data_FA) / 2)) + data_FA
arr = [] arr = []
arr.append(extra_01) arr.append(extra_01)
...@@ -369,8 +373,9 @@ class Location_msg(MessageBase): ...@@ -369,8 +373,9 @@ class Location_msg(MessageBase):
arr.append(dataId_001D) arr.append(dataId_001D)
mult = self.getRandomNum(0,12) mult = self.getRandomNum(0,12)
temp = [] temp = []
data = ""
for i in range(0, mult): for i in range(0, mult):
con = int(self.getRandomNum(intArr=arr)) con = self.getRandomNum(intArr=arr)
if con in temp: if con in temp:
con = "" con = ""
temp.append(con) temp.append(con)
......
...@@ -228,7 +228,7 @@ class MessageBase(Base): ...@@ -228,7 +228,7 @@ class MessageBase(Base):
return data return data
####################################################### #######################################################
# 获取一个随机数 # 获取一个随机数,也可以指定获取数组中的随机字符串
####################################################### #######################################################
def getRandomNum(self,s=1,e=1,intArr=[],mult=0): def getRandomNum(self,s=1,e=1,intArr=[],mult=0):
if intArr == []: if intArr == []:
...@@ -261,7 +261,7 @@ class MessageBase(Base): ...@@ -261,7 +261,7 @@ class MessageBase(Base):
num = random.choice(intArr) num = random.choice(intArr)
if num in temp: if num in temp:
# num = int(random.choice(intArr)) # num = int(random.choice(intArr))
num = 0 num = "0"
temp.append(num) temp.append(num)
data = data + num data = data + num
return data return data
......
...@@ -12,7 +12,7 @@ class AlarmEvent_data(MessageBase): ...@@ -12,7 +12,7 @@ class AlarmEvent_data(MessageBase):
pass pass
##################################################### #####################################################
# 创建轿车OBD数据 # 创建报警事件数据
##################################################### #####################################################
def generateAlarmEvent_data(self): def generateAlarmEvent_data(self):
data = "" data = ""
...@@ -59,6 +59,81 @@ class AlarmEvent_data(MessageBase): ...@@ -59,6 +59,81 @@ class AlarmEvent_data(MessageBase):
data = data + sharpBendAlarm + crashAlarm + rapidChangeLines data = data + sharpBendAlarm + crashAlarm + rapidChangeLines
return data return data
# 创建报警事件数据,数据随机产生
def generateAlarmEvent_data_random(self):
data = ""
ignition = "0001" + self.int2hexStringByBytes(0) #点火上报
flameout = "0002" + self.int2hexStringByBytes(0) #熄火上报
setUpDefences = "0003" + self.int2hexStringByBytes(0) #设防上报
withdrawGarrision = "0004" + self.int2hexStringByBytes(0) #撤防上报
doorOpen = "0005" + self.int2hexStringByBytes(0) #车门打开
doorClose = "0006" + self.int2hexStringByBytes(0) #车门关闭
systemStart = "0007" + self.int2hexStringByBytes(0) #系统启动
trailCarAlarm = "0101" + self.int2hexStringByBytes(0) #拖车报警
locationTooLong = "0102" + self.int2hexStringByBytes(0) #定位过长报警
terminalPullOut = "0103" + self.int2hexStringByBytes(0) #终端拔出报警
terminalInsert = "0104" + self.int2hexStringByBytes(0) #终端插入报警
lowVoltage = "0105" + self.int2hexStringByBytes(0) #低电压报警
#怠速过长报警 附带信息见 表 C6EXT1
idlingSpeedOver = "0106" + self.int2hexStringByBytes(9) + self.getIdlingSpeedOver_random()
#超速报警 附带信息见 表 C6EXT2
overspeedAlarm = "0107" + self.int2hexStringByBytes(9) + self.getOverspeedAlarm_random()
#疲劳驾驶报警 附带信息见 表 C6EXT3
fatigueDriving = "0108" + self.int2hexStringByBytes(5) + self.getFatigueDriving_random()
#水温报警 附带信息见 表 C6EXT4
waterTemperatureAlarm = "0109" + self.int2hexStringByBytes(9) + self.getWaterTemperatureAlarm_random()
highSpeedNeutralGear = "010A" + self.int2hexStringByBytes(0) #高速空档滑行报警
oilExpendNotSurport = "010B" +self.int2hexStringByBytes(0) #油耗不支持报警
OBDNotSurport = "010C" + self.int2hexStringByBytes(0) #OBD 不支持报警
lowWaterTemperatureHighSpeed = "010D" +self.int2hexStringByBytes(0) #低水温高转速
buslineNotSleep = "010E" + self.int2hexStringByBytes(0) #总线不睡眠报警
illegalOpenDoor = "010f" + self.int2hexStringByBytes(0) #非法开门
illegalFire = "0110" + self.int2hexStringByBytes(0) #非法点火
rapidAccelerateAlarm = "0111" + self.int2hexStringByBytes(0) #急加速报警
sharpSlowdownAlarm = "0112" + self.int2hexStringByBytes(0) #急减速报警
sharpBendAlarm = "0113" + self.int2hexStringByBytes(0) #急拐弯报警
crashAlarm = "0114" + self.int2hexStringByBytes(0) #碰撞报警
rapidChangeLines = "0115" + self.int2hexStringByBytes(0) #急变道报警
arr = []
arr.append(ignition)
arr.append(flameout)
arr.append(setUpDefences)
arr.append(withdrawGarrision)
arr.append(doorOpen)
arr.append(doorClose)
arr.append(systemStart)
arr.append(trailCarAlarm)
arr.append(locationTooLong)
arr.append(terminalPullOut)
arr.append(terminalInsert)
arr.append(lowVoltage)
arr.append(idlingSpeedOver)
arr.append(overspeedAlarm)
arr.append(fatigueDriving)
arr.append(waterTemperatureAlarm)
arr.append(highSpeedNeutralGear)
arr.append(oilExpendNotSurport)
arr.append(OBDNotSurport)
arr.append(lowWaterTemperatureHighSpeed)
arr.append(buslineNotSleep)
arr.append(illegalOpenDoor)
arr.append(illegalFire)
arr.append(rapidAccelerateAlarm)
arr.append(sharpSlowdownAlarm)
arr.append(sharpBendAlarm)
arr.append(crashAlarm)
arr.append(rapidChangeLines)
mult = self.getRandomNum(0, 28)
temp = []
for i in range(0, mult):
con = self.getRandomNum(intArr=arr, mult=1)
if con in temp:
con = ""
temp.append(con)
data = data + con
return data
##################################################### #####################################################
# 获取怠速过长附带信息 # 获取怠速过长附带信息
##################################################### #####################################################
...@@ -75,6 +150,19 @@ class AlarmEvent_data(MessageBase): ...@@ -75,6 +150,19 @@ class AlarmEvent_data(MessageBase):
idlingEngineMinSpeed = self.int2hexStringByBytes(500,2) idlingEngineMinSpeed = self.int2hexStringByBytes(500,2)
data = alarmType + idlingTimeOfDuration + idlingOilExpend + idlingEngineMaxSpeed + idlingEngineMinSpeed data = alarmType + idlingTimeOfDuration + idlingOilExpend + idlingEngineMaxSpeed + idlingEngineMinSpeed
return data return data
def getIdlingSpeedOver_random(self):
#报警属性 1:报警触发(无下面的数据内容项)0:报警解除(有下面的数据内容项)
alarmType = self.int2hexStringByBytes(self.getRandomNum(intArr=[0,1]))
#怠速持续时间 怠速持续的时间(含报警前的预判时间),单位为秒
idlingTimeOfDuration = self.int2hexStringByBytes(self.getRandomNum(0,65535),2)
#怠速耗油量 单位 mL
idlingOilExpend = self.int2hexStringByBytes(self.getRandomNum(0,65535),2)
#怠速最高转速 单位 RPM
idlingEngineMaxSpeed = self.int2hexStringByBytes(self.getRandomNum(0,65535),2)
#怠速最低转速 单位 RPM
idlingEngineMinSpeed = self.int2hexStringByBytes(self.getRandomNum(0,65535),2)
data = alarmType + idlingTimeOfDuration + idlingOilExpend + idlingEngineMaxSpeed + idlingEngineMinSpeed
return data
##################################################### #####################################################
# 获取超速报警信息 # 获取超速报警信息
...@@ -92,6 +180,19 @@ class AlarmEvent_data(MessageBase): ...@@ -92,6 +180,19 @@ class AlarmEvent_data(MessageBase):
overspeedDistance = self.int2hexStringByBytes(10000,2) overspeedDistance = self.int2hexStringByBytes(10000,2)
data = alarmType + overspeedTimeOfDuration + maxSpeed + averageSpeed + overspeedDistance data = alarmType + overspeedTimeOfDuration + maxSpeed + averageSpeed + overspeedDistance
return data return data
def getOverspeedAlarm_random(self):
#报警属性 1 BYTE 1:报警触发(无下面的数据内容项) 0:报警解除(有下面的数据内容项)
alarmType = self.int2hexStringByBytes(self.getRandomNum(intArr=[0,1]))
#超速持续时间 2 WORD 怠速持续的时间(含报警前的预判时间),单位为秒
overspeedTimeOfDuration = self.int2hexStringByBytes(self.getRandomNum(0,65535),2)
#最高车速 2 WORD 单位 0.1KM/H
maxSpeed = self.int2hexStringByBytes(self.getRandomNum(0,65535),2)
#平均车速 2 WORD 单位 0.1KM/H
averageSpeed = self.int2hexStringByBytes(self.getRandomNum(0,65535),2)
#超速行驶距离 2 WORD 单位米
overspeedDistance = self.int2hexStringByBytes(self.getRandomNum(0,65535),2)
data = alarmType + overspeedTimeOfDuration + maxSpeed + averageSpeed + overspeedDistance
return data
##################################################### #####################################################
# 获取疲劳驾驶报警附带信息 # 获取疲劳驾驶报警附带信息
...@@ -103,6 +204,13 @@ class AlarmEvent_data(MessageBase): ...@@ -103,6 +204,13 @@ class AlarmEvent_data(MessageBase):
totalContinueDrivingTime = self.int2hexStringByBytes(21000,4) totalContinueDrivingTime = self.int2hexStringByBytes(21000,4)
data = alarmType + totalContinueDrivingTime data = alarmType + totalContinueDrivingTime
return data return data
def getFatigueDriving_random(self):
#报警属性 1 BYTE 1:报警触发(无下面的数据内容项) 0:报警解除(有下面的数据内容项)
alarmType = self.int2hexStringByBytes(self.getRandomNum(intArr=[0,1]))
#累计持续驾驶时间 4 DWORD 车辆点火行驶到报警解除的累计行驶时间,单位为秒
totalContinueDrivingTime = self.int2hexStringByBytes(self.getRandomNum(0,2147483648),4)
data = alarmType + totalContinueDrivingTime
return data
##################################################### #####################################################
# 获取疲劳驾驶报警附带信息 # 获取疲劳驾驶报警附带信息
...@@ -118,6 +226,17 @@ class AlarmEvent_data(MessageBase): ...@@ -118,6 +226,17 @@ class AlarmEvent_data(MessageBase):
averageTemperature = self.int2hexStringByBytes(55,2) averageTemperature = self.int2hexStringByBytes(55,2)
data = alarmType + timeOfDuration + maxTemperature + averageTemperature data = alarmType + timeOfDuration + maxTemperature + averageTemperature
return data return data
def getWaterTemperatureAlarm_random(self):
#报警属性 1 BYTE 1:报警触发(无下面的数据内容项) 0:报警解除(有下面的数据内容项)
alarmType = self.int2hexStringByBytes(self.getRandomNum(intArr=[0,1]))
#持续时长 4 DWORD 单位秒
timeOfDuration = self.int2hexStringByBytes(self.getRandomNum(0,2147483648),4)
#最高温度 2 WORD 单位 0.1 度
maxTemperature = self.int2hexStringByBytes(self.getRandomNum(0,2500),2)
#平均温度 2 WORD 单位 0.1 度
averageTemperature = self.int2hexStringByBytes(self.getRandomNum(0,1500),2)
data = alarmType + timeOfDuration + maxTemperature + averageTemperature
return data
if __name__ == "__main__": if __name__ == "__main__":
print(AlarmEvent_data().generateAlarmEvent_data()) print(AlarmEvent_data().generateAlarmEvent_data())
......
...@@ -69,6 +69,68 @@ class SaloonCarOBD_data(MessageBase): ...@@ -69,6 +69,68 @@ class SaloonCarOBD_data(MessageBase):
#续航里程 0.1 km ; 显示值为上传值/10 #续航里程 0.1 km ; 显示值为上传值/10
enduranceMileage = "6707" + self.int2hexStringByBytes(4) + self.int2hexStringByBytes(382,4) enduranceMileage = "6707" + self.int2hexStringByBytes(4) + self.int2hexStringByBytes(382,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
return data
def generateSaloonCarOBDData_random(self):
data = ""
#发动机转速 , 0 - 8000 rpm
engineSpeed = "60C0" + self.int2hexStringByBytes(2) + self.int2hexStringByBytes(self.getRandomNum(0,8000),2)
#车速 , 0 - 240 Km/h
carSpeed = "60D0" + self.int2hexStringByBytes(1) + self.int2hexStringByBytes(self.getRandomNum(0,240))
#剩余油量 ,剩余油量,单位 L 或%Bit15=0 百分比%,OBD 都为百分比Bit15=1 单位 L,显示值为上传值/10
surplusOil = "62f0" + self.int2hexStringByBytes(2) + self.getSurplusOil_random()
#冷却液温度 ,-40.0℃ 到 +210℃,上传值减去 40
coolingLiquidTemperature = "6050" + self.int2hexStringByBytes(1) + self.int2hexStringByBytes(self.getRandomNum(0,250))
#进气口温度 ,-40.0℃ 到 +210℃,上传值减去 40
airInletTemperature = "60F0" + self.int2hexStringByBytes(1) + self.int2hexStringByBytes(self.getRandomNum(0,250))
#进气(岐管绝对)压力 , 0 - 250kpa
intakeManifoldPressure = "60B0" + self.int2hexStringByBytes(1) + self.int2hexStringByBytes(self.getRandomNum(0,250))
#大气压力 , 0 - 125kpa
atmosphericPressure = "6330" + self.int2hexStringByBytes(1) + self.int2hexStringByBytes(self.getRandomNum(0,125))
#环境温度 , -40.0℃ 到 +210℃,上传值减去 40
envTemperature = "6460" + self.int2hexStringByBytes(1) + self.int2hexStringByBytes(self.getRandomNum(0,250))
#加速踏板位置 , 0% - 100%
acceleratorLocation = "6490" + self.int2hexStringByBytes(1) + self.int2hexStringByBytes(self.getRandomNum(0,100))
#燃油压力 , 0 - 500kpa
oilPressure = "60A0" + self.int2hexStringByBytes(2) + self.int2hexStringByBytes(self.getRandomNum(0,500),2)
#故障码状态 , 发动机故障码状态
troubleCodeStatus = "6014" + self.int2hexStringByBytes(1) + self.int2hexStringByBytes(self.getRandomNum(intArr=[0,1]))
#故障码个数
troubleCodeNum = "6010" + self.int2hexStringByBytes(1) + self.int2hexStringByBytes(self.getRandomNum(0,255))
#空气流量 , 0.1 实际值为上传值/10 0.1g/s
airFlow = "6100" + self.int2hexStringByBytes(2) + self.int2hexStringByBytes(self.getRandomNum(0,65535),2)
#绝对气门位置
valveLocation = "6110" + self.int2hexStringByBytes(2) + self.int2hexStringByBytes(self.getRandomNum(0,65535),2)
#自发动机启动运行时间 sec
engineRunTime = "61F0" + self.int2hexStringByBytes(2) + self.int2hexStringByBytes(self.getRandomNum(0,65535),2)
#故障行驶里程 , Km
troubleMileage = "6210" + self.int2hexStringByBytes(4) + self.int2hexStringByBytes(self.getRandomNum(0,2147483648),4)
#计算负荷值
calculateLoadValue = "6040" + self.int2hexStringByBytes(1) + self.int2hexStringByBytes(self.getRandomNum(0,255))
#长期燃油修正(气缸列 1 和 3)
fuelTrim = "6070" + self.int2hexStringByBytes(2) + self.int2hexStringByBytes(self.getRandomNum(0,65535),2)
#第一缸点火正时提前角 ,显示值为上传值-64
fireAngle = "60E0" + self.int2hexStringByBytes(2) + self.int2hexStringByBytes(self.getRandomNum(0,65435),2)
#前刹车片磨损 , 0 正常/否则,显示对应数据,单位:级
frontBrakeBlockAbrasion = "6701" + self.int2hexStringByBytes(1) + self.int2hexStringByBytes(self.getRandomNum(0,255))
#后刹车片磨损 , 0 正常/否则,显示对应数据,单位:级
backBrakeBlockAbrasion = "6702" + self.int2hexStringByBytes(1) + self.int2hexStringByBytes(self.getRandomNum(0,255))
#制动液液位 , 0:不正 1:正常 其他:无法使用
brakeFluidLocation = "6703" + self.int2hexStringByBytes(1) + self.int2hexStringByBytes(self.getRandomNum(intArr=[0,1]))
#机油液位 , 显示值为上传值/1000 单位 毫米
engineOilLocation = "6704" + self.int2hexStringByBytes(2) + self.int2hexStringByBytes(self.getRandomNum(0,65535),2)
#胎压报警 0:当前无警告 1:存在胎压失压 其他:不可用
tirePressureAlarm = "6705" + self.int2hexStringByBytes(2) + self.int2hexStringByBytes(self.getRandomNum(intArr=[0,1]),2)
#冷却液液位 , 显示值为上传值-48
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)
data = data + engineSpeed + carSpeed + surplusOil + coolingLiquidTemperature + airInletTemperature data = data + engineSpeed + carSpeed + surplusOil + coolingLiquidTemperature + airInletTemperature
data = data + intakeManifoldPressure + atmosphericPressure + envTemperature + acceleratorLocation + oilPressure data = data + intakeManifoldPressure + atmosphericPressure + envTemperature + acceleratorLocation + oilPressure
data = data + troubleCodeStatus + troubleCodeNum + airFlow + valveLocation + engineRunTime data = data + troubleCodeStatus + troubleCodeNum + airFlow + valveLocation + engineRunTime
...@@ -87,6 +149,13 @@ class SaloonCarOBD_data(MessageBase): ...@@ -87,6 +149,13 @@ class SaloonCarOBD_data(MessageBase):
data = units + surplusOil data = units + surplusOil
dataHex = self.int2hexStringByBytes(data,2) dataHex = self.int2hexStringByBytes(data,2)
return dataHex return dataHex
def getSurplusOil_random(self):
# 剩余油量 ,剩余油量,单位L或% ; Bit15=0 百分比%,OBD都为百分比 ;Bit15=1 单位 L,显示值为上传值/10 (32768)
units = self.getRandomNum(intArr=[0,32768])
surplusOil = self.getRandomNum(0,16384)
data = units + surplusOil
dataHex = self.int2hexStringByBytes(data,2)
return dataHex
if __name__ == "__main__": if __name__ == "__main__":
......
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