Files
sics/site_ansto/instrument/config/beamline/he3_polanal.sct
2014-10-16 15:52:30 +11:00

79 lines
2.5 KiB
Plaintext

# vim: ts=8 sts=2 sw=2 expandtab autoindent smartindent nocindent
driver he3_polanal = {
protocol = std;
class = instrument;
simulation_group = rfgen_simulation;
group = {
var spin = {
type = text;
readable = 10;
read_command = 'spin 0 0';
writeable = 1;
write_command = 'spin ';
check_function = chkWrite;
}
}
code chkWrite = {%%
rdValue ${tc_root}
%%}
code rdValue = {%%
set dlist [split ${data}]
if {[lindex ${dlist} 0] != "Spin"} {
sct geterror "Unexpected 'Spin' response '${data}'"
error "[sct geterror]"
}
set idx [lsearch ${dlist} "and"]
if { ${idx} < 0 } {
sct geterror "Unexpected 'and' response '${data}'"
error "[sct geterror]"
}
set plist [lrange ${dlist} 1 ${idx}-1]
set alist [lrange ${dlist} ${idx}+1 end]
if {[lindex ${plist} 0] != "Polariser"} {
sct geterror "Unexpected 'Polariser' response '${data}'"
error "[sct geterror]"
} elseif {[lindex ${plist} 1] == "In" && [lindex ${plist} 3] == "State"} {
set pstate [string index [lindex ${plist} 2] 1]
} elseif {[lindex ${plist} 1] == "Not" && [lindex ${plist} 2] == "Active"} {
set pstate 0
} else {
sct geterror "Unexpected 'Polariser State' response '${data}'"
error "[sct geterror]"
}
if {[lindex ${alist} 0] != "Analyser"} {
sct geterror "Unexpected 'Analyser' response '${data}'"
error "[sct geterror]"
} elseif {[lindex ${alist} 1] == "In" && [lindex ${alist} 3] == "State"} {
set astate [string index [lindex ${alist} 2] 1]
} elseif {[lindex ${alist} 1] == "Not" && [lindex ${alist} 2] == "Active."} {
set astate 0
} else {
sct geterror "Unexpected 'Analyser State' response '${data}'"
error "[sct geterror]"
}
set data "${pstate} ${astate}"
%%}
code setValue = {%%
set geterror "Spin target must be 'x/y', where x,y are 0,+,- and not '[sct target]'"
set dlist [split [sct target]]
if {[llength ${dlist}] != 2} {
set dlist [split [sct target] /]
if {[llength ${dlist}] != 2} {
sct geterror ${geterror}
error "[sct geterror]"
}
}
if { [lindex ${dlist} 0] != "+" && [lindex ${dlist} 0] != "-" && [lindex ${dlist} 0] != "0" } {
sct geterror ${geterror}
error "[sct geterror]"
}
if { [lindex ${dlist} 1] != "+" && [lindex ${dlist} 1] != "-" && [lindex ${dlist} 1] != "0" } {
sct geterror ${geterror}
error "[sct geterror]"
}
set cmd "spin [lindex ${dlist} 0] [lindex ${dlist} 1]"
%%}
}