diff --git a/site_ansto/instrument/config/beamline/he3_polanal.sct b/site_ansto/instrument/config/beamline/he3_polanal.sct index ebee331a..68ba2a24 100644 --- a/site_ansto/instrument/config/beamline/he3_polanal.sct +++ b/site_ansto/instrument/config/beamline/he3_polanal.sct @@ -8,7 +8,7 @@ driver he3_polanal = { group polariser = { conditional = '[string equal -nocase ${has_pol} "true"]'; - type = text; + type = float; var spin = { readable = 900; read_command = 'polariser'; @@ -27,7 +27,7 @@ driver he3_polanal = { } group polariser_start = { conditional = '[string equal -nocase ${has_pol} "true"]'; - type = text; + type = float; var spin = { } var amplitude = { } var freq = { units = 'Hertz'; } @@ -39,7 +39,7 @@ driver he3_polanal = { group analyser = { conditional = '[string equal -nocase ${has_anal} "true"]'; - type = text; + type = float; var spin = { readable = 900; read_command = 'analyser'; @@ -58,7 +58,7 @@ driver he3_polanal = { } group analyser_start = { conditional = '[string equal -nocase ${has_anal} "true"]'; - type = text; + type = float; var spin = { } var amplitude = { } var freq = { units = 'Hertz'; } @@ -92,27 +92,13 @@ driver he3_polanal = { set data [lindex ${dlist} 1] } set path [pathname [sct]] - set timestamp [clock format [clock seconds] -format "%T"] - if {[llength ${dlist}] > 2} { - set new_value [lindex ${dlist} 2] - if { "${new_value}" == "NaN" } { - set new_value 0 - } - hupdateif ${path}/amplitude "${new_value}" - } - if {[llength ${dlist}] > 3} { - hupdateif ${path}/freq "[lindex ${dlist} 3]" - } - if {[llength ${dlist}] > 4} { - hupdateif ${path}/phase "[lindex ${dlist} 4]" - } - if {[llength ${dlist}] > 5} { - hupdateif ${path}/time2 "[lindex ${dlist} 5]" - } - if {[llength ${dlist}] > 6} { - hupdateif ${path}/field "[lindex ${dlist} 6]" - } - hupdateif ${path}/timestamp "${timestamp}" + set timestamp [clock seconds] + [namespace current]::do_update ${path}/amplitude ${dlist} 2 + [namespace current]::do_update ${path}/freq ${dlist} 3 + [namespace current]::do_update ${path}/phase ${dlist} 4 + [namespace current]::do_update ${path}/time2 ${dlist} 5 + [namespace current]::do_update ${path}/field ${dlist} 6 + hupdateif ${path}/timestamp ${timestamp} %%} code setValue = {%% @@ -142,6 +128,19 @@ driver he3_polanal = { set cmd "${cmd_str} +" } %%} + code preamble = { + @TCL + proc do_update { node dlist idx } { + if {[llength ${dlist}] > ${idx}} { + if {![string is double [lindex ${dlist} ${idx}]]} { + hupdateif ${node} 0.0 + } else { + hupdateif ${node} [lindex ${dlist} ${idx}] + } + } + } + @END + } code postamble = { @TCL proc stash {node} {