From f80bec1403336af60e11f1521b743fe7a005696e Mon Sep 17 00:00:00 2001 From: Douglas Clowes Date: Mon, 16 Feb 2015 12:38:02 +1100 Subject: [PATCH] Changes to get and set the field coil values --- .../config/beamline/he3_polanal.sct | 80 +++++++++++++++++-- 1 file changed, 75 insertions(+), 5 deletions(-) diff --git a/site_ansto/instrument/config/beamline/he3_polanal.sct b/site_ansto/instrument/config/beamline/he3_polanal.sct index 5352068d..7d48a708 100644 --- a/site_ansto/instrument/config/beamline/he3_polanal.sct +++ b/site_ansto/instrument/config/beamline/he3_polanal.sct @@ -3,7 +3,7 @@ driver he3_polanal = { protocol = std; class = instrument; 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 = { conditional = '[string equal -nocase ${has_pol} "true"]'; @@ -11,7 +11,7 @@ driver he3_polanal = { var spin = { readable = 900; read_command = 'polariser'; - read_function = rdValue; + read_function = read_spin; writeable = 1; write_command = 'polariser'; check_function = chkWrite; @@ -42,7 +42,7 @@ driver he3_polanal = { var spin = { readable = 900; read_command = 'analyser'; - read_function = rdValue; + read_function = read_spin; writeable = 1; write_command = 'analyser'; check_function = chkWrite; @@ -67,12 +67,82 @@ driver he3_polanal = { 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 = {%% - [namespace current]::rdValue ${tc_root} + [namespace current]::read_spin ${tc_root} clientput [sct result] %%} - code rdValue = {%% + code read_spin = {%% set dlist [split [string trim ${data}]] if {[llength ${dlist}] < 2} { sct geterror "Syntax Error: '${data}'"