diff --git a/tools/ADC25generator.py b/tools/ADC25generator.py index aa39e45c..f8541e24 100755 --- a/tools/ADC25generator.py +++ b/tools/ADC25generator.py @@ -2,7 +2,7 @@ import os import re import sys -import copy +from copy import deepcopy from statistics import mean from math import nan,isnan from pathlib import Path @@ -35,31 +35,43 @@ if args.articles is not None or args.sets is not None: articles.add(article) outputdir=datadir/"test" if args.debug else datadir ADC23re=re.compile(r"ADC\(([23])\)") -def getValue(ADC2,ADC3,parametername): - vals = [getattr(x,parametername) for x in [ADC2,ADC3]] - isObject=hasattr(vals[0], '__dict__') - if isObject: - if vars(vals[0]) == vars(vals[1]): - return copy.deepcopy(vals[0]) - else: - if vals[0] == vals[1]: - return vals[0] +def getValue(ADC2,ADC3,parametername,exADC2=None,exADC3=None): + def isObject(x): + return hasattr(x, '__dict__') + def extractVals(x): + if isObject(x): + return vars(x) + else: + return x + def copy(x): + if isObject(x): + return deepcopy(x) + else: + return x + + def isSame(a,b): + return extractVals(a)==extractVals(b) + + objs=[ADC2,ADC3] + exs=[exADC2,exADC3] + if all([x!=None for x in exs]): + objs=exs + vals = [getattr(x,parametername) for x in objs] + if isSame(*vals): + return copy(vals[0]) d=OrderedDict() for i in range(2): key=f"ADC({i+2})" - if isObject: - d[key]=copy.deepcopy(vals[i]) - else: - d[key]=vals[i] + d[key]=copy(vals[i]) index=-1 while len(vals)