diff --git a/site_ansto/instrument/util/gen_sct.py b/site_ansto/instrument/util/gen_sct.py index 61cda0ab..e9756c4c 100755 --- a/site_ansto/instrument/util/gen_sct.py +++ b/site_ansto/instrument/util/gen_sct.py @@ -573,6 +573,8 @@ def build_variable(MyDriver, p): MyVar['Property'][key2] = ContextStack[ContextIndex][key][key2] elif not key in MyVar: MyVar[key] = ContextStack[ContextIndex][key] + if 'sdsinfo' not in MyVar['Property']: + MyVar['Property']['sdsinfo'] = '::nexus::scobj::sdsinfo' # set the type if not explicitly set if 'type' not in MyVar['Property']: if 'driveable' in MyVar and MyVar['driveable']: @@ -774,6 +776,8 @@ def put_write_function(MyDriver, func): txt += [' debug_log 1 "[sct] error: [sct geterror]"'] txt += [' error "[sct geterror]"'] txt += [' }'] + else: + txt += ['# hook code goes here'] txt += [' if { [hpropexists [sct] driving] } {'] txt += [' if { [hpropexists [sct] writestatus] && [sct writestatus] == "start" } {'] txt += [' sct driving 1'] @@ -799,6 +803,8 @@ def put_check_function(MyDriver, func): txt += ['# hook code starts'] txt += MyDriver['Funcs'][func]['text'] txt += ['# hook code ends'] + else: + txt += ['# hook code goes here'] txt += [' return "idle"'] txt += [' } catch_message ]'] txt += [' handle_exception ${catch_status} ${catch_message}'] @@ -823,6 +829,8 @@ def put_fetch_function(MyDriver, func): txt += [' debug_log 1 "[sct] error: [sct geterror]"'] txt += [' error "[sct geterror]"'] txt += [' }'] + else: + txt += ['# hook code goes here'] txt += [' debug_log 1 "%s sct send ${cmd}"' % func] txt += [' sct send "${cmd}"'] txt += [' return ${nextState}'] @@ -855,6 +863,8 @@ def put_read_function(MyDriver, func): txt += [' debug_log 1 "[sct] error: [sct geterror]"'] txt += [' error "[sct geterror]"'] txt += [' }'] + else: + txt += ['# hook code goes here'] txt += [' if { ${data} != [sct oldval] } {'] txt += [' debug_log 1 "[sct] changed to new:${data}, from old:[sct oldval]"'] txt += [' sct oldval ${data}'] @@ -890,6 +900,8 @@ def put_checkrange_function(MyDriver, func): txt += ['# hook code starts'] txt += MyDriver['Funcs'][func]['text'] txt += ['# hook code ends'] + else: + txt += ['# hook code goes here'] txt += [' if { ${setpoint} < ${lolimit} || ${setpoint} > ${hilimit} } {'] txt += [' error "setpoint ${setpoint} violates limits (${lolimit}..${hilimit}) on [sct]"'] txt += [' }'] @@ -922,6 +934,8 @@ def put_checklimits_function(MyDriver, func): txt += ['# hook code starts'] txt += MyDriver['Funcs'][func]['text'] txt += ['# hook code ends'] + else: + txt += ['# hook code goes here'] txt += [' if { ${setpoint} < ${lolimit} || ${setpoint} > ${hilimit} } {'] txt += [' sct driving 0'] txt += [' error "setpoint ${setpoint} violates limits (${lolimit}..${hilimit}) on [sct]"'] @@ -941,6 +955,8 @@ def put_checkstatus_function(MyDriver, func): txt += ['# hook code starts'] txt += MyDriver['Funcs'][func]['text'] txt += ['# hook code ends'] + else: + txt += ['# hook code goes here'] txt += [' if {[sct driving]} {'] txt += [' set sp "[sct target]"'] txt += [' set pv "[hval ${tc_root}/[sct driveable]]"'] @@ -968,6 +984,8 @@ def put_halt_function(MyDriver, func): txt += ['# hook code starts'] txt += MyDriver['Funcs'][func]['text'] txt += ['# hook code ends'] + else: + txt += ['# hook code goes here'] txt += [' sct driving 0'] txt += [' return "idle"'] txt += [' } catch_message ]'] @@ -998,6 +1016,8 @@ def put_pid_function(MyDriver, func): txt += ['# hook code starts'] txt += MyDriver['Funcs'][func]['text'] txt += ['# hook code ends'] + else: + txt += ['# hook code goes here'] txt += [' sct pid_output ${pid}'] txt += [' } catch_message ]'] txt += [' handle_exception ${catch_status} ${catch_message}'] @@ -1103,9 +1123,17 @@ def put_group(MyDriver, MyGroup): txt += [' hsetprop ${scobj_hpath}/%s oldval 0.0' % nodename] else: txt += [' hsetprop ${scobj_hpath}/%s oldval UNKNOWN' % nodename] - if 'Property' in MyVar: - for key in sorted(MyVar['Property']): - txt += [' hsetprop ${scobj_hpath}/%s %s "%s"' % (nodename, key, MyVar['Property'][key])] + for key in sorted(MyVar['Property']): + txt += [' hsetprop ${scobj_hpath}/%s %s "%s"' % (nodename, key, MyVar['Property'][key])] + if 'nxalias' not in MyVar['Property']: + # TODO: generated at runtime __ + path = MyVar['path'] + if len(path) > 0: + path = path.replace('/', '_') + '_' + path += MyVar['name'] + print "Path: %s" % MyVar['path'] + nxalias = '${name}_' + path + txt += [' hsetprop ${scobj_hpath}/%s nxalias "%s"' % (nodename, nxalias)] if not MyGroup['name']: if 'GroupProperty' in MyGroup: txt += [''] @@ -1161,6 +1189,8 @@ def put_mk_sct_driver(MyDriver): txt += ['# hook code starts'] txt += MyDriver['Funcs']['mkDriver']['text'] txt += ['# hook code ends'] + else: + txt += ['# hook code goes here'] txt += [' } catch_message ]'] txt += [' handle_exception ${catch_status} ${catch_message}'] txt += ['}']