diff --git a/site_ansto/instrument/util/gen_sct.py b/site_ansto/instrument/util/gen_sct.py index 6c3e1b67..8769de9d 100755 --- a/site_ansto/instrument/util/gen_sct.py +++ b/site_ansto/instrument/util/gen_sct.py @@ -117,6 +117,7 @@ reserved = { 'VAR' : 'VAR', 'PROPERTY' : 'PROPERTY', 'CONTROL' : 'CONTROL', + 'CONDITIONAL' : 'CONDITIONAL', 'DATA' : 'DATA', 'NXSAVE' : 'NXSAVE', 'MUTABLE' : 'MUTABLE', @@ -456,6 +457,7 @@ def p_var_typ_ass(p): | DATA EQUALS true_false | NXSAVE EQUALS true_false | MUTABLE EQUALS true_false + | CONDITIONAL EQUALS text_string ''' p[0] = { p[1] : p[3] } @@ -1445,6 +1447,19 @@ def put_var(MyDriver, MyGroup, MyVar): txt += [' %s::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for %s"' % (MyDriver['namespace'], MyDriver['name'])] txt += [' }'] + if 'conditional' in MyVar: + for idx, line in enumerate(txt): + if len(line) > 0: + txt[idx] = ' ' + line + txt.insert(0, ' if {%s} {' % MyVar['conditional']) + txt.append(' }') + if len(postfix) > 0: + for idx, line in enumerate(postfix): + if len(line) > 0: + postfix[idx] = ' ' + line + postfix.insert(0, ' if {%s} {' % MyVar['conditional']) + postfix.append(' }') + return (txt, postfix) def put_group(MyDriver, MyGroup): @@ -1478,6 +1493,13 @@ def put_group(MyDriver, MyGroup): txt += dfr + if 'conditional' in MyGroup: + for idx, line in enumerate(txt): + if len(line) > 0: + txt[idx] = ' ' + line + txt.insert(0, ' if {%s} {' % MyGroup['conditional']) + txt.append(' }') + return txt def put_mkDriver(MyDriver):