# vim: ts=8 sts=2 sw=2 expandtab autoindent smartindent nocindent driver he3_polanal = { protocol = std; class = instrument; simulation_group = rfgen_simulation; make_args = '{has_pol true} {has_anal true}'; group polariser = { conditional = '[string equal -nocase ${has_pol} "true"]'; type = float; var spin = { readable = 900; read_command = 'polariser'; read_function = rdValue; writeable = 1; write_command = 'polariser'; check_function = chkWrite; allowed = "-1,0,+1" } var amplitude = { } var freq = { units = 'Hertz'; } var phase = { units = 'Degree'; } var time2 = { units = 'Second'; } var field = { units = 'Oersted'; } var timestamp = { type = int; } } group polariser_start = { conditional = '[string equal -nocase ${has_pol} "true"]'; type = float; var spin = { } var amplitude = { } var freq = { units = 'Hertz'; } var phase = { units = 'Degree'; } var time2 = { units = 'Second'; } var field = { units = 'Oersted'; } var timestamp = { type = int; } } group analyser = { conditional = '[string equal -nocase ${has_anal} "true"]'; type = float; var spin = { readable = 900; read_command = 'analyser'; read_function = rdValue; writeable = 1; write_command = 'analyser'; check_function = chkWrite; allowed = "+,-,Refresh" } var amplitude = { } var freq = { units = 'Hertz'; } var phase = { units = 'Degree'; } var time2 = { units = 'Second'; } var field = { units = 'Oersted'; } var timestamp = { type = int; } } group analyser_start = { conditional = '[string equal -nocase ${has_anal} "true"]'; type = float; var spin = { } var amplitude = { } var freq = { units = 'Hertz'; } var phase = { units = 'Degree'; } var time2 = { units = 'Second'; } var field = { units = 'Oersted'; } var timestamp = { type = int; } } code chkWrite = {%% [namespace current]::rdValue ${tc_root} clientput [sct result] %%} code rdValue = {%% set dlist [split [string trim ${data}]] if {[llength ${dlist}] < 2} { sct geterror "Syntax Error: '${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 (${my_name})" } if {[string match "*Not Active*" "${data}"]} { set data 0 } elseif {[string match -nocase "*Error:*" "${data}"]} { sct geterror "${data}" error "[sct geterror]" } else { set data [lindex ${dlist} 1] } set path [pathname [sct]] set timestamp [clock seconds] [namespace current]::do_update ${path}/amplitude ${dlist} 2 [namespace current]::do_update ${path}/freq ${dlist} 3 [namespace current]::do_update ${path}/phase ${dlist} 4 [namespace current]::do_update ${path}/time2 ${dlist} 5 [namespace current]::do_update ${path}/field ${dlist} 6 hupdateif ${path}/timestamp ${timestamp} %%} code setValue = {%% set cmd "${cmd_str}" if {[sct target] == "-" || [sct target] == -1} { set cmd "${cmd_str} -" } if {[sct target] == "+" || [sct target] == 1} { set cmd "${cmd_str} +" } %%} code preamble = { @TCL proc do_update { node dlist idx } { if {[llength ${dlist}] > ${idx}} { if {![string is double [lindex ${dlist} ${idx}]]} { hupdateif ${node} 0.0 } else { hupdateif ${node} [lindex ${dlist} ${idx}] } } } @END } code postamble = { @TCL proc stash {node} { foreach arg {spin amplitude freq phase time2 field timestamp} { hupdateif ${node}_start/${arg} [hval ${node}/${arg}] } } @END } }