Changes to 3He driver

This commit is contained in:
Douglas Clowes
2014-10-22 11:56:28 +11:00
parent d9660d1f7b
commit 2ed8269a0f
2 changed files with 117 additions and 111 deletions

View File

@@ -1,16 +1,31 @@
# 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 = {
group polariser = {
var spin = {
type = text;
readable = 10;
read_command = 'spin 0 0';
read_command = 'polariser';
read_function = rdValue;
writeable = 1;
write_command = 'spin ';
write_command = 'polariser';
check_function = chkWrite;
allowed = "+,-,0"
}
}
group analyser = {
var spin = {
type = text;
readable = 10;
read_command = 'analyser';
read_function = rdValue;
writeable = 1;
write_command = 'analyser';
check_function = chkWrite;
allowed = "+,-,0"
}
}
code chkWrite = {%%
@@ -19,60 +34,40 @@ driver he3_polanal = {
code rdValue = {%%
set dlist [split ${data}]
if {[lindex ${dlist} 0] != "Spin"} {
sct geterror "Unexpected 'Spin' response '${data}'"
if {[llength ${dlist}] < 2} {
sct geterror "Syntax Error: '${data}'"
error "[sct geterror]"
}
set idx [lsearch ${dlist} "and"]
if { ${idx} < 0 } {
sct geterror "Unexpected 'and' response '${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}"
}
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}'"
if {[string match "*Not Active*" "${data}"]} {
set data 0
} elseif {[string match -nocase "*Error:*" "${data}"]} {
sct geterror "${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]"
set data [lindex ${dlist} 1]
}
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]"
}
set cmd "${cmd_str}"
if {[string equal -nocase [sct target] "dn"]} {
set cmd "${cmd_str} -"
}
if { [lindex ${dlist} 0] != "+" && [lindex ${dlist} 0] != "-" && [lindex ${dlist} 0] != "0" } {
sct geterror ${geterror}
error "[sct geterror]"
if {[string equal -nocase [sct target] "down"]} {
set cmd "${cmd_str} -"
}
if { [lindex ${dlist} 1] != "+" && [lindex ${dlist} 1] != "-" && [lindex ${dlist} 1] != "0" } {
sct geterror ${geterror}
error "[sct geterror]"
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} +"
}
set cmd "spin [lindex ${dlist} 0] [lindex ${dlist} 1]"
%%}
}