def main(): dsUnitIndexFilePath = u"../../txt/DsUnitIndex.txt" tt = TextTool(u"../../txt/中国通用/Type1/Ds.txt") unitDict = {} #单位索引 和 标志 组成的字典 rt = ReadText(dsUnitIndexFilePath, 1) for k, vList in rt.items(): # print(k + "\t" + vList[0]) unitDict[k] = vList[0] allSectDict = tt.allSectDictOfFile for sectKey in allSectDict: sectDict = allSectDict[sectKey] # print ('{0}'.format(sectKey)) for filedKey in sectDict: filedDict = sectDict[filedKey] # print ('[{0}]'.format(filedKey)) for keyPairKey in filedDict: if ("Item" not in keyPairKey) or (keyPairKey == "ItemNum"): continue splitedList = filedDict[keyPairKey][0].split(',') if (len(splitedList) > 0): try: tmpDsUnitIndex = splitedList[1].upper() flag = unitDict[tmpDsUnitIndex] #直接获取, 如果没有,引发异常 except: #print(splitedList) print(sectKey + "\t" + filedKey + "\t" + keyPairKey) print("error!!!!") continue if flag.strip() == '0': addStr = "82FF" elif flag.strip() == '1': addStr = "8250" elif tmpDsUnitIndex == "NULL": continue else: print(tmpDsUnitIndex) print("$$$$$$$$$$$") continue #加82FF 或者 8250 newSplitedList = splitedList newSplitedList[0] = addStr + splitedList[ 0] #数据流文本 加 82FF 或者 8250 newSplitedList[1] = addStr + splitedList[ 1] #数据流单位 加 82FF 或者 8250 newJoinedStr = ','.join(newSplitedList) #以逗号分隔 filedDict[keyPairKey][0] = newJoinedStr #放回去 pass #for tt.WriteFile("../../doc/tmp/new_Type1_Ds.txt") #输出已经修改了的 pass #def
def main2(): tt = TextTool(gInDir) allSectDict = tt.allSectDictOfFile for sectKey in allSectDict: sectDict = allSectDict[sectKey] try: mode = sectDict["INFORMATION"]["InfoMode"][0] if mode != "0003": continue else: print ('{0}'.format(sectKey)) for filedKey in sectDict: filedDict = sectDict[filedKey] print ('[{0}]'.format(filedKey)) for keyPairKey in filedDict: for listItem in filedDict[keyPairKey]: print('{0}={1}'.format(keyPairKey, listItem)) print ('\n') except: pass pass pass
def main(): dtcPath = u"../../txt/中国通用/Type1/Dtc.txt" tt = TextTool(dtcPath) #tt.ShowAll() cmdList = [] allSectDict = tt.allSectDictOfFile for sectKey in allSectDict: sectDict = allSectDict[sectKey] #print ('{0}'.format(sectKey)) if "ReadDtc" in sectDict: try: dtcCmd = sectDict["ReadDtc"]["Cmd"][0] if dtcCmd not in cmdList: cmdList.append(dtcCmd) #print(sectDict["ReadDtc"]["Cmd"][0]) except: pass cmdList = sorted(cmdList) for cmd in cmdList: print(cmd) pass pass
def main1(): tt = TextTool(gInDir) # tt.ShowAll() # def ShowAll(self): ''' :return: 无 打印 ''' indexList = [] with open(u"../../txt/版本信息的索引.txt") as inFile: for line in inFile.readlines(): indexList.append(line.strip()) allSectDict = tt.allSectDictOfFile for sectKey in allSectDict: sectDict = allSectDict[sectKey] # print ('{0}'.format(sectKey)) try: mode = int(sectDict["INFORMATION"]["InfoMode"][0], 10) if mode == 3: try: if("InfoCmd" in sectDict["INFORMATION"]): if Del0x(sectKey) in indexList: print(Del0x(sectKey)) pass except: pass pass except: pass pass
def main(): tt = TextTool(u"../../txt/中国通用/Type1/Ds.txt") #tt.ShowAll() allSectDict = tt.allSectDictOfFile for sectKey in allSectDict: if(sectKey.split(',')[0] != "0x20"): continue sectDict = allSectDict[sectKey] #print ('{0}'.format(sectKey)) if "DATASTREAM" in sectDict: if "Menu" in sectDict["DATASTREAM"]: strValue = sectDict["DATASTREAM"]["Menu"][0] subMenuTitleList = strValue.split(',') if len(subMenuTitleList) > 1: print(sectKey) #结论: 所有在 8250中查找的数据流, 都只有一个 数据流子菜单 pass
def main(): tt = TextTool(gDtcPath) #tt.ShowAll() allSectDict = tt.allSectDictOfFile for sectKey in allSectDict: sectDict = allSectDict[sectKey] #print ('{0}'.format(sectKey)) try: pass except: pass tt.WriteFile("../doc/tmp/2018_01_20_Dtc.txt") pass
def main(): tt = TextTool(u"../../txt/中国通用/Type1/Ds.txt") cn_text_Path = u"../../txt/中国通用/cn_text.txt" rtp = ReadTextPlus(cn_text_Path, 2) unitSet = set() #单位索引的集合 allSectDict = tt.allSectDictOfFile for sectKey in allSectDict: sectDict = allSectDict[sectKey] #print ('{0}'.format(sectKey)) for filedKey in sectDict: filedDict = sectDict[filedKey] #print ('[{0}]'.format(filedKey)) for keyPairKey in filedDict: if("Item" not in keyPairKey): continue splitedList = filedDict[keyPairKey][0].split(',') if (len(splitedList) != 0): unitSet.add(splitedList[1].upper()) #print ('\n') with open("../../doc/tmp/unit_text.txt", "w") as outFile: for unitIndex in unitSet: textStr82FF = "" textStr8250 = "" retList82FF = GetTextFromTextLib("82FF" + unitIndex, rtp) if (len(retList82FF) == 0): textStr82FF = "null" else: textStr82FF = retList82FF[0].strip().replace('"', '') retList8250 = GetTextFromTextLib("8250" + unitIndex, rtp) if (len(retList8250) == 0): textStr8250 = "null" else: textStr8250 = retList8250[0].strip().replace('"', '') print(unitIndex + "\t" + textStr82FF + "\t" + textStr8250) outFile.write(unitIndex + "\t" + textStr82FF + "\t" + textStr8250 + "\t" + " " +"\n") pass
def main(): tt = TextTool(gDtcPath) #tt.ShowAll() allSectDict = tt.allSectDictOfFile for sectKey in allSectDict: sectDict = allSectDict[sectKey] #print ('{0}'.format(sectKey)) try: menu = sectDict["Protocol"]["Menu"][0] if menu.upper() == "READDTC": if "ClearDtc" in sectDict: if "Cmd" in sectDict["ClearDtc"]: #替换掉 tt.allSectDictOfFile[sectKey]["Protocol"]["Menu"] = [ "ReadDtc,ClearDtc" ] pass except: pass tt.WriteFile("../doc/tmp/2018_01_17_Dtc.txt") pass
def main(): tt = TextTool(u"../txt/中国通用/Type1/Ds.txt") # tt.ShowAll() allSectDict = tt.allSectDictOfFile for sectKey in allSectDict: sectDict = allSectDict[sectKey] print ('{0}'.format(sectKey)) for filedKey in sectDict: filedDict = sectDict[filedKey] print ('[{0}]'.format(filedKey)) for keyPairKey in filedDict: for listItem in filedDict[keyPairKey]: print('{0}={1}'.format(keyPairKey, listItem)) print ('\n') pass
def main(): indexList = [] with open(u"../../txt/版本信息的索引.txt") as inFile: for line in inFile.readlines(): indexList.append(line.strip()) tt = TextTool(u"../../txt/中国通用/Type1/Information.txt") #tt.ShowAll() # def ShowAll(self): # ''' # :return: 无 # 打印 # ''' allSectDict = tt.allSectDictOfFile iCount = 0 for sectKey in allSectDict: sectDict = allSectDict[sectKey] if "INFORMATION" in sectDict: try: menuStr = sectDict["INFORMATION"]["Menu"][0] if ("0X") in menuStr.upper(): #print(Del0x(sectKey)) if Del0x(sectKey) in indexList: print(sectKey) iCount += 1 else: print(">>>{0}".format(sectKey)) except: pass print(iCount) pass
import os import datetime beginTime = datetime.datetime.now() gIndexPath = u"../../txt/中国通用/RootMenuIndex.txt" gType1List = [ "00000100" , "00000200", "00000300" ,"00000400"\ ,"00000500" , "00000600" , "00000700" , "00000102"\ , "000012FE" ] gT1DtcTT = TextTool(u"../../txt/中国通用/Type1/Dtc.txt") gT1DsTT = TextTool(u"../../txt/中国通用/Type1/Ds.txt") gT1InfoTT = TextTool(u"../../txt/中国通用/Type1/Information.txt") gThreadCount = 256 gLinesList = [] gThreadOutputPath = u"../../doc/tmp/threadOutput" gOutputDict = {} gOutputFilePath = u"../../doc/tmp/中国通用车型表_1208.txt" def Type1_DTC(index): d = gT1DtcTT.allSectDictOfFile
def main(): GetEcuIdList(u"../../txt/中国通用_所有索引.txt") infoFilePath = u"../../txt/中国通用/Type1/Information.txt" tt = TextTool(infoFilePath) #tt.ShowAll() with open(u"../../doc/tmp/中国通用_版本信息表_12_13.txt", "w") as outFile: allSectDict = tt.allSectDictOfFile for sectKey in allSectDict: if Del0x(sectKey) not in gEcuIdList: continue sectDict = allSectDict[sectKey] #print ('{0}\t'.format(Del0x(sectKey))), #索引 if "INFORMATION" in sectDict: if "InfoMode" in sectDict["INFORMATION"]: outFile.write('{0}\t'.format(Del0x(sectKey))) outFile.write('{0}\t'.format( sectDict["INFORMATION"]["InfoMode"][0])) elif "Menu" in sectDict["INFORMATION"]: tmpStr = sectDict["INFORMATION"]["Menu"][0] for tmpAddr in tmpStr.split(","): outFile.write('{0}\t'.format(Del0x(sectKey))) if tmpAddr in sectDict: if "InfoMode" in sectDict[tmpAddr]: outFile.write('{0}\t'.format( sectDict[tmpAddr]["InfoMode"][0])) if "Protocol" in sectDict: if "Protocol" in sectDict["Protocol"]: outFile.write('{0}\t'.format( sectDict["Protocol"]["Protocol"][0])) if "ToolID" in sectDict["Protocol"]: outFile.write('{0}\t'.format( sectDict["Protocol"]["ToolID"][0])) if "EcuID" in sectDict["Protocol"]: outFile.write('{0}\t'.format( sectDict["Protocol"]["EcuID"][0])) if "DStreamCmd" in sectDict[tmpAddr]: outFile.write('{0}\t'.format( sectDict[tmpAddr]["DStreamCmd"][0])) outFile.write("\n") continue #继续后面的 if "Protocol" in sectDict: if "Protocol" in sectDict["Protocol"]: outFile.write('{0}\t'.format( sectDict["Protocol"]["Protocol"][0])) if "ToolID" in sectDict["Protocol"]: outFile.write('{0}\t'.format( sectDict["Protocol"]["ToolID"][0])) if "EcuID" in sectDict["Protocol"]: outFile.write('{0}\t'.format( sectDict["Protocol"]["EcuID"][0])) if "INFORMATION" in sectDict: if "DStreamCmd" in sectDict["INFORMATION"]: outFile.write('{0}\t'.format( sectDict["INFORMATION"]["DStreamCmd"][0])) outFile.write("\n") pass
def CheckDsText(path, inDict1, inDict2): ''' 检查菜单 :param path: :param inDict1: :param inDict2: cn_text.txt字典 :return: ''' tt = TextTool(path) # def ShowAll(self): # ''' # :return: 无 # 打印 # ''' # # allSectDict = self.allSectDictOfFile # for sectKey in allSectDict: # sectDict = allSectDict[sectKey] # print ('{0}'.format(sectKey)) # for filedKey in sectDict: # filedDict = sectDict[filedKey] # print ('[{0}]'.format(filedKey)) # for keyPairKey in filedDict: # for listItem in filedDict[keyPairKey]: # print('{0}={1}'.format(keyPairKey, listItem)) # print ('\n') # pass _8250List = set() _82FFList = set() allSectDict = tt.allSectDictOfFile for sectKey in allSectDict: sectDict = allSectDict[sectKey] mode = -1 for filedKey in sectDict: filedDict = sectDict[filedKey] if ("DStreamCmd" in filedDict): mode = 1 break if ("ScanCmd" in filedDict): mode = 2 break for filedKey in sectDict: filedDict = sectDict[filedKey] num = 0 if ("Num" in filedDict): num = int(filedDict["Num"][0][2:], 16) # 获取item个数, 转成十进制 for keyPairKey in filedDict: if "Item" in keyPairKey: #print(filedDict[keyPairKey][0]) tmpStr = filedDict[keyPairKey][0] dsText = tmpStr.split(',')[0] #获取数据流文本索引 if mode == 1: if Add0x("82FF" + dsText.upper()) not in inDict2: #print (sectKey + "不在82FF") #print(dsText) _82FFList.add(sectKey) break if mode == 2: if Add0x("8250" + dsText.upper()) not in inDict2: # if(dsText[0] != '4'): # try: # if(int(dsText, 16) < 0x5003): # print(dsText + "不在8250") # except: # pass #print(sectKey + "不在8250") _8250List.add(sectKey) break for _8250 in _8250List: #print(_8250 + " 不在8250") pass # print(len(_8250List)) for _82FF in _82FFList: #print(_82FF + " 不在82FF") pass # for _82 return _8250List pass