Rework the he3_polanal.sct driver

This commit is contained in:
Douglas Clowes
2014-11-06 18:17:02 +11:00
parent c488733bcd
commit 3602f56352

View File

@ -4,42 +4,73 @@ 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}';
group polariser = { group polariser = {
conditional = '[string equal -nocase ${has_pol} "true"]';
type = text;
var spin = { var spin = {
type = text;
readable = 900; readable = 900;
read_command = 'polariser'; read_command = 'polariser';
read_function = rdValue; read_function = rdValue;
writeable = 1; writeable = 1;
write_command = 'polariser'; write_command = 'polariser';
check_function = chkWrite; check_function = chkWrite;
allowed = "+,-,0" allowed = "+,-,Refresh"
} }
var Amplitude = { type = text; } var Amplitude = { }
var Freq = { type = text; units = 'Hertz'; } var Freq = { units = 'Hertz'; }
var Phase = { type = text; units = 'Degree'; } var Phase = { units = 'Degree'; }
var Time2 = { type = text; units = 'Second'; } var Time2 = { units = 'Second'; }
var Field = { type = text; units = 'Oersted'; } var Field = { units = 'Oersted'; }
var Timestamp = { }
} }
group polariser_start = {
conditional = '[string equal -nocase ${has_pol} "true"]';
type = text;
var spin = { }
var Amplitude = { }
var Freq = { units = 'Hertz'; }
var Phase = { units = 'Degree'; }
var Time2 = { units = 'Second'; }
var Field = { units = 'Oersted'; }
var Timestamp = { }
}
group analyser = { group analyser = {
conditional = '[string equal -nocase ${has_anal} "true"]';
type = text;
var spin = { var spin = {
type = text;
readable = 900; readable = 900;
read_command = 'analyser'; read_command = 'analyser';
read_function = rdValue; read_function = rdValue;
writeable = 1; writeable = 1;
write_command = 'analyser'; write_command = 'analyser';
check_function = chkWrite; check_function = chkWrite;
allowed = "+,-,0" allowed = "+,-,Refresh"
} }
var Amplitude = { type = text; } var Amplitude = { }
var Freq = { type = text; units = 'Hertz'; } var Freq = { units = 'Hertz'; }
var Phase = { type = text; units = 'Degree'; } var Phase = { units = 'Degree'; }
var Time2 = { type = text; units = 'Second'; } var Time2 = { units = 'Second'; }
var Field = { type = text; units = 'Oersted'; } var Field = { units = 'Oersted'; }
var Timestamp = { }
} }
group analyser_start = {
conditional = '[string equal -nocase ${has_anal} "true"]';
type = text;
var spin = { }
var Amplitude = { }
var Freq = { units = 'Hertz'; }
var Phase = { units = 'Degree'; }
var Time2 = { units = 'Second'; }
var Field = { units = 'Oersted'; }
var Timestamp = { }
}
code chkWrite = {%% code chkWrite = {%%
[namespace current]::rdValue ${tc_root} [namespace current]::rdValue ${tc_root}
clientput [sct result]
%%} %%}
code rdValue = {%% code rdValue = {%%
@ -61,6 +92,7 @@ driver he3_polanal = {
set data [lindex ${dlist} 1] set data [lindex ${dlist} 1]
} }
set path [pathname [sct]] set path [pathname [sct]]
set timestamp [clock format [clock seconds] -format "%T"]
if {[llength ${dlist}] > 2} { if {[llength ${dlist}] > 2} {
set new_value [lindex ${dlist} 2] set new_value [lindex ${dlist} 2]
if { "${new_value}" == "NaN" } { if { "${new_value}" == "NaN" } {
@ -80,6 +112,7 @@ driver he3_polanal = {
if {[llength ${dlist}] > 6} { if {[llength ${dlist}] > 6} {
hupdateif ${path}/Field "[lindex ${dlist} 6]" hupdateif ${path}/Field "[lindex ${dlist} 6]"
} }
hupdateif ${path}/Timestamp "${timestamp}"
%%} %%}
code setValue = {%% code setValue = {%%
@ -87,6 +120,9 @@ driver he3_polanal = {
if {[string equal -nocase [sct target] "refresh"]} { if {[string equal -nocase [sct target] "refresh"]} {
set cmd "${cmd_str}" set cmd "${cmd_str}"
} }
if {[string equal -nocase [sct target] "minus"]} {
set cmd "${cmd_str} -"
}
if {[string equal -nocase [sct target] "dn"]} { if {[string equal -nocase [sct target] "dn"]} {
set cmd "${cmd_str} -" set cmd "${cmd_str} -"
} }
@ -96,6 +132,9 @@ driver he3_polanal = {
if {[sct target] == "-" || [sct target] == -1} { if {[sct target] == "-" || [sct target] == -1} {
set cmd "${cmd_str} -" set cmd "${cmd_str} -"
} }
if {[string equal -nocase [sct target] "plus"]} {
set cmd "${cmd_str} +"
}
if {[string equal -nocase [sct target] "up"]} { if {[string equal -nocase [sct target] "up"]} {
set cmd "${cmd_str} +" set cmd "${cmd_str} +"
} }