Merge branch 'RELEASE-3_1'
This commit is contained in:
@ -1,6 +1,5 @@
|
||||
# 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;
|
||||
|
@ -3,7 +3,7 @@
|
||||
#
|
||||
|
||||
namespace eval ::scobj::he3_polanal {
|
||||
set debug_threshold 0
|
||||
set debug_threshold 5
|
||||
# preamble hook code starts
|
||||
proc do_update { node dlist idx } {
|
||||
if {[llength ${dlist}] > ${idx}} {
|
||||
@ -595,7 +595,7 @@ proc ::scobj::he3_polanal::mkDriver { sct_controller name device_class simulatio
|
||||
}
|
||||
hsetprop ${scobj_hpath} klass ${device_class}
|
||||
hsetprop ${scobj_hpath} data true
|
||||
hsetprop ${scobj_hpath} debug_threshold 0
|
||||
hsetprop ${scobj_hpath} debug_threshold 5
|
||||
# mkDriver hook code goes here
|
||||
} catch_message ]
|
||||
handle_exception ${catch_status} ${catch_message}
|
||||
|
@ -3,7 +3,6 @@
|
||||
# vim: ft=tcl ts=8 sts=2 sw=2 expandtab autoindent smartindent nocindent
|
||||
#
|
||||
driver knauer_pump = {
|
||||
debug_threshold = 0;
|
||||
vendor = knauer; device = pump40p; protocol = knauer_ap;
|
||||
class = environment;
|
||||
simulation_group = environment_simulation;
|
||||
|
@ -3,7 +3,7 @@
|
||||
#
|
||||
|
||||
namespace eval ::scobj::knauer_pump {
|
||||
set debug_threshold 0
|
||||
set debug_threshold 5
|
||||
}
|
||||
|
||||
proc ::scobj::knauer_pump::debug_log {tc_root debug_level debug_string} {
|
||||
@ -1176,7 +1176,7 @@ proc ::scobj::knauer_pump::mkDriver { sct_controller name device_class simulatio
|
||||
ansto_makesctdrive ${name}_pump_volume_setp ${scobj_hpath}/pump/volume/setp ${scobj_hpath}/pump/volume/pval ${sct_controller}
|
||||
hsetprop ${scobj_hpath} klass ${device_class}
|
||||
hsetprop ${scobj_hpath} data true
|
||||
hsetprop ${scobj_hpath} debug_threshold 0
|
||||
hsetprop ${scobj_hpath} debug_threshold 5
|
||||
# mkDriver hook code starts
|
||||
#hset ${scobj_hpath}/pump/remote 1
|
||||
# mkDriver hook code ends
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,11 @@
|
||||
#
|
||||
# Template driver for the Lakeshore 218 Temperature Monitor
|
||||
# vim: ft=tcl ts=8 sts=2 sw=2 expandtab autoindent smartindent nocindent
|
||||
#
|
||||
driver lakeshore_218 = {
|
||||
vendor = lakeshore; device = ls218; protocol = std;
|
||||
class = NXdetector; simulation_group = detector_simulation;
|
||||
make_args = '{num_chans 8}';
|
||||
|
||||
group = {
|
||||
data = false;
|
||||
@ -11,28 +16,34 @@ driver lakeshore_218 = {
|
||||
var krdg = {
|
||||
type = text;
|
||||
read_command = "KRDG? 0";
|
||||
value = "0,0,0,0,0,0,0,0";
|
||||
read_function = read_krdg;
|
||||
value = '"Hidden in real_data property"';
|
||||
property real_data = '0,0,0,0,0,0,0,0';
|
||||
}
|
||||
}
|
||||
|
||||
group sensor = {
|
||||
priv = user; mutable = true;
|
||||
type = float;
|
||||
readable = 1;
|
||||
readable = 15;
|
||||
fetch_function = getTemp;
|
||||
var ch1 = { read_command = '0'; }
|
||||
var ch2 = { read_command = '1'; }
|
||||
var ch3 = { read_command = '2'; }
|
||||
var ch4 = { read_command = '3'; }
|
||||
var ch5 = { read_command = '4'; }
|
||||
var ch6 = { read_command = '5'; }
|
||||
var ch7 = { read_command = '6'; }
|
||||
var ch8 = { read_command = '7'; }
|
||||
var ch1 = { read_command = '0'; conditional = '${num_chans} > 0'; }
|
||||
var ch2 = { read_command = '1'; conditional = '${num_chans} > 1'; }
|
||||
var ch3 = { read_command = '2'; conditional = '${num_chans} > 2'; }
|
||||
var ch4 = { read_command = '3'; conditional = '${num_chans} > 3'; }
|
||||
var ch5 = { read_command = '4'; conditional = '${num_chans} > 4'; }
|
||||
var ch6 = { read_command = '5'; conditional = '${num_chans} > 5'; }
|
||||
var ch7 = { read_command = '6'; conditional = '${num_chans} > 6'; }
|
||||
var ch8 = { read_command = '7'; conditional = '${num_chans} > 7'; }
|
||||
}
|
||||
|
||||
code fetch_function getTemp = {%%
|
||||
set temps [split "[hval ${tc_root}/krdg]" ","]
|
||||
set temps [split "[hgetpropval ${tc_root}/krdg real_data]" ","]
|
||||
sct result [lindex ${temps} ${cmd_str}]
|
||||
set cmd "@@NOSEND@@"
|
||||
%%}
|
||||
code read_krdg = {%%
|
||||
sct real_data "${data}"
|
||||
set data "Hidden in real_data property"
|
||||
%%}
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ proc ::scobj::lakeshore_218::getTemp {tc_root nextState cmd_str} {
|
||||
}
|
||||
set cmd "${cmd_str}"
|
||||
# getTemp hook code starts
|
||||
set temps [split "[hval ${tc_root}/krdg]" ","]
|
||||
set temps [split "[hgetpropval ${tc_root}/krdg real_data]" ","]
|
||||
sct result [lindex ${temps} ${cmd_str}]
|
||||
set cmd "@@NOSEND@@"
|
||||
# getTemp hook code ends
|
||||
@ -136,6 +136,39 @@ proc ::scobj::lakeshore_218::rdValue {tc_root} {
|
||||
handle_exception ${catch_status} ${catch_message}
|
||||
}
|
||||
|
||||
# function to parse the read of a parameter on a device
|
||||
proc ::scobj::lakeshore_218::read_krdg {tc_root} {
|
||||
set catch_status [ catch {
|
||||
debug_log ${tc_root} 1 "read_krdg tc_root=${tc_root} sct=[sct] result=[sct result]"
|
||||
if { [hpropexists [sct] geterror] } {
|
||||
hdelprop [sct] geterror
|
||||
}
|
||||
set data [sct result]
|
||||
set nextState "idle"
|
||||
if {[string equal -nocase -length 7 ${data} "ASCERR:"]} {
|
||||
# the protocol driver has reported an error
|
||||
sct geterror "${data}"
|
||||
error "[sct geterror]"
|
||||
}
|
||||
# read_krdg hook code starts
|
||||
sct real_data "${data}"
|
||||
set data "Hidden in real_data property"
|
||||
# read_krdg hook code ends
|
||||
if { [hpropexists [sct] geterror] } {
|
||||
debug_log ${tc_root} 9 "[sct] error: [sct geterror]"
|
||||
error "[sct geterror]"
|
||||
}
|
||||
if { ${data} != [sct oldval] } {
|
||||
debug_log ${tc_root} 1 "[sct] changed to new:${data}, from old:[sct oldval]"
|
||||
sct oldval ${data}
|
||||
sct update ${data}
|
||||
sct utime readtime
|
||||
}
|
||||
return ${nextState}
|
||||
} catch_message ]
|
||||
handle_exception ${catch_status} ${catch_message}
|
||||
}
|
||||
|
||||
# function to write a parameter value on a device
|
||||
proc ::scobj::lakeshore_218::setValue {tc_root nextState cmd_str} {
|
||||
set catch_status [ catch {
|
||||
@ -160,8 +193,8 @@ proc ::scobj::lakeshore_218::setValue {tc_root nextState cmd_str} {
|
||||
handle_exception ${catch_status} ${catch_message}
|
||||
}
|
||||
|
||||
proc ::scobj::lakeshore_218::mkDriver { sct_controller name device_class simulation_flag ip_address tcp_port } {
|
||||
::scobj::lakeshore_218::sics_log 9 "::scobj::lakeshore_218::mkDriver ${sct_controller} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}"
|
||||
proc ::scobj::lakeshore_218::mkDriver { sct_controller name device_class simulation_flag ip_address tcp_port {num_chans 8} } {
|
||||
::scobj::lakeshore_218::sics_log 9 "::scobj::lakeshore_218::mkDriver ${sct_controller} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${num_chans}"
|
||||
set ns "[namespace current]"
|
||||
set catch_status [ catch {
|
||||
|
||||
@ -173,14 +206,15 @@ proc ::scobj::lakeshore_218::mkDriver { sct_controller name device_class simulat
|
||||
set scobj_hpath /sics/${name}
|
||||
|
||||
hfactory ${scobj_hpath}/krdg plain user text
|
||||
hsetprop ${scobj_hpath}/krdg read ${ns}::getValue ${scobj_hpath} rdValue {KRDG? 0}
|
||||
hsetprop ${scobj_hpath}/krdg rdValue ${ns}::rdValue ${scobj_hpath}
|
||||
hsetprop ${scobj_hpath}/krdg read ${ns}::getValue ${scobj_hpath} read_krdg {KRDG? 0}
|
||||
hsetprop ${scobj_hpath}/krdg read_krdg ${ns}::read_krdg ${scobj_hpath}
|
||||
hsetprop ${scobj_hpath}/krdg control false
|
||||
hsetprop ${scobj_hpath}/krdg data false
|
||||
hsetprop ${scobj_hpath}/krdg mutable true
|
||||
hsetprop ${scobj_hpath}/krdg nxsave false
|
||||
hsetprop ${scobj_hpath}/krdg oldval 0,0,0,0,0,0,0,0
|
||||
hset ${scobj_hpath}/krdg 0,0,0,0,0,0,0,0
|
||||
hsetprop ${scobj_hpath}/krdg oldval "Hidden in real_data property"
|
||||
hset ${scobj_hpath}/krdg "Hidden in real_data property"
|
||||
hsetprop ${scobj_hpath}/krdg real_data "0,0,0,0,0,0,0,0"
|
||||
hsetprop ${scobj_hpath}/krdg sdsinfo "::nexus::scobj::sdsinfo"
|
||||
hsetprop ${scobj_hpath}/krdg type "part"
|
||||
hsetprop ${scobj_hpath}/krdg nxalias "${name}_krdg"
|
||||
@ -199,172 +233,188 @@ proc ::scobj::lakeshore_218::mkDriver { sct_controller name device_class simulat
|
||||
|
||||
hfactory ${scobj_hpath}/sensor plain spy none
|
||||
|
||||
hfactory ${scobj_hpath}/sensor/ch1 plain user float
|
||||
hsetprop ${scobj_hpath}/sensor/ch1 read ${ns}::getTemp ${scobj_hpath} rdValue {0}
|
||||
hsetprop ${scobj_hpath}/sensor/ch1 rdValue ${ns}::rdValue ${scobj_hpath}
|
||||
hsetprop ${scobj_hpath}/sensor/ch1 control true
|
||||
hsetprop ${scobj_hpath}/sensor/ch1 data true
|
||||
hsetprop ${scobj_hpath}/sensor/ch1 mutable true
|
||||
hsetprop ${scobj_hpath}/sensor/ch1 nxsave true
|
||||
hsetprop ${scobj_hpath}/sensor/ch1 oldval 0.0
|
||||
hsetprop ${scobj_hpath}/sensor/ch1 klass "parameter"
|
||||
hsetprop ${scobj_hpath}/sensor/ch1 sdsinfo "::nexus::scobj::sdsinfo"
|
||||
hsetprop ${scobj_hpath}/sensor/ch1 type "part"
|
||||
hsetprop ${scobj_hpath}/sensor/ch1 nxalias "${name}_sensor_ch1"
|
||||
if {${num_chans} > 0} {
|
||||
hfactory ${scobj_hpath}/sensor/ch1 plain user float
|
||||
hsetprop ${scobj_hpath}/sensor/ch1 read ${ns}::getTemp ${scobj_hpath} rdValue {0}
|
||||
hsetprop ${scobj_hpath}/sensor/ch1 rdValue ${ns}::rdValue ${scobj_hpath}
|
||||
hsetprop ${scobj_hpath}/sensor/ch1 control true
|
||||
hsetprop ${scobj_hpath}/sensor/ch1 data true
|
||||
hsetprop ${scobj_hpath}/sensor/ch1 mutable true
|
||||
hsetprop ${scobj_hpath}/sensor/ch1 nxsave true
|
||||
hsetprop ${scobj_hpath}/sensor/ch1 oldval 0.0
|
||||
hsetprop ${scobj_hpath}/sensor/ch1 klass "parameter"
|
||||
hsetprop ${scobj_hpath}/sensor/ch1 sdsinfo "::nexus::scobj::sdsinfo"
|
||||
hsetprop ${scobj_hpath}/sensor/ch1 type "part"
|
||||
hsetprop ${scobj_hpath}/sensor/ch1 nxalias "${name}_sensor_ch1"
|
||||
|
||||
if {[string equal -nocase "${simulation_flag}" "false"]} {
|
||||
${sct_controller} poll ${scobj_hpath}/sensor/ch1 1
|
||||
hsetprop ${scobj_hpath}/sensor/ch1 simulated false
|
||||
} else {
|
||||
::scobj::lakeshore_218::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for lakeshore_218"
|
||||
hsetprop ${scobj_hpath}/sensor/ch1 simulated true
|
||||
if {[string equal -nocase "${simulation_flag}" "false"]} {
|
||||
${sct_controller} poll ${scobj_hpath}/sensor/ch1 15
|
||||
hsetprop ${scobj_hpath}/sensor/ch1 simulated false
|
||||
} else {
|
||||
::scobj::lakeshore_218::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for lakeshore_218"
|
||||
hsetprop ${scobj_hpath}/sensor/ch1 simulated true
|
||||
}
|
||||
}
|
||||
|
||||
hfactory ${scobj_hpath}/sensor/ch2 plain user float
|
||||
hsetprop ${scobj_hpath}/sensor/ch2 read ${ns}::getTemp ${scobj_hpath} rdValue {1}
|
||||
hsetprop ${scobj_hpath}/sensor/ch2 rdValue ${ns}::rdValue ${scobj_hpath}
|
||||
hsetprop ${scobj_hpath}/sensor/ch2 control true
|
||||
hsetprop ${scobj_hpath}/sensor/ch2 data true
|
||||
hsetprop ${scobj_hpath}/sensor/ch2 mutable true
|
||||
hsetprop ${scobj_hpath}/sensor/ch2 nxsave true
|
||||
hsetprop ${scobj_hpath}/sensor/ch2 oldval 0.0
|
||||
hsetprop ${scobj_hpath}/sensor/ch2 klass "parameter"
|
||||
hsetprop ${scobj_hpath}/sensor/ch2 sdsinfo "::nexus::scobj::sdsinfo"
|
||||
hsetprop ${scobj_hpath}/sensor/ch2 type "part"
|
||||
hsetprop ${scobj_hpath}/sensor/ch2 nxalias "${name}_sensor_ch2"
|
||||
if {${num_chans} > 1} {
|
||||
hfactory ${scobj_hpath}/sensor/ch2 plain user float
|
||||
hsetprop ${scobj_hpath}/sensor/ch2 read ${ns}::getTemp ${scobj_hpath} rdValue {1}
|
||||
hsetprop ${scobj_hpath}/sensor/ch2 rdValue ${ns}::rdValue ${scobj_hpath}
|
||||
hsetprop ${scobj_hpath}/sensor/ch2 control true
|
||||
hsetprop ${scobj_hpath}/sensor/ch2 data true
|
||||
hsetprop ${scobj_hpath}/sensor/ch2 mutable true
|
||||
hsetprop ${scobj_hpath}/sensor/ch2 nxsave true
|
||||
hsetprop ${scobj_hpath}/sensor/ch2 oldval 0.0
|
||||
hsetprop ${scobj_hpath}/sensor/ch2 klass "parameter"
|
||||
hsetprop ${scobj_hpath}/sensor/ch2 sdsinfo "::nexus::scobj::sdsinfo"
|
||||
hsetprop ${scobj_hpath}/sensor/ch2 type "part"
|
||||
hsetprop ${scobj_hpath}/sensor/ch2 nxalias "${name}_sensor_ch2"
|
||||
|
||||
if {[string equal -nocase "${simulation_flag}" "false"]} {
|
||||
${sct_controller} poll ${scobj_hpath}/sensor/ch2 1
|
||||
hsetprop ${scobj_hpath}/sensor/ch2 simulated false
|
||||
} else {
|
||||
::scobj::lakeshore_218::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for lakeshore_218"
|
||||
hsetprop ${scobj_hpath}/sensor/ch2 simulated true
|
||||
if {[string equal -nocase "${simulation_flag}" "false"]} {
|
||||
${sct_controller} poll ${scobj_hpath}/sensor/ch2 15
|
||||
hsetprop ${scobj_hpath}/sensor/ch2 simulated false
|
||||
} else {
|
||||
::scobj::lakeshore_218::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for lakeshore_218"
|
||||
hsetprop ${scobj_hpath}/sensor/ch2 simulated true
|
||||
}
|
||||
}
|
||||
|
||||
hfactory ${scobj_hpath}/sensor/ch3 plain user float
|
||||
hsetprop ${scobj_hpath}/sensor/ch3 read ${ns}::getTemp ${scobj_hpath} rdValue {2}
|
||||
hsetprop ${scobj_hpath}/sensor/ch3 rdValue ${ns}::rdValue ${scobj_hpath}
|
||||
hsetprop ${scobj_hpath}/sensor/ch3 control true
|
||||
hsetprop ${scobj_hpath}/sensor/ch3 data true
|
||||
hsetprop ${scobj_hpath}/sensor/ch3 mutable true
|
||||
hsetprop ${scobj_hpath}/sensor/ch3 nxsave true
|
||||
hsetprop ${scobj_hpath}/sensor/ch3 oldval 0.0
|
||||
hsetprop ${scobj_hpath}/sensor/ch3 klass "parameter"
|
||||
hsetprop ${scobj_hpath}/sensor/ch3 sdsinfo "::nexus::scobj::sdsinfo"
|
||||
hsetprop ${scobj_hpath}/sensor/ch3 type "part"
|
||||
hsetprop ${scobj_hpath}/sensor/ch3 nxalias "${name}_sensor_ch3"
|
||||
if {${num_chans} > 2} {
|
||||
hfactory ${scobj_hpath}/sensor/ch3 plain user float
|
||||
hsetprop ${scobj_hpath}/sensor/ch3 read ${ns}::getTemp ${scobj_hpath} rdValue {2}
|
||||
hsetprop ${scobj_hpath}/sensor/ch3 rdValue ${ns}::rdValue ${scobj_hpath}
|
||||
hsetprop ${scobj_hpath}/sensor/ch3 control true
|
||||
hsetprop ${scobj_hpath}/sensor/ch3 data true
|
||||
hsetprop ${scobj_hpath}/sensor/ch3 mutable true
|
||||
hsetprop ${scobj_hpath}/sensor/ch3 nxsave true
|
||||
hsetprop ${scobj_hpath}/sensor/ch3 oldval 0.0
|
||||
hsetprop ${scobj_hpath}/sensor/ch3 klass "parameter"
|
||||
hsetprop ${scobj_hpath}/sensor/ch3 sdsinfo "::nexus::scobj::sdsinfo"
|
||||
hsetprop ${scobj_hpath}/sensor/ch3 type "part"
|
||||
hsetprop ${scobj_hpath}/sensor/ch3 nxalias "${name}_sensor_ch3"
|
||||
|
||||
if {[string equal -nocase "${simulation_flag}" "false"]} {
|
||||
${sct_controller} poll ${scobj_hpath}/sensor/ch3 1
|
||||
hsetprop ${scobj_hpath}/sensor/ch3 simulated false
|
||||
} else {
|
||||
::scobj::lakeshore_218::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for lakeshore_218"
|
||||
hsetprop ${scobj_hpath}/sensor/ch3 simulated true
|
||||
if {[string equal -nocase "${simulation_flag}" "false"]} {
|
||||
${sct_controller} poll ${scobj_hpath}/sensor/ch3 15
|
||||
hsetprop ${scobj_hpath}/sensor/ch3 simulated false
|
||||
} else {
|
||||
::scobj::lakeshore_218::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for lakeshore_218"
|
||||
hsetprop ${scobj_hpath}/sensor/ch3 simulated true
|
||||
}
|
||||
}
|
||||
|
||||
hfactory ${scobj_hpath}/sensor/ch4 plain user float
|
||||
hsetprop ${scobj_hpath}/sensor/ch4 read ${ns}::getTemp ${scobj_hpath} rdValue {3}
|
||||
hsetprop ${scobj_hpath}/sensor/ch4 rdValue ${ns}::rdValue ${scobj_hpath}
|
||||
hsetprop ${scobj_hpath}/sensor/ch4 control true
|
||||
hsetprop ${scobj_hpath}/sensor/ch4 data true
|
||||
hsetprop ${scobj_hpath}/sensor/ch4 mutable true
|
||||
hsetprop ${scobj_hpath}/sensor/ch4 nxsave true
|
||||
hsetprop ${scobj_hpath}/sensor/ch4 oldval 0.0
|
||||
hsetprop ${scobj_hpath}/sensor/ch4 klass "parameter"
|
||||
hsetprop ${scobj_hpath}/sensor/ch4 sdsinfo "::nexus::scobj::sdsinfo"
|
||||
hsetprop ${scobj_hpath}/sensor/ch4 type "part"
|
||||
hsetprop ${scobj_hpath}/sensor/ch4 nxalias "${name}_sensor_ch4"
|
||||
if {${num_chans} > 3} {
|
||||
hfactory ${scobj_hpath}/sensor/ch4 plain user float
|
||||
hsetprop ${scobj_hpath}/sensor/ch4 read ${ns}::getTemp ${scobj_hpath} rdValue {3}
|
||||
hsetprop ${scobj_hpath}/sensor/ch4 rdValue ${ns}::rdValue ${scobj_hpath}
|
||||
hsetprop ${scobj_hpath}/sensor/ch4 control true
|
||||
hsetprop ${scobj_hpath}/sensor/ch4 data true
|
||||
hsetprop ${scobj_hpath}/sensor/ch4 mutable true
|
||||
hsetprop ${scobj_hpath}/sensor/ch4 nxsave true
|
||||
hsetprop ${scobj_hpath}/sensor/ch4 oldval 0.0
|
||||
hsetprop ${scobj_hpath}/sensor/ch4 klass "parameter"
|
||||
hsetprop ${scobj_hpath}/sensor/ch4 sdsinfo "::nexus::scobj::sdsinfo"
|
||||
hsetprop ${scobj_hpath}/sensor/ch4 type "part"
|
||||
hsetprop ${scobj_hpath}/sensor/ch4 nxalias "${name}_sensor_ch4"
|
||||
|
||||
if {[string equal -nocase "${simulation_flag}" "false"]} {
|
||||
${sct_controller} poll ${scobj_hpath}/sensor/ch4 1
|
||||
hsetprop ${scobj_hpath}/sensor/ch4 simulated false
|
||||
} else {
|
||||
::scobj::lakeshore_218::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for lakeshore_218"
|
||||
hsetprop ${scobj_hpath}/sensor/ch4 simulated true
|
||||
if {[string equal -nocase "${simulation_flag}" "false"]} {
|
||||
${sct_controller} poll ${scobj_hpath}/sensor/ch4 15
|
||||
hsetprop ${scobj_hpath}/sensor/ch4 simulated false
|
||||
} else {
|
||||
::scobj::lakeshore_218::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for lakeshore_218"
|
||||
hsetprop ${scobj_hpath}/sensor/ch4 simulated true
|
||||
}
|
||||
}
|
||||
|
||||
hfactory ${scobj_hpath}/sensor/ch5 plain user float
|
||||
hsetprop ${scobj_hpath}/sensor/ch5 read ${ns}::getTemp ${scobj_hpath} rdValue {4}
|
||||
hsetprop ${scobj_hpath}/sensor/ch5 rdValue ${ns}::rdValue ${scobj_hpath}
|
||||
hsetprop ${scobj_hpath}/sensor/ch5 control true
|
||||
hsetprop ${scobj_hpath}/sensor/ch5 data true
|
||||
hsetprop ${scobj_hpath}/sensor/ch5 mutable true
|
||||
hsetprop ${scobj_hpath}/sensor/ch5 nxsave true
|
||||
hsetprop ${scobj_hpath}/sensor/ch5 oldval 0.0
|
||||
hsetprop ${scobj_hpath}/sensor/ch5 klass "parameter"
|
||||
hsetprop ${scobj_hpath}/sensor/ch5 sdsinfo "::nexus::scobj::sdsinfo"
|
||||
hsetprop ${scobj_hpath}/sensor/ch5 type "part"
|
||||
hsetprop ${scobj_hpath}/sensor/ch5 nxalias "${name}_sensor_ch5"
|
||||
if {${num_chans} > 4} {
|
||||
hfactory ${scobj_hpath}/sensor/ch5 plain user float
|
||||
hsetprop ${scobj_hpath}/sensor/ch5 read ${ns}::getTemp ${scobj_hpath} rdValue {4}
|
||||
hsetprop ${scobj_hpath}/sensor/ch5 rdValue ${ns}::rdValue ${scobj_hpath}
|
||||
hsetprop ${scobj_hpath}/sensor/ch5 control true
|
||||
hsetprop ${scobj_hpath}/sensor/ch5 data true
|
||||
hsetprop ${scobj_hpath}/sensor/ch5 mutable true
|
||||
hsetprop ${scobj_hpath}/sensor/ch5 nxsave true
|
||||
hsetprop ${scobj_hpath}/sensor/ch5 oldval 0.0
|
||||
hsetprop ${scobj_hpath}/sensor/ch5 klass "parameter"
|
||||
hsetprop ${scobj_hpath}/sensor/ch5 sdsinfo "::nexus::scobj::sdsinfo"
|
||||
hsetprop ${scobj_hpath}/sensor/ch5 type "part"
|
||||
hsetprop ${scobj_hpath}/sensor/ch5 nxalias "${name}_sensor_ch5"
|
||||
|
||||
if {[string equal -nocase "${simulation_flag}" "false"]} {
|
||||
${sct_controller} poll ${scobj_hpath}/sensor/ch5 1
|
||||
hsetprop ${scobj_hpath}/sensor/ch5 simulated false
|
||||
} else {
|
||||
::scobj::lakeshore_218::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for lakeshore_218"
|
||||
hsetprop ${scobj_hpath}/sensor/ch5 simulated true
|
||||
if {[string equal -nocase "${simulation_flag}" "false"]} {
|
||||
${sct_controller} poll ${scobj_hpath}/sensor/ch5 15
|
||||
hsetprop ${scobj_hpath}/sensor/ch5 simulated false
|
||||
} else {
|
||||
::scobj::lakeshore_218::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for lakeshore_218"
|
||||
hsetprop ${scobj_hpath}/sensor/ch5 simulated true
|
||||
}
|
||||
}
|
||||
|
||||
hfactory ${scobj_hpath}/sensor/ch6 plain user float
|
||||
hsetprop ${scobj_hpath}/sensor/ch6 read ${ns}::getTemp ${scobj_hpath} rdValue {5}
|
||||
hsetprop ${scobj_hpath}/sensor/ch6 rdValue ${ns}::rdValue ${scobj_hpath}
|
||||
hsetprop ${scobj_hpath}/sensor/ch6 control true
|
||||
hsetprop ${scobj_hpath}/sensor/ch6 data true
|
||||
hsetprop ${scobj_hpath}/sensor/ch6 mutable true
|
||||
hsetprop ${scobj_hpath}/sensor/ch6 nxsave true
|
||||
hsetprop ${scobj_hpath}/sensor/ch6 oldval 0.0
|
||||
hsetprop ${scobj_hpath}/sensor/ch6 klass "parameter"
|
||||
hsetprop ${scobj_hpath}/sensor/ch6 sdsinfo "::nexus::scobj::sdsinfo"
|
||||
hsetprop ${scobj_hpath}/sensor/ch6 type "part"
|
||||
hsetprop ${scobj_hpath}/sensor/ch6 nxalias "${name}_sensor_ch6"
|
||||
if {${num_chans} > 5} {
|
||||
hfactory ${scobj_hpath}/sensor/ch6 plain user float
|
||||
hsetprop ${scobj_hpath}/sensor/ch6 read ${ns}::getTemp ${scobj_hpath} rdValue {5}
|
||||
hsetprop ${scobj_hpath}/sensor/ch6 rdValue ${ns}::rdValue ${scobj_hpath}
|
||||
hsetprop ${scobj_hpath}/sensor/ch6 control true
|
||||
hsetprop ${scobj_hpath}/sensor/ch6 data true
|
||||
hsetprop ${scobj_hpath}/sensor/ch6 mutable true
|
||||
hsetprop ${scobj_hpath}/sensor/ch6 nxsave true
|
||||
hsetprop ${scobj_hpath}/sensor/ch6 oldval 0.0
|
||||
hsetprop ${scobj_hpath}/sensor/ch6 klass "parameter"
|
||||
hsetprop ${scobj_hpath}/sensor/ch6 sdsinfo "::nexus::scobj::sdsinfo"
|
||||
hsetprop ${scobj_hpath}/sensor/ch6 type "part"
|
||||
hsetprop ${scobj_hpath}/sensor/ch6 nxalias "${name}_sensor_ch6"
|
||||
|
||||
if {[string equal -nocase "${simulation_flag}" "false"]} {
|
||||
${sct_controller} poll ${scobj_hpath}/sensor/ch6 1
|
||||
hsetprop ${scobj_hpath}/sensor/ch6 simulated false
|
||||
} else {
|
||||
::scobj::lakeshore_218::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for lakeshore_218"
|
||||
hsetprop ${scobj_hpath}/sensor/ch6 simulated true
|
||||
if {[string equal -nocase "${simulation_flag}" "false"]} {
|
||||
${sct_controller} poll ${scobj_hpath}/sensor/ch6 15
|
||||
hsetprop ${scobj_hpath}/sensor/ch6 simulated false
|
||||
} else {
|
||||
::scobj::lakeshore_218::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for lakeshore_218"
|
||||
hsetprop ${scobj_hpath}/sensor/ch6 simulated true
|
||||
}
|
||||
}
|
||||
|
||||
hfactory ${scobj_hpath}/sensor/ch7 plain user float
|
||||
hsetprop ${scobj_hpath}/sensor/ch7 read ${ns}::getTemp ${scobj_hpath} rdValue {6}
|
||||
hsetprop ${scobj_hpath}/sensor/ch7 rdValue ${ns}::rdValue ${scobj_hpath}
|
||||
hsetprop ${scobj_hpath}/sensor/ch7 control true
|
||||
hsetprop ${scobj_hpath}/sensor/ch7 data true
|
||||
hsetprop ${scobj_hpath}/sensor/ch7 mutable true
|
||||
hsetprop ${scobj_hpath}/sensor/ch7 nxsave true
|
||||
hsetprop ${scobj_hpath}/sensor/ch7 oldval 0.0
|
||||
hsetprop ${scobj_hpath}/sensor/ch7 klass "parameter"
|
||||
hsetprop ${scobj_hpath}/sensor/ch7 sdsinfo "::nexus::scobj::sdsinfo"
|
||||
hsetprop ${scobj_hpath}/sensor/ch7 type "part"
|
||||
hsetprop ${scobj_hpath}/sensor/ch7 nxalias "${name}_sensor_ch7"
|
||||
if {${num_chans} > 6} {
|
||||
hfactory ${scobj_hpath}/sensor/ch7 plain user float
|
||||
hsetprop ${scobj_hpath}/sensor/ch7 read ${ns}::getTemp ${scobj_hpath} rdValue {6}
|
||||
hsetprop ${scobj_hpath}/sensor/ch7 rdValue ${ns}::rdValue ${scobj_hpath}
|
||||
hsetprop ${scobj_hpath}/sensor/ch7 control true
|
||||
hsetprop ${scobj_hpath}/sensor/ch7 data true
|
||||
hsetprop ${scobj_hpath}/sensor/ch7 mutable true
|
||||
hsetprop ${scobj_hpath}/sensor/ch7 nxsave true
|
||||
hsetprop ${scobj_hpath}/sensor/ch7 oldval 0.0
|
||||
hsetprop ${scobj_hpath}/sensor/ch7 klass "parameter"
|
||||
hsetprop ${scobj_hpath}/sensor/ch7 sdsinfo "::nexus::scobj::sdsinfo"
|
||||
hsetprop ${scobj_hpath}/sensor/ch7 type "part"
|
||||
hsetprop ${scobj_hpath}/sensor/ch7 nxalias "${name}_sensor_ch7"
|
||||
|
||||
if {[string equal -nocase "${simulation_flag}" "false"]} {
|
||||
${sct_controller} poll ${scobj_hpath}/sensor/ch7 1
|
||||
hsetprop ${scobj_hpath}/sensor/ch7 simulated false
|
||||
} else {
|
||||
::scobj::lakeshore_218::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for lakeshore_218"
|
||||
hsetprop ${scobj_hpath}/sensor/ch7 simulated true
|
||||
if {[string equal -nocase "${simulation_flag}" "false"]} {
|
||||
${sct_controller} poll ${scobj_hpath}/sensor/ch7 15
|
||||
hsetprop ${scobj_hpath}/sensor/ch7 simulated false
|
||||
} else {
|
||||
::scobj::lakeshore_218::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for lakeshore_218"
|
||||
hsetprop ${scobj_hpath}/sensor/ch7 simulated true
|
||||
}
|
||||
}
|
||||
|
||||
hfactory ${scobj_hpath}/sensor/ch8 plain user float
|
||||
hsetprop ${scobj_hpath}/sensor/ch8 read ${ns}::getTemp ${scobj_hpath} rdValue {7}
|
||||
hsetprop ${scobj_hpath}/sensor/ch8 rdValue ${ns}::rdValue ${scobj_hpath}
|
||||
hsetprop ${scobj_hpath}/sensor/ch8 control true
|
||||
hsetprop ${scobj_hpath}/sensor/ch8 data true
|
||||
hsetprop ${scobj_hpath}/sensor/ch8 mutable true
|
||||
hsetprop ${scobj_hpath}/sensor/ch8 nxsave true
|
||||
hsetprop ${scobj_hpath}/sensor/ch8 oldval 0.0
|
||||
hsetprop ${scobj_hpath}/sensor/ch8 klass "parameter"
|
||||
hsetprop ${scobj_hpath}/sensor/ch8 sdsinfo "::nexus::scobj::sdsinfo"
|
||||
hsetprop ${scobj_hpath}/sensor/ch8 type "part"
|
||||
hsetprop ${scobj_hpath}/sensor/ch8 nxalias "${name}_sensor_ch8"
|
||||
if {${num_chans} > 7} {
|
||||
hfactory ${scobj_hpath}/sensor/ch8 plain user float
|
||||
hsetprop ${scobj_hpath}/sensor/ch8 read ${ns}::getTemp ${scobj_hpath} rdValue {7}
|
||||
hsetprop ${scobj_hpath}/sensor/ch8 rdValue ${ns}::rdValue ${scobj_hpath}
|
||||
hsetprop ${scobj_hpath}/sensor/ch8 control true
|
||||
hsetprop ${scobj_hpath}/sensor/ch8 data true
|
||||
hsetprop ${scobj_hpath}/sensor/ch8 mutable true
|
||||
hsetprop ${scobj_hpath}/sensor/ch8 nxsave true
|
||||
hsetprop ${scobj_hpath}/sensor/ch8 oldval 0.0
|
||||
hsetprop ${scobj_hpath}/sensor/ch8 klass "parameter"
|
||||
hsetprop ${scobj_hpath}/sensor/ch8 sdsinfo "::nexus::scobj::sdsinfo"
|
||||
hsetprop ${scobj_hpath}/sensor/ch8 type "part"
|
||||
hsetprop ${scobj_hpath}/sensor/ch8 nxalias "${name}_sensor_ch8"
|
||||
|
||||
if {[string equal -nocase "${simulation_flag}" "false"]} {
|
||||
${sct_controller} poll ${scobj_hpath}/sensor/ch8 1
|
||||
hsetprop ${scobj_hpath}/sensor/ch8 simulated false
|
||||
} else {
|
||||
::scobj::lakeshore_218::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for lakeshore_218"
|
||||
hsetprop ${scobj_hpath}/sensor/ch8 simulated true
|
||||
if {[string equal -nocase "${simulation_flag}" "false"]} {
|
||||
${sct_controller} poll ${scobj_hpath}/sensor/ch8 15
|
||||
hsetprop ${scobj_hpath}/sensor/ch8 simulated false
|
||||
} else {
|
||||
::scobj::lakeshore_218::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for lakeshore_218"
|
||||
hsetprop ${scobj_hpath}/sensor/ch8 simulated true
|
||||
}
|
||||
}
|
||||
hsetprop ${scobj_hpath}/sensor data "true"
|
||||
hsetprop ${scobj_hpath}/sensor klass "@none"
|
||||
@ -379,7 +429,7 @@ proc ::scobj::lakeshore_218::mkDriver { sct_controller name device_class simulat
|
||||
|
||||
proc ::scobj::lakeshore_218::add_driver {name device_class simulation_flag ip_address tcp_port} {
|
||||
set catch_status [ catch {
|
||||
::scobj::lakeshore_218::sics_log 9 "::scobj::lakeshore_218::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}"
|
||||
::scobj::lakeshore_218::sics_log 9 "::scobj::lakeshore_218::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${num_chans}"
|
||||
if {[string equal -nocase "${simulation_flag}" "false"]} {
|
||||
if {[string equal -nocase "aqadapter" "${ip_address}"]} {
|
||||
::scobj::lakeshore_218::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}"
|
||||
@ -393,8 +443,8 @@ proc ::scobj::lakeshore_218::add_driver {name device_class simulation_flag ip_ad
|
||||
::scobj::lakeshore_218::sics_log 9 "makesctcontroller sct_${name} aqadapter NULL"
|
||||
makesctcontroller sct_${name} aqadapter NULL
|
||||
}
|
||||
::scobj::lakeshore_218::sics_log 1 "::scobj::lakeshore_218::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}"
|
||||
::scobj::lakeshore_218::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}
|
||||
::scobj::lakeshore_218::sics_log 1 "::scobj::lakeshore_218::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${num_chans}"
|
||||
::scobj::lakeshore_218::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${num_chans}
|
||||
} catch_message ]
|
||||
handle_exception ${catch_status} ${catch_message}
|
||||
}
|
||||
@ -485,7 +535,26 @@ proc ::scobj::lakeshore_218::read_config {} {
|
||||
}
|
||||
makesctcontroller sct_${name} aqadapter ${asyncqueue}
|
||||
}
|
||||
${ns}::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}
|
||||
set arg_list [list]
|
||||
set missing_list [list]
|
||||
array unset default_map
|
||||
array set default_map [list num_chans 8]
|
||||
foreach arg {num_chans} {
|
||||
if {[dict exists $u $arg]} {
|
||||
lappend arg_list "[dict get $u $arg]"
|
||||
} elseif {[dict exists $v $arg]} {
|
||||
lappend arg_list "[dict get $v $arg]"
|
||||
} elseif {[info exists default_map($arg)]} {
|
||||
lappend arg_list $default_map($arg)
|
||||
} else {
|
||||
${ns}::sics_log 9 "Missing configuration value $arg"
|
||||
lappend missing_list $arg
|
||||
}
|
||||
}
|
||||
if { [llength $missing_list] > 0 } {
|
||||
error "$name is missing configuration values $missing_list"
|
||||
}
|
||||
${ns}::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} {*}$arg_list
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,891 +0,0 @@
|
||||
# vim: ts=8 sw=2 sta sts=2 et ai si
|
||||
# This is a template driver for a mercury temperaure controller from Oxford Instruments
|
||||
#
|
||||
# Author: Douglas Clowes
|
||||
# Date: August 2012
|
||||
#
|
||||
if { "[lindex [split [info nameofexecutable] "/"] end]" == "tclsh"} {
|
||||
# This block is to suppress spurious error/warning messages when loaded in Nagelfar
|
||||
set catch_status [ catch {
|
||||
puts "TCLSH"
|
||||
proc environment_simulation {} { return "" }
|
||||
proc SplitReply {str} { return "" }
|
||||
proc makesctcontroller {args} { }
|
||||
proc MakeSICSObj {args} { }
|
||||
proc sicslist {args} { }
|
||||
proc hfactory {args} { }
|
||||
proc hdelprop {args} { }
|
||||
proc hsetprop {args} { }
|
||||
proc hgetprop {args} { }
|
||||
proc hpropexists {args} { }
|
||||
proc hlistprop {args} { }
|
||||
proc hset {args} { }
|
||||
proc hget {args} { }
|
||||
proc hval {args} { }
|
||||
proc hinfo {args} { }
|
||||
proc hlist {args} { }
|
||||
proc sct {args} { }
|
||||
proc debug_log {args} { }
|
||||
proc pathname {args} { }
|
||||
proc basename {args} { }
|
||||
proc channel {args} { }
|
||||
proc ns {args} { }
|
||||
} catch_message ]
|
||||
if {$catch_status != 0} {
|
||||
puts "error in main $catch_message"
|
||||
return -code error "in main $catch_message"
|
||||
}
|
||||
}
|
||||
|
||||
set vendor "oxford"
|
||||
set device "mercury"
|
||||
|
||||
namespace eval ::scobj::[set vendor]_[set device] {
|
||||
proc ns {} {
|
||||
return "[namespace current]"
|
||||
}
|
||||
# All of this takes place in a namespace based on the vendor and device
|
||||
# Debug prints and vendor/device save
|
||||
clientput "Namespace: [namespace current]"
|
||||
clientput "Vendor:[set vendor]"
|
||||
clientput "Device:[set device]"
|
||||
set [namespace current]::vendor [set ::vendor]
|
||||
set [namespace current]::device [set ::device]
|
||||
set [namespace current]::ven_dev "[set ::vendor]_[set ::device]"
|
||||
clientput "[namespace current]::vendor [set [namespace current]::vendor]"
|
||||
clientput "[namespace current]::device [set [namespace current]::device]"
|
||||
clientput "[namespace current]::ven_dev [set [namespace current]::ven_dev]"
|
||||
|
||||
proc debug_log {debug_level arg_string} {
|
||||
# write a timestamped string message to a log file for debugging
|
||||
set debug_threshold 0
|
||||
if {$debug_level >= $debug_threshold} {
|
||||
set fd [open "[set [namespace current]::log_file]" "a"]
|
||||
set line "[clock format [clock seconds] -format "%T"] $arg_string"
|
||||
puts $fd "$line"
|
||||
close $fd
|
||||
}
|
||||
}
|
||||
|
||||
proc channel {arg} {
|
||||
# strip the trailing digits from the arg and return them as a string
|
||||
set result 0
|
||||
for { set i 0 } { $i < [string length $arg] } { incr i } {
|
||||
if { ! [string match {[0-9]} [string index $arg end-$i]] } {
|
||||
break
|
||||
}
|
||||
set result [string range "$arg" end-$i end]
|
||||
}
|
||||
debug_log 1 "Extract channel $result from argument $arg"
|
||||
return $result
|
||||
}
|
||||
|
||||
proc setPoint {tc_root nextState cmd} {
|
||||
# send a command to set a value
|
||||
debug_log 1 "setPoint tc_root=$tc_root sct=[sct] $cmd [sct target]"
|
||||
if { [hpropexists [sct] geterror] } {
|
||||
hdelprop [sct] geterror
|
||||
}
|
||||
set par [sct target]
|
||||
set command "$cmd:$par"
|
||||
|
||||
debug_log 1 "setPoint tc_root=$tc_root sct=[sct] Write $command"
|
||||
sct send "$command"
|
||||
sct driving 1
|
||||
sct time_check [clock seconds]
|
||||
if {$par != [sct oldval]} {
|
||||
sct oldval $par
|
||||
sct update $par
|
||||
sct utime readtime
|
||||
debug_log 1 "setPoint: new data for $tc_root [sct] result=$par"
|
||||
}
|
||||
return $nextState
|
||||
}
|
||||
|
||||
proc chkWrite {tc_root} {
|
||||
# process the response to the write
|
||||
# - not all devices will respond to writes
|
||||
set data [sct result]
|
||||
debug_log 1 "chkWrite tc_root=$tc_root sct=[sct] resp=$data"
|
||||
if {[string equal -nocase -length 7 $data "ASCERR:"]} {
|
||||
# the protocol driver has reported an error
|
||||
sct geterror "$data"
|
||||
} elseif {[string equal -nocase -length 1 $data "?"]} {
|
||||
# the device has reported an error
|
||||
sct geterror "Error: $data"
|
||||
} else {
|
||||
# the write was successful, record the data
|
||||
set data [sct target]
|
||||
if {$data != [sct oldval]} {
|
||||
sct oldval $data
|
||||
sct update $data
|
||||
sct utime readtime
|
||||
debug_log 1 "chkWrite new data for $tc_root [sct] result=$data"
|
||||
}
|
||||
}
|
||||
return idle
|
||||
}
|
||||
|
||||
proc noResponse {tc_root} {
|
||||
set data "[sct result]"
|
||||
debug_log 1 "noResponse tc_root=$tc_root sct=[sct] resp=$data"
|
||||
return idle
|
||||
}
|
||||
|
||||
proc getValue {tc_root nextState cmd} {
|
||||
# send a command to request a value
|
||||
debug_log 1 "getValue tc_root=$tc_root sct=[sct] $cmd"
|
||||
if { [hpropexists [sct] geterror] } {
|
||||
hdelprop [sct] geterror
|
||||
}
|
||||
if { [string equal -nocase -length 4 "$cmd" "XXXX"] } {
|
||||
set cmd "$cmd [channel [pathname [sct]]]"
|
||||
}
|
||||
debug_log 1 "getValue sct send $cmd"
|
||||
sct send "$cmd"
|
||||
return $nextState
|
||||
}
|
||||
|
||||
proc rdValue {tc_root} {
|
||||
# process the received response to the read request
|
||||
debug_log 1 "[ns]::rdValue tc_root=$tc_root sct=[sct] result=[sct result]"
|
||||
set data [sct result]
|
||||
if {[string equal -nocase -length 7 $data "ASCERR:"]} {
|
||||
# the protocol driver has reported an error
|
||||
sct geterror "$data"
|
||||
} elseif {[string equal -nocase -length 1 $data "?"]} {
|
||||
# the device has reported an error
|
||||
sct geterror "Error: $data"
|
||||
} else {
|
||||
if { [string equal -nocase [basename [sct]] "XXXX"] } {
|
||||
return "idle"
|
||||
}
|
||||
scan [lindex [split "$data" ":"] end] "%g" data
|
||||
if {$data != [sct oldval]} {
|
||||
debug_log 1 "[sct] changed to new:$data, from old:[sct oldval]"
|
||||
sct oldval $data
|
||||
sct update $data
|
||||
sct utime readtime
|
||||
}
|
||||
}
|
||||
return "idle"
|
||||
}
|
||||
|
||||
proc rdText {tc_root} {
|
||||
# process the received response to the read request
|
||||
debug_log 1 "[ns]::rdText tc_root=$tc_root sct=[sct] result=[sct result]"
|
||||
set data [sct result]
|
||||
if {[string equal -nocase -length 7 $data "ASCERR:"]} {
|
||||
# the protocol driver has reported an error
|
||||
sct geterror "$data"
|
||||
} elseif {[string equal -nocase -length 1 $data "?"]} {
|
||||
# the device has reported an error
|
||||
sct geterror "Error: $data"
|
||||
} else {
|
||||
if { [string equal -nocase [basename [sct]] "XXXX"] } {
|
||||
return "idle"
|
||||
}
|
||||
scan [lindex [split "$data" ":"] end] "%s" data
|
||||
if {$data != [sct oldval]} {
|
||||
debug_log 1 "[sct] changed to new:$data, from old:[sct oldval]"
|
||||
sct oldval $data
|
||||
sct update $data
|
||||
sct utime readtime
|
||||
}
|
||||
}
|
||||
return "idle"
|
||||
}
|
||||
|
||||
proc rdTextAll {tc_root} {
|
||||
# process the received response to the read request
|
||||
debug_log 1 "[ns]::rdText tc_root=$tc_root sct=[sct] result=[sct result]"
|
||||
set data [sct result]
|
||||
if {[string equal -nocase -length 7 $data "ASCERR:"]} {
|
||||
# the protocol driver has reported an error
|
||||
sct geterror "$data"
|
||||
} elseif {[string equal -nocase -length 1 $data "?"]} {
|
||||
# the device has reported an error
|
||||
sct geterror "Error: $data"
|
||||
} else {
|
||||
if { [string equal -nocase [basename [sct]] "XXXX"] } {
|
||||
return "idle"
|
||||
}
|
||||
#scan [lindex [split "$data" ":"] end] "%s" data
|
||||
if {$data != [sct oldval]} {
|
||||
debug_log 1 "[sct] changed to new:$data, from old:[sct oldval]"
|
||||
sct oldval $data
|
||||
sct update $data
|
||||
sct utime readtime
|
||||
}
|
||||
}
|
||||
return "idle"
|
||||
}
|
||||
|
||||
proc getTemp {tc_root nextState cmd} {
|
||||
debug_log 1 "getTemp tc_root=$tc_root sct=[sct] $cmd"
|
||||
if { ! [hpropexists [sct] my_state] } {
|
||||
sct my_state 0
|
||||
}
|
||||
if { [sct my_state] == 0 } {
|
||||
set command "CSET?"
|
||||
} else {
|
||||
set command "RDGK? [sct channel]"
|
||||
}
|
||||
debug_log 1 "getTemp sct send $command"
|
||||
sct send "$command"
|
||||
return "$nextState"
|
||||
}
|
||||
|
||||
proc rdTemp {tc_root} {
|
||||
debug_log 1 "rdTemp tc_root=$tc_root sct=[sct] result=[sct result]"
|
||||
if { [sct my_state] == 0 } {
|
||||
set response "[split [sct result] ","]"
|
||||
sct channel [lindex $response 0]
|
||||
sct filter [lindex $response 1]
|
||||
sct my_state 1
|
||||
return "read"
|
||||
} else {
|
||||
set data "[sct result]"
|
||||
if {$data != [sct oldval]} {
|
||||
debug_log 1 "[sct] changed to new:$data, from old:[sct oldval]"
|
||||
sct oldval $data
|
||||
sct update $data
|
||||
sct utime readtime
|
||||
}
|
||||
sct my_state 0
|
||||
return "idle"
|
||||
}
|
||||
}
|
||||
|
||||
proc gtLoop {tc_root nextState cmd} {
|
||||
debug_log 1 "gtLoop tc_root=$tc_root sct=[sct] nextState=$nextState cmd=$cmd"
|
||||
debug_log 1 "gtLoop tc_root=$tc_root pathname=[pathname [sct]] basename=[basename [sct]]"
|
||||
if { ! [hpropexists [sct] my_state] } {
|
||||
debug_log 1 "gtLoop setting my_state to zero because it doesn't exist"
|
||||
sct my_state 0
|
||||
}
|
||||
if { [sct my_state] == 0 } {
|
||||
set command "RAMP?"
|
||||
} else {
|
||||
set command "SETP?"
|
||||
}
|
||||
debug_log 1 "gtLoop sct=[sct] command=$command"
|
||||
sct send "$command"
|
||||
return "$nextState"
|
||||
return idle
|
||||
}
|
||||
|
||||
proc rdLoop {tc_root} {
|
||||
debug_log 1 "rdLoop tc_root=$tc_root sct=[sct] result=[sct result]"
|
||||
debug_log 1 "rdLoop tc_root=$tc_root pathname=[pathname [sct]] basename=[basename [sct]]"
|
||||
set nextState "read"
|
||||
if { [sct my_state] == 0 } {
|
||||
debug_log 1 "rdLoop sct=[sct] RAMP - result=[sct result]"
|
||||
set nextState "read"
|
||||
} else {
|
||||
debug_log 1 "rdLoop sct=[sct] SETP - result=[sct result]"
|
||||
set nextState "idle"
|
||||
sct my_state -1
|
||||
}
|
||||
sct my_state "[expr {[sct my_state] + 1}]"
|
||||
return $nextState
|
||||
}
|
||||
|
||||
proc wrLoop {tc_root nextState cmd} {
|
||||
debug_log 1 "wrLoop tc_root=$tc_root sct=[sct] nextState=$nextState cmd=$cmd"
|
||||
if { ! [hpropexists [sct] my_state] } {
|
||||
debug_log 1 "wrLoop setting my_state to zero because it doesn't exist"
|
||||
sct my_state 0
|
||||
}
|
||||
if { [sct writestatus] == "start" } {
|
||||
debug_log 1 "wrLoop setting my_state to zero because writestatus is [sct writestatus]"
|
||||
sct my_state 0
|
||||
}
|
||||
debug_log 1 "wrLoop target=[sct target] writestatus=[sct writestatus] my_state=[sct my_state]"
|
||||
if { [sct my_state] == 0 } {
|
||||
set my_rate [hval [sct]/ramp_rate]
|
||||
if { $my_rate > 0.0 } {
|
||||
set command "RAMP 0,0;RAMP?"
|
||||
} else {
|
||||
set command "RAMP 1,$my_rate;RAMP?"
|
||||
}
|
||||
} else {
|
||||
set command "SETP [hval [sct]/setpoint];SETP?"
|
||||
}
|
||||
debug_log 1 "wrLoop sct=[sct] command=$command"
|
||||
sct send "$command"
|
||||
return "$nextState"
|
||||
}
|
||||
|
||||
proc ckLoop {tc_root} {
|
||||
debug_log 1 "ckLoop tc_root=$tc_root sct=[sct] result=[sct result]"
|
||||
debug_log 1 "ckLoop target=[sct target] writestatus=[sct writestatus] my_state=[sct my_state]"
|
||||
set nextState "write"
|
||||
if { [sct my_state] == 0 } {
|
||||
debug_log 1 "ckLoop sct=[sct] RAMP - result=[sct result]"
|
||||
[ns]::rdValue $tc_root
|
||||
set nextState "write"
|
||||
} else {
|
||||
debug_log 1 "ckLoop sct=[sct] SETP - result=[sct result]"
|
||||
[ns]::rdValue $tc_root
|
||||
sct my_state -1
|
||||
set nextState "idle"
|
||||
}
|
||||
sct my_state "[expr {[sct my_state] + 1}]"
|
||||
return $nextState
|
||||
}
|
||||
|
||||
##
|
||||
# @brief getState() sends commands/requests to the device under control
|
||||
#
|
||||
# @param tc_root the path to the device_state node
|
||||
# @param nextState the next sct state (rdState)
|
||||
# @param cmd empty argument
|
||||
#
|
||||
# @return the next sct state (rdState)
|
||||
#
|
||||
proc getState {tc_root nextState cmd} {
|
||||
if { [hpropexists [sct] geterror] } {
|
||||
hdelprop [sct] geterror
|
||||
}
|
||||
debug_log 1 "getState $tc_root sct=[sct] state=[hval [sct]] substate=[sct substate] next=$nextState"
|
||||
set my_state [hval [sct]]
|
||||
set my_substate [sct substate]
|
||||
if {$my_state == "STATE_INIT"} {
|
||||
if { $my_substate == 0 } {
|
||||
set command "*IDN?"
|
||||
} elseif { $my_substate == 1 } {
|
||||
set command "*TST?"
|
||||
}
|
||||
} elseif { $my_state == "STATE_CURVE"} {
|
||||
if { $my_substate == 0 } {
|
||||
set my_substate 1000
|
||||
sct substate $my_substate
|
||||
}
|
||||
if { ($my_substate % 1000) == 0 } {
|
||||
set command "CRVHDR? [expr {int($my_substate / 1000)}]"
|
||||
} else {
|
||||
set command "CRVPT? [expr {int($my_substate / 1000)}],[expr {($my_substate % 1000)}]"
|
||||
}
|
||||
} elseif { $my_state == "STATE_IDLE"} {
|
||||
if { $my_substate == 0 } {
|
||||
set command "*ESE?"
|
||||
} elseif { $my_substate == 1 } {
|
||||
set command "*ESR?"
|
||||
} elseif { $my_substate == 2 } {
|
||||
set command "*STB?"
|
||||
}
|
||||
}
|
||||
debug_log 1 "getState sct send $command"
|
||||
sct send $command
|
||||
return "$nextState"
|
||||
}
|
||||
|
||||
##
|
||||
# @brief rdState() handles events from the device under control
|
||||
#
|
||||
# @param tc_root the path to the device_state node
|
||||
#
|
||||
proc rdState {tc_root} {
|
||||
if { [hpropexists [sct] geterror] } {
|
||||
hdelprop [sct] geterror
|
||||
}
|
||||
debug_log 1 "rdState $tc_root sct=[sct] state=[hval [sct]] substate=[sct substate] response=\"[sct result]\""
|
||||
set nextState "read"
|
||||
set my_state [hval [sct]]
|
||||
set my_substate [sct substate]
|
||||
if {$my_state == "STATE_INIT"} {
|
||||
if { $my_substate == 0 } { # IDN
|
||||
sct identity [sct result]
|
||||
incr my_substate
|
||||
} elseif { $my_substate == 1 } {
|
||||
sct selftest [sct result]
|
||||
incr my_substate
|
||||
}
|
||||
if { $my_substate > 1 } {
|
||||
#hset [sct] "STATE_IDLE"
|
||||
hset [sct] "STATE_CURVE"
|
||||
set my_substate 0
|
||||
}
|
||||
} elseif { $my_state == "STATE_CURVE"} {
|
||||
if { ($my_substate % 1000) == 0 } {
|
||||
debug_log 1 "Curve: [expr {$my_substate / 1000}] Header: [sct result]"
|
||||
} else {
|
||||
debug_log 1 "Curve: [expr {$my_substate / 1000}] Point: [expr {$my_substate % 1000}] Value: [sct result]"
|
||||
set rslt [scan "[sct result]" "%f,%f" units temperature]
|
||||
debug_log 1 "Curve: [expr {$my_substate / 1000}] Point: [expr {$my_substate % 1000}] Result: $rslt Units: $units Temp: $temperature"
|
||||
if { $units == 0.0 && $temperature == 0.0 } {
|
||||
set my_substate [expr { (($my_substate / 1000)) * 1000 + 999}]
|
||||
}
|
||||
}
|
||||
if { ($my_substate % 1000) >= 200 } {
|
||||
if { ($my_substate / 1000) >= 20 } {
|
||||
hset [sct] "STATE_IDLE"
|
||||
set my_substate 0
|
||||
} else {
|
||||
set my_substate [expr { (($my_substate / 1000) + 1) * 1000 }]
|
||||
}
|
||||
} else {
|
||||
set my_substate [expr { $my_substate + 1 }]
|
||||
}
|
||||
} elseif { $my_state == "STATE_IDLE"} {
|
||||
if { $my_substate == 0 } { # ESE
|
||||
sct the_ese [sct result]
|
||||
incr my_substate
|
||||
} elseif { $my_substate == 1 } { # ESR
|
||||
sct the_esr [sct result]
|
||||
incr my_substate
|
||||
} elseif { $my_substate == 2 } { # STB
|
||||
sct the_stb [sct result]
|
||||
incr my_substate
|
||||
}
|
||||
if { $my_substate > 2 } {
|
||||
set my_substate 0
|
||||
set nextState "idle"
|
||||
}
|
||||
}
|
||||
sct substate $my_substate
|
||||
if { $my_state != [hval [sct]] } {
|
||||
debug_log 1 "device_state $my_state to [hval [sct]]"
|
||||
}
|
||||
return "$nextState"
|
||||
}
|
||||
|
||||
proc chkTarget {tc_root par} {
|
||||
set target {}
|
||||
if {[hpropexists [sct] values]} {
|
||||
set values [split [SplitReply [sct values]] ","]
|
||||
foreach value $values {
|
||||
#sct print "Testing $par against $value"
|
||||
set lo_hi [split $value ":"]
|
||||
if {[llength $lo_hi] == 2} {
|
||||
if {[lindex $lo_hi 0] <= $par && [lindex $lo_hi 1] >= $par} {
|
||||
#sct print "Success $par between [lindex $lo_hi 0] and [lindex $lo_hi 1]"
|
||||
set target "$par"
|
||||
break
|
||||
}
|
||||
} else {
|
||||
if {[string toupper "$par"] == [string toupper "$value"]} {
|
||||
#sct print "Success $par matches $value"
|
||||
set target "$par"
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
if {"$target" == ""} {
|
||||
#sct print "Failure $par no matches in $values"
|
||||
return -code error "Invalid value: \"$par\""
|
||||
}
|
||||
} else {
|
||||
set target "$par"
|
||||
}
|
||||
return $target
|
||||
}
|
||||
|
||||
##
|
||||
# @brief Implement the checkstatus command for the drivable interface
|
||||
#
|
||||
# NOTE: The drive adapter initially sets the writestatus to "start" and will
|
||||
# only call this when writestatus!="start"
|
||||
proc drivestatus {tc_root} {
|
||||
#debug_log 1 "drivestatus tc_root=$tc_root, sct=[sct], setpoint=[hval [sct]], temp=[hval [pathname [sct]]/sensor], driving=[sct driving]"
|
||||
if {[sct driving]} {
|
||||
# tolerance
|
||||
set temp [hval [pathname [sct]]/sensor]
|
||||
set loval [expr {[hval [sct]] - [sct tolerance]}]
|
||||
set hival [expr {[hval [sct]] + [sct tolerance]}]
|
||||
if {$loval <= $temp && $temp <= $hival} {
|
||||
# settle time
|
||||
set timeout [sct settletime]
|
||||
set timecheck [sct time_check]
|
||||
set currtime [clock seconds]
|
||||
#debug_log 1 "drivestatus tc_root=$tc_root, sct=[sct], setpoint=[hval [sct]], temp=[hval [pathname [sct]]/sensor], temp=($loval, $temp, $hival), time=($timecheck, $currtime, $timeout)"
|
||||
if { ($currtime - $timecheck) >= $timeout } {
|
||||
debug_log 1 "drivestatus tc_root=$tc_root, sct=[sct], finished driving"
|
||||
sct driving 0
|
||||
}
|
||||
} else {
|
||||
sct time_check [clock seconds]
|
||||
}
|
||||
return busy
|
||||
} else {
|
||||
debug_log 1 "drivestatus tc_root=$tc_root, sct=[sct], now idle"
|
||||
return idle
|
||||
}
|
||||
}
|
||||
|
||||
proc halt {tc_root} {
|
||||
debug_log 1 "halt $tc_root"
|
||||
foreach loop {Loop1 Loop2 Loop3 Loop4} {
|
||||
set catch_status [ catch {
|
||||
hset $tc_root/$loop/setpoint [hval $tc_root/$loop/sensor]
|
||||
hsetprop $tc_root/$loop/setpoint driving 0
|
||||
} catch_message ]
|
||||
}
|
||||
debug_log 1 "halt $tc_root done driving"
|
||||
return idle
|
||||
}
|
||||
|
||||
proc check {tc_root} {
|
||||
debug_log 1 "check tc_root=$tc_root, sct=[sct], target=[sct target]"
|
||||
set catch_status [ catch {
|
||||
set target [chkTarget $tc_root [sct target]]
|
||||
if { "$target" == "" } {
|
||||
error "setpoint violates limits"
|
||||
}
|
||||
} catch_message ]
|
||||
if {$catch_status != 0} {
|
||||
return -code error $catch_message
|
||||
}
|
||||
return OK
|
||||
}
|
||||
|
||||
proc wrNode {tc_root cmd level} {
|
||||
set space [string repeat " " $level]
|
||||
set val [hval $tc_root]
|
||||
if {"$val" == ""} {
|
||||
set line "$tc_root ([hinfo $tc_root])"
|
||||
} else {
|
||||
set line "$tc_root ([hinfo $tc_root]) = $val"
|
||||
}
|
||||
sct print "$space* $line"
|
||||
if {"[string tolower "$cmd"]" == "-prop"} {
|
||||
set props [hlistprop $tc_root]
|
||||
#sct print "<<$props>>"
|
||||
foreach prop $props {
|
||||
#sct print "prop: $prop"
|
||||
set flds [split $prop "="]
|
||||
#sct print "flds: $flds"
|
||||
if {[llength $flds] > 1} {
|
||||
set fld0 [lindex $flds 0]
|
||||
#sct print "fld0: $fld0"
|
||||
if {[hpropexists $tc_root $fld0]} {
|
||||
sct print "$space - [hgetprop $tc_root $fld0]"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach node [hlist $tc_root] {
|
||||
[ns]::wrNode $tc_root/$node "$cmd" [expr {$level + 1}]
|
||||
}
|
||||
}
|
||||
|
||||
proc wrTree {tc_root nextState cmd} {
|
||||
debug_log 1 "wrTree root=$tc_root sct=[sct] cmd=$cmd target=[sct target]"
|
||||
sct print "$tc_root"
|
||||
[ns]::wrNode $tc_root "[sct target]" 1
|
||||
return idle
|
||||
}
|
||||
|
||||
##
|
||||
# @brief createNode() creates a node for the given nodename with the properties given
|
||||
#
|
||||
# @param scobj_hpath string variable holding the path to the object's base node in sics (/sample/tc1)
|
||||
# @param sct_controller name of the scriptcontext object (typically sct_xxx_yyy)
|
||||
# @param cmdGroup subdirectory (below /sample/tc*/) in which the node is to be created
|
||||
# @param varName name of the actual node typically representing one device command
|
||||
# @param readable set to 1 if the node represents a query command, 0 if it is not
|
||||
# @param writable set to 1 if the node represents a request for a change in settings sent to the device
|
||||
# @param drivable if set to 1 it prepares the node to provide a drivable interface
|
||||
# @param dataType data type of the node, must be one of none, int, float, text
|
||||
# @param permission defines what user group may read/write to this node (is one of spy, user, manager)
|
||||
# @param rdCmd actual device query command to be sent to the device
|
||||
# @param rdFunc nextState Function to be called after the getValue function, typically rdValue()
|
||||
# @param wrCmd actual device write command to be sent to the device
|
||||
# @param wrFunc Function to be called to send the wrCmd to the device, typically setValue()
|
||||
# @param allowedValues allowed values for the node data - does not permit other
|
||||
# @param klass Nexus class name (?)
|
||||
# @return OK
|
||||
proc createNode {scobj_hpath sct_controller\
|
||||
cmdGroup varName\
|
||||
readable writable drivable\
|
||||
dataType permission\
|
||||
rdCmd rdFunc\
|
||||
wrCmd wrFunc\
|
||||
allowedValues klass} {
|
||||
|
||||
set catch_status [ catch {
|
||||
set ns "[ns]"
|
||||
set nodeName "$scobj_hpath/$cmdGroup/$varName"
|
||||
if {1 > [string length $cmdGroup]} {
|
||||
set nodeName "$scobj_hpath/$varName"
|
||||
}
|
||||
debug_log 1 "Creating node $nodeName"
|
||||
hfactory $nodeName plain $permission $dataType
|
||||
if {$readable > 0} {
|
||||
# the node is readable so set it up to be polled using the rdFunc
|
||||
# rdFunc is getValueFunc.rdValueFunc with both explicit functions
|
||||
# or rdValueFunc where "getValue" is the implied getValueFunc
|
||||
set parts [split "$rdFunc" "."]
|
||||
if { [llength $parts] == 2 } {
|
||||
set func_name [lindex $parts 0]
|
||||
set next_state [lindex $parts 1]
|
||||
} else {
|
||||
set func_name "getValue"
|
||||
set next_state [lindex $parts 0]
|
||||
}
|
||||
hsetprop $nodeName read ${ns}::$func_name $scobj_hpath $next_state $rdCmd
|
||||
hsetprop $nodeName $next_state ${ns}::$next_state $scobj_hpath
|
||||
# set the poll rate as a period in seconds
|
||||
# TODO allow directly settable value in seconds
|
||||
set poll_period 5
|
||||
if { $readable >= 0 && $readable <= 300 } {
|
||||
set poll_period [expr {int($readable)}]
|
||||
}
|
||||
debug_log 1 "Registering node $nodeName for poll at $poll_period seconds"
|
||||
$sct_controller poll $nodeName $poll_period
|
||||
}
|
||||
if {$writable == 1} {
|
||||
# the node is writable so set it up to invoke a callback when written
|
||||
# rdFunc is putValueFunc.chkWriteFunc with both explicit functions
|
||||
# or putValueFunc where "noResponse" is the implied chkWriteFunc
|
||||
set parts [split "$wrFunc" "."]
|
||||
if { [llength $parts] == 2 } {
|
||||
set func_name [lindex $parts 0]
|
||||
set next_state [lindex $parts 1]
|
||||
} else {
|
||||
set func_name [lindex $parts 0]
|
||||
set next_state "noResponse"
|
||||
}
|
||||
hsetprop $nodeName write ${ns}::$func_name $scobj_hpath $next_state $wrCmd
|
||||
hsetprop $nodeName $next_state ${ns}::$next_state $scobj_hpath
|
||||
hsetprop $nodeName writestatus UNKNOWN
|
||||
debug_log 1 "Registering node $nodeName for write callback"
|
||||
$sct_controller write $nodeName
|
||||
}
|
||||
# Initialise the previous value to test against
|
||||
switch -exact $dataType {
|
||||
"none" { }
|
||||
"int" { hsetprop $nodeName oldval -1 }
|
||||
"float" { hsetprop $nodeName oldval -1.0 }
|
||||
default { hsetprop $nodeName oldval UNKNOWN }
|
||||
}
|
||||
# Set the allowed values property
|
||||
if {1 < [string length $allowedValues]} {
|
||||
hsetprop $nodeName values $allowedValues
|
||||
}
|
||||
# Drive adapter interface
|
||||
# TODO make it a separate function and pass in all this stuff
|
||||
if {$drivable == 1} {
|
||||
hsetprop $nodeName check ${ns}::check $scobj_hpath
|
||||
hsetprop $nodeName driving 0
|
||||
hsetprop $nodeName checklimits ${ns}::check $scobj_hpath
|
||||
hsetprop $nodeName checkstatus ${ns}::drivestatus $scobj_hpath
|
||||
hsetprop $nodeName halt ${ns}::halt $scobj_hpath
|
||||
} else {
|
||||
hsetprop $nodeName driving 0
|
||||
}
|
||||
} catch_message ]
|
||||
if {$catch_status != 0} {
|
||||
debug_log 5 "error in [ns]::createNode $catch_message"
|
||||
return -code error "in [ns]::createNode $catch_message"
|
||||
}
|
||||
return OK
|
||||
}
|
||||
|
||||
proc mk_sct_driver {sct_controller the_klass the_name tol CID CTYPE} {
|
||||
debug_log 1 "mk_sct_driver $sct_controller $the_klass $the_name $tol $CID $CTYPE"
|
||||
set catch_status [ catch {
|
||||
|
||||
MakeSICSObj $the_name SCT_OBJECT
|
||||
sicslist setatt $the_name klass $the_klass
|
||||
sicslist setatt $the_name long_name $the_name
|
||||
|
||||
set scobj_hpath /sics/$the_name
|
||||
|
||||
hfactory $scobj_hpath/Loop1 plain spy none
|
||||
hfactory $scobj_hpath/Loop2 plain spy none
|
||||
hfactory $scobj_hpath/Loop3 plain spy none
|
||||
hfactory $scobj_hpath/Loop4 plain spy none
|
||||
hfactory $scobj_hpath/Level plain spy none
|
||||
|
||||
set deviceCommand {\
|
||||
Loop1 setpoint 5 1 1 float user {READ:DEV:MB1.T1:TEMP:LOOP:TSET} {rdValue} {SET:DEV:MB1.T1:TEMP:LOOP:TSET} {setPoint} {1:333}\
|
||||
Loop1 sensor 1 0 0 float user {READ:DEV:MB1.T1:TEMP:SIG:TEMP} {rdValue} {} {} {}\
|
||||
Loop1 nick 5 0 0 text user {READ:DEV:MB1.T1:TEMP:NICK} {rdText} {} {} {}\
|
||||
Loop1 temp 0 0 0 text user {READ:DEV:MB1.T1:TEMP} {rdTextAll} {} {} {}\
|
||||
Loop1 loop 0 0 0 text user {READ:DEV:MB1.T1:TEMP:LOOP} {rdTextAll} {} {} {}\
|
||||
Loop1 heater 0 0 0 text user {READ:DEV:MB0.H1:HTR} {rdTextAll} {} {} {}\
|
||||
Loop1 power 5 0 0 float user {READ:DEV:MB0.H1:HTR:SIG:POWR} {rdValue} {} {} {}\
|
||||
Loop2 setpoint 5 1 1 float user {READ:DEV:DB6.T1:TEMP:LOOP:TSET} {rdValue} {SET:DEV:DB6.T1:TEMP:LOOP:TSET} {setPoint} {1:333}\
|
||||
Loop2 sensor 1 0 0 float user {READ:DEV:DB6.T1:TEMP:SIG:TEMP} {rdValue} {} {} {}\
|
||||
Loop2 nick 5 0 0 text user {READ:DEV:DB6.T1:TEMP:NICK} {rdText} {} {} {}\
|
||||
Loop2 temp 0 0 0 text user {READ:DEV:DB6.T1:TEMP} {rdTextAll} {} {} {}\
|
||||
Loop2 loop 0 0 0 text user {READ:DEV:DB6.T1:TEMP:LOOP} {rdTextAll} {} {} {}\
|
||||
Loop2 heater 0 0 0 text user {READ:DEV:DB1.H1:HTR} {rdTextAll} {} {} {}\
|
||||
Loop2 power 5 0 0 float user {READ:DEV:DB1.H1:HTR:SIG:POWR} {rdValue} {} {} {}\
|
||||
Loop3 setpoint 5 1 1 float user {READ:DEV:DB7.T1:TEMP:LOOP:TSET} {rdValue} {SET:DEV:DB7.T1:TEMP:LOOP:TSET} {setPoint} {1:333}\
|
||||
Loop3 sensor 1 0 0 float user {READ:DEV:DB7.T1:TEMP:SIG:TEMP} {rdValue} {} {} {}\
|
||||
Loop3 nick 5 0 0 text user {READ:DEV:DB7.T1:TEMP:NICK} {rdText} {} {} {}\
|
||||
Loop3 temp 0 0 0 text user {READ:DEV:DB7.T1:TEMP} {rdTextAll} {} {} {}\
|
||||
Loop3 loop 0 0 0 text user {READ:DEV:DB7.T1:TEMP:LOOP} {rdTextAll} {} {} {}\
|
||||
Loop3 heater 0 0 0 text user {READ:DEV:DB2.H1:HTR} {rdTextAll} {} {} {}\
|
||||
Loop3 power 5 0 0 float user {READ:DEV:DB2.H1:HTR:SIG:POWR} {rdValue} {} {} {}\
|
||||
Loop4 setpoint 5 1 1 float user {READ:DEV:DB8.T1:TEMP:LOOP:TSET} {rdValue} {SET:DEV:DB8.T1:TEMP:LOOP:TSET} {setPoint} {1:333}\
|
||||
Loop4 sensor 1 0 0 float user {READ:DEV:DB8.T1:TEMP:SIG:TEMP} {rdValue} {} {} {}\
|
||||
Loop4 nick 5 0 0 text user {READ:DEV:DB8.T1:TEMP:NICK} {rdText} {} {} {}\
|
||||
Loop4 temp 0 0 0 text user {READ:DEV:DB8.T1:TEMP} {rdTextAll} {} {} {}\
|
||||
Loop4 loop 0 0 0 text user {READ:DEV:DB7.T1:TEMP:LOOP} {rdTextAll} {} {} {}\
|
||||
Loop4 heater 0 0 0 text user {READ:DEV:DB3.H1:HTR} {rdTextAll} {} {} {}\
|
||||
Loop4 power 5 0 0 float user {READ:DEV:DB3.H1:HTR:SIG:POWR} {rdValue} {} {} {}\
|
||||
Level Nitrogen 15 0 0 float user {READ:DEV:DB5.L1:LVL:SIG:NIT:LEV} {rdValue} {} {} {}\
|
||||
Level Helium 15 0 0 float user {READ:DEV:DB5.L1:LVL:SIG:HEL:LEV} {rdValue} {} {} {}\
|
||||
}
|
||||
|
||||
foreach {cmdGroup varName\
|
||||
readable writable drivable\
|
||||
dataType permission\
|
||||
rdCmd rdFunc\
|
||||
wrCmd wrFunc\
|
||||
allowedValues} $deviceCommand {
|
||||
[ns]::createNode $scobj_hpath $sct_controller\
|
||||
$cmdGroup $varName\
|
||||
$readable $writable $drivable\
|
||||
$dataType $permission\
|
||||
$rdCmd $rdFunc\
|
||||
$wrCmd $wrFunc\
|
||||
$allowedValues $the_klass
|
||||
}
|
||||
|
||||
foreach cmdGroup { Loop1 Loop2 Loop3 Loop4 } {
|
||||
set pathName "$scobj_hpath/$cmdGroup"
|
||||
hsetprop $pathName type part
|
||||
hsetprop $pathName klass NXsensor
|
||||
hsetprop $pathName privilege spy
|
||||
hsetprop $pathName control true
|
||||
hsetprop $pathName data true
|
||||
hsetprop $pathName nxsave true
|
||||
hsetprop $pathName/setpoint tolerance $tol
|
||||
hsetprop $pathName/setpoint settletime 5
|
||||
foreach varName { setpoint sensor nick } {
|
||||
set nodeName "$pathName/$varName"
|
||||
hsetprop $nodeName nxalias ${the_name}_${cmdGroup}_${varName}_value
|
||||
hsetprop $nodeName long_name $varName
|
||||
hsetprop $nodeName klass sensor
|
||||
hsetprop $nodeName priviledge user
|
||||
hsetprop $nodeName control true
|
||||
hsetprop $nodeName data true
|
||||
hsetprop $nodeName nxsave true
|
||||
hsetprop $nodeName mutable true
|
||||
hsetprop $nodeName sdsinfo ::nexus::scobj::sdsinfo
|
||||
}
|
||||
}
|
||||
|
||||
foreach cmdGroup { Level } {
|
||||
set pathName "$scobj_hpath/$cmdGroup"
|
||||
hsetprop $pathName type part
|
||||
hsetprop $pathName klass NXsensor
|
||||
hsetprop $pathName privilege spy
|
||||
hsetprop $pathName control true
|
||||
hsetprop $pathName data true
|
||||
hsetprop $pathName nxsave true
|
||||
foreach varName { Nitrogen Helium } {
|
||||
set nodeName "$pathName/$varName"
|
||||
hsetprop $nodeName long_name $varName
|
||||
hsetprop $nodeName klass sensor
|
||||
hsetprop $nodeName priviledge user
|
||||
hsetprop $nodeName control true
|
||||
hsetprop $nodeName data true
|
||||
hsetprop $nodeName nxsave true
|
||||
hsetprop $nodeName nxalias ${the_name}_${cmdGroup}_${varName}_value
|
||||
hsetprop $nodeName mutable true
|
||||
hsetprop $nodeName sdsinfo ::nexus::scobj::sdsinfo
|
||||
}
|
||||
}
|
||||
|
||||
hfactory $scobj_hpath/device_state plain spy none
|
||||
hset $scobj_hpath/device_state "STATE_INIT"
|
||||
hsetprop $scobj_hpath/device_state substate 0
|
||||
|
||||
set point 0
|
||||
set catch_status_2 [ catch {
|
||||
hsetprop $scobj_hpath privilege spy
|
||||
hsetprop $scobj_hpath long_name $the_name
|
||||
hsetprop $scobj_hpath sicsdev $the_name
|
||||
hsetprop $scobj_hpath nxalias $the_name
|
||||
hsetprop $scobj_hpath control true
|
||||
hsetprop $scobj_hpath data true
|
||||
hsetprop $scobj_hpath nxsave true
|
||||
hsetprop $scobj_hpath mutable true
|
||||
hsetprop $scobj_hpath klass parameter
|
||||
hsetprop $scobj_hpath sdsinfo ::nexus::scobj::sdsinfo
|
||||
set point 1
|
||||
if {0} {
|
||||
::scobj::hinitprops $the_name Loop1
|
||||
set point 2
|
||||
::scobj::hinitprops $the_name Loop2/setpoint
|
||||
set point 3
|
||||
::scobj::hinitprops $the_name Loop3/setpoint
|
||||
set point 4
|
||||
::scobj::hinitprops $the_name Loop4/setpoint
|
||||
set point 5
|
||||
}
|
||||
} catch_message_2 ]
|
||||
if {$catch_status_2 != 0} {
|
||||
debug_log 5 "error in [ns]::mk_sct_driver($point) $catch_message_2"
|
||||
return -code error "in [ns]::mk_sct_driver($point) $catch_message_2"
|
||||
}
|
||||
hsetprop $scobj_hpath/Loop1/setpoint permlink data_set ${CTYPE}${CID}SP1
|
||||
hsetprop $scobj_hpath/Loop1/setpoint @description ${CTYPE}${CID}SP1
|
||||
hsetprop $scobj_hpath/Loop1/setpoint permlink data_set ${CTYPE}${CID}SP1
|
||||
hsetprop $scobj_hpath/Loop1/setpoint @description ${CTYPE}${CID}SP1
|
||||
hsetprop $scobj_hpath/Loop2/setpoint permlink data_set ${CTYPE}${CID}SP2
|
||||
hsetprop $scobj_hpath/Loop2/setpoint @description ${CTYPE}${CID}SP2
|
||||
hsetprop $scobj_hpath/Loop3/setpoint permlink data_set ${CTYPE}${CID}SP3
|
||||
hsetprop $scobj_hpath/Loop3/setpoint @description ${CTYPE}${CID}SP3
|
||||
hsetprop $scobj_hpath/Loop4/setpoint permlink data_set ${CTYPE}${CID}SP4
|
||||
hsetprop $scobj_hpath/Loop4/setpoint @description ${CTYPE}${CID}SP4
|
||||
|
||||
hsetprop $scobj_hpath/Loop1/sensor permlink data_set ${CTYPE}${CID}S1
|
||||
hsetprop $scobj_hpath/Loop1/sensor @description ${CTYPE}${CID}S1
|
||||
hsetprop $scobj_hpath/Loop2/sensor permlink data_set ${CTYPE}${CID}S2
|
||||
hsetprop $scobj_hpath/Loop2/sensor @description ${CTYPE}${CID}S2
|
||||
hsetprop $scobj_hpath/Loop3/sensor permlink data_set ${CTYPE}${CID}S3
|
||||
hsetprop $scobj_hpath/Loop3/sensor @description ${CTYPE}${CID}S3
|
||||
hsetprop $scobj_hpath/Loop4/sensor permlink data_set ${CTYPE}${CID}S4
|
||||
hsetprop $scobj_hpath/Loop4/sensor @description ${CTYPE}${CID}S4
|
||||
|
||||
if {[SplitReply [environment_simulation]]=="false"} {
|
||||
hsetprop $scobj_hpath/Loop1/setpoint type drivable
|
||||
hsetprop $scobj_hpath/Loop2/setpoint type drivable
|
||||
hsetprop $scobj_hpath/Loop3/setpoint type drivable
|
||||
hsetprop $scobj_hpath/Loop4/setpoint type drivable
|
||||
ansto_makesctdrive ${the_name}_loop1 $scobj_hpath/Loop1/setpoint $scobj_hpath/Loop1/sensor $sct_controller
|
||||
ansto_makesctdrive ${the_name}_loop2 $scobj_hpath/Loop2/setpoint $scobj_hpath/Loop2/sensor $sct_controller
|
||||
ansto_makesctdrive ${the_name}_loop3 $scobj_hpath/Loop3/setpoint $scobj_hpath/Loop3/sensor $sct_controller
|
||||
ansto_makesctdrive ${the_name}_loop4 $scobj_hpath/Loop4/setpoint $scobj_hpath/Loop4/sensor $sct_controller
|
||||
}
|
||||
} catch_message ]
|
||||
if {$catch_status != 0} {
|
||||
debug_log 5 "error in [ns]::mk_sct_driver $catch_message"
|
||||
return -code error "in [ns]::mk_sct_driver $catch_message"
|
||||
}
|
||||
}
|
||||
|
||||
proc add_[set vendor]_[set device] {the_name IP port CID CTYPE terminator {_tol 5.0}} {
|
||||
set [ns]::log_file "../log/[set [ns]::ven_dev]_[set the_name].log"
|
||||
set fd [open [set [ns]::log_file] "w"]
|
||||
close $fd
|
||||
debug_log 1 "add_[set [ns]::vendor]_[set [ns]::device] ${the_name} ${IP} ${port} ${_tol}"
|
||||
clientput "Namespace: [namespace current]"
|
||||
clientput "::vendor $::vendor"
|
||||
clientput "::device $::device"
|
||||
clientput "[namespace current]::vendor [set [namespace current]::vendor]"
|
||||
clientput "[namespace current]::device [set [namespace current]::device]"
|
||||
clientput "[namespace current]::ven_dev [set [namespace current]::ven_dev]"
|
||||
clientput "[namespace current]::log_file [set [namespace current]::log_file]"
|
||||
if {[SplitReply [environment_simulation]]=="false"} {
|
||||
debug_log 1 "makesctcontroller sct_${the_name} std ${IP}:${port} $terminator"
|
||||
makesctcontroller sct_${the_name} std ${IP}:${port} $terminator
|
||||
}
|
||||
debug_log 1 "::scobj::oxford_mercury::mk_sct_driver sct_${the_name} environment ${the_name} ${_tol} $CID $CTYPE"
|
||||
::scobj::oxford_mercury::mk_sct_driver sct_${the_name} environment ${the_name} ${_tol} $CID $CTYPE
|
||||
}
|
||||
|
||||
|
||||
namespace export add_[set vendor]_[set device]
|
||||
}
|
||||
|
||||
namespace import ::scobj::[set vendor]_[set device]::*
|
||||
|
||||
|
Reference in New Issue
Block a user