From 5ee7e6719fbdb43f85a0dd4377eb64d5ace956f3 Mon Sep 17 00:00:00 2001 From: Douglas Clowes Date: Fri, 11 Jul 2014 10:11:27 +1000 Subject: [PATCH] Defer makesctdrive to end of mkDriver to avoid possible forward references. --- site_ansto/instrument/util/gen_sct.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/site_ansto/instrument/util/gen_sct.py b/site_ansto/instrument/util/gen_sct.py index bca5dc3d..7c94502b 100755 --- a/site_ansto/instrument/util/gen_sct.py +++ b/site_ansto/instrument/util/gen_sct.py @@ -1284,7 +1284,7 @@ def put_group(MyDriver, MyGroup): if MyVar['driveable']: # Generate __ at runtime for driveable driveable = '${name}_' + make_path(MyVar) - txt += [' ansto_makesctdrive %s ${scobj_hpath}/%s ${scobj_hpath}/%s ${sct_controller}' % (driveable, nodename, MyVar['driveable'])] + MyDriver['Deferred'] += ['ansto_makesctdrive %s ${scobj_hpath}/%s ${scobj_hpath}/%s ${sct_controller}' % (driveable, nodename, MyVar['driveable'])] txt += [' } else {'] txt += [' %s::sics_log 9 "[%s] => No poll/write for %s"' % (MyDriver['namespace'], MyDriver['simulation_group'], MyDriver['name'])] txt += [' }'] @@ -1328,6 +1328,11 @@ def put_mkDriver(MyDriver): txt += [' hsetprop ${scobj_hpath} klass %s' % MyDriver['class']] txt += [' hsetprop ${scobj_hpath} debug_threshold %s' % str(MyDriver['debug_threshold'])] + if len(MyDriver['Deferred']) > 0: + txt += [' if {[string equal -nocase [SplitReply [%s]] "false"]} {' % MyDriver['simulation_group']] + for line in MyDriver['Deferred']: + txt += [' ' + line] + txt += [' }'] func = 'mkDriver' if func in MyDriver['Funcs']: txt += ['# %s hook code starts' % func] @@ -1530,6 +1535,7 @@ def process_drivers(TheDrivers): MyDriver['Groups'] = {} MyDriver['Funcs'] = {} MyDriver['Permlink'] = {} + MyDriver['Deferred'] = [] build_driver(MyDriver, TheDrivers[driver]) if Verbose: print "MyDriver:", MyDriver['name'], '=', MyDriver