From 5be03cc63bbcc056631c864586bb7f0b06abe31b Mon Sep 17 00:00:00 2001 From: Douglas Clowes Date: Tue, 5 Aug 2014 16:04:55 +1000 Subject: [PATCH] make default mutable 'true' and data on branches --- site_ansto/instrument/util/gen_sct.py | 39 +++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/site_ansto/instrument/util/gen_sct.py b/site_ansto/instrument/util/gen_sct.py index e6de8e13..19a81601 100755 --- a/site_ansto/instrument/util/gen_sct.py +++ b/site_ansto/instrument/util/gen_sct.py @@ -583,7 +583,7 @@ def init_context(): ContextStack[ContextIndex]['driveable'] = None ContextStack[ContextIndex]['control'] = 'true' ContextStack[ContextIndex]['data'] = 'true' - ContextStack[ContextIndex]['mutable'] = 'false' + ContextStack[ContextIndex]['mutable'] = 'true' ContextStack[ContextIndex]['nxsave'] = 'true' ContextStack[ContextIndex]['read_function'] = 'rdValue' ContextStack[ContextIndex]['write_function'] = 'setValue' @@ -730,8 +730,40 @@ def build_group(MyDriver, p): if key in ContextStack[ContextIndex]: ContextStack[ContextIndex][key] = item[key] pop_context() + adjust_group(MyGroup) return MyGroup +def adjust_group(MyGroup): + if Verbose: + print 'ante adjust_group', MyGroup + MyData = None + for var in MyGroup['Vars']: + if Verbose: + print "Var:", MyGroup['Vars'][var] + if 'data' in MyGroup['Vars'][var]: + if MyGroup['Vars'][var]['data'] == 'true': + MyData = 'true' + else: + MyData = 'false' + break + if MyData is None: + for grp in MyGroup['Groups']: + if Verbose: + print "Grp:", MyGroup['Groups'][grp] + adjust_group(MyGroup['Groups'][grp]) + if 'data' in MyGroup['Groups'][grp]['GroupProperty']: + if MyGroup['Groups'][grp]['GroupProperty']['data'] == 'true': + MyData = 'true' + else: + MyData = 'false' + break + if MyData is not None: + if 'GroupProperty' not in MyGroup: + MyGroup['GroupProperty'] = {} + MyGroup['GroupProperty']['data'] = MyData + if Verbose: + print 'post adjust_group', MyGroup + def build_driver(MyDriver, TheTree): if Verbose: print "TheTree:", TheTree @@ -784,8 +816,11 @@ def dump_driver_groups(groups, indent): print indent + 'GROUP ' + item + ' = {' else: print indent + 'GROUP = {' - for subitem in sorted([x for x in groups[item] if not x in ['Groups', 'Vars']]): + for subitem in sorted([x for x in groups[item] if not x in ['Groups', 'Vars', 'GroupProperty']]): print indent + ' ', subitem, '=', groups[item][subitem] + if 'GroupProperty' in groups[item]: + for subitem in groups[item]['GroupProperty']: + print indent + ' GroupProperty', subitem, '=', groups[item]['GroupProperty'][subitem] dump_driver_vars(groups[item]['Vars'], indent) dump_driver_groups(groups[item]['Groups'], indent + ' ') print indent + '}'