9q Emprovements for favorites and terminal
This commit is contained in:
parent
0e2a6f9f29
commit
7c56018259
@ -195,7 +195,7 @@ class ECU:
|
|||||||
if len(flist)==0: return
|
if len(flist)==0: return
|
||||||
flist.sort()
|
flist.sort()
|
||||||
dumpname = os.path.join("./dumps/", flist[-1])
|
dumpname = os.path.join("./dumps/", flist[-1])
|
||||||
|
|
||||||
print 'Loading dump:', dumpname
|
print 'Loading dump:', dumpname
|
||||||
|
|
||||||
df = open(dumpname,'rt')
|
df = open(dumpname,'rt')
|
||||||
@ -491,8 +491,10 @@ class ECU:
|
|||||||
c = kb.getch()
|
c = kb.getch()
|
||||||
if len(c)!=1: continue
|
if len(c)!=1: continue
|
||||||
if path[:3] == 'FAV':
|
if path[:3] == 'FAV':
|
||||||
if ord(c) == 13:
|
if ord(c) == 13 or ord(c) == 10:
|
||||||
|
kb.set_normal_term()
|
||||||
self.add_favourite()
|
self.add_favourite()
|
||||||
|
kb.set_getch_term()
|
||||||
else:
|
else:
|
||||||
if mod_globals.opt_csv and (c in mod_globals.opt_usrkey):
|
if mod_globals.opt_csv and (c in mod_globals.opt_usrkey):
|
||||||
csvline += ";" + c
|
csvline += ";" + c
|
||||||
@ -521,31 +523,40 @@ class ECU:
|
|||||||
def add_favourite(self):
|
def add_favourite(self):
|
||||||
H = 25
|
H = 25
|
||||||
if len(favouriteScreen.datarefs) < H:
|
if len(favouriteScreen.datarefs) < H:
|
||||||
userData = raw_input("\nEnter parameter/state that you want to monitor: ").upper()
|
userDataStr = raw_input("\nEnter parameter/state that you want to monitor: ").upper()
|
||||||
if userData[:2] == 'PR':
|
for userData in userDataStr.split(','):
|
||||||
for pr in self.Parameters.keys():
|
userData = userData.strip()
|
||||||
if self.Parameters[pr].agcdRef == userData:
|
if userData[:2] == 'PR':
|
||||||
if not any(pr == dr.name for dr in favouriteScreen.datarefs):
|
for pr in self.Parameters.keys():
|
||||||
favouriteScreen.datarefs.append(ecu_screen_dataref("",pr,"Parameter"))
|
if self.Parameters[pr].agcdRef == userData:
|
||||||
else:
|
if not any(pr == dr.name for dr in favouriteScreen.datarefs):
|
||||||
for dr in favouriteScreen.datarefs:
|
favouriteScreen.datarefs.append(ecu_screen_dataref("",pr,"Parameter"))
|
||||||
if pr == dr.name:
|
else:
|
||||||
favouriteScreen.datarefs.remove(dr)
|
for dr in favouriteScreen.datarefs:
|
||||||
elif userData[:2] == 'ET':
|
if pr == dr.name:
|
||||||
for st in self.States.keys():
|
favouriteScreen.datarefs.remove(dr)
|
||||||
if self.States[st].agcdRef == userData:
|
elif userData[:2] == 'ET':
|
||||||
if not any(st == dr.name for dr in favouriteScreen.datarefs):
|
for st in self.States.keys():
|
||||||
favouriteScreen.datarefs.append(ecu_screen_dataref("",st,"State"))
|
if self.States[st].agcdRef == userData:
|
||||||
else:
|
if not any(st == dr.name for dr in favouriteScreen.datarefs):
|
||||||
for dr in favouriteScreen.datarefs:
|
favouriteScreen.datarefs.append(ecu_screen_dataref("",st,"State"))
|
||||||
if st == dr.name:
|
else:
|
||||||
favouriteScreen.datarefs.remove(dr)
|
for dr in favouriteScreen.datarefs:
|
||||||
|
if st == dr.name:
|
||||||
|
favouriteScreen.datarefs.remove(dr)
|
||||||
clearScreen()
|
clearScreen()
|
||||||
|
|
||||||
def loadFavList(self):
|
def loadFavList(self):
|
||||||
fl = open("./cache/favlist.txt", "r").readlines()
|
|
||||||
|
fn = "./cache/favlist_"+self.ecudata['ecuname']+".txt"
|
||||||
|
|
||||||
|
if not os.path.isfile(fn):
|
||||||
|
favlistfile = open( fn, "wb" )
|
||||||
|
favlistfile.close()
|
||||||
|
|
||||||
|
|
||||||
|
fl = open(fn, "r").readlines()
|
||||||
if len(fl) > 1:
|
if len(fl) > 1:
|
||||||
if(fl[-1] != self.ecudata['ecuname']): return False
|
|
||||||
for drname in fl:
|
for drname in fl:
|
||||||
drname = drname.strip().replace('\n','')
|
drname = drname.strip().replace('\n','')
|
||||||
if drname[:1] == "P":
|
if drname[:1] == "P":
|
||||||
@ -554,6 +565,7 @@ class ECU:
|
|||||||
favouriteScreen.datarefs.append(ecu_screen_dataref("", drname,"State"))
|
favouriteScreen.datarefs.append(ecu_screen_dataref("", drname,"State"))
|
||||||
else:
|
else:
|
||||||
return drname
|
return drname
|
||||||
|
return True
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@ -763,10 +775,9 @@ class ECU:
|
|||||||
menu.append("<Up>")
|
menu.append("<Up>")
|
||||||
choice = Choice(menu, "Choose :")
|
choice = Choice(menu, "Choose :")
|
||||||
if choice[0]=="<Up>":
|
if choice[0]=="<Up>":
|
||||||
fl = open("./cache/favlist.txt", "w")
|
fl = open("./cache/favlist_"+self.ecudata['ecuname']+".txt", "w")
|
||||||
for dr in favouriteScreen.datarefs:
|
for dr in favouriteScreen.datarefs:
|
||||||
fl.write(dr.name + "\n")
|
fl.write(dr.name + "\n")
|
||||||
fl.write(self.ecudata['ecuname'])
|
|
||||||
fl.close()
|
fl.close()
|
||||||
favouriteScreen.datarefs = []
|
favouriteScreen.datarefs = []
|
||||||
return
|
return
|
||||||
@ -795,16 +806,20 @@ class ECU:
|
|||||||
gc.collect ()
|
gc.collect ()
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
fav_sc = self.screens[int(choice[1]) - 1]
|
||||||
if choice[0][:3] == "FAV":
|
if choice[0][:3] == "FAV":
|
||||||
|
for sc in self.screens:
|
||||||
|
if sc.name.startswith('FAV'):
|
||||||
|
fav_sc = sc
|
||||||
if not favouriteScreen.datarefs:
|
if not favouriteScreen.datarefs:
|
||||||
if self.loadFavList():
|
if self.loadFavList():
|
||||||
self.show_screen(self.screens[int(choice[1])-1])
|
self.show_screen(fav_sc)
|
||||||
else:
|
else:
|
||||||
self.add_favourite()
|
self.add_favourite()
|
||||||
else:
|
else:
|
||||||
self.show_screen(self.screens[int(choice[1])-1])
|
self.show_screen(fav_sc)
|
||||||
else:
|
else:
|
||||||
self.show_screen(self.screens[int(choice[1])-1])
|
self.show_screen(fav_sc)
|
||||||
|
|
||||||
def getLanguageMap(self):
|
def getLanguageMap(self):
|
||||||
|
|
||||||
|
@ -549,6 +549,10 @@ def proc_line( l, elm ):
|
|||||||
|
|
||||||
l = l.strip()
|
l = l.strip()
|
||||||
|
|
||||||
|
if l.startswith(':'):
|
||||||
|
print l
|
||||||
|
return
|
||||||
|
|
||||||
if len(l) == 0:
|
if len(l) == 0:
|
||||||
print
|
print
|
||||||
return
|
return
|
||||||
@ -616,6 +620,9 @@ def proc_line( l, elm ):
|
|||||||
bit_cmd( l.lower()[7:], elm, fnc='exit_if' )
|
bit_cmd( l.lower()[7:], elm, fnc='exit_if' )
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if len(l_parts) > 0 and l_parts[0] in ['go','goto']:
|
||||||
|
print l
|
||||||
|
return l_parts[1]
|
||||||
|
|
||||||
if l.lower().startswith('_'):
|
if l.lower().startswith('_'):
|
||||||
print elm.send_raw(l[1:])
|
print elm.send_raw(l[1:])
|
||||||
@ -672,7 +679,7 @@ def main():
|
|||||||
if auto_macro in macro.keys():
|
if auto_macro in macro.keys():
|
||||||
play_macro( auto_macro, elm )
|
play_macro( auto_macro, elm )
|
||||||
else:
|
else:
|
||||||
print 'Error: unknown macro mane:', auto_macro
|
print 'Error: unknown macro name:', auto_macro
|
||||||
|
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
@ -688,7 +695,16 @@ def main():
|
|||||||
l = "# end of command file"
|
l = "# end of command file"
|
||||||
print l
|
print l
|
||||||
|
|
||||||
proc_line( l, elm )
|
goto = proc_line( l, elm )
|
||||||
|
|
||||||
|
if goto and len(cmd_lines):
|
||||||
|
c_str = 0
|
||||||
|
for c in cmd_lines:
|
||||||
|
if c.startswith(':'):
|
||||||
|
if goto == c[1:].strip():
|
||||||
|
cmd_ref = c_str
|
||||||
|
break
|
||||||
|
c_str += 1
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
@ -39,6 +39,9 @@ else:
|
|||||||
class KBHit:
|
class KBHit:
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
self.set_getch_term()
|
||||||
|
|
||||||
|
def set_getch_term(self):
|
||||||
'''Creates a KBHit object that you can call to do various keyboard things.
|
'''Creates a KBHit object that you can call to do various keyboard things.
|
||||||
'''
|
'''
|
||||||
|
|
||||||
@ -274,7 +277,7 @@ def clearScreen():
|
|||||||
def upScreen():
|
def upScreen():
|
||||||
sys.stdout.write(chr(27)+"[;H")
|
sys.stdout.write(chr(27)+"[;H")
|
||||||
|
|
||||||
def hex_VIN_plus_CRC( VIN ):
|
def hex_VIN_plus_CRC( VIN, plusCRC=True):
|
||||||
'''The VIN must be composed of 17 alphanumeric characters apart from "I" and "O"'''
|
'''The VIN must be composed of 17 alphanumeric characters apart from "I" and "O"'''
|
||||||
|
|
||||||
#VIN ='VF1LM1B0H11111111'
|
#VIN ='VF1LM1B0H11111111'
|
||||||
@ -306,7 +309,10 @@ def hex_VIN_plus_CRC( VIN ):
|
|||||||
sCRC = '0'*(4-len(sCRC))+sCRC
|
sCRC = '0'*(4-len(sCRC))+sCRC
|
||||||
|
|
||||||
# result
|
# result
|
||||||
return hexVIN+sCRC
|
if plusCRC:
|
||||||
|
return hexVIN+sCRC
|
||||||
|
else:
|
||||||
|
return hexVIN
|
||||||
|
|
||||||
# Test
|
# Test
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
@ -306,11 +306,7 @@ def main():
|
|||||||
ecu = ECU(choosen_ecu, lang.dict ) #loading original data for chosen ECU
|
ecu = ECU(choosen_ecu, lang.dict ) #loading original data for chosen ECU
|
||||||
pickle.dump( ecu, open( ecucashfile, "wb" ) ) #and save cache
|
pickle.dump( ecu, open( ecucashfile, "wb" ) ) #and save cache
|
||||||
|
|
||||||
if not os.path.isfile("./cache/favlist.txt"):
|
ecu.initELM( elm ) #init ELM for chosen ECU
|
||||||
favlistfile = open( "./cache/favlist.txt", "wb" )
|
|
||||||
favlistfile.close()
|
|
||||||
|
|
||||||
ecu.initELM( elm ) #init ELM for chosen ECU
|
|
||||||
|
|
||||||
if mod_globals.opt_demo:
|
if mod_globals.opt_demo:
|
||||||
print "Loading dump"
|
print "Loading dump"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user