Files
sics/site_ansto/instrument/config/beamline/he3_polanal.sct
2014-10-27 17:50:55 +11:00

107 lines
3.0 KiB
Plaintext

# vim: ts=8 sts=2 sw=2 expandtab autoindent smartindent nocindent
driver he3_polanal = {
debug_threshold = 0;
protocol = std;
class = instrument;
simulation_group = rfgen_simulation;
group polariser = {
var spin = {
type = text;
readable = 900;
read_command = 'polariser';
read_function = rdValue;
writeable = 1;
write_command = 'polariser';
check_function = chkWrite;
allowed = "+,-,0"
}
var Amplitude = { type = text; }
var Freq = { type = text; units = 'Hertz'; }
var Phase = { type = text; units = 'Degree'; }
var Time2 = { type = text; units = 'Second'; }
var Field = { type = text; units = 'Oersted'; }
}
group analyser = {
var spin = {
type = text;
readable = 900;
read_command = 'analyser';
read_function = rdValue;
writeable = 1;
write_command = 'analyser';
check_function = chkWrite;
allowed = "+,-,0"
}
var Amplitude = { type = text; }
var Freq = { type = text; units = 'Hertz'; }
var Phase = { type = text; units = 'Degree'; }
var Time2 = { type = text; units = 'Second'; }
var Field = { type = text; units = 'Oersted'; }
}
code chkWrite = {%%
[namespace current]::rdValue ${tc_root}
%%}
code rdValue = {%%
set dlist [split ${data}]
if {[llength ${dlist}] < 2} {
sct geterror "Syntax Error: '${data}'"
error "[sct geterror]"
}
set my_name [basename [pathname [sct]]]
if {![string equal -nocase "[lindex ${dlist} 0]" "${my_name}"]} {
error "[lindex ${dlist} 0] is not my name (${my_name})"
}
if {[string match "*Not Active*" "${data}"]} {
set data 0
} elseif {[string match -nocase "*Error:*" "${data}"]} {
sct geterror "${data}"
error "[sct geterror]"
} else {
set data [lindex ${dlist} 1]
}
set path [pathname [sct]]
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]"
}
%%}
code setValue = {%%
set cmd "${cmd_str}"
if {[string equal -nocase [sct target] "refresh"]} {
set cmd "${cmd_str}"
}
if {[string equal -nocase [sct target] "dn"]} {
set cmd "${cmd_str} -"
}
if {[string equal -nocase [sct target] "down"]} {
set cmd "${cmd_str} -"
}
if {[sct target] == "-" || [sct target] == -1} {
set cmd "${cmd_str} -"
}
if {[string equal -nocase [sct target] "up"]} {
set cmd "${cmd_str} +"
}
if {[sct target] == "+" || [sct target] == 1} {
set cmd "${cmd_str} +"
}
%%}
}