fix some issues

This commit is contained in:
shrlnm 2023-04-09 21:00:34 +03:00
parent 4449cc8b0f
commit d76a0a6cdf
8 changed files with 89 additions and 39 deletions

View File

@ -105,6 +105,12 @@ def optParser():
default=False,
action="store_true")
parser.add_argument("--exp",
help="Explore options",
dest="exp",
default=False,
action="store_true")
parser.add_argument("--vin",
help="vin number",
dest="vinnum",
@ -160,6 +166,7 @@ def optParser():
mod_globals.opt_verbose2 = options.verbose2
mod_globals.opt_ref = options.ref
mod_globals.opt_mtc = options.mtc
mod_globals.opt_exp = options.exp
if options.dev=='' or len(options.dev)!=4 or options.dev[0:2]!='10':
mod_globals.opt_dev = False
@ -305,9 +312,11 @@ def main():
else:
print("%2s : %s : " % (m['idf'],m['sref']))
#for option in mtc:
# acf_MTC_optionsExplorer( de, option )
if mod_globals.opt_exp:
for option in sorted(mtc):
res = acf_MTC_optionsExplorer( module_list, option, mtc )
for l in res:
print( l )
if __name__ == '__main__':
main()

View File

@ -230,7 +230,7 @@ def acf_MTC_findDiff( m, mtc, elm ):
#acf_form_commands( m, cu, op )
break
def acf_MTC_optinInfluence( m, option ):
def acf_MTC_optinInfluence( m, option, allmtc ):
''' m - module definition map '''
''' option - option name from MTC list '''
''' this function finds dependent parameters in one module'''
@ -260,7 +260,7 @@ def acf_MTC_optinInfluence( m, option ):
#check every mtc
for op in cu.opts:
if option not in op.MTC: continue
res = acf_MTC_compare(op.MTC, option)
res = acf_MTC_compare(op.MTC, allmtc)
if res:
tmpMTC = op.MTC.split()
if op.MTC.startswith('SAUF'): continue
@ -271,22 +271,25 @@ def acf_MTC_optinInfluence( m, option ):
return out
def acf_MTC_optionsExplorer( de, option ):
def acf_MTC_optionsExplorer( de, option, allmtc ):
''' de - list of all ecus '''
''' option - option name from MTC list '''
''' this function finds dependent parameters in every module'''
print('################### ', '%-10s'%(option), ' #########################')
res = []
res.append(f'################### {option:10} #########################')
for m in de:
if 'sref' not in list(m.keys()) or m['sref']=='': continue
if 'sref' in list(m.keys()):
if 'mo' in list(m.keys()) and m['mo']!='':
out = acf_MTC_optinInfluence( m, option )
out = acf_MTC_optinInfluence( m, option, allmtc )
if len(out)>0:
print('-'*30," Family : ",m['idf'], ' : ', m['fam_txt'])
print(out)
res.append(f"--------------------- Family : {m['idf']} : {m['fam_txt']}")
res.append(out)
return res

View File

@ -1197,10 +1197,10 @@ def AutoIdents_distance( DiagVersion, Supplier, Soft, Version, ai ):
#catch not hex supplier with len 6
pass
d = distance( DiagVersion, ai['DiagVersion']) * 0.25
d = d + distance( Supplier, ai['Supplier']) * 0.25
d = d + distance( Soft, ai['Soft']) * 0.25
d = d + distance( Version, ai['Version']) * 0.25
d = distance( DiagVersion, ai['DiagVersion']) * 0.35
d = d + distance( Supplier, ai['Supplier']) * 0.35
d = d + distance( Soft, ai['Soft']) * 0.15
d = d + distance( Version, ai['Version']) * 0.15
return round( d, 4 )

View File

@ -126,6 +126,7 @@ class FindDialog (tkinter.simpledialog.Dialog):
def __init__(self, parent, ecu ):
self.ecu = ecu
self.choise = ''
self.top = tk.Toplevel (parent)
self.top.title ('Find Dialog')
@ -1083,6 +1084,12 @@ class DDTScreen (tk.Frame):
self.root.wait_window (dialog.top)
def find(self):
restart = False
if self.start:
self.startStop()
restart = True
scr_name = FindDialog(self.root, self.decu ).show()
if '@' in scr_name:
key = scr_name.split('@')[0]
@ -1090,6 +1097,10 @@ class DDTScreen (tk.Frame):
#self.loadSyntheticScreen (self.Screens[key])
#else:
self.loadScreen (self.Screens[key])
if restart:
self.startStop()
return
def torqpids(self):
@ -1417,6 +1428,19 @@ class DDTScreen (tk.Frame):
self.loadSyntheticScreen(scr)
return
#debug
#deb_time1 = time.time()
#print( "#"*50 )
# stop ratary. Do not read ELM
restart = False
if self.start:
self.startStop()
restart = True
#debug
#print( f"DEBUG POINT1: {time.time()-deb_time1}")
ns = {'ns0': 'http://www-diag.renault.com/2002/ECU',
'ns1': 'http://www-diag.renault.com/2002/screens'}
@ -1446,7 +1470,6 @@ class DDTScreen (tk.Frame):
max_y = h
# print xrLeft, xrTop, xrHeight, xrWidth
deb_time1 = time.time()
# main frame re-create
self.ddt.delete ('all')
self.ddt.update_idletasks ()
@ -1855,6 +1878,9 @@ class DDTScreen (tk.Frame):
# clear elm cache
self.decu.clearELMcache ()
if restart:
self.startStop()
# request to update dInputs
self.update_dInputs ()
@ -1874,9 +1900,14 @@ class DDTScreen (tk.Frame):
if len (self.sReq_lst):
self.startScreen ()
def loadSyntheticScreen(self, rq):
# stop ratary. Do not read ELM
restart = False
if self.start:
self.startStop()
restart = True
read_cmd = self.decu.requests[rq].SentBytes
if read_cmd[:2]=='21':
read_cmd = read_cmd[:4]
@ -2035,6 +2066,10 @@ class DDTScreen (tk.Frame):
# clear elm cache
self.decu.clearELMcache ()
# restart if need
if restart:
self.startStop()
# request to update dInputs
self.update_dInputs ()

View File

@ -330,7 +330,7 @@ class Port:
print('*' * 40)
print('* Connection to ELM was lost')
mod_globals.opt_demo = True
if type(byte) == str:
byte = byte.encode()
@ -485,6 +485,7 @@ class Port:
self.hdr.timeout = 1
self.hdr.baudrate = boudrate
time.sleep (0.1)
self.write ("\r")
# search >

2
pyren3/mod_globals.py Executable file → Normal file
View File

@ -36,6 +36,8 @@ opt_stn = False #STN(PIC24) ELM327 which has ability to automatically s
opt_sd = False #separate doc files
opt_performance = False
opt_minordtc = False
opt_ref = "" #alternative ref set for acf
opt_mtc = "" #alternative mtc set for acf
dumpName = ""
state_scan = False

View File

@ -78,12 +78,12 @@ def optParser():
default="")
parser.add_argument("-s",
help="com port speed configured on ELM {38400[default],57600,115200,230400,500000} DEPRECATED",
help="com port speed configured on ELM {38400[default],115200,230400,500000} DEPRECATED",
dest="speed",
default="38400")
parser.add_argument("-r",
help="com port rate during diagnostic session {38400[default],57600,115200,230400,500000}",
help="com port rate during diagnostic session {38400[default],115200,230400,500000}",
dest="rate",
default="38400",)

View File

@ -477,8 +477,8 @@ class tl:
y1 = float(line['volt'][i*2+1])
self.CV.create_line(tx + x0 * xm, ty + (ymax - y0) * ym, tx + x1 * xm, ty + (ymax - y1) * ym, width=1, fill=f )
if hist:
return
#if hist:
# return
self.findPoints( line )
@ -498,6 +498,13 @@ class tl:
except:
Tc = int(line['temp'])
# average interval among points
interval = (line['volt'][-2] - line['volt'][0]) / len(line['volt']) * 2
#points in 50ms (take in to account only odds)
# 50ms radius of zone for local min/max
radius = int(.1 / interval ) * 2 + 1
self.T0 = line['volt'][0]
u = 2
mean = 0
@ -509,29 +516,21 @@ class tl:
self.V0 = mean // count
# find first min
min = line['volt'][u-1]
while line['volt'][u+1]-min < 0.25 and u<len(line['volt']):
if line['volt'][u+1]<min:
min = line['volt'][u+1]
self.T1 = line['volt'][u]
smin = min(list(line['volt'][u-5:u+radius:2]))
while line['volt'][u+1]!=smin:
u += 2
self.V1 = min
self.T1 = line['volt'][u]
self.V1 = smin
# find first max
max = min
while max - line['volt'][u+1] < 0.25 and u<len(line['volt']):
if line['volt'][u+1]>max:
max = line['volt'][u+1]
while line['volt'][u+1]<max(list(line['volt'][u-1:u+radius:2])) and u<len(line['volt'])-radius-1:
u += 2
# find second min
min = line['volt'][u-1]
while line['volt'][u+1]-min < 0.25 and u<len(line['volt']):
if line['volt'][u+1]<min:
min = line['volt'][u+1]
self.T2 = line['volt'][u]
while line['volt'][u+1]>min(list(line['volt'][u-1:u+radius:2])) and u<len(line['volt'])-radius-1:
u += 2
self.V2 = min
self.T2 = line['volt'][u]
self.V2 = line['volt'][u+1]
self.vth1 = 0
tpol = [ 2.40384615e-09, -7.79428904e-08, -6.37383450e-06, 8.12208625e-05, 1.06745338e-02, 1.97290210e-01]
@ -552,6 +551,7 @@ class tl:
else:
self.l_volt.config(fg='black', bg = "red")
print( (self.V2-self.V1)/(self.T2-self.T1)/8*100, self.V1, self.V2)
return
def axis( self, top ):
@ -570,7 +570,7 @@ class tl:
else:
self.CV.create_line( tx+x*xm, ty, tx+x*xm, self.ch-ty, width=0, dash=(5,5), fill='lightgray')
self.CV.create_text(tx+x*xm, self.ch-ty//2., text=str(x), justify=tk.CENTER, font="Verdana 8")
self.CV.create_text(tx+x*xm, self.ch-ty//2., text=str(x)[:4], justify=tk.CENTER, font="Verdana 8")
x = x + 0.2
y = 0