Changes to get and set the field coil values

This commit is contained in:
Douglas Clowes
2015-02-16 12:38:02 +11:00
parent 22bb612296
commit f80bec1403

View File

@ -3,7 +3,7 @@ driver he3_polanal = {
protocol = std; protocol = std;
class = instrument; class = instrument;
simulation_group = rfgen_simulation; simulation_group = rfgen_simulation;
make_args = '{has_pol true} {has_anal true}'; make_args = '{has_pol true} {has_anal true} {has_coil false}';
group polariser = { group polariser = {
conditional = '[string equal -nocase ${has_pol} "true"]'; conditional = '[string equal -nocase ${has_pol} "true"]';
@ -11,7 +11,7 @@ driver he3_polanal = {
var spin = { var spin = {
readable = 900; readable = 900;
read_command = 'polariser'; read_command = 'polariser';
read_function = rdValue; read_function = read_spin;
writeable = 1; writeable = 1;
write_command = 'polariser'; write_command = 'polariser';
check_function = chkWrite; check_function = chkWrite;
@ -42,7 +42,7 @@ driver he3_polanal = {
var spin = { var spin = {
readable = 900; readable = 900;
read_command = 'analyser'; read_command = 'analyser';
read_function = rdValue; read_function = read_spin;
writeable = 1; writeable = 1;
write_command = 'analyser'; write_command = 'analyser';
check_function = chkWrite; check_function = chkWrite;
@ -67,12 +67,82 @@ driver he3_polanal = {
var timestamp = { type = int; } var timestamp = { type = int; }
} }
group magnet = {
conditional = '[string equal -nocase ${has_coil} "true"]';
type = float;
group sense = {
var x_voltage = {}
var x_current = {}
var y_voltage = {}
var y_current = {}
var z_voltage = {}
var z_current = {}
var sense = {
type = int; data = false; mutable = false; nxsave = false;
readable = 30;
read_command = 'magnet_xyz';
read_function = read_magnet;
writeable = 1;
write_function = fetch_magnet;
write_command = 'magnet_xyz';
}
}
group setpoint = {
var x_current_sp = {}
var y_current_sp = {}
var z_current_sp = {}
var store = {
type = int; data = false; mutable = false; nxsave = false;
writeable = 1;
write_function = write_magnet;
write_command = 'magnet_xyz';
}
}
}
code read_magnet = {
@TCL
set dlist [split [string trim ${data}]]
if {[llength $dlist] != 7} {
error "Syntax error: '${data}'"
}
set index 1
set path [pathname [sct]]
set ns [namespace current]
foreach node {x_voltage x_current y_voltage y_current z_voltage z_current} {
hsetprop ${path}/${node} result [lindex $dlist ${index}]
sct with ${path}/${node} "${ns}::rdValue ${tc_root}"
incr index
}
set data 0
@END
}
code fetch_magnet = {
@TCL
# Just do a fetch and go on to the read state
set cmd "${cmd_str}"
set nextState "read_magnet"
@END
}
code write_magnet = {
@TCL
# Just do a fetch and go on to the read state
set path [pathname [sct]]
set cmd "${cmd_str}"
set cmd "${cmd} [hval ${path}/x_current_sp]"
set cmd "${cmd} [hval ${path}/y_current_sp]"
set cmd "${cmd} [hval ${path}/z_current_sp]"
@END
}
code chkWrite = {%% code chkWrite = {%%
[namespace current]::rdValue ${tc_root} [namespace current]::read_spin ${tc_root}
clientput [sct result] clientput [sct result]
%%} %%}
code rdValue = {%% code read_spin = {%%
set dlist [split [string trim ${data}]] set dlist [split [string trim ${data}]]
if {[llength ${dlist}] < 2} { if {[llength ${dlist}] < 2} {
sct geterror "Syntax Error: '${data}'" sct geterror "Syntax Error: '${data}'"