Refactor
This commit is contained in:
parent
f2a3bbe5f4
commit
94414a6085
@ -180,6 +180,8 @@ def run( elm, ecu, command, data ):
|
|||||||
else:
|
else:
|
||||||
correctEcu = ecusList[0]
|
correctEcu = ecusList[0]
|
||||||
|
|
||||||
|
if not correctEcu and mod_globals.opt_demo:
|
||||||
|
correctEcu = ecusList[0]
|
||||||
# for i in ecusList:
|
# for i in ecusList:
|
||||||
# print i.vdiag
|
# print i.vdiag
|
||||||
# print i.ncalib
|
# print i.ncalib
|
||||||
@ -206,19 +208,29 @@ def run( elm, ecu, command, data ):
|
|||||||
|
|
||||||
#Get identifications
|
#Get identifications
|
||||||
identsList = OrderedDict()
|
identsList = OrderedDict()
|
||||||
|
identsKeys = OrderedDict()
|
||||||
def getIdents(start, end):
|
|
||||||
identsDict = OrderedDict()
|
|
||||||
for idnum in range(start,end + 1):
|
|
||||||
identsDict['D'+str(idnum)] = ScmParam['Ident'+str(idnum)]
|
|
||||||
return identsDict
|
|
||||||
|
|
||||||
for param in ScmParam.keys():
|
for param in ScmParam.keys():
|
||||||
if param.startswith('Idents') and param.endswith('Begin'):
|
if param.startswith('Idents') and param.endswith('Begin'):
|
||||||
key = param[6:-5]
|
key = param[6:-5]
|
||||||
start = int(ScmParam['Idents'+key+'Begin'])
|
begin = int(ScmParam['Idents'+key+'Begin'])
|
||||||
end = int(ScmParam['Idents'+key+'End'])
|
end = int(ScmParam['Idents'+key+'End'])
|
||||||
identsList[key] = getIdents(start, end)
|
identsKeys[key] = {"begin": begin, "end": end}
|
||||||
|
for idnum in range(begin ,end + 1):
|
||||||
|
identsList['D'+str(idnum)] = ScmParam['Ident'+str(idnum)]
|
||||||
|
|
||||||
|
# def getIdents(start, end):
|
||||||
|
# identsDict = OrderedDict()
|
||||||
|
# for idnum in range(start,end + 1):
|
||||||
|
# identsDict['D'+str(idnum)] = ScmParam['Ident'+str(idnum)]
|
||||||
|
# return identsDict
|
||||||
|
|
||||||
|
# for param in ScmParam.keys():
|
||||||
|
# if param.startswith('Idents') and param.endswith('Begin'):
|
||||||
|
# key = param[6:-5]
|
||||||
|
# start = int(ScmParam['Idents'+key+'Begin'])
|
||||||
|
# end = int(ScmParam['Idents'+key+'End'])
|
||||||
|
# identsList[key] = getIdents(start, end)
|
||||||
|
|
||||||
#Get commands
|
#Get commands
|
||||||
commands = {}
|
commands = {}
|
||||||
@ -229,24 +241,33 @@ def run( elm, ecu, command, data ):
|
|||||||
for param in child:
|
for param in child:
|
||||||
commands[param.attrib["name"]] = param.attrib["value"]
|
commands[param.attrib["name"]] = param.attrib["value"]
|
||||||
|
|
||||||
def resetEGRValve():
|
def getValuesToChange(resetItem):
|
||||||
paramToSend = ""
|
|
||||||
params = {}
|
params = {}
|
||||||
for child in root:
|
for child in root:
|
||||||
if child.attrib["name"] == "EGR_VALVE":
|
if child.attrib["name"] == resetItem:
|
||||||
if len(child.keys()) == 1:
|
if len(child.keys()) == 1:
|
||||||
for param in child:
|
for param in child:
|
||||||
params[param.attrib["name"]] = param.attrib["value"]
|
params[param.attrib["name"]] = param.attrib["value"]
|
||||||
|
return params
|
||||||
|
|
||||||
confirm = get_message('MessageBox5')
|
def replaceValues(params):
|
||||||
|
for k,v in params.iteritems():
|
||||||
|
if v in identsList.keys():
|
||||||
|
identsList[k] = ecu.get_id(identsList[v], 1)
|
||||||
|
else:
|
||||||
|
identsList[k] = v
|
||||||
|
|
||||||
|
def resetEGRValve():
|
||||||
|
paramToSend = ""
|
||||||
|
params = getValuesToChange("EGR_VALVE")
|
||||||
|
|
||||||
|
confirm = get_message_by_id('19800')
|
||||||
successMessage = get_message('Message32')
|
successMessage = get_message('Message32')
|
||||||
|
failMessage = get_message('MessageNACK')
|
||||||
clearScreen()
|
clearScreen()
|
||||||
|
|
||||||
# for k,v in params.iteritems():
|
for idKey in range(identsKeys[identsKeys.keys()[0]]['begin'], identsKeys[identsKeys.keys()[0]]['end'] + 1):
|
||||||
# print k,v
|
identsList["D" + str(idKey)] = ecu.get_id(identsList["D" + str(idKey)], 1)
|
||||||
|
|
||||||
for idKey in identsList['X'].keys():
|
|
||||||
identsList['X'][idKey] = ecu.get_id(identsList['X'][idKey], 1)
|
|
||||||
|
|
||||||
print buttons[2]
|
print buttons[2]
|
||||||
print
|
print
|
||||||
@ -256,14 +277,22 @@ def run( elm, ecu, command, data ):
|
|||||||
if ch.upper()!='YES':
|
if ch.upper()!='YES':
|
||||||
return
|
return
|
||||||
|
|
||||||
for k,v in params.iteritems():
|
clearScreen()
|
||||||
identsList['X'][k] = v
|
|
||||||
|
|
||||||
for v in identsList['X'].values():
|
replaceValues(params)
|
||||||
paramToSend += v
|
|
||||||
|
|
||||||
ecu.run_cmd(commands['Cmd5'],paramToSend)
|
for idKey in range(identsKeys[identsKeys.keys()[0]]['begin'], identsKeys[identsKeys.keys()[0]]['end'] + 1):
|
||||||
|
paramToSend += identsList["D" + str(idKey)]
|
||||||
|
|
||||||
|
print
|
||||||
|
response = ecu.run_cmd(commands['Cmd5'],paramToSend)
|
||||||
|
if "NR" in response:
|
||||||
|
print failMessage
|
||||||
|
else:
|
||||||
|
print successMessage
|
||||||
|
|
||||||
|
print
|
||||||
|
ch = raw_input('Press ENTER to exit')
|
||||||
|
|
||||||
functions = OrderedDict()
|
functions = OrderedDict()
|
||||||
functions[2] = resetEGRValve
|
functions[2] = resetEGRValve
|
||||||
@ -296,7 +325,7 @@ def run( elm, ecu, command, data ):
|
|||||||
# print pyren_encode(datastr1)
|
# print pyren_encode(datastr1)
|
||||||
# print pyren_encode(datastr2)
|
# print pyren_encode(datastr2)
|
||||||
|
|
||||||
ch = raw_input('')
|
return
|
||||||
#
|
#
|
||||||
# Important information
|
# Important information
|
||||||
#
|
#
|
||||||
|
Loading…
x
Reference in New Issue
Block a user