Command linked to the frames
This commit is contained in:
parent
a3707c21ba
commit
3138414533
@ -219,13 +219,19 @@ def run( elm, ecu, command, data ):
|
|||||||
buttons["exit"] = '<exit>'
|
buttons["exit"] = '<exit>'
|
||||||
|
|
||||||
#Get commands
|
#Get commands
|
||||||
commands = {}
|
commands = OrderedDict()
|
||||||
|
|
||||||
for child in root:
|
for child in root:
|
||||||
if child.attrib["name"] == "Commands":
|
if child.attrib["name"] == "Commands":
|
||||||
if len(child.keys()) == 1:
|
if len(child.keys()) == 1:
|
||||||
for param in child:
|
for param in child:
|
||||||
commands[param.attrib["name"]] = param.attrib["value"]
|
serviceIDs = ecu.get_ref_cmd(param.attrib["value"]).serviceID
|
||||||
|
startReq = ""
|
||||||
|
for sid in serviceIDs:
|
||||||
|
if ecu.Services[sid].params:
|
||||||
|
startReq = ecu.Services[sid].startReq
|
||||||
|
break
|
||||||
|
commands[param.attrib["name"]] = {"command": param.attrib["value"], "startReq": startReq}
|
||||||
|
|
||||||
#Get identifications
|
#Get identifications
|
||||||
identsList = OrderedDict()
|
identsList = OrderedDict()
|
||||||
@ -236,7 +242,6 @@ def run( elm, ecu, command, data ):
|
|||||||
key = param[6:-5]
|
key = param[6:-5]
|
||||||
begin = int(ScmParam['Idents'+key+'Begin'])
|
begin = int(ScmParam['Idents'+key+'Begin'])
|
||||||
end = int(ScmParam['Idents'+key+'End'])
|
end = int(ScmParam['Idents'+key+'End'])
|
||||||
identsRangeKeys[key] = {"begin": begin, "end": end}
|
|
||||||
try: #10099 trap
|
try: #10099 trap
|
||||||
identsList['D'+str(begin)] = ScmParam['Ident'+str(begin)]
|
identsList['D'+str(begin)] = ScmParam['Ident'+str(begin)]
|
||||||
except:
|
except:
|
||||||
@ -244,6 +249,8 @@ def run( elm, ecu, command, data ):
|
|||||||
else:
|
else:
|
||||||
for idnum in range(begin ,end + 1):
|
for idnum in range(begin ,end + 1):
|
||||||
identsList['D'+str(idnum)] = ScmParam['Ident'+str(idnum)]
|
identsList['D'+str(idnum)] = ScmParam['Ident'+str(idnum)]
|
||||||
|
frame = ecu.Mnemonics[ecu.get_ref_id(identsList['D'+str(begin)]).mnemolist[0]].request
|
||||||
|
identsRangeKeys[key] = {"begin": begin, "end": end, "frame": frame}
|
||||||
|
|
||||||
def getValuesToChange(resetItem):
|
def getValuesToChange(resetItem):
|
||||||
params = {}
|
params = {}
|
||||||
@ -254,15 +261,40 @@ def run( elm, ecu, command, data ):
|
|||||||
params[param.attrib["name"].replace("D0", "D")] = param.attrib["value"]
|
params[param.attrib["name"].replace("D0", "D")] = param.attrib["value"]
|
||||||
return params
|
return params
|
||||||
|
|
||||||
def getValuesFromEcu(rangeKey):
|
def takesParams(request):
|
||||||
paramToSend = ""
|
for cmd in commands.values():
|
||||||
idRangeKey = identsRangeKeys[identsRangeKeys.keys()[rangeKey]]
|
if cmd['startReq'] == request:
|
||||||
|
commandToRun = cmd['command']
|
||||||
|
return commandToRun
|
||||||
|
|
||||||
for idKey in range(idRangeKey['begin'], idRangeKey['end'] + 1):
|
def getValuesFromEcu(params):
|
||||||
|
paramToSend = ""
|
||||||
|
commandToRun = ""
|
||||||
|
requestToFindInCommandsRequests = ""
|
||||||
|
|
||||||
|
try:
|
||||||
|
idKeyToFindInRange = int((params.keys()[0]).replace("D",""))
|
||||||
|
except:
|
||||||
|
return commandToRun, paramToSend
|
||||||
|
else:
|
||||||
|
for rangeK in identsRangeKeys.keys():
|
||||||
|
if identsRangeKeys[rangeK]['begin'] <= idKeyToFindInRange <= identsRangeKeys[rangeK]['end']:
|
||||||
|
requestToFindInCommandsRequests = "3B" + identsRangeKeys[rangeK]['frame'][-2:]
|
||||||
|
isTakingParams = takesParams(requestToFindInCommandsRequests)
|
||||||
|
if isTakingParams:
|
||||||
|
for k,v in params.iteritems():
|
||||||
|
if v in identsList.keys():
|
||||||
|
identsList[k] = ecu.get_id(identsList[v], 1)
|
||||||
|
else:
|
||||||
|
identsList[k] = v
|
||||||
|
for idKey in range(identsRangeKeys[rangeK]['begin'], identsRangeKeys[rangeK]['end'] + 1):
|
||||||
if identsList["D" + str(idKey)].startswith("ID"):
|
if identsList["D" + str(idKey)].startswith("ID"):
|
||||||
identsList["D" + str(idKey)] = ecu.get_id(identsList["D" + str(idKey)], 1)
|
identsList["D" + str(idKey)] = ecu.get_id(identsList["D" + str(idKey)], 1)
|
||||||
paramToSend += identsList["D" + str(idKey)]
|
paramToSend += identsList["D" + str(idKey)]
|
||||||
return paramToSend
|
commandToRun = isTakingParams
|
||||||
|
break
|
||||||
|
|
||||||
|
return commandToRun, paramToSend
|
||||||
|
|
||||||
confirm = get_message_by_id('19800')
|
confirm = get_message_by_id('19800')
|
||||||
successMessage = get_message('Message32')
|
successMessage = get_message('Message32')
|
||||||
@ -300,7 +332,7 @@ def run( elm, ecu, command, data ):
|
|||||||
print
|
print
|
||||||
ch = raw_input('Press ENTER to exit')
|
ch = raw_input('Press ENTER to exit')
|
||||||
|
|
||||||
def afterEcuChange(title, button, command, rangeKey):
|
def afterEcuChange(title, button):
|
||||||
params = getValuesToChange(title)
|
params = getValuesToChange(title)
|
||||||
infoMessage = get_message("Message262")
|
infoMessage = get_message("Message262")
|
||||||
mileageText = get_message_by_id('2110')
|
mileageText = get_message_by_id('2110')
|
||||||
@ -341,16 +373,12 @@ def run( elm, ecu, command, data ):
|
|||||||
|
|
||||||
mileage = int(mileage)
|
mileage = int(mileage)
|
||||||
|
|
||||||
for k,v in params.iteritems():
|
for paramkey in params.keys():
|
||||||
if v in identsList.keys():
|
if params[paramkey] == "Mileage":
|
||||||
identsList[k] = ecu.get_id(identsList[v], 1)
|
identValue = ecu.get_id(identsList[paramkey], 1)
|
||||||
elif v == "Mileage":
|
params[paramkey] = "{0:0{1}X}".format(mileage,len(identValue))
|
||||||
identValue = ecu.get_id(identsList[k], 1)
|
|
||||||
identsList[k] = "{0:0{1}X}".format(mileage,len(identValue))
|
|
||||||
else:
|
|
||||||
identsList[k] = v
|
|
||||||
|
|
||||||
paramToSend = getValuesFromEcu(rangeKey)
|
command, paramToSend = getValuesFromEcu(params)
|
||||||
|
|
||||||
clearScreen()
|
clearScreen()
|
||||||
|
|
||||||
@ -366,7 +394,7 @@ def run( elm, ecu, command, data ):
|
|||||||
print
|
print
|
||||||
ch = raw_input('Press ENTER to exit')
|
ch = raw_input('Press ENTER to exit')
|
||||||
|
|
||||||
def setGlowPlugsType(title, button, command, rangeKey):
|
def setGlowPlugsType(title, button):
|
||||||
params = getValuesToChange(title)
|
params = getValuesToChange(title)
|
||||||
currentType = ecu.get_id(identsList[params["IdentToBeDisplayed"].replace("Ident", "D")], 1)
|
currentType = ecu.get_id(identsList[params["IdentToBeDisplayed"].replace("Ident", "D")], 1)
|
||||||
slowTypeValue = get_message('ValueSlowParam')
|
slowTypeValue = get_message('ValueSlowParam')
|
||||||
@ -406,9 +434,10 @@ def run( elm, ecu, command, data ):
|
|||||||
print
|
print
|
||||||
print inProgressMessage
|
print inProgressMessage
|
||||||
|
|
||||||
identsList[params["IdentToBeDisplayed"].replace("Ident", "D")] = typesButtons[choice[0]]
|
params[params["IdentToBeDisplayed"].replace("Ident", "D")] = typesButtons[choice[0]]
|
||||||
|
params.pop("IdentToBeDisplayed")
|
||||||
|
|
||||||
paramToSend = getValuesFromEcu(rangeKey)
|
command, paramToSend = getValuesFromEcu(params)
|
||||||
|
|
||||||
clearScreen()
|
clearScreen()
|
||||||
|
|
||||||
@ -424,28 +453,11 @@ def run( elm, ecu, command, data ):
|
|||||||
print
|
print
|
||||||
ch = raw_input('Press ENTER to exit')
|
ch = raw_input('Press ENTER to exit')
|
||||||
|
|
||||||
def resetValues(title, button, command, rangeKey):
|
def resetValues(title, button, defaultCommand):
|
||||||
paramToSend = ""
|
paramToSend = ""
|
||||||
commandTakesParams = True
|
commandTakesParams = True
|
||||||
params = getValuesToChange(title)
|
params = getValuesToChange(title)
|
||||||
|
|
||||||
commandServices = ecu.Commands[command.replace("VP", "V")].serviceID
|
|
||||||
for sid in commandServices:
|
|
||||||
if not ecu.Services[sid].params: #For INLET_FLAP VP042 in 10959 or VP018 EGR_VALVE in 10527
|
|
||||||
commandTakesParams = False
|
|
||||||
else:
|
|
||||||
commandTakesParams = True
|
|
||||||
break
|
|
||||||
|
|
||||||
if commandTakesParams:
|
|
||||||
for k,v in params.iteritems():
|
|
||||||
if v in identsList.keys():
|
|
||||||
identsList[k] = ecu.get_id(identsList[v], 1)
|
|
||||||
else:
|
|
||||||
identsList[k] = v
|
|
||||||
|
|
||||||
paramToSend = getValuesFromEcu(rangeKey)
|
|
||||||
|
|
||||||
clearScreen()
|
clearScreen()
|
||||||
|
|
||||||
print mainText
|
print mainText
|
||||||
@ -465,13 +477,19 @@ def run( elm, ecu, command, data ):
|
|||||||
if ch.upper()!='YES':
|
if ch.upper()!='YES':
|
||||||
return
|
return
|
||||||
|
|
||||||
|
clearScreen()
|
||||||
|
print
|
||||||
|
print inProgressMessage
|
||||||
|
|
||||||
|
command, paramToSend = getValuesFromEcu(params)
|
||||||
|
|
||||||
clearScreen()
|
clearScreen()
|
||||||
|
|
||||||
print
|
print
|
||||||
if commandTakesParams:
|
if command:
|
||||||
response = ecu.run_cmd(command,paramToSend)
|
response = ecu.run_cmd(command,paramToSend)
|
||||||
else:
|
else:
|
||||||
response = ecu.run_cmd(command)
|
response = ecu.run_cmd(defaultCommand)
|
||||||
print
|
print
|
||||||
|
|
||||||
if "NR" in response:
|
if "NR" in response:
|
||||||
@ -487,22 +505,22 @@ def run( elm, ecu, command, data ):
|
|||||||
for cmdKey in commands.keys():
|
for cmdKey in commands.keys():
|
||||||
if cmdKey == 'Cmd1':
|
if cmdKey == 'Cmd1':
|
||||||
injectorsDict = OrderedDict()
|
injectorsDict = OrderedDict()
|
||||||
injectorsDict[get_message('Cylinder1', 0)] = commands['Cmd1']
|
injectorsDict[get_message('Cylinder1', 0)] = commands['Cmd1']['command']
|
||||||
injectorsDict[get_message('Cylinder2', 0)] = commands['Cmd2']
|
injectorsDict[get_message('Cylinder2', 0)] = commands['Cmd2']['command']
|
||||||
injectorsDict[get_message('Cylinder3', 0)] = commands['Cmd3']
|
injectorsDict[get_message('Cylinder3', 0)] = commands['Cmd3']['command']
|
||||||
injectorsDict[get_message('Cylinder4', 0)] = commands['Cmd4']
|
injectorsDict[get_message('Cylinder4', 0)] = commands['Cmd4']['command']
|
||||||
injectorsDict['<exit>'] = ""
|
injectorsDict['<exit>'] = ""
|
||||||
functions[1] = [1, injectorsDict]
|
functions[1] = [1, injectorsDict]
|
||||||
if cmdKey == 'Cmd5':
|
if cmdKey == 'Cmd5':
|
||||||
functions[2] = ["EGR_VALVE", 2, commands['Cmd5'], 0]
|
functions[2] = ["EGR_VALVE", 2, commands['Cmd5']['command']]
|
||||||
if cmdKey == 'Cmd6':
|
if cmdKey == 'Cmd6':
|
||||||
functions[3] = ["INLET_FLAP", 3, commands['Cmd6'], 1]
|
functions[3] = ["INLET_FLAP", 3, commands['Cmd6']['command']]
|
||||||
if cmdKey == 'Cmd7':
|
if cmdKey == 'Cmd7':
|
||||||
functions[4] = ["PARTICLE_FILTER", 4, commands['Cmd7'], 2]
|
functions[4] = ["PARTICLE_FILTER", 4, commands['Cmd7']['command']]
|
||||||
functions[5] = ["Button5ChangeData", 5, commands['Cmd7'], 2]
|
functions[5] = ["Button5ChangeData", 5, commands['Cmd7']['command']]
|
||||||
functions[6] = ["Button6ChangeData", 6, commands['Cmd7'], 2]
|
functions[6] = ["Button6ChangeData", 6, commands['Cmd7']['command']]
|
||||||
if cmdKey == 'Cmd9':
|
if cmdKey == 'Cmd9':
|
||||||
functions[8] = ["Button8DisplayData", 8, commands["Cmd9"], len(identsRangeKeys) - 1]
|
functions[8] = ["Button8DisplayData", 8]
|
||||||
|
|
||||||
infoMessage = get_message('Message1')
|
infoMessage = get_message('Message1')
|
||||||
|
|
||||||
@ -524,9 +542,9 @@ def run( elm, ecu, command, data ):
|
|||||||
if key == 1:
|
if key == 1:
|
||||||
resetInjetorsData(functions[key][0],functions[key][1])
|
resetInjetorsData(functions[key][0],functions[key][1])
|
||||||
elif key == 6:
|
elif key == 6:
|
||||||
afterEcuChange(functions[key][0],functions[key][1],functions[key][2],functions[key][3])
|
afterEcuChange(functions[key][0],functions[key][1])
|
||||||
elif key == 8:
|
elif key == 8:
|
||||||
setGlowPlugsType(functions[key][0],functions[key][1],functions[key][2],functions[key][3])
|
setGlowPlugsType(functions[key][0],functions[key][1])
|
||||||
else:
|
else:
|
||||||
resetValues(functions[key][0],functions[key][1],functions[key][2],functions[key][3])
|
resetValues(functions[key][0],functions[key][1],functions[key][2])
|
||||||
return
|
return
|
Loading…
x
Reference in New Issue
Block a user