Merge branch 'RELEASE-3_1' into RELEASE-3_2
Conflicts: sics/site_ansto/instrument/bilby/config/chopper/sct_astrium_chopper.tcl sics/site_ansto/instrument/bilby/config/motors/shutters_sct.tcl sics/site_ansto/instrument/bilby/config/motors/tank_sct.tcl sics/site_ansto/instrument/bilby/util/sics_config.ini sics/site_ansto/instrument/config/environment/hiden_xcs_sct.tcl sics/site_ansto/instrument/config/environment/huber_pilot_sct.tcl sics/site_ansto/instrument/config/environment/isotech_ps_sct.tcl sics/site_ansto/instrument/config/environment/keithley_m2700_sct.tcl sics/site_ansto/instrument/config/environment/magneticField/oxford12tlv_sct.tcl sics/site_ansto/instrument/config/environment/magneticField/tsi_smc_sct.tcl sics/site_ansto/instrument/config/environment/nhq_200_sct.tcl sics/site_ansto/instrument/config/environment/omron_hldc_sct.tcl sics/site_ansto/instrument/config/environment/protekmm_sct.tcl sics/site_ansto/instrument/config/environment/temperature/eurotherm_m2000_sct.tcl sics/site_ansto/instrument/config/environment/temperature/julabo_lh45_gen_sct.tcl sics/site_ansto/instrument/config/environment/temperature/lakeshore_218_sct.tcl sics/site_ansto/instrument/config/environment/temperature/ls336_sct.tcl sics/site_ansto/instrument/config/environment/temperature/ls340_sct.tcl sics/site_ansto/instrument/config/environment/temperature/mercury_base_sct.tcl sics/site_ansto/instrument/config/environment/temperature/mercury_level_sct.tcl sics/site_ansto/instrument/config/environment/temperature/mercury_pres_sct.tcl sics/site_ansto/instrument/config/environment/temperature/mercury_scpi_sct.tcl sics/site_ansto/instrument/config/environment/temperature/mercury_temp_sct.tcl sics/site_ansto/instrument/config/environment/temperature/mercury_valve_sct.tcl sics/site_ansto/instrument/config/environment/temperature/nprvasm2_sct.tcl sics/site_ansto/instrument/config/environment/temperature/pfeiffer_hg_sct.tcl sics/site_ansto/instrument/config/environment/temperature/watlow_mpm_sct.tcl sics/site_ansto/instrument/config/environment/temperature/watlow_mrm_sct.tcl sics/site_ansto/instrument/config/environment/temperature/watlow_mst4_sct.tcl sics/site_ansto/instrument/config/environment/temperature/west_6100.sct sics/site_ansto/instrument/config/source/reactor_status_sct.tcl sics/site_ansto/instrument/hrpd/echidna_configuration.tcl sics/site_ansto/instrument/sans/quokka_configuration.tcl sics/site_ansto/instrument/tas/config/motors/motor_configuration.tcl sics/site_ansto/instrument/util/gen_sct.py sics/site_ansto/instrument/util/motor_utility.tcl
This commit is contained in:
@@ -45,13 +45,18 @@ proc handle_acscript_exception {status message args} {
|
||||
proc ::anticollider::loadscript {args} {
|
||||
variable veto_rules
|
||||
|
||||
set fh [open $::cfPath(anticollider)/[lindex $args 0] RDONLY ]
|
||||
while {[gets $fh line] >= 0} {
|
||||
# Skip empty lines and comments
|
||||
if [regexp {^\s*$|^ *#} $line] {
|
||||
continue
|
||||
catch {
|
||||
set fh [open $::cfPath(anticollider)/[lindex $args 0] RDONLY ]
|
||||
while {[gets $fh line] >= 0} {
|
||||
# Skip empty lines and comments
|
||||
if [regexp {^\s*$|^ *#} $line] {
|
||||
continue
|
||||
}
|
||||
lappend veto_rules $line
|
||||
}
|
||||
lappend veto_rules $line
|
||||
}
|
||||
catch {
|
||||
close $fh
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,8 +27,8 @@ proc ::scobj::agilent_33220A::sics_log {debug_level debug_string} {
|
||||
} catch_message ]
|
||||
}
|
||||
|
||||
proc ::scobj::agilent_33220A::mkDriver { sct_controller name ip_address tcp_port } {
|
||||
::scobj::agilent_33220A::sics_log 9 "::scobj::agilent_33220A::mkDriver ${sct_controller} ${name} ${ip_address} ${tcp_port}"
|
||||
proc ::scobj::agilent_33220A::mkDriver { sct_controller name device_class simulation_flag ip_address tcp_port } {
|
||||
::scobj::agilent_33220A::sics_log 9 "::scobj::agilent_33220A::mkDriver ${sct_controller} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}"
|
||||
set ns "[namespace current]"
|
||||
set catch_status [ catch {
|
||||
|
||||
@@ -40,21 +40,27 @@ proc ::scobj::agilent_33220A::mkDriver { sct_controller name ip_address tcp_port
|
||||
handle_exception ${catch_status} ${catch_message}
|
||||
}
|
||||
|
||||
proc ::scobj::agilent_33220A::add_driver {name device_class simulation_flag ip_address tcp_port} {
|
||||
set catch_status [ catch {
|
||||
::scobj::agilent_33220A::sics_log 9 "::scobj::agilent_33220A::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}"
|
||||
::scobj::agilent_33220A::sics_log 9 "No sctcontroller for agilent_33220A"
|
||||
::scobj::agilent_33220A::sics_log 1 "::scobj::agilent_33220A::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}"
|
||||
::scobj::agilent_33220A::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}
|
||||
} catch_message ]
|
||||
handle_exception ${catch_status} ${catch_message}
|
||||
}
|
||||
|
||||
namespace eval ::scobj::agilent_33220A {
|
||||
namespace export debug_threshold
|
||||
namespace export debug_log
|
||||
namespace export sics_log
|
||||
namespace export mkDriver
|
||||
namespace export add_driver
|
||||
}
|
||||
|
||||
proc add_agilent_33220A {name ip_address tcp_port} {
|
||||
set catch_status [ catch {
|
||||
::scobj::agilent_33220A::sics_log 9 "add_agilent_33220A ${name} ${ip_address} ${tcp_port}"
|
||||
::scobj::agilent_33220A::sics_log 9 "No sctcontroller for agilent_33220A"
|
||||
::scobj::agilent_33220A::sics_log 1 "::scobj::agilent_33220A::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port}"
|
||||
::scobj::agilent_33220A::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port}
|
||||
} catch_message ]
|
||||
handle_exception ${catch_status} ${catch_message}
|
||||
set simulation_flag "[string tolower [SplitReply [environment_simulation]]]"
|
||||
::scobj::agilent_33220A::add_driver ${name} "environment" "${simulation_flag}" ${ip_address} ${tcp_port}
|
||||
}
|
||||
|
||||
clientput "file evaluation of agilent_33220A_sct.tcl"
|
||||
@@ -65,6 +71,8 @@ proc ::scobj::agilent_33220A::read_config {} {
|
||||
set ns "::scobj::agilent_33220A"
|
||||
dict for {k u} $::config_dict {
|
||||
if { [dict exists $u "implementation"] } {
|
||||
set simulation_flag "[string tolower [SplitReply [environment_simulation]]]"
|
||||
set device_class "environment"
|
||||
if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } {
|
||||
continue
|
||||
}
|
||||
@@ -72,6 +80,12 @@ proc ::scobj::agilent_33220A::read_config {} {
|
||||
if { ! ([string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"]) } {
|
||||
continue
|
||||
}
|
||||
if { [dict exists $u "simulation_group"] } {
|
||||
set simulation_flag [SplitReply [[string tolower [dict get $u "simulation_group"]]]]
|
||||
}
|
||||
if { [dict exists $u "device_class"] } {
|
||||
set device_class "[dict get $u "device_class"]"
|
||||
}
|
||||
set name [dict get $u name]
|
||||
set implementation [dict get $u "implementation"]
|
||||
if { !([dict exists $::config_dict $implementation]) } {
|
||||
@@ -82,9 +96,9 @@ proc ::scobj::agilent_33220A::read_config {} {
|
||||
continue
|
||||
}
|
||||
if { [string equal -nocase [dict get $v "driver"] "agilent_33220A"] } {
|
||||
if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } {
|
||||
if { ![string equal -nocase "${simulation_flag}" "false"] } {
|
||||
set asyncqueue "null"
|
||||
${ns}::sics_log 9 "[environment_simulation] => using null asyncqueue"
|
||||
${ns}::sics_log 9 "simulation_flag=${simulation_flag} => using null asyncqueue"
|
||||
} elseif { [dict exists $v "asyncqueue"] } {
|
||||
set asyncqueue [dict get $v "asyncqueue"]
|
||||
if { [string equal -nocase ${asyncqueue} "sct"] } {
|
||||
@@ -111,9 +125,9 @@ proc ::scobj::agilent_33220A::read_config {} {
|
||||
}
|
||||
}
|
||||
if { [string equal -nocase ${asyncqueue} "sct"] } {
|
||||
add_agilent_33220A ${name} ${ip_address} ${tcp_port}
|
||||
${ns}::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}
|
||||
} else {
|
||||
add_agilent_33220A ${name} "aqadapter" ${asyncqueue}
|
||||
${ns}::add_driver ${name} ${device_class} ${simulation_flag} "aqadapter" ${asyncqueue}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
372
site_ansto/instrument/config/environment/knauer_pump.sct
Normal file
372
site_ansto/instrument/config/environment/knauer_pump.sct
Normal file
@@ -0,0 +1,372 @@
|
||||
#
|
||||
# Template driver for the Knauer BlueShadow Pump 40P
|
||||
# vim: 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;
|
||||
#
|
||||
group dummy = {
|
||||
type = text; readable = 1; data = false; control = false; nxsave = false;
|
||||
var status = { read_command = 'STATUS?'; read_function = read_status; }
|
||||
var glp = { read_command = 'GLP?'; read_function = read_glp; property real_data = ' '; }
|
||||
}
|
||||
|
||||
group pump = {
|
||||
var remote = {
|
||||
type = int;
|
||||
readable = 1; read_command = 'REMOTE?'; read_function = remote_read;
|
||||
writeable = 1; write_function = remote_write;
|
||||
}
|
||||
var state = {
|
||||
type = text;
|
||||
readable = 1;
|
||||
read_command = ' ';
|
||||
fetch_function = state_fetch;
|
||||
}
|
||||
var status = {
|
||||
type = text;
|
||||
readable = 1;
|
||||
read_command = ' ';
|
||||
fetch_function = status_fetch;
|
||||
}
|
||||
var volume_pv = {
|
||||
type = float;
|
||||
readable = 1;
|
||||
read_command = ' ';
|
||||
fetch_function = volume_fetch;
|
||||
#checkrange_function = volume_reject;
|
||||
property 'units' = 'mL';
|
||||
}
|
||||
var volume_sp = {
|
||||
type = float;
|
||||
writeable = 1;
|
||||
write_command = ' ';
|
||||
write_function = volume_write;
|
||||
driveable = pump/volume_pv
|
||||
checkstatus_function = volume_checkstatus;
|
||||
halt_function = volume_halt;
|
||||
lowerlimit = 0; upperlimit = 100; tolerance = 0.01;
|
||||
readable = 1;
|
||||
read_command = ' ';
|
||||
fetch_function = volume_checkpumping;
|
||||
property 'units' = 'mL';
|
||||
}
|
||||
var ratio_pv = {
|
||||
type = text;
|
||||
readable = 1; read_command = ' '; fetch_function = ratios_fetch;
|
||||
property 'units' = 'percent';
|
||||
}
|
||||
var ratio_sp = {
|
||||
type = text;
|
||||
writeable = 1; write_command = ' '; write_function = ratios_write; checkrange_function = ratios_check;
|
||||
property 'units' = 'percent';
|
||||
}
|
||||
var flow_pv = {
|
||||
type = float;
|
||||
readable = 1; read_command = ' '; fetch_function = flow_fetch;
|
||||
property 'units' = 'mL/min';
|
||||
}
|
||||
var flow_sp = {
|
||||
type = float;
|
||||
writeable = 1; write_command = ' '; write_function = flow_write;
|
||||
lowerlimit = 0; upperlimit = 10;
|
||||
property 'units' = 'mL/min';
|
||||
}
|
||||
}
|
||||
|
||||
group stuff = {
|
||||
readable = 60;
|
||||
type = text;
|
||||
data = false; control = false; nxsave = false;
|
||||
var an_out = { read_command = 'AN_OUT?'; }
|
||||
var boardinfo = { read_command = 'BOARDINFO?'; }
|
||||
var config = { read_command = 'CONFIG?'; }
|
||||
var cprofinfo = { read_command = 'CPROFINFO?'; }
|
||||
var dout = { read_command = 'DOUT?'; }
|
||||
var error = { read_command = 'ERROR?'; }
|
||||
var errors = { read_command = 'ERRORS?'; }
|
||||
var flushpmp = { read_command = 'FLUSHPMP?'; }
|
||||
var head = { read_command = 'HEAD?'; }
|
||||
var head_par = { read_command = 'HEAD_PAR?'; }
|
||||
var identify = { read_command = 'IDENTIFY?'; }
|
||||
var lpg = { read_command = 'LPG?'; }
|
||||
var oem = { read_command = 'OEM?'; }
|
||||
var opt = { read_command = 'OPT?'; }
|
||||
var plim = { read_command = 'PLIM?'; }
|
||||
var pressure = { read_command = 'PRESSURE?'; }
|
||||
var prfastacq = { read_command = 'PRFASTACQ?'; }
|
||||
var purge = { read_command = 'PURGE?'; }
|
||||
var remote = { read_command = 'REMOTE?'; }
|
||||
var rfid = { read_command = 'RFID?'; }
|
||||
var service = { read_command = 'SERVICE?'; }
|
||||
var sysinfo = { read_command = 'SYSINFO?'; }
|
||||
var 'units' = { read_command = 'UNITS?'; }
|
||||
var valves = { read_command = 'VALVES?'; }
|
||||
}
|
||||
group prog = {
|
||||
readable = 30;
|
||||
type = text;
|
||||
var line_01 = { read_command = "TT_GET:1,1"; }
|
||||
var line_02 = { read_command = "TT_GET:1,2"; }
|
||||
var line_03 = { read_command = "TT_GET:1,3"; }
|
||||
var line_04 = { read_command = "TT_GET:1,4"; }
|
||||
var line_05 = { read_command = "TT_GET:1,5"; }
|
||||
}
|
||||
group glp = {
|
||||
type = text;
|
||||
readable = 1;
|
||||
fetch_function = fetch_from_glp;
|
||||
var board_time = { read_command = '0'; }
|
||||
var motor_time = { read_command = '1'; }
|
||||
var head_count = { read_command = '3'; }
|
||||
var head_time = { read_command = '4'; }
|
||||
var head_volm = { read_command = '5'; }
|
||||
var head_voln = { read_command = '6'; }
|
||||
var head_pwrhi = { read_command = '7'; }
|
||||
var head_pwrlo = { read_command = '8'; }
|
||||
var pump_revs = { read_command = '9'; }
|
||||
var pump_volm = { read_command = '10'; }
|
||||
var pump_voln = { read_command = '11'; }
|
||||
var pump_pwrhi = { read_command = '12'; }
|
||||
var pump_pwrlo = { read_command = '13'; }
|
||||
}
|
||||
group status = {
|
||||
type = text;
|
||||
readable = 1;
|
||||
fetch_function = fetch_from_status;
|
||||
var state = { read_command = '1'; }
|
||||
var cur_error = { read_command = '2'; }
|
||||
var cur_run_time = { read_command = '3'; }
|
||||
var flow_rate = { read_command = '4'; }
|
||||
var lpg_0 = { read_command = '5'; }
|
||||
var lpg_1 = { read_command = '6'; }
|
||||
var lpg_2 = { read_command = '7'; }
|
||||
var lpg_3 = { read_command = '8'; }
|
||||
var evt_0 = { read_command = '9'; }
|
||||
var evt_1 = { read_command = '10'; }
|
||||
var evt_2 = { read_command = '11'; }
|
||||
var evt_3 = { read_command = '12'; }
|
||||
var evt_4 = { read_command = '13'; }
|
||||
var evt_5 = { read_command = '14'; }
|
||||
var evt_6 = { read_command = '15'; }
|
||||
var evt_7 = { read_command = '16'; }
|
||||
var cur_pres = { read_command = '17'; }
|
||||
var start_in = { read_command = '18'; }
|
||||
var error_in = { read_command = '19'; }
|
||||
}
|
||||
|
||||
code fetch_from_glp = {%%
|
||||
set index ${cmd_str}
|
||||
set data [hgetpropval ${tc_root}/dummy/glp real_data]
|
||||
set dlist [split ${data} ","]
|
||||
if { [llength ${dlist}] > ${index} } {
|
||||
sct result [lindex ${dlist} ${index}]
|
||||
} else {
|
||||
sct result ""
|
||||
}
|
||||
set cmd "@@NOSEND@@"
|
||||
%%}
|
||||
|
||||
code fetch_from_status = {%%
|
||||
set index ${cmd_str}
|
||||
set data [hgetpropval ${tc_root}/dummy/status real_data]
|
||||
set dlist [split ${data} ","]
|
||||
if { [llength ${dlist}] > ${index} } {
|
||||
sct result [lindex ${dlist} ${index}]
|
||||
} else {
|
||||
sct result ""
|
||||
}
|
||||
set cmd "@@NOSEND@@"
|
||||
%%}
|
||||
|
||||
code read_glp = {%%
|
||||
if { [string equal -nocase -length 6 ${data} "ERROR:"] } {
|
||||
} else {
|
||||
set dlist [split [lindex [split ${data} ":"] 1] ","]
|
||||
sct real_data "[join [lrange ${dlist} 0 end] ,]"
|
||||
set data "Hidden in real_data property"
|
||||
}
|
||||
%%}
|
||||
code read_status = {%%
|
||||
set dlist [split [lindex [split ${data} ":"] 1] ","]
|
||||
sct real_data "[join [lrange ${dlist} 0 end] ,]"
|
||||
set data "Hidden in real_data property"
|
||||
%%}
|
||||
code status_fetch = {%%
|
||||
set index 1
|
||||
set data [hgetpropval ${tc_root}/dummy/status real_data]
|
||||
set dlist [split ${data} ","]
|
||||
set status_code [lindex ${dlist} ${index}]
|
||||
set cmd "@@NOSEND@@"
|
||||
if { ${status_code} == 3 } {
|
||||
sct result "PUMPING"
|
||||
} else {
|
||||
sct result "IDLE"
|
||||
}
|
||||
%%}
|
||||
code state_fetch = {%%
|
||||
set index 1
|
||||
set data [hgetpropval ${tc_root}/dummy/status real_data]
|
||||
set dlist [split ${data} ","]
|
||||
set state_code [lindex ${dlist} ${index}]
|
||||
set cmd "@@NOSEND@@"
|
||||
if { ${state_code} < 0 || ${state_code} > 9 } {
|
||||
sct geterror "Invalid device_state ${state_code}"
|
||||
error "[sct geterror]"
|
||||
}
|
||||
set slist [list "SYS_ST_INITIALIZING" \
|
||||
"SYS_ST_OFF" \
|
||||
"SYS_ST_IDLE" \
|
||||
"SYS_ST_RUN" \
|
||||
"SYS_ST_HOLD" \
|
||||
"SYS_ST_PURGE" \
|
||||
"SYS_ST_STANDBY" \
|
||||
"SYS_ST_FAILED" \
|
||||
"SYS_ST_RUNATEND" \
|
||||
]
|
||||
sct result [lindex ${slist} ${state_code}]
|
||||
%%}
|
||||
|
||||
code halt = {%%
|
||||
set rlist [hval ${tc_root}/pump/ratio_sp]
|
||||
set ratio_tgt [join [split ${rlist} /] ,]
|
||||
set cmd "RAMP:0,0,${ratio_tgt},0,0,0,0,0,0,0,0,2"
|
||||
%%}
|
||||
|
||||
code flow_fetch = {%%
|
||||
set data [hgetpropval ${tc_root}/dummy/status real_data]
|
||||
set dlist [split ${data} ","]
|
||||
set flow_pv [lindex ${dlist} 4]
|
||||
sct result [expr {0.001 * ${flow_pv}}]
|
||||
set cmd "@@NOSEND@@"
|
||||
%%}
|
||||
code flow_write = {%%
|
||||
set data [sct target]
|
||||
set cmd "@@NOSEND@@"
|
||||
set nextState idle
|
||||
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
|
||||
}
|
||||
%%}
|
||||
|
||||
code ratios_check = {%%
|
||||
set rlist [split ${setpoint} /]
|
||||
if { [llength ${rlist}] != 4 } {
|
||||
sct geterror "${setpoint} has [llength ${rlist}] components, needs 4"
|
||||
error [sct geterror]
|
||||
}
|
||||
set sum [expr [lindex ${rlist} 0] + [lindex ${rlist} 1] + [lindex ${rlist} 2] + [lindex ${rlist} 3]]
|
||||
if { ${sum} != 100 } {
|
||||
sct geterror "sum is ${sum}, must be 100"
|
||||
error [sct geterror]
|
||||
}
|
||||
%%}
|
||||
|
||||
code ratios_fetch = {%%
|
||||
set data [hgetpropval ${tc_root}/dummy/status real_data]
|
||||
set dlist [split ${data} ","]
|
||||
set ratio_vals "[lindex ${dlist} 5]/[lindex ${dlist} 6]/[lindex ${dlist} 7]/[lindex ${dlist} 8]"
|
||||
sct result ${ratio_vals}
|
||||
set cmd "@@NOSEND@@"
|
||||
%%}
|
||||
code ratios_write = {%%
|
||||
set data [sct target]
|
||||
set cmd "@@NOSEND@@"
|
||||
set nextState idle
|
||||
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
|
||||
}
|
||||
%%}
|
||||
|
||||
code remote_read = {%%
|
||||
if { [string equal -length 7 ${data} "REMOTE:"] } {
|
||||
set data [lindex [split ${data} :] 1]
|
||||
} else {
|
||||
sct geterror "bad response"
|
||||
error "[sct geterror]"
|
||||
}
|
||||
%%}
|
||||
|
||||
code remote_write = {%%
|
||||
if { ${par} == 0 } {
|
||||
set cmd "LOCAL"
|
||||
} else {
|
||||
set cmd "REMOTE"
|
||||
}
|
||||
%%}
|
||||
code volume_fetch = {%%
|
||||
set data [hgetpropval ${tc_root}/dummy/glp real_data]
|
||||
set dlist [split ${data} ","]
|
||||
if { [llength ${dlist}] > 11 } {
|
||||
set pump_volm [lindex ${dlist} 10]
|
||||
set pump_voln [lindex ${dlist} 11]
|
||||
set pump_volume [expr {${pump_volm} + 0.000001 * ${pump_voln}}]
|
||||
} else {
|
||||
set pump_volume 0.0
|
||||
}
|
||||
sct raw_volume ${pump_volume}
|
||||
if { [hpropexists [sct] base_volume] } {
|
||||
set pump_volume [expr {${pump_volume} - [sct base_volume]}]
|
||||
} elseif { [hpropexists [sct] raw_volume] } {
|
||||
sct base_volume [sct raw_volume]
|
||||
}
|
||||
sct result [format "%.2f" ${pump_volume}]
|
||||
set cmd "@@NOSEND@@"
|
||||
%%}
|
||||
code volume_write = {%%
|
||||
hsetprop ${tc_root}/[sct driveable] base_volume [hgetpropval ${tc_root}/[sct driveable] raw_volume]
|
||||
hset ${tc_root}/[sct driveable] 0.0
|
||||
set flow_tgt [expr {int(1000.0 * [hval ${tc_root}/pump/flow_sp])}]
|
||||
set ratio_tgt [join [split [hval ${tc_root}/pump/ratio_sp] /] ,]
|
||||
set cmd "RAMP:0,${flow_tgt},${ratio_tgt},0,0,0,0,0,0,0,0,3"
|
||||
sct pumping 1
|
||||
set data ${par}
|
||||
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
|
||||
}
|
||||
%%}
|
||||
|
||||
code volume_checkpumping = {%%
|
||||
set cmd "@@NOSEND@@"
|
||||
set nextState idle
|
||||
if { [hpropexists [sct] pumping] && [sct pumping] } {
|
||||
if { [hpropexists [sct] driving] && [sct driving] } {
|
||||
volume_checkstatus "${tc_root}"
|
||||
}
|
||||
set sp "[sct target]"
|
||||
set pv "[hval ${tc_root}/[sct driveable]]"
|
||||
if { (${sp} - ${pv}) <= [sct tolerance] } {
|
||||
set flow_tgt 0
|
||||
set ratio_tgt [join [split [hval ${tc_root}/pump/ratio_sp] /] ,]
|
||||
set cmd "RAMP:0,${flow_tgt},${ratio_tgt},0,0,0,0,0,0,0,0,2"
|
||||
set nextState noResponse
|
||||
sct driving 0
|
||||
sct pumping 0
|
||||
}
|
||||
}
|
||||
%%}
|
||||
|
||||
code volume_halt = {%%
|
||||
set flow_tgt 0
|
||||
set ratio_tgt [join [split [hval ${tc_root}/pump/ratio_sp] /] ,]
|
||||
set cmd "RAMP:0,${flow_tgt},${ratio_tgt},0,0,0,0,0,0,0,0,2"
|
||||
sct send ${cmd}
|
||||
%%}
|
||||
|
||||
code volume_reject = {%%
|
||||
sct geterror "cannot use hset on [sct]"
|
||||
error "[sct geterror]"
|
||||
%%}
|
||||
}
|
||||
@@ -27,8 +27,8 @@ proc ::scobj::green_magnet_labview::sics_log {debug_level debug_string} {
|
||||
} catch_message ]
|
||||
}
|
||||
|
||||
proc ::scobj::green_magnet_labview::mkDriver { sct_controller name ip_address tcp_port } {
|
||||
::scobj::green_magnet_labview::sics_log 9 "::scobj::green_magnet_labview::mkDriver ${sct_controller} ${name} ${ip_address} ${tcp_port}"
|
||||
proc ::scobj::green_magnet_labview::mkDriver { sct_controller name device_class simulation_flag ip_address tcp_port } {
|
||||
::scobj::green_magnet_labview::sics_log 9 "::scobj::green_magnet_labview::mkDriver ${sct_controller} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}"
|
||||
set ns "[namespace current]"
|
||||
set catch_status [ catch {
|
||||
|
||||
@@ -46,21 +46,27 @@ proc ::scobj::green_magnet_labview::mkDriver { sct_controller name ip_address tc
|
||||
handle_exception ${catch_status} ${catch_message}
|
||||
}
|
||||
|
||||
proc ::scobj::green_magnet_labview::add_driver {name device_class simulation_flag ip_address tcp_port} {
|
||||
set catch_status [ catch {
|
||||
::scobj::green_magnet_labview::sics_log 9 "::scobj::green_magnet_labview::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}"
|
||||
::scobj::green_magnet_labview::sics_log 9 "No sctcontroller for green_magnet_labview"
|
||||
::scobj::green_magnet_labview::sics_log 1 "::scobj::green_magnet_labview::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}"
|
||||
::scobj::green_magnet_labview::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}
|
||||
} catch_message ]
|
||||
handle_exception ${catch_status} ${catch_message}
|
||||
}
|
||||
|
||||
namespace eval ::scobj::green_magnet_labview {
|
||||
namespace export debug_threshold
|
||||
namespace export debug_log
|
||||
namespace export sics_log
|
||||
namespace export mkDriver
|
||||
namespace export add_driver
|
||||
}
|
||||
|
||||
proc add_green_magnet_labview {name ip_address tcp_port} {
|
||||
set catch_status [ catch {
|
||||
::scobj::green_magnet_labview::sics_log 9 "add_green_magnet_labview ${name} ${ip_address} ${tcp_port}"
|
||||
::scobj::green_magnet_labview::sics_log 9 "No sctcontroller for green_magnet_labview"
|
||||
::scobj::green_magnet_labview::sics_log 1 "::scobj::green_magnet_labview::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port}"
|
||||
::scobj::green_magnet_labview::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port}
|
||||
} catch_message ]
|
||||
handle_exception ${catch_status} ${catch_message}
|
||||
set simulation_flag "[string tolower [SplitReply [environment_simulation]]]"
|
||||
::scobj::green_magnet_labview::add_driver ${name} "environment" "${simulation_flag}" ${ip_address} ${tcp_port}
|
||||
}
|
||||
|
||||
clientput "file evaluation of green_magnet_labview_sct.tcl"
|
||||
@@ -71,6 +77,8 @@ proc ::scobj::green_magnet_labview::read_config {} {
|
||||
set ns "::scobj::green_magnet_labview"
|
||||
dict for {k u} $::config_dict {
|
||||
if { [dict exists $u "implementation"] } {
|
||||
set simulation_flag "[string tolower [SplitReply [environment_simulation]]]"
|
||||
set device_class "environment"
|
||||
if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } {
|
||||
continue
|
||||
}
|
||||
@@ -78,6 +86,12 @@ proc ::scobj::green_magnet_labview::read_config {} {
|
||||
if { ! ([string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"]) } {
|
||||
continue
|
||||
}
|
||||
if { [dict exists $u "simulation_group"] } {
|
||||
set simulation_flag [SplitReply [[string tolower [dict get $u "simulation_group"]]]]
|
||||
}
|
||||
if { [dict exists $u "device_class"] } {
|
||||
set device_class "[dict get $u "device_class"]"
|
||||
}
|
||||
set name [dict get $u name]
|
||||
set implementation [dict get $u "implementation"]
|
||||
if { !([dict exists $::config_dict $implementation]) } {
|
||||
@@ -88,9 +102,9 @@ proc ::scobj::green_magnet_labview::read_config {} {
|
||||
continue
|
||||
}
|
||||
if { [string equal -nocase [dict get $v "driver"] "green_magnet_labview"] } {
|
||||
if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } {
|
||||
if { ![string equal -nocase "${simulation_flag}" "false"] } {
|
||||
set asyncqueue "null"
|
||||
${ns}::sics_log 9 "[environment_simulation] => using null asyncqueue"
|
||||
${ns}::sics_log 9 "simulation_flag=${simulation_flag} => using null asyncqueue"
|
||||
} elseif { [dict exists $v "asyncqueue"] } {
|
||||
set asyncqueue [dict get $v "asyncqueue"]
|
||||
if { [string equal -nocase ${asyncqueue} "sct"] } {
|
||||
@@ -117,9 +131,9 @@ proc ::scobj::green_magnet_labview::read_config {} {
|
||||
}
|
||||
}
|
||||
if { [string equal -nocase ${asyncqueue} "sct"] } {
|
||||
add_green_magnet_labview ${name} ${ip_address} ${tcp_port}
|
||||
${ns}::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}
|
||||
} else {
|
||||
add_green_magnet_labview ${name} "aqadapter" ${asyncqueue}
|
||||
${ns}::add_driver ${name} ${device_class} ${simulation_flag} "aqadapter" ${asyncqueue}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
#
|
||||
driver nhq_200 = {
|
||||
vendor = FastComTech; device = NHQ; protocol = std;
|
||||
class = environment;
|
||||
simulation_group = environment_simulation;
|
||||
class = NXdetector;
|
||||
simulation_group = detector_simulation;
|
||||
|
||||
group = {
|
||||
readable = 10;
|
||||
|
||||
1877
site_ansto/instrument/config/environment/sct_knauer_pump.tcl
Normal file
1877
site_ansto/instrument/config/environment/sct_knauer_pump.tcl
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
||||
driver lakeshore_218 = {
|
||||
vendor = lakeshore; device = ls218; protocol = std;
|
||||
class = environment; simulation_group = environment_simulation;
|
||||
class = NXdetector; simulation_group = detector_simulation;
|
||||
|
||||
group = {
|
||||
data = false;
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
# vim: ts=8 sts=2 sw=2 expandtab autoindent smartindent nocindent
|
||||
driver lakeshore_m370 = {
|
||||
protocol = std
|
||||
sobj_priv_type = 'user float'
|
||||
sobj_priv_type = 'user none'
|
||||
class = environment
|
||||
simulation_group = environment_simulation
|
||||
add_args = 'id tol'
|
||||
make_args = 'id tol'
|
||||
code mkDriver = {%%
|
||||
::scobj::lakeshore_370::mk_sct_driver $sct_controller environment $name $tol
|
||||
hsetprop ${scobj_hpath}/setpoint permlink data_set T[format "%02d" ${id}]SP01
|
||||
hsetprop ${scobj_hpath}/setpoint @description T[format "%02d" ${id}]SP01
|
||||
hsetprop ${scobj_hpath}/Loop1/setpoint permlink data_set T[format "%02d" ${id}]SP01
|
||||
hsetprop ${scobj_hpath}/Loop1/setpoint @description T[format "%02d" ${id}]SP01
|
||||
hsetprop ${scobj_hpath}/Sensor/value permlink data_set T[format "%02d" ${id}]S01
|
||||
hsetprop ${scobj_hpath}/Sensor/value @description T[format "%02d" ${id}]S01
|
||||
%%}
|
||||
|
||||
@@ -27,24 +27,23 @@ proc ::scobj::lakeshore_m370::sics_log {debug_level debug_string} {
|
||||
} catch_message ]
|
||||
}
|
||||
|
||||
proc ::scobj::lakeshore_m370::mkDriver { sct_controller name ip_address tcp_port id tol } {
|
||||
::scobj::lakeshore_m370::sics_log 9 "::scobj::lakeshore_m370::mkDriver ${sct_controller} ${name} ${ip_address} ${tcp_port} ${id} ${tol}"
|
||||
proc ::scobj::lakeshore_m370::mkDriver { sct_controller name id tol} {
|
||||
::scobj::lakeshore_m370::sics_log 9 "::scobj::lakeshore_m370::mkDriver ${sct_controller} ${name} ${id} ${tol}"
|
||||
set ns "[namespace current]"
|
||||
set catch_status [ catch {
|
||||
|
||||
MakeSICSObj ${name} SCT_OBJECT user float
|
||||
MakeSICSObj ${name} SCT_OBJECT user none
|
||||
|
||||
sicslist setatt ${name} klass environment
|
||||
sicslist setatt ${name} long_name ${name}
|
||||
|
||||
set scobj_hpath /sics/${name}
|
||||
hsetprop ${scobj_hpath} klass environment
|
||||
hsetprop ${scobj_hpath} data true
|
||||
hsetprop ${scobj_hpath} debug_threshold 5
|
||||
# mkDriver hook code starts
|
||||
::scobj::lakeshore_370::mk_sct_driver $sct_controller environment $name $tol
|
||||
hsetprop ${scobj_hpath}/setpoint permlink data_set T[format "%02d" ${id}]SP01
|
||||
hsetprop ${scobj_hpath}/setpoint @description T[format "%02d" ${id}]SP01
|
||||
hsetprop ${scobj_hpath}/Loop1/setpoint permlink data_set T[format "%02d" ${id}]SP01
|
||||
hsetprop ${scobj_hpath}/Loop1/setpoint @description T[format "%02d" ${id}]SP01
|
||||
hsetprop ${scobj_hpath}/Sensor/value permlink data_set T[format "%02d" ${id}]S01
|
||||
hsetprop ${scobj_hpath}/Sensor/value @description T[format "%02d" ${id}]S01
|
||||
# mkDriver hook code ends
|
||||
@@ -59,24 +58,24 @@ namespace eval ::scobj::lakeshore_m370 {
|
||||
namespace export mkDriver
|
||||
}
|
||||
|
||||
proc add_lakeshore_m370 {name ip_address tcp_port id tol} {
|
||||
proc add_lakeshore_m370 {name IP port id tol} {
|
||||
set catch_status [ catch {
|
||||
::scobj::lakeshore_m370::sics_log 9 "add_lakeshore_m370 ${name} ${ip_address} ${tcp_port} ${id} ${tol}"
|
||||
::scobj::lakeshore_m370::sics_log 9 "add_lakeshore_m370 ${name} ${IP} ${port} ${tol}"
|
||||
if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} {
|
||||
if {[string equal -nocase "aqadapter" "${ip_address}"]} {
|
||||
::scobj::lakeshore_m370::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}"
|
||||
makesctcontroller sct_${name} aqadapter ${tcp_port}
|
||||
if {[string equal -nocase "aqadapter" "${IP}"]} {
|
||||
::scobj::lakeshore_m370::sics_log 9 "makesctcontroller sct_${name} aqadapter ${port}"
|
||||
makesctcontroller sct_${name} aqadapter ${port}
|
||||
} else {
|
||||
::scobj::lakeshore_m370::sics_log 9 "makesctcontroller sct_${name} std ${ip_address}:${tcp_port}"
|
||||
makesctcontroller sct_${name} std ${ip_address}:${tcp_port}
|
||||
::scobj::lakeshore_m370::sics_log 9 "makesctcontroller sct_${name} std ${IP}:${port}"
|
||||
makesctcontroller sct_${name} std ${IP}:${port}
|
||||
}
|
||||
} else {
|
||||
::scobj::lakeshore_m370::sics_log 9 "[environment_simulation] => Null sctcontroller for lakeshore_m370"
|
||||
::scobj::lakeshore_m370::sics_log 9 "makesctcontroller sct_${name} aqadapter NULL"
|
||||
makesctcontroller sct_${name} aqadapter NULL
|
||||
}
|
||||
::scobj::lakeshore_m370::sics_log 1 "::scobj::lakeshore_m370::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} ${id} ${tol}"
|
||||
::scobj::lakeshore_m370::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} ${id} ${tol}
|
||||
::scobj::lakeshore_m370::sics_log 1 "::scobj::lakeshore_m370::mkDriver sct_${name} ${name} ${id} ${tol}"
|
||||
::scobj::lakeshore_m370::mkDriver sct_${name} ${name} ${id} ${tol}
|
||||
} catch_message ]
|
||||
handle_exception ${catch_status} ${catch_message}
|
||||
}
|
||||
@@ -87,20 +86,29 @@ clientput "file evaluation of lakeshore_m370_sct.tcl"
|
||||
proc ::scobj::lakeshore_m370::read_config {} {
|
||||
set catch_status [ catch {
|
||||
set ns "::scobj::lakeshore_m370"
|
||||
dict for {k u} $::config_dict {
|
||||
if { [dict exists $u "implementation"] } {
|
||||
if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } {
|
||||
dict for {k v} $::config_dict {
|
||||
if { [dict exists $v "implementation"] } {
|
||||
if { !([dict exists $v "name"] && [dict exists $v "enabled"]) } {
|
||||
continue
|
||||
}
|
||||
set enabled [string tolower [dict get $u "enabled"]]
|
||||
set enabled [string tolower [dict get $v "enabled"]]
|
||||
if { ! ([string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"]) } {
|
||||
continue
|
||||
}
|
||||
set name [dict get $u name]
|
||||
set implementation [dict get $u "implementation"]
|
||||
set name [dict get $v name]
|
||||
set implementation [dict get $v "implementation"]
|
||||
if { !([dict exists $::config_dict $implementation]) } {
|
||||
continue
|
||||
}
|
||||
set arg_list [list]
|
||||
foreach arg {id} {
|
||||
if {[dict exists $v $arg]} {
|
||||
lappend arg_list "[dict get $v $arg]"
|
||||
} else {
|
||||
${ns}::sics_log 9 "Missing configuration value $arg"
|
||||
error "Missing configuration value $arg"
|
||||
}
|
||||
}
|
||||
set v [dict get $::config_dict $implementation]
|
||||
if { !([dict exists $v "driver"]) } {
|
||||
continue
|
||||
@@ -112,8 +120,8 @@ proc ::scobj::lakeshore_m370::read_config {} {
|
||||
} elseif { [dict exists $v "asyncqueue"] } {
|
||||
set asyncqueue [dict get $v "asyncqueue"]
|
||||
if { [string equal -nocase ${asyncqueue} "sct"] } {
|
||||
set ip_address [dict get $v ip]
|
||||
set tcp_port [dict get $v port]
|
||||
set IP [dict get $v ip]
|
||||
set PORT [dict get $v port]
|
||||
}
|
||||
} else {
|
||||
if { [dict exists $v "asyncprotocol"] } {
|
||||
@@ -127,30 +135,23 @@ proc ::scobj::lakeshore_m370::read_config {} {
|
||||
}
|
||||
}
|
||||
set asyncqueue ${name}_queue
|
||||
set ip_address [dict get $v ip]
|
||||
set tcp_port [dict get $v port]
|
||||
MakeAsyncQueue ${asyncqueue} ${asyncprotocol} ${ip_address} ${tcp_port}
|
||||
set IP [dict get $v ip]
|
||||
set PORT [dict get $v port]
|
||||
MakeAsyncQueue ${asyncqueue} ${asyncprotocol} ${IP} ${PORT}
|
||||
if { [dict exists $v "timeout"] } {
|
||||
${asyncqueue} timeout "[dict get $v "timeout"]"
|
||||
}
|
||||
}
|
||||
set arg_list [list]
|
||||
set missing_list [list]
|
||||
foreach arg {id tol} {
|
||||
if {[dict exists $u $arg]} {
|
||||
lappend arg_list "[dict get $u $arg]"
|
||||
} elseif {[dict exists $v $arg]} {
|
||||
foreach arg {tol} {
|
||||
if {[dict exists $v $arg]} {
|
||||
lappend arg_list "[dict get $v $arg]"
|
||||
} else {
|
||||
${ns}::sics_log 9 "Missing configuration value $arg"
|
||||
lappend missing_list $arg
|
||||
error "Missing configuration value $arg"
|
||||
}
|
||||
}
|
||||
if { [llength $missing_list] > 0 } {
|
||||
error "$name is missing configuration values $missing_list"
|
||||
}
|
||||
if { [string equal -nocase ${asyncqueue} "sct"] } {
|
||||
add_lakeshore_m370 ${name} ${ip_address} ${tcp_port} {*}$arg_list
|
||||
add_lakeshore_m370 ${name} ${IP} ${PORT} {*}$arg_list
|
||||
} else {
|
||||
add_lakeshore_m370 ${name} "aqadapter" ${asyncqueue} {*}$arg_list
|
||||
}
|
||||
|
||||
@@ -989,6 +989,8 @@ proc sendCmd {tc_root nextState cmd {idx ""}} {
|
||||
set sensorValue $tc_root/sensor/sensorValue$whichSensor
|
||||
if {$whichCtrlLoop <= 2} {
|
||||
set nodename $tc_root/sensor/setpoint$whichCtrlLoop
|
||||
hset $tc_root/control/tolerance1 1
|
||||
hset $tc_root/control/tolerance2 1
|
||||
hset $nodename [hval $sensorValue]
|
||||
hsetprop $nodename driving 0
|
||||
}
|
||||
|
||||
@@ -0,0 +1,459 @@
|
||||
# Generated driver for srs_sr630
|
||||
# vim: ft=tcl tabstop=8 softtabstop=2 shiftwidth=2 nocindent smartindent
|
||||
#
|
||||
|
||||
namespace eval ::scobj::srs_sr630 {
|
||||
set debug_threshold 5
|
||||
}
|
||||
|
||||
proc ::scobj::srs_sr630::debug_log {tc_root debug_level debug_string} {
|
||||
set catch_status [ catch {
|
||||
set debug_threshold [hgetpropval ${tc_root} debug_threshold]
|
||||
if {${debug_level} >= ${debug_threshold}} {
|
||||
set fd [open "../log/srs_sr630_[basename ${tc_root}].log" "a"]
|
||||
set line "[clock format [clock seconds] -format "%T"] ${debug_string}"
|
||||
puts ${fd} "${line}"
|
||||
close ${fd}
|
||||
}
|
||||
} catch_message ]
|
||||
}
|
||||
|
||||
proc ::scobj::srs_sr630::sics_log {debug_level debug_string} {
|
||||
set catch_status [ catch {
|
||||
set debug_threshold ${::scobj::srs_sr630::debug_threshold}
|
||||
if {${debug_level} >= ${debug_threshold}} {
|
||||
sicslog "::scobj::srs_sr630::${debug_string}"
|
||||
}
|
||||
} catch_message ]
|
||||
}
|
||||
|
||||
# check function for hset change
|
||||
proc ::scobj::srs_sr630::checkrange {tc_root} {
|
||||
set catch_status [ catch {
|
||||
debug_log ${tc_root} 1 "checkrange tc_root=${tc_root} sct=[sct] target=[sct target]"
|
||||
set setpoint [sct target]
|
||||
if { [hpropexists [sct] lowerlimit] } {
|
||||
set lolimit [sct lowerlimit]
|
||||
} else {
|
||||
# lowerlimit not set, use target
|
||||
set lolimit [sct target]
|
||||
}
|
||||
if { [hpropexists [sct] upperlimit] } {
|
||||
set hilimit [sct upperlimit]
|
||||
} else {
|
||||
# upperlimit not set, use target
|
||||
set hilimit [sct target]
|
||||
}
|
||||
# checkrange hook code goes here
|
||||
if { ${setpoint} < ${lolimit} || ${setpoint} > ${hilimit} } {
|
||||
error "setpoint ${setpoint} violates limits (${lolimit}..${hilimit}) on [sct]"
|
||||
}
|
||||
return OK
|
||||
} catch_message ]
|
||||
handle_exception ${catch_status} ${catch_message}
|
||||
}
|
||||
|
||||
# function to request the read of a parameter on a device
|
||||
proc ::scobj::srs_sr630::fetch_id {tc_root nextState cmd_str} {
|
||||
set catch_status [ catch {
|
||||
debug_log ${tc_root} 1 "fetch_id tc_root=${tc_root} sct=[sct] cmd=${cmd_str}"
|
||||
if { [hpropexists [sct] geterror] } {
|
||||
hdelprop [sct] geterror
|
||||
}
|
||||
set cmd "${cmd_str}"
|
||||
# fetch_id hook code starts
|
||||
if {[hval [sct]] == "UNKNOWN"} {
|
||||
set cmd "[clock format [clock seconds] -format "DATE %m,%d,%Y;TIME %H,%M,%S;*IDN?"]"
|
||||
} else {
|
||||
set cmd "*IDN?"
|
||||
}
|
||||
# fetch_id hook code ends
|
||||
if { [hpropexists [sct] geterror] } {
|
||||
debug_log ${tc_root} 9 "[sct] error: [sct geterror]"
|
||||
error "[sct geterror]"
|
||||
}
|
||||
debug_log ${tc_root} 1 "fetch_id sct send ${cmd}"
|
||||
if {![string equal -nocase -length 10 ${cmd} "@@NOSEND@@"]} {
|
||||
sct send "${cmd}"
|
||||
}
|
||||
return ${nextState}
|
||||
} catch_message ]
|
||||
handle_exception ${catch_status} ${catch_message}
|
||||
}
|
||||
|
||||
# function to request the read of a parameter on a device
|
||||
proc ::scobj::srs_sr630::getSensor {tc_root nextState cmd_str} {
|
||||
set catch_status [ catch {
|
||||
debug_log ${tc_root} 1 "getSensor tc_root=${tc_root} sct=[sct] cmd=${cmd_str}"
|
||||
if { [hpropexists [sct] geterror] } {
|
||||
hdelprop [sct] geterror
|
||||
}
|
||||
set cmd "${cmd_str}"
|
||||
# getSensor hook code starts
|
||||
set cmd "UNIT ${cmd_str},ABS;MEAS? ${cmd_str}"
|
||||
# getSensor hook code ends
|
||||
if { [hpropexists [sct] geterror] } {
|
||||
debug_log ${tc_root} 9 "[sct] error: [sct geterror]"
|
||||
error "[sct geterror]"
|
||||
}
|
||||
debug_log ${tc_root} 1 "getSensor sct send ${cmd}"
|
||||
if {![string equal -nocase -length 10 ${cmd} "@@NOSEND@@"]} {
|
||||
sct send "${cmd}"
|
||||
}
|
||||
return ${nextState}
|
||||
} catch_message ]
|
||||
handle_exception ${catch_status} ${catch_message}
|
||||
}
|
||||
|
||||
# function to check the write parameter on a device
|
||||
proc ::scobj::srs_sr630::noResponse {tc_root} {
|
||||
set catch_status [ catch {
|
||||
debug_log ${tc_root} 1 "noResponse tc_root=${tc_root} sct=[sct] resp=[sct result]"
|
||||
# noResponse hook code goes here
|
||||
return "idle"
|
||||
} catch_message ]
|
||||
handle_exception ${catch_status} ${catch_message}
|
||||
}
|
||||
|
||||
# function to parse the read of a parameter on a device
|
||||
proc ::scobj::srs_sr630::readSensor {tc_root} {
|
||||
set catch_status [ catch {
|
||||
debug_log ${tc_root} 1 "readSensor 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]"
|
||||
}
|
||||
# readSensor hook code goes here
|
||||
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 parse the read of a parameter on a device
|
||||
proc ::scobj::srs_sr630::read_id {tc_root} {
|
||||
set catch_status [ catch {
|
||||
debug_log ${tc_root} 1 "read_id 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_id hook code goes here
|
||||
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::srs_sr630::setValue {tc_root nextState cmd_str} {
|
||||
set catch_status [ catch {
|
||||
debug_log ${tc_root} 1 "setValue tc_root=${tc_root} sct=[sct] cmd=${cmd_str}"
|
||||
if { [hpropexists [sct] geterror] } {
|
||||
hdelprop [sct] geterror
|
||||
}
|
||||
set par [sct target]
|
||||
set cmd "${cmd_str}${par}"
|
||||
# setValue hook code goes here
|
||||
if { [hpropexists [sct] driving] } {
|
||||
if { [hpropexists [sct] writestatus] && [sct writestatus] == "start" } {
|
||||
sct driving 1
|
||||
}
|
||||
}
|
||||
debug_log ${tc_root} 1 "setValue sct send ${cmd}"
|
||||
if {![string equal -nocase -length 10 ${cmd} "@@NOSEND@@"]} {
|
||||
sct send "${cmd}"
|
||||
}
|
||||
return ${nextState}
|
||||
} catch_message ]
|
||||
handle_exception ${catch_status} ${catch_message}
|
||||
}
|
||||
|
||||
proc ::scobj::srs_sr630::mkDriver { sct_controller name device_class simulation_flag ip_address tcp_port } {
|
||||
::scobj::srs_sr630::sics_log 9 "::scobj::srs_sr630::mkDriver ${sct_controller} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}"
|
||||
set ns "[namespace current]"
|
||||
set catch_status [ catch {
|
||||
|
||||
MakeSICSObj ${name} SCT_OBJECT
|
||||
|
||||
sicslist setatt ${name} klass ${device_class}
|
||||
sicslist setatt ${name} long_name ${name}
|
||||
|
||||
set scobj_hpath /sics/${name}
|
||||
|
||||
hfactory ${scobj_hpath}/id plain user text
|
||||
hsetprop ${scobj_hpath}/id read ${ns}::fetch_id ${scobj_hpath} read_id {@}
|
||||
hsetprop ${scobj_hpath}/id read_id ${ns}::read_id ${scobj_hpath}
|
||||
hsetprop ${scobj_hpath}/id control true
|
||||
hsetprop ${scobj_hpath}/id data true
|
||||
hsetprop ${scobj_hpath}/id mutable true
|
||||
hsetprop ${scobj_hpath}/id nxsave true
|
||||
hsetprop ${scobj_hpath}/id oldval UNKNOWN
|
||||
hset ${scobj_hpath}/id UNKNOWN
|
||||
hsetprop ${scobj_hpath}/id klass "parameter"
|
||||
hsetprop ${scobj_hpath}/id sdsinfo "::nexus::scobj::sdsinfo"
|
||||
hsetprop ${scobj_hpath}/id type "part"
|
||||
hsetprop ${scobj_hpath}/id nxalias "${name}_id"
|
||||
|
||||
hfactory ${scobj_hpath}/sensor_01 plain user float
|
||||
hsetprop ${scobj_hpath}/sensor_01 read ${ns}::getSensor ${scobj_hpath} readSensor {1}
|
||||
hsetprop ${scobj_hpath}/sensor_01 readSensor ${ns}::readSensor ${scobj_hpath}
|
||||
hsetprop ${scobj_hpath}/sensor_01 control true
|
||||
hsetprop ${scobj_hpath}/sensor_01 data true
|
||||
hsetprop ${scobj_hpath}/sensor_01 mutable true
|
||||
hsetprop ${scobj_hpath}/sensor_01 nxsave true
|
||||
hsetprop ${scobj_hpath}/sensor_01 oldval 0.0
|
||||
hsetprop ${scobj_hpath}/sensor_01 klass "parameter"
|
||||
hsetprop ${scobj_hpath}/sensor_01 sdsinfo "::nexus::scobj::sdsinfo"
|
||||
hsetprop ${scobj_hpath}/sensor_01 type "part"
|
||||
hsetprop ${scobj_hpath}/sensor_01 nxalias "${name}_sensor_01"
|
||||
|
||||
hfactory ${scobj_hpath}/sensor_02 plain user float
|
||||
hsetprop ${scobj_hpath}/sensor_02 read ${ns}::getSensor ${scobj_hpath} readSensor {2}
|
||||
hsetprop ${scobj_hpath}/sensor_02 readSensor ${ns}::readSensor ${scobj_hpath}
|
||||
hsetprop ${scobj_hpath}/sensor_02 control true
|
||||
hsetprop ${scobj_hpath}/sensor_02 data true
|
||||
hsetprop ${scobj_hpath}/sensor_02 mutable true
|
||||
hsetprop ${scobj_hpath}/sensor_02 nxsave true
|
||||
hsetprop ${scobj_hpath}/sensor_02 oldval 0.0
|
||||
hsetprop ${scobj_hpath}/sensor_02 klass "parameter"
|
||||
hsetprop ${scobj_hpath}/sensor_02 sdsinfo "::nexus::scobj::sdsinfo"
|
||||
hsetprop ${scobj_hpath}/sensor_02 type "part"
|
||||
hsetprop ${scobj_hpath}/sensor_02 nxalias "${name}_sensor_02"
|
||||
|
||||
hfactory ${scobj_hpath}/sensor_03 plain user float
|
||||
hsetprop ${scobj_hpath}/sensor_03 read ${ns}::getSensor ${scobj_hpath} readSensor {3}
|
||||
hsetprop ${scobj_hpath}/sensor_03 readSensor ${ns}::readSensor ${scobj_hpath}
|
||||
hsetprop ${scobj_hpath}/sensor_03 control true
|
||||
hsetprop ${scobj_hpath}/sensor_03 data true
|
||||
hsetprop ${scobj_hpath}/sensor_03 mutable true
|
||||
hsetprop ${scobj_hpath}/sensor_03 nxsave true
|
||||
hsetprop ${scobj_hpath}/sensor_03 oldval 0.0
|
||||
hsetprop ${scobj_hpath}/sensor_03 klass "parameter"
|
||||
hsetprop ${scobj_hpath}/sensor_03 sdsinfo "::nexus::scobj::sdsinfo"
|
||||
hsetprop ${scobj_hpath}/sensor_03 type "part"
|
||||
hsetprop ${scobj_hpath}/sensor_03 nxalias "${name}_sensor_03"
|
||||
|
||||
hfactory ${scobj_hpath}/sensor_04 plain user float
|
||||
hsetprop ${scobj_hpath}/sensor_04 read ${ns}::getSensor ${scobj_hpath} readSensor {4}
|
||||
hsetprop ${scobj_hpath}/sensor_04 readSensor ${ns}::readSensor ${scobj_hpath}
|
||||
hsetprop ${scobj_hpath}/sensor_04 control true
|
||||
hsetprop ${scobj_hpath}/sensor_04 data true
|
||||
hsetprop ${scobj_hpath}/sensor_04 mutable true
|
||||
hsetprop ${scobj_hpath}/sensor_04 nxsave true
|
||||
hsetprop ${scobj_hpath}/sensor_04 oldval 0.0
|
||||
hsetprop ${scobj_hpath}/sensor_04 klass "parameter"
|
||||
hsetprop ${scobj_hpath}/sensor_04 sdsinfo "::nexus::scobj::sdsinfo"
|
||||
hsetprop ${scobj_hpath}/sensor_04 type "part"
|
||||
hsetprop ${scobj_hpath}/sensor_04 nxalias "${name}_sensor_04"
|
||||
|
||||
hfactory ${scobj_hpath}/sensor_05 plain user float
|
||||
hsetprop ${scobj_hpath}/sensor_05 read ${ns}::getSensor ${scobj_hpath} readSensor {5}
|
||||
hsetprop ${scobj_hpath}/sensor_05 readSensor ${ns}::readSensor ${scobj_hpath}
|
||||
hsetprop ${scobj_hpath}/sensor_05 control true
|
||||
hsetprop ${scobj_hpath}/sensor_05 data true
|
||||
hsetprop ${scobj_hpath}/sensor_05 mutable true
|
||||
hsetprop ${scobj_hpath}/sensor_05 nxsave true
|
||||
hsetprop ${scobj_hpath}/sensor_05 oldval 0.0
|
||||
hsetprop ${scobj_hpath}/sensor_05 klass "parameter"
|
||||
hsetprop ${scobj_hpath}/sensor_05 sdsinfo "::nexus::scobj::sdsinfo"
|
||||
hsetprop ${scobj_hpath}/sensor_05 type "part"
|
||||
hsetprop ${scobj_hpath}/sensor_05 nxalias "${name}_sensor_05"
|
||||
|
||||
hfactory ${scobj_hpath}/sensor_06 plain user float
|
||||
hsetprop ${scobj_hpath}/sensor_06 read ${ns}::getSensor ${scobj_hpath} readSensor {6}
|
||||
hsetprop ${scobj_hpath}/sensor_06 readSensor ${ns}::readSensor ${scobj_hpath}
|
||||
hsetprop ${scobj_hpath}/sensor_06 control true
|
||||
hsetprop ${scobj_hpath}/sensor_06 data true
|
||||
hsetprop ${scobj_hpath}/sensor_06 mutable true
|
||||
hsetprop ${scobj_hpath}/sensor_06 nxsave true
|
||||
hsetprop ${scobj_hpath}/sensor_06 oldval 0.0
|
||||
hsetprop ${scobj_hpath}/sensor_06 klass "parameter"
|
||||
hsetprop ${scobj_hpath}/sensor_06 sdsinfo "::nexus::scobj::sdsinfo"
|
||||
hsetprop ${scobj_hpath}/sensor_06 type "part"
|
||||
hsetprop ${scobj_hpath}/sensor_06 nxalias "${name}_sensor_06"
|
||||
|
||||
hfactory ${scobj_hpath}/sensor_07 plain user float
|
||||
hsetprop ${scobj_hpath}/sensor_07 read ${ns}::getSensor ${scobj_hpath} readSensor {7}
|
||||
hsetprop ${scobj_hpath}/sensor_07 readSensor ${ns}::readSensor ${scobj_hpath}
|
||||
hsetprop ${scobj_hpath}/sensor_07 control true
|
||||
hsetprop ${scobj_hpath}/sensor_07 data true
|
||||
hsetprop ${scobj_hpath}/sensor_07 mutable true
|
||||
hsetprop ${scobj_hpath}/sensor_07 nxsave true
|
||||
hsetprop ${scobj_hpath}/sensor_07 oldval 0.0
|
||||
hsetprop ${scobj_hpath}/sensor_07 klass "parameter"
|
||||
hsetprop ${scobj_hpath}/sensor_07 sdsinfo "::nexus::scobj::sdsinfo"
|
||||
hsetprop ${scobj_hpath}/sensor_07 type "part"
|
||||
hsetprop ${scobj_hpath}/sensor_07 nxalias "${name}_sensor_07"
|
||||
|
||||
hfactory ${scobj_hpath}/sensor_08 plain user float
|
||||
hsetprop ${scobj_hpath}/sensor_08 read ${ns}::getSensor ${scobj_hpath} readSensor {8}
|
||||
hsetprop ${scobj_hpath}/sensor_08 readSensor ${ns}::readSensor ${scobj_hpath}
|
||||
hsetprop ${scobj_hpath}/sensor_08 control true
|
||||
hsetprop ${scobj_hpath}/sensor_08 data true
|
||||
hsetprop ${scobj_hpath}/sensor_08 mutable true
|
||||
hsetprop ${scobj_hpath}/sensor_08 nxsave true
|
||||
hsetprop ${scobj_hpath}/sensor_08 oldval 0.0
|
||||
hsetprop ${scobj_hpath}/sensor_08 klass "parameter"
|
||||
hsetprop ${scobj_hpath}/sensor_08 sdsinfo "::nexus::scobj::sdsinfo"
|
||||
hsetprop ${scobj_hpath}/sensor_08 type "part"
|
||||
hsetprop ${scobj_hpath}/sensor_08 nxalias "${name}_sensor_08"
|
||||
|
||||
hsetprop ${scobj_hpath} data "true"
|
||||
hsetprop ${scobj_hpath} klass "@none"
|
||||
hsetprop ${scobj_hpath} type "part"
|
||||
|
||||
if {[string equal -nocase "${simulation_flag}" "false"]} {
|
||||
${sct_controller} poll ${scobj_hpath}/id 600
|
||||
${sct_controller} poll ${scobj_hpath}/sensor_01 60
|
||||
${sct_controller} poll ${scobj_hpath}/sensor_02 600
|
||||
${sct_controller} poll ${scobj_hpath}/sensor_03 600
|
||||
${sct_controller} poll ${scobj_hpath}/sensor_04 600
|
||||
${sct_controller} poll ${scobj_hpath}/sensor_05 600
|
||||
${sct_controller} poll ${scobj_hpath}/sensor_06 600
|
||||
${sct_controller} poll ${scobj_hpath}/sensor_07 600
|
||||
${sct_controller} poll ${scobj_hpath}/sensor_08 600
|
||||
} else {
|
||||
::scobj::srs_sr630::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for srs_sr630"
|
||||
}
|
||||
hsetprop ${scobj_hpath} klass ${device_class}
|
||||
hsetprop ${scobj_hpath} data true
|
||||
hsetprop ${scobj_hpath} debug_threshold 5
|
||||
# mkDriver hook code goes here
|
||||
} catch_message ]
|
||||
handle_exception ${catch_status} ${catch_message}
|
||||
}
|
||||
|
||||
proc ::scobj::srs_sr630::add_driver {name device_class simulation_flag ip_address tcp_port} {
|
||||
set catch_status [ catch {
|
||||
::scobj::srs_sr630::sics_log 9 "::scobj::srs_sr630::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}"
|
||||
if {[string equal -nocase "${simulation_flag}" "false"]} {
|
||||
if {[string equal -nocase "aqadapter" "${ip_address}"]} {
|
||||
::scobj::srs_sr630::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}"
|
||||
makesctcontroller sct_${name} aqadapter ${tcp_port}
|
||||
} else {
|
||||
::scobj::srs_sr630::sics_log 9 "makesctcontroller sct_${name} std ${ip_address}:${tcp_port}"
|
||||
makesctcontroller sct_${name} std ${ip_address}:${tcp_port}
|
||||
}
|
||||
} else {
|
||||
::scobj::srs_sr630::sics_log 9 "simulation_flag={simulation_flag} => No sctcontroller for srs_sr630"
|
||||
}
|
||||
::scobj::srs_sr630::sics_log 1 "::scobj::srs_sr630::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}"
|
||||
::scobj::srs_sr630::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}
|
||||
} catch_message ]
|
||||
handle_exception ${catch_status} ${catch_message}
|
||||
}
|
||||
|
||||
namespace eval ::scobj::srs_sr630 {
|
||||
namespace export debug_threshold
|
||||
namespace export debug_log
|
||||
namespace export sics_log
|
||||
namespace export mkDriver
|
||||
namespace export add_driver
|
||||
}
|
||||
|
||||
proc add_srs_sr630 {name ip_address tcp_port} {
|
||||
set simulation_flag "[string tolower [SplitReply [detector_simulation]]]"
|
||||
::scobj::srs_sr630::add_driver ${name} "NXdetector" "${simulation_flag}" ${ip_address} ${tcp_port}
|
||||
}
|
||||
|
||||
clientput "file evaluation of sct_srs_sr630.tcl"
|
||||
::scobj::srs_sr630::sics_log 9 "file evaluation of sct_srs_sr630.tcl"
|
||||
|
||||
proc ::scobj::srs_sr630::read_config {} {
|
||||
set catch_status [ catch {
|
||||
set ns "::scobj::srs_sr630"
|
||||
dict for {k u} $::config_dict {
|
||||
if { [dict exists $u "implementation"] } {
|
||||
set simulation_flag "[string tolower [SplitReply [detector_simulation]]]"
|
||||
set device_class "NXdetector"
|
||||
if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } {
|
||||
continue
|
||||
}
|
||||
set enabled [string tolower [dict get $u "enabled"]]
|
||||
if { ! ([string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"]) } {
|
||||
continue
|
||||
}
|
||||
if { [dict exists $u "simulation_group"] } {
|
||||
set simulation_flag [SplitReply [[string tolower [dict get $u "simulation_group"]]]]
|
||||
}
|
||||
if { [dict exists $u "device_class"] } {
|
||||
set device_class "[dict get $u "device_class"]"
|
||||
}
|
||||
set name [dict get $u name]
|
||||
set implementation [dict get $u "implementation"]
|
||||
if { !([dict exists $::config_dict $implementation]) } {
|
||||
continue
|
||||
}
|
||||
set v [dict get $::config_dict $implementation]
|
||||
if { !([dict exists $v "driver"]) } {
|
||||
continue
|
||||
}
|
||||
if { [string equal -nocase [dict get $v "driver"] "srs_sr630"] } {
|
||||
if { ![string equal -nocase "${simulation_flag}" "false"] } {
|
||||
set asyncqueue "null"
|
||||
${ns}::sics_log 9 "simulation_flag=${simulation_flag} => using null asyncqueue"
|
||||
} elseif { [dict exists $v "asyncqueue"] } {
|
||||
set asyncqueue [dict get $v "asyncqueue"]
|
||||
if { [string equal -nocase ${asyncqueue} "sct"] } {
|
||||
set ip_address [dict get $v ip]
|
||||
set tcp_port [dict get $v port]
|
||||
}
|
||||
} else {
|
||||
if { [dict exists $v "asyncprotocol"] } {
|
||||
set asyncprotocol [dict get $v "asyncprotocol"]
|
||||
} else {
|
||||
set asyncprotocol ${name}_protocol
|
||||
MakeAsyncProtocol ${asyncprotocol}
|
||||
if { [dict exists $v "terminator"] } {
|
||||
${asyncprotocol} sendterminator "[dict get $v "terminator"]"
|
||||
${asyncprotocol} replyterminator "[dict get $v "terminator"]"
|
||||
}
|
||||
}
|
||||
set asyncqueue ${name}_queue
|
||||
set ip_address [dict get $v ip]
|
||||
set tcp_port [dict get $v port]
|
||||
MakeAsyncQueue ${asyncqueue} ${asyncprotocol} ${ip_address} ${tcp_port}
|
||||
if { [dict exists $v "timeout"] } {
|
||||
${asyncqueue} timeout "[dict get $v "timeout"]"
|
||||
}
|
||||
}
|
||||
if { [string equal -nocase ${asyncqueue} "sct"] } {
|
||||
${ns}::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}
|
||||
} else {
|
||||
${ns}::add_driver ${name} ${device_class} ${simulation_flag} "aqadapter" ${asyncqueue}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch_message ]
|
||||
handle_exception ${catch_status} ${catch_message}
|
||||
}
|
||||
|
||||
if { [info exists ::config_dict] } {
|
||||
::scobj::srs_sr630::read_config
|
||||
} else {
|
||||
::scobj::srs_sr630::sics_log 5 "No config dict"
|
||||
}
|
||||
@@ -0,0 +1,604 @@
|
||||
# Generated driver for west_6100
|
||||
# vim: ft=tcl tabstop=8 softtabstop=2 shiftwidth=2 nocindent smartindent
|
||||
#
|
||||
|
||||
namespace eval ::scobj::west_6100 {
|
||||
set debug_threshold 5
|
||||
}
|
||||
|
||||
proc ::scobj::west_6100::debug_log {tc_root debug_level debug_string} {
|
||||
set catch_status [ catch {
|
||||
set debug_threshold [hgetpropval ${tc_root} debug_threshold]
|
||||
if {${debug_level} >= ${debug_threshold}} {
|
||||
set fd [open "../log/west_6100_[basename ${tc_root}].log" "a"]
|
||||
set line "[clock format [clock seconds] -format "%T"] ${debug_string}"
|
||||
puts ${fd} "${line}"
|
||||
close ${fd}
|
||||
}
|
||||
} catch_message ]
|
||||
}
|
||||
|
||||
proc ::scobj::west_6100::sics_log {debug_level debug_string} {
|
||||
set catch_status [ catch {
|
||||
set debug_threshold ${::scobj::west_6100::debug_threshold}
|
||||
if {${debug_level} >= ${debug_threshold}} {
|
||||
sicslog "::scobj::west_6100::${debug_string}"
|
||||
}
|
||||
} catch_message ]
|
||||
}
|
||||
|
||||
# check function for hset change
|
||||
proc ::scobj::west_6100::checkrange {tc_root} {
|
||||
set catch_status [ catch {
|
||||
debug_log ${tc_root} 1 "checkrange tc_root=${tc_root} sct=[sct] target=[sct target]"
|
||||
set setpoint [sct target]
|
||||
if { [hpropexists [sct] lowerlimit] } {
|
||||
set lolimit [sct lowerlimit]
|
||||
} else {
|
||||
# lowerlimit not set, use target
|
||||
set lolimit [sct target]
|
||||
}
|
||||
if { [hpropexists [sct] upperlimit] } {
|
||||
set hilimit [sct upperlimit]
|
||||
} else {
|
||||
# upperlimit not set, use target
|
||||
set hilimit [sct target]
|
||||
}
|
||||
# checkrange hook code goes here
|
||||
if { ${setpoint} < ${lolimit} || ${setpoint} > ${hilimit} } {
|
||||
error "setpoint ${setpoint} violates limits (${lolimit}..${hilimit}) on [sct]"
|
||||
}
|
||||
return OK
|
||||
} catch_message ]
|
||||
handle_exception ${catch_status} ${catch_message}
|
||||
}
|
||||
|
||||
# function to request the read of a parameter on a device
|
||||
proc ::scobj::west_6100::getDecimal {tc_root nextState cmd_str} {
|
||||
set catch_status [ catch {
|
||||
debug_log ${tc_root} 1 "getDecimal tc_root=${tc_root} sct=[sct] cmd=${cmd_str}"
|
||||
if { [hpropexists [sct] geterror] } {
|
||||
hdelprop [sct] geterror
|
||||
}
|
||||
set cmd "${cmd_str}"
|
||||
# getDecimal hook code starts
|
||||
set cmd "1:3:${cmd_str}:1:U16"
|
||||
# getDecimal hook code ends
|
||||
if { [hpropexists [sct] geterror] } {
|
||||
debug_log ${tc_root} 9 "[sct] error: [sct geterror]"
|
||||
error "[sct geterror]"
|
||||
}
|
||||
debug_log ${tc_root} 1 "getDecimal sct send ${cmd}"
|
||||
if {![string equal -nocase -length 10 ${cmd} "@@NOSEND@@"]} {
|
||||
sct send "${cmd}"
|
||||
}
|
||||
return ${nextState}
|
||||
} catch_message ]
|
||||
handle_exception ${catch_status} ${catch_message}
|
||||
}
|
||||
|
||||
# function to request the read of a parameter on a device
|
||||
proc ::scobj::west_6100::getInteger {tc_root nextState cmd_str} {
|
||||
set catch_status [ catch {
|
||||
debug_log ${tc_root} 1 "getInteger tc_root=${tc_root} sct=[sct] cmd=${cmd_str}"
|
||||
if { [hpropexists [sct] geterror] } {
|
||||
hdelprop [sct] geterror
|
||||
}
|
||||
set cmd "${cmd_str}"
|
||||
# getInteger hook code starts
|
||||
set cmd "1:3:${cmd_str}:1:U16"
|
||||
# getInteger hook code ends
|
||||
if { [hpropexists [sct] geterror] } {
|
||||
debug_log ${tc_root} 9 "[sct] error: [sct geterror]"
|
||||
error "[sct geterror]"
|
||||
}
|
||||
debug_log ${tc_root} 1 "getInteger sct send ${cmd}"
|
||||
if {![string equal -nocase -length 10 ${cmd} "@@NOSEND@@"]} {
|
||||
sct send "${cmd}"
|
||||
}
|
||||
return ${nextState}
|
||||
} catch_message ]
|
||||
handle_exception ${catch_status} ${catch_message}
|
||||
}
|
||||
|
||||
# function to check the write parameter on a device
|
||||
proc ::scobj::west_6100::noResponse {tc_root} {
|
||||
set catch_status [ catch {
|
||||
debug_log ${tc_root} 1 "noResponse tc_root=${tc_root} sct=[sct] resp=[sct result]"
|
||||
# noResponse hook code goes here
|
||||
return "idle"
|
||||
} catch_message ]
|
||||
handle_exception ${catch_status} ${catch_message}
|
||||
}
|
||||
|
||||
# function to parse the read of a parameter on a device
|
||||
proc ::scobj::west_6100::rdDecimal {tc_root} {
|
||||
set catch_status [ catch {
|
||||
debug_log ${tc_root} 1 "rdDecimal 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]"
|
||||
}
|
||||
# rdDecimal hook code starts
|
||||
set decimal [hval ${tc_root}/aux/decimal]
|
||||
if { ${decimal} > 0 } {
|
||||
set data [expr {pow(10, -${decimal}) * ${data}}]
|
||||
}
|
||||
# rdDecimal 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 parse the read of a parameter on a device
|
||||
proc ::scobj::west_6100::rdInteger {tc_root} {
|
||||
set catch_status [ catch {
|
||||
debug_log ${tc_root} 1 "rdInteger 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]"
|
||||
}
|
||||
# rdInteger hook code goes here
|
||||
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::west_6100::setValue {tc_root nextState cmd_str} {
|
||||
set catch_status [ catch {
|
||||
debug_log ${tc_root} 1 "setValue tc_root=${tc_root} sct=[sct] cmd=${cmd_str}"
|
||||
if { [hpropexists [sct] geterror] } {
|
||||
hdelprop [sct] geterror
|
||||
}
|
||||
set par [sct target]
|
||||
set cmd "${cmd_str}${par}"
|
||||
# setValue hook code goes here
|
||||
if { [hpropexists [sct] driving] } {
|
||||
if { [hpropexists [sct] writestatus] && [sct writestatus] == "start" } {
|
||||
sct driving 1
|
||||
}
|
||||
}
|
||||
debug_log ${tc_root} 1 "setValue sct send ${cmd}"
|
||||
if {![string equal -nocase -length 10 ${cmd} "@@NOSEND@@"]} {
|
||||
sct send "${cmd}"
|
||||
}
|
||||
return ${nextState}
|
||||
} catch_message ]
|
||||
handle_exception ${catch_status} ${catch_message}
|
||||
}
|
||||
|
||||
# function to write a parameter value on a device
|
||||
proc ::scobj::west_6100::wrDecimal {tc_root nextState cmd_str} {
|
||||
set catch_status [ catch {
|
||||
debug_log ${tc_root} 1 "wrDecimal tc_root=${tc_root} sct=[sct] cmd=${cmd_str}"
|
||||
if { [hpropexists [sct] geterror] } {
|
||||
hdelprop [sct] geterror
|
||||
}
|
||||
set par [sct target]
|
||||
set cmd "${cmd_str}${par}"
|
||||
# wrDecimal hook code starts
|
||||
set decimal [hval ${tc_root}/aux/decimal]
|
||||
set par [sct target]
|
||||
if { ${decimal} > 0 } {
|
||||
set par [expr {pow(10, ${decimal}) * ${par}}]
|
||||
}
|
||||
set par [expr {round(${par})}]
|
||||
set cmd "1:16:${cmd_str}:1:U16:${par}"
|
||||
# wrDecimal hook code ends
|
||||
if { [hpropexists [sct] geterror] } {
|
||||
debug_log ${tc_root} 9 "[sct] error: [sct geterror]"
|
||||
error "[sct geterror]"
|
||||
}
|
||||
if { [hpropexists [sct] driving] } {
|
||||
if { [hpropexists [sct] writestatus] && [sct writestatus] == "start" } {
|
||||
sct driving 1
|
||||
}
|
||||
}
|
||||
debug_log ${tc_root} 1 "wrDecimal sct send ${cmd}"
|
||||
if {![string equal -nocase -length 10 ${cmd} "@@NOSEND@@"]} {
|
||||
sct send "${cmd}"
|
||||
}
|
||||
return ${nextState}
|
||||
} catch_message ]
|
||||
handle_exception ${catch_status} ${catch_message}
|
||||
}
|
||||
|
||||
# function to write a parameter value on a device
|
||||
proc ::scobj::west_6100::wrInteger {tc_root nextState cmd_str} {
|
||||
set catch_status [ catch {
|
||||
debug_log ${tc_root} 1 "wrInteger tc_root=${tc_root} sct=[sct] cmd=${cmd_str}"
|
||||
if { [hpropexists [sct] geterror] } {
|
||||
hdelprop [sct] geterror
|
||||
}
|
||||
set par [sct target]
|
||||
set cmd "${cmd_str}${par}"
|
||||
# wrInteger hook code starts
|
||||
set cmd "1:16:${cmd_str}:1:U16:${par}"
|
||||
# wrInteger hook code ends
|
||||
if { [hpropexists [sct] geterror] } {
|
||||
debug_log ${tc_root} 9 "[sct] error: [sct geterror]"
|
||||
error "[sct geterror]"
|
||||
}
|
||||
if { [hpropexists [sct] driving] } {
|
||||
if { [hpropexists [sct] writestatus] && [sct writestatus] == "start" } {
|
||||
sct driving 1
|
||||
}
|
||||
}
|
||||
debug_log ${tc_root} 1 "wrInteger sct send ${cmd}"
|
||||
if {![string equal -nocase -length 10 ${cmd} "@@NOSEND@@"]} {
|
||||
sct send "${cmd}"
|
||||
}
|
||||
return ${nextState}
|
||||
} catch_message ]
|
||||
handle_exception ${catch_status} ${catch_message}
|
||||
}
|
||||
|
||||
proc ::scobj::west_6100::mkDriver { sct_controller name device_class simulation_flag ip_address tcp_port dev_id } {
|
||||
::scobj::west_6100::sics_log 9 "::scobj::west_6100::mkDriver ${sct_controller} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${dev_id}"
|
||||
set ns "[namespace current]"
|
||||
set catch_status [ catch {
|
||||
|
||||
MakeSICSObj ${name} SCT_OBJECT
|
||||
|
||||
sicslist setatt ${name} klass ${device_class}
|
||||
sicslist setatt ${name} long_name ${name}
|
||||
|
||||
set scobj_hpath /sics/${name}
|
||||
|
||||
hfactory ${scobj_hpath}/alarm1 plain user float
|
||||
hsetprop ${scobj_hpath}/alarm1 read ${ns}::getDecimal ${scobj_hpath} rdDecimal {13}
|
||||
hsetprop ${scobj_hpath}/alarm1 rdDecimal ${ns}::rdDecimal ${scobj_hpath}
|
||||
hsetprop ${scobj_hpath}/alarm1 write ${ns}::wrDecimal ${scobj_hpath} noResponse {13}
|
||||
hsetprop ${scobj_hpath}/alarm1 noResponse ${ns}::noResponse ${scobj_hpath}
|
||||
hsetprop ${scobj_hpath}/alarm1 check ${ns}::checkrange ${scobj_hpath}
|
||||
hsetprop ${scobj_hpath}/alarm1 control true
|
||||
hsetprop ${scobj_hpath}/alarm1 data true
|
||||
hsetprop ${scobj_hpath}/alarm1 mutable true
|
||||
hsetprop ${scobj_hpath}/alarm1 nxsave true
|
||||
hsetprop ${scobj_hpath}/alarm1 oldval 0.0
|
||||
hsetprop ${scobj_hpath}/alarm1 klass "parameter"
|
||||
hsetprop ${scobj_hpath}/alarm1 sdsinfo "::nexus::scobj::sdsinfo"
|
||||
hsetprop ${scobj_hpath}/alarm1 type "part"
|
||||
hsetprop ${scobj_hpath}/alarm1 nxalias "${name}_alarm1"
|
||||
|
||||
hfactory ${scobj_hpath}/alarm2 plain user float
|
||||
hsetprop ${scobj_hpath}/alarm2 read ${ns}::getDecimal ${scobj_hpath} rdDecimal {14}
|
||||
hsetprop ${scobj_hpath}/alarm2 rdDecimal ${ns}::rdDecimal ${scobj_hpath}
|
||||
hsetprop ${scobj_hpath}/alarm2 write ${ns}::wrDecimal ${scobj_hpath} noResponse {14}
|
||||
hsetprop ${scobj_hpath}/alarm2 noResponse ${ns}::noResponse ${scobj_hpath}
|
||||
hsetprop ${scobj_hpath}/alarm2 check ${ns}::checkrange ${scobj_hpath}
|
||||
hsetprop ${scobj_hpath}/alarm2 control true
|
||||
hsetprop ${scobj_hpath}/alarm2 data true
|
||||
hsetprop ${scobj_hpath}/alarm2 mutable true
|
||||
hsetprop ${scobj_hpath}/alarm2 nxsave true
|
||||
hsetprop ${scobj_hpath}/alarm2 oldval 0.0
|
||||
hsetprop ${scobj_hpath}/alarm2 klass "parameter"
|
||||
hsetprop ${scobj_hpath}/alarm2 sdsinfo "::nexus::scobj::sdsinfo"
|
||||
hsetprop ${scobj_hpath}/alarm2 type "part"
|
||||
hsetprop ${scobj_hpath}/alarm2 nxalias "${name}_alarm2"
|
||||
|
||||
hfactory ${scobj_hpath}/power plain user int
|
||||
hsetprop ${scobj_hpath}/power read ${ns}::getInteger ${scobj_hpath} rdInteger {3}
|
||||
hsetprop ${scobj_hpath}/power rdInteger ${ns}::rdInteger ${scobj_hpath}
|
||||
hsetprop ${scobj_hpath}/power control true
|
||||
hsetprop ${scobj_hpath}/power data true
|
||||
hsetprop ${scobj_hpath}/power mutable true
|
||||
hsetprop ${scobj_hpath}/power nxsave true
|
||||
hsetprop ${scobj_hpath}/power oldval 0
|
||||
hsetprop ${scobj_hpath}/power klass "parameter"
|
||||
hsetprop ${scobj_hpath}/power sdsinfo "::nexus::scobj::sdsinfo"
|
||||
hsetprop ${scobj_hpath}/power type "part"
|
||||
hsetprop ${scobj_hpath}/power nxalias "${name}_power"
|
||||
|
||||
hfactory ${scobj_hpath}/powermax plain user int
|
||||
hsetprop ${scobj_hpath}/powermax read ${ns}::getInteger ${scobj_hpath} rdInteger {20}
|
||||
hsetprop ${scobj_hpath}/powermax rdInteger ${ns}::rdInteger ${scobj_hpath}
|
||||
hsetprop ${scobj_hpath}/powermax write ${ns}::wrInteger ${scobj_hpath} noResponse {20}
|
||||
hsetprop ${scobj_hpath}/powermax noResponse ${ns}::noResponse ${scobj_hpath}
|
||||
hsetprop ${scobj_hpath}/powermax check ${ns}::checkrange ${scobj_hpath}
|
||||
hsetprop ${scobj_hpath}/powermax control true
|
||||
hsetprop ${scobj_hpath}/powermax data true
|
||||
hsetprop ${scobj_hpath}/powermax mutable true
|
||||
hsetprop ${scobj_hpath}/powermax nxsave true
|
||||
hsetprop ${scobj_hpath}/powermax oldval 0
|
||||
hsetprop ${scobj_hpath}/powermax klass "parameter"
|
||||
hsetprop ${scobj_hpath}/powermax sdsinfo "::nexus::scobj::sdsinfo"
|
||||
hsetprop ${scobj_hpath}/powermax type "part"
|
||||
hsetprop ${scobj_hpath}/powermax nxalias "${name}_powermax"
|
||||
|
||||
hfactory ${scobj_hpath}/ramprate plain user float
|
||||
hsetprop ${scobj_hpath}/ramprate read ${ns}::getDecimal ${scobj_hpath} rdDecimal {24}
|
||||
hsetprop ${scobj_hpath}/ramprate rdDecimal ${ns}::rdDecimal ${scobj_hpath}
|
||||
hsetprop ${scobj_hpath}/ramprate write ${ns}::wrDecimal ${scobj_hpath} noResponse {24}
|
||||
hsetprop ${scobj_hpath}/ramprate noResponse ${ns}::noResponse ${scobj_hpath}
|
||||
hsetprop ${scobj_hpath}/ramprate check ${ns}::checkrange ${scobj_hpath}
|
||||
hsetprop ${scobj_hpath}/ramprate control true
|
||||
hsetprop ${scobj_hpath}/ramprate data true
|
||||
hsetprop ${scobj_hpath}/ramprate mutable true
|
||||
hsetprop ${scobj_hpath}/ramprate nxsave true
|
||||
hsetprop ${scobj_hpath}/ramprate oldval 0.0
|
||||
hsetprop ${scobj_hpath}/ramprate klass "parameter"
|
||||
hsetprop ${scobj_hpath}/ramprate sdsinfo "::nexus::scobj::sdsinfo"
|
||||
hsetprop ${scobj_hpath}/ramprate type "part"
|
||||
hsetprop ${scobj_hpath}/ramprate nxalias "${name}_ramprate"
|
||||
|
||||
hfactory ${scobj_hpath}/sensor plain user float
|
||||
hsetprop ${scobj_hpath}/sensor read ${ns}::getDecimal ${scobj_hpath} rdDecimal {1}
|
||||
hsetprop ${scobj_hpath}/sensor rdDecimal ${ns}::rdDecimal ${scobj_hpath}
|
||||
hsetprop ${scobj_hpath}/sensor control true
|
||||
hsetprop ${scobj_hpath}/sensor data true
|
||||
hsetprop ${scobj_hpath}/sensor mutable true
|
||||
hsetprop ${scobj_hpath}/sensor nxsave true
|
||||
hsetprop ${scobj_hpath}/sensor oldval 0.0
|
||||
hsetprop ${scobj_hpath}/sensor klass "parameter"
|
||||
hsetprop ${scobj_hpath}/sensor sdsinfo "::nexus::scobj::sdsinfo"
|
||||
hsetprop ${scobj_hpath}/sensor type "part"
|
||||
hsetprop ${scobj_hpath}/sensor nxalias "${name}_sensor"
|
||||
|
||||
hfactory ${scobj_hpath}/setpoint plain user float
|
||||
hsetprop ${scobj_hpath}/setpoint read ${ns}::getDecimal ${scobj_hpath} rdDecimal {2}
|
||||
hsetprop ${scobj_hpath}/setpoint rdDecimal ${ns}::rdDecimal ${scobj_hpath}
|
||||
hsetprop ${scobj_hpath}/setpoint write ${ns}::wrDecimal ${scobj_hpath} noResponse {2}
|
||||
hsetprop ${scobj_hpath}/setpoint noResponse ${ns}::noResponse ${scobj_hpath}
|
||||
hsetprop ${scobj_hpath}/setpoint check ${ns}::checkrange ${scobj_hpath}
|
||||
hsetprop ${scobj_hpath}/setpoint control true
|
||||
hsetprop ${scobj_hpath}/setpoint data true
|
||||
hsetprop ${scobj_hpath}/setpoint mutable true
|
||||
hsetprop ${scobj_hpath}/setpoint nxsave true
|
||||
hsetprop ${scobj_hpath}/setpoint oldval 0.0
|
||||
hsetprop ${scobj_hpath}/setpoint klass "parameter"
|
||||
hsetprop ${scobj_hpath}/setpoint sdsinfo "::nexus::scobj::sdsinfo"
|
||||
hsetprop ${scobj_hpath}/setpoint type "part"
|
||||
hsetprop ${scobj_hpath}/setpoint nxalias "${name}_setpoint"
|
||||
|
||||
hfactory ${scobj_hpath}/w_sp plain user float
|
||||
hsetprop ${scobj_hpath}/w_sp read ${ns}::getDecimal ${scobj_hpath} rdDecimal {21}
|
||||
hsetprop ${scobj_hpath}/w_sp rdDecimal ${ns}::rdDecimal ${scobj_hpath}
|
||||
hsetprop ${scobj_hpath}/w_sp write ${ns}::wrDecimal ${scobj_hpath} noResponse {21}
|
||||
hsetprop ${scobj_hpath}/w_sp noResponse ${ns}::noResponse ${scobj_hpath}
|
||||
hsetprop ${scobj_hpath}/w_sp check ${ns}::checkrange ${scobj_hpath}
|
||||
hsetprop ${scobj_hpath}/w_sp control true
|
||||
hsetprop ${scobj_hpath}/w_sp data true
|
||||
hsetprop ${scobj_hpath}/w_sp mutable true
|
||||
hsetprop ${scobj_hpath}/w_sp nxsave true
|
||||
hsetprop ${scobj_hpath}/w_sp oldval 0.0
|
||||
hsetprop ${scobj_hpath}/w_sp klass "parameter"
|
||||
hsetprop ${scobj_hpath}/w_sp sdsinfo "::nexus::scobj::sdsinfo"
|
||||
hsetprop ${scobj_hpath}/w_sp type "part"
|
||||
hsetprop ${scobj_hpath}/w_sp nxalias "${name}_w_sp"
|
||||
|
||||
hsetprop ${scobj_hpath} data "true"
|
||||
hsetprop ${scobj_hpath} klass "@none"
|
||||
hsetprop ${scobj_hpath} type "part"
|
||||
|
||||
if {[string equal -nocase "${simulation_flag}" "false"]} {
|
||||
${sct_controller} poll ${scobj_hpath}/alarm1 1
|
||||
${sct_controller} poll ${scobj_hpath}/alarm2 1
|
||||
${sct_controller} poll ${scobj_hpath}/power 1
|
||||
${sct_controller} poll ${scobj_hpath}/powermax 1
|
||||
${sct_controller} poll ${scobj_hpath}/ramprate 1
|
||||
${sct_controller} poll ${scobj_hpath}/sensor 1
|
||||
${sct_controller} poll ${scobj_hpath}/setpoint 1
|
||||
${sct_controller} poll ${scobj_hpath}/w_sp 1
|
||||
${sct_controller} write ${scobj_hpath}/alarm1
|
||||
${sct_controller} write ${scobj_hpath}/alarm2
|
||||
${sct_controller} write ${scobj_hpath}/powermax
|
||||
${sct_controller} write ${scobj_hpath}/ramprate
|
||||
${sct_controller} write ${scobj_hpath}/setpoint
|
||||
${sct_controller} write ${scobj_hpath}/w_sp
|
||||
} else {
|
||||
::scobj::west_6100::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for west_6100"
|
||||
}
|
||||
|
||||
hfactory ${scobj_hpath}/aux plain spy none
|
||||
hsetprop ${scobj_hpath}/aux data "false"
|
||||
hsetprop ${scobj_hpath}/aux klass "@none"
|
||||
hsetprop ${scobj_hpath}/aux type "part"
|
||||
|
||||
hfactory ${scobj_hpath}/aux/decimal plain user int
|
||||
hsetprop ${scobj_hpath}/aux/decimal read ${ns}::getInteger ${scobj_hpath} rdInteger {18}
|
||||
hsetprop ${scobj_hpath}/aux/decimal rdInteger ${ns}::rdInteger ${scobj_hpath}
|
||||
hsetprop ${scobj_hpath}/aux/decimal control false
|
||||
hsetprop ${scobj_hpath}/aux/decimal data false
|
||||
hsetprop ${scobj_hpath}/aux/decimal mutable false
|
||||
hsetprop ${scobj_hpath}/aux/decimal nxsave false
|
||||
hsetprop ${scobj_hpath}/aux/decimal oldval 0
|
||||
hset ${scobj_hpath}/aux/decimal 0
|
||||
hsetprop ${scobj_hpath}/aux/decimal sdsinfo "::nexus::scobj::sdsinfo"
|
||||
hsetprop ${scobj_hpath}/aux/decimal type "part"
|
||||
hsetprop ${scobj_hpath}/aux/decimal nxalias "${name}_aux_decimal"
|
||||
|
||||
hfactory ${scobj_hpath}/aux/instatus plain user int
|
||||
hsetprop ${scobj_hpath}/aux/instatus read ${ns}::getInteger ${scobj_hpath} rdInteger {133}
|
||||
hsetprop ${scobj_hpath}/aux/instatus rdInteger ${ns}::rdInteger ${scobj_hpath}
|
||||
hsetprop ${scobj_hpath}/aux/instatus control false
|
||||
hsetprop ${scobj_hpath}/aux/instatus data false
|
||||
hsetprop ${scobj_hpath}/aux/instatus mutable false
|
||||
hsetprop ${scobj_hpath}/aux/instatus nxsave false
|
||||
hsetprop ${scobj_hpath}/aux/instatus oldval 0
|
||||
hsetprop ${scobj_hpath}/aux/instatus sdsinfo "::nexus::scobj::sdsinfo"
|
||||
hsetprop ${scobj_hpath}/aux/instatus type "part"
|
||||
hsetprop ${scobj_hpath}/aux/instatus nxalias "${name}_aux_instatus"
|
||||
|
||||
hfactory ${scobj_hpath}/aux/model plain user int
|
||||
hsetprop ${scobj_hpath}/aux/model read ${ns}::getInteger ${scobj_hpath} rdInteger {122}
|
||||
hsetprop ${scobj_hpath}/aux/model rdInteger ${ns}::rdInteger ${scobj_hpath}
|
||||
hsetprop ${scobj_hpath}/aux/model control false
|
||||
hsetprop ${scobj_hpath}/aux/model data false
|
||||
hsetprop ${scobj_hpath}/aux/model mutable false
|
||||
hsetprop ${scobj_hpath}/aux/model nxsave false
|
||||
hsetprop ${scobj_hpath}/aux/model oldval 0
|
||||
hsetprop ${scobj_hpath}/aux/model sdsinfo "::nexus::scobj::sdsinfo"
|
||||
hsetprop ${scobj_hpath}/aux/model type "part"
|
||||
hsetprop ${scobj_hpath}/aux/model nxalias "${name}_aux_model"
|
||||
|
||||
if {[string equal -nocase "${simulation_flag}" "false"]} {
|
||||
${sct_controller} poll ${scobj_hpath}/aux/decimal 2
|
||||
${sct_controller} poll ${scobj_hpath}/aux/instatus 2
|
||||
${sct_controller} poll ${scobj_hpath}/aux/model 2
|
||||
} else {
|
||||
::scobj::west_6100::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for west_6100"
|
||||
}
|
||||
hsetprop ${scobj_hpath} klass ${device_class}
|
||||
hsetprop ${scobj_hpath} data true
|
||||
hsetprop ${scobj_hpath} debug_threshold 5
|
||||
# mkDriver hook code goes here
|
||||
} catch_message ]
|
||||
handle_exception ${catch_status} ${catch_message}
|
||||
}
|
||||
|
||||
proc ::scobj::west_6100::add_driver {name device_class simulation_flag ip_address tcp_port dev_id} {
|
||||
set catch_status [ catch {
|
||||
::scobj::west_6100::sics_log 9 "::scobj::west_6100::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${dev_id}"
|
||||
if {[string equal -nocase "${simulation_flag}" "false"]} {
|
||||
if {[string equal -nocase "aqadapter" "${ip_address}"]} {
|
||||
::scobj::west_6100::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}"
|
||||
makesctcontroller sct_${name} aqadapter ${tcp_port}
|
||||
} else {
|
||||
::scobj::west_6100::sics_log 9 "makesctcontroller sct_${name} modbus_ap ${ip_address}:${tcp_port}"
|
||||
makesctcontroller sct_${name} modbus_ap ${ip_address}:${tcp_port}
|
||||
}
|
||||
} else {
|
||||
::scobj::west_6100::sics_log 9 "simulation_flag={simulation_flag} => No sctcontroller for west_6100"
|
||||
}
|
||||
::scobj::west_6100::sics_log 1 "::scobj::west_6100::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${dev_id}"
|
||||
::scobj::west_6100::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${dev_id}
|
||||
} catch_message ]
|
||||
handle_exception ${catch_status} ${catch_message}
|
||||
}
|
||||
|
||||
namespace eval ::scobj::west_6100 {
|
||||
namespace export debug_threshold
|
||||
namespace export debug_log
|
||||
namespace export sics_log
|
||||
namespace export mkDriver
|
||||
namespace export add_driver
|
||||
}
|
||||
|
||||
proc add_west_6100 {name ip_address tcp_port dev_id} {
|
||||
set simulation_flag "[string tolower [SplitReply [environment_simulation]]]"
|
||||
::scobj::west_6100::add_driver ${name} "environment" "${simulation_flag}" ${ip_address} ${tcp_port} "${dev_id}"
|
||||
}
|
||||
|
||||
clientput "file evaluation of sct_west_6100.tcl"
|
||||
::scobj::west_6100::sics_log 9 "file evaluation of sct_west_6100.tcl"
|
||||
|
||||
proc ::scobj::west_6100::read_config {} {
|
||||
set catch_status [ catch {
|
||||
set ns "::scobj::west_6100"
|
||||
dict for {k u} $::config_dict {
|
||||
if { [dict exists $u "implementation"] } {
|
||||
set simulation_flag "[string tolower [SplitReply [environment_simulation]]]"
|
||||
set device_class "environment"
|
||||
if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } {
|
||||
continue
|
||||
}
|
||||
set enabled [string tolower [dict get $u "enabled"]]
|
||||
if { ! ([string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"]) } {
|
||||
continue
|
||||
}
|
||||
if { [dict exists $u "simulation_group"] } {
|
||||
set simulation_flag [SplitReply [[string tolower [dict get $u "simulation_group"]]]]
|
||||
}
|
||||
if { [dict exists $u "device_class"] } {
|
||||
set device_class "[dict get $u "device_class"]"
|
||||
}
|
||||
set name [dict get $u name]
|
||||
set implementation [dict get $u "implementation"]
|
||||
if { !([dict exists $::config_dict $implementation]) } {
|
||||
continue
|
||||
}
|
||||
set v [dict get $::config_dict $implementation]
|
||||
if { !([dict exists $v "driver"]) } {
|
||||
continue
|
||||
}
|
||||
if { [string equal -nocase [dict get $v "driver"] "west_6100"] } {
|
||||
if { ![string equal -nocase "${simulation_flag}" "false"] } {
|
||||
set asyncqueue "null"
|
||||
${ns}::sics_log 9 "simulation_flag=${simulation_flag} => using null asyncqueue"
|
||||
} elseif { [dict exists $v "asyncqueue"] } {
|
||||
set asyncqueue [dict get $v "asyncqueue"]
|
||||
if { [string equal -nocase ${asyncqueue} "sct"] } {
|
||||
set ip_address [dict get $v ip]
|
||||
set tcp_port [dict get $v port]
|
||||
}
|
||||
} else {
|
||||
if { [dict exists $v "asyncprotocol"] } {
|
||||
set asyncprotocol [dict get $v "asyncprotocol"]
|
||||
} else {
|
||||
set asyncprotocol ${name}_protocol
|
||||
MakeAsyncProtocol ${asyncprotocol}
|
||||
if { [dict exists $v "terminator"] } {
|
||||
${asyncprotocol} sendterminator "[dict get $v "terminator"]"
|
||||
${asyncprotocol} replyterminator "[dict get $v "terminator"]"
|
||||
}
|
||||
}
|
||||
set asyncqueue ${name}_queue
|
||||
set ip_address [dict get $v ip]
|
||||
set tcp_port [dict get $v port]
|
||||
MakeAsyncQueue ${asyncqueue} ${asyncprotocol} ${ip_address} ${tcp_port}
|
||||
if { [dict exists $v "timeout"] } {
|
||||
${asyncqueue} timeout "[dict get $v "timeout"]"
|
||||
}
|
||||
}
|
||||
set arg_list [list]
|
||||
set missing_list [list]
|
||||
foreach arg {dev_id} {
|
||||
if {[dict exists $u $arg]} {
|
||||
lappend arg_list "[dict get $u $arg]"
|
||||
} elseif {[dict exists $v $arg]} {
|
||||
lappend arg_list "[dict get $v $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"
|
||||
}
|
||||
if { [string equal -nocase ${asyncqueue} "sct"] } {
|
||||
${ns}::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} {*}$arg_list
|
||||
} else {
|
||||
${ns}::add_driver ${name} ${device_class} ${simulation_flag} "aqadapter" ${asyncqueue} {*}$arg_list
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch_message ]
|
||||
handle_exception ${catch_status} ${catch_message}
|
||||
}
|
||||
|
||||
if { [info exists ::config_dict] } {
|
||||
::scobj::west_6100::read_config
|
||||
} else {
|
||||
::scobj::west_6100::sics_log 5 "No config dict"
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
# Stanford Research Systems SR630 Thermocouple Monitor
|
||||
# vim: ts=8 sts=2 sw=2 expandtab nocindent autoindent smartindent
|
||||
driver srs_sr630 = {
|
||||
vendor = StanfordResearchSystems; device=SR630;
|
||||
protocol = std;
|
||||
class = NXdetector;
|
||||
simulation_group = detector_simulation;
|
||||
|
||||
group = {
|
||||
priv = user;
|
||||
var id = {
|
||||
readable = 600;
|
||||
type = text;
|
||||
fetch_function = fetch_id;
|
||||
read_function = read_id;
|
||||
read_command = "@";
|
||||
value = "UNKNOWN";
|
||||
}
|
||||
type = float;
|
||||
fetch_function = getSensor;
|
||||
read_function = readSensor;
|
||||
var sensor_01 = { readable = 60; read_command = "1"; }
|
||||
var sensor_02 = { readable = 600; read_command = "2"; }
|
||||
var sensor_03 = { readable = 600; read_command = "3"; }
|
||||
var sensor_04 = { readable = 600; read_command = "4"; }
|
||||
var sensor_05 = { readable = 600; read_command = "5"; }
|
||||
var sensor_06 = { readable = 600; read_command = "6"; }
|
||||
var sensor_07 = { readable = 600; read_command = "7"; }
|
||||
var sensor_08 = { readable = 600; read_command = "8"; }
|
||||
}
|
||||
code fetch_id = {%%
|
||||
if {[hval [sct]] == "UNKNOWN"} {
|
||||
set cmd "[clock format [clock seconds] -format "DATE %m,%d,%Y;TIME %H,%M,%S;*IDN?"]"
|
||||
} else {
|
||||
set cmd "*IDN?"
|
||||
}
|
||||
%%}
|
||||
code read_id = {%%
|
||||
%%}
|
||||
code getSensor = {%%
|
||||
set cmd "UNIT ${cmd_str},ABS;MEAS? ${cmd_str}"
|
||||
%%}
|
||||
code readSensor = {%%
|
||||
%%}
|
||||
}
|
||||
@@ -27,8 +27,8 @@ proc ::scobj::west4100::sics_log {debug_level debug_string} {
|
||||
} catch_message ]
|
||||
}
|
||||
|
||||
proc ::scobj::west4100::mkDriver { sct_controller name ip_address tcp_port dev_id } {
|
||||
::scobj::west4100::sics_log 9 "::scobj::west4100::mkDriver ${sct_controller} ${name} ${ip_address} ${tcp_port} ${dev_id}"
|
||||
proc ::scobj::west4100::mkDriver { sct_controller name device_class simulation_flag ip_address tcp_port dev_id } {
|
||||
::scobj::west4100::sics_log 9 "::scobj::west4100::mkDriver ${sct_controller} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${dev_id}"
|
||||
set ns "[namespace current]"
|
||||
set catch_status [ catch {
|
||||
|
||||
@@ -39,21 +39,27 @@ proc ::scobj::west4100::mkDriver { sct_controller name ip_address tcp_port dev_i
|
||||
handle_exception ${catch_status} ${catch_message}
|
||||
}
|
||||
|
||||
proc ::scobj::west4100::add_driver {name device_class simulation_flag ip_address tcp_port dev_id} {
|
||||
set catch_status [ catch {
|
||||
::scobj::west4100::sics_log 9 "::scobj::west4100::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${dev_id}"
|
||||
::scobj::west4100::sics_log 9 "No sctcontroller for west4100"
|
||||
::scobj::west4100::sics_log 1 "::scobj::west4100::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${dev_id}"
|
||||
::scobj::west4100::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${dev_id}
|
||||
} catch_message ]
|
||||
handle_exception ${catch_status} ${catch_message}
|
||||
}
|
||||
|
||||
namespace eval ::scobj::west4100 {
|
||||
namespace export debug_threshold
|
||||
namespace export debug_log
|
||||
namespace export sics_log
|
||||
namespace export mkDriver
|
||||
namespace export add_driver
|
||||
}
|
||||
|
||||
proc add_west4100 {name ip_address tcp_port dev_id} {
|
||||
set catch_status [ catch {
|
||||
::scobj::west4100::sics_log 9 "add_west4100 ${name} ${ip_address} ${tcp_port} ${dev_id}"
|
||||
::scobj::west4100::sics_log 9 "No sctcontroller for west4100"
|
||||
::scobj::west4100::sics_log 1 "::scobj::west4100::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} ${dev_id}"
|
||||
::scobj::west4100::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} ${dev_id}
|
||||
} catch_message ]
|
||||
handle_exception ${catch_status} ${catch_message}
|
||||
set simulation_flag "[string tolower [SplitReply [environment_simulation]]]"
|
||||
::scobj::west4100::add_driver ${name} "environment" "${simulation_flag}" ${ip_address} ${tcp_port} "${dev_id}"
|
||||
}
|
||||
|
||||
clientput "file evaluation of west4100_sct.tcl"
|
||||
@@ -64,6 +70,8 @@ proc ::scobj::west4100::read_config {} {
|
||||
set ns "::scobj::west4100"
|
||||
dict for {k u} $::config_dict {
|
||||
if { [dict exists $u "implementation"] } {
|
||||
set simulation_flag "[string tolower [SplitReply [environment_simulation]]]"
|
||||
set device_class "environment"
|
||||
if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } {
|
||||
continue
|
||||
}
|
||||
@@ -71,6 +79,12 @@ proc ::scobj::west4100::read_config {} {
|
||||
if { ! ([string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"]) } {
|
||||
continue
|
||||
}
|
||||
if { [dict exists $u "simulation_group"] } {
|
||||
set simulation_flag [SplitReply [[string tolower [dict get $u "simulation_group"]]]]
|
||||
}
|
||||
if { [dict exists $u "device_class"] } {
|
||||
set device_class "[dict get $u "device_class"]"
|
||||
}
|
||||
set name [dict get $u name]
|
||||
set implementation [dict get $u "implementation"]
|
||||
if { !([dict exists $::config_dict $implementation]) } {
|
||||
@@ -81,9 +95,9 @@ proc ::scobj::west4100::read_config {} {
|
||||
continue
|
||||
}
|
||||
if { [string equal -nocase [dict get $v "driver"] "west4100"] } {
|
||||
if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } {
|
||||
if { ![string equal -nocase "${simulation_flag}" "false"] } {
|
||||
set asyncqueue "null"
|
||||
${ns}::sics_log 9 "[environment_simulation] => using null asyncqueue"
|
||||
${ns}::sics_log 9 "simulation_flag=${simulation_flag} => using null asyncqueue"
|
||||
} elseif { [dict exists $v "asyncqueue"] } {
|
||||
set asyncqueue [dict get $v "asyncqueue"]
|
||||
if { [string equal -nocase ${asyncqueue} "sct"] } {
|
||||
@@ -125,9 +139,9 @@ proc ::scobj::west4100::read_config {} {
|
||||
error "$name is missing configuration values $missing_list"
|
||||
}
|
||||
if { [string equal -nocase ${asyncqueue} "sct"] } {
|
||||
add_west4100 ${name} ${ip_address} ${tcp_port} {*}$arg_list
|
||||
${ns}::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} {*}$arg_list
|
||||
} else {
|
||||
add_west4100 ${name} "aqadapter" ${asyncqueue} {*}$arg_list
|
||||
${ns}::add_driver ${name} ${device_class} ${simulation_flag} "aqadapter" ${asyncqueue} {*}$arg_list
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ driver west_6100 = {
|
||||
fetch_function = getInteger;
|
||||
read_function = rdInteger;
|
||||
var model = { type = int; read_command = "122"; }
|
||||
var decimal = { type = int; read_command = "18"; }
|
||||
var decimal = { type = int; read_command = "18"; value = 0; }
|
||||
var instatus = { type = int; read_command = "133"; }
|
||||
}
|
||||
code fetch_function getInteger = {
|
||||
@@ -59,12 +59,20 @@ driver west_6100 = {
|
||||
}
|
||||
code read_function rdDecimal = {
|
||||
@TCL
|
||||
set data [expr {0.10 * ${data}}]
|
||||
set decimal [hval ${tc_root}/aux/decimal]
|
||||
if { ${decimal} > 0 } {
|
||||
set data [expr {pow(10, -${decimal}) * ${data}}]
|
||||
}
|
||||
@END
|
||||
}
|
||||
code write_function wrDecimal = {
|
||||
@TCL
|
||||
set par [expr {round(10.0 * [sct target])}]
|
||||
set decimal [hval ${tc_root}/aux/decimal]
|
||||
set par [sct target]
|
||||
if { ${decimal} > 0 } {
|
||||
set par [expr {pow(10, ${decimal}) * ${par}}]
|
||||
}
|
||||
set par [expr {round(${par})}]
|
||||
set cmd "1:16:${cmd_str}:1:U16:${par}"
|
||||
@END
|
||||
}
|
||||
|
||||
15
site_ansto/instrument/config/robots/epson_pandp.sct
Normal file
15
site_ansto/instrument/config/robots/epson_pandp.sct
Normal file
@@ -0,0 +1,15 @@
|
||||
# Simple driver generator for the Epson Pick and Place Robots
|
||||
# vim: ts=8 sts=2 sw=2 expandtab autoindent smartindent
|
||||
driver epson_pandp = {
|
||||
vendor = Epson; device = 'Pick and Place Robot'; protocol = std;
|
||||
class = environment;
|
||||
simulation_group = environment_simulation;
|
||||
add_args = "robot_name"
|
||||
make_args = "robot_name"
|
||||
wrapper_property nosctcontroller = True;
|
||||
|
||||
code mkWrapper = {%%
|
||||
clientput "add_robot ${robot_name} ${ip_address} ${tcp_port}"
|
||||
add_robot ${robot_name} ${ip_address} ${tcp_port}
|
||||
%%}
|
||||
}
|
||||
158
site_ansto/instrument/config/robots/sct_epson_pandp.tcl
Normal file
158
site_ansto/instrument/config/robots/sct_epson_pandp.tcl
Normal file
@@ -0,0 +1,158 @@
|
||||
# Generated driver for epson_pandp
|
||||
# vim: ft=tcl tabstop=8 softtabstop=2 shiftwidth=2 nocindent smartindent
|
||||
#
|
||||
|
||||
namespace eval ::scobj::epson_pandp {
|
||||
set debug_threshold 5
|
||||
}
|
||||
|
||||
proc ::scobj::epson_pandp::debug_log {tc_root debug_level debug_string} {
|
||||
set catch_status [ catch {
|
||||
set debug_threshold [hgetpropval ${tc_root} debug_threshold]
|
||||
if {${debug_level} >= ${debug_threshold}} {
|
||||
set fd [open "../log/epson_pandp_[basename ${tc_root}].log" "a"]
|
||||
set line "[clock format [clock seconds] -format "%T"] ${debug_string}"
|
||||
puts ${fd} "${line}"
|
||||
close ${fd}
|
||||
}
|
||||
} catch_message ]
|
||||
}
|
||||
|
||||
proc ::scobj::epson_pandp::sics_log {debug_level debug_string} {
|
||||
set catch_status [ catch {
|
||||
set debug_threshold ${::scobj::epson_pandp::debug_threshold}
|
||||
if {${debug_level} >= ${debug_threshold}} {
|
||||
sicslog "::scobj::epson_pandp::${debug_string}"
|
||||
}
|
||||
} catch_message ]
|
||||
}
|
||||
|
||||
proc ::scobj::epson_pandp::mkDriver { sct_controller name device_class simulation_flag ip_address tcp_port robot_name } {
|
||||
::scobj::epson_pandp::sics_log 9 "::scobj::epson_pandp::mkDriver ${sct_controller} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${robot_name}"
|
||||
set ns "[namespace current]"
|
||||
set catch_status [ catch {
|
||||
|
||||
# mkWrapper hook code starts
|
||||
clientput "add_robot ${robot_name} ${ip_address} ${tcp_port}"
|
||||
add_robot ${robot_name} ${ip_address} ${tcp_port}
|
||||
# mkWrapper hook code ends
|
||||
} catch_message ]
|
||||
handle_exception ${catch_status} ${catch_message}
|
||||
}
|
||||
|
||||
proc ::scobj::epson_pandp::add_driver {name device_class simulation_flag ip_address tcp_port robot_name} {
|
||||
set catch_status [ catch {
|
||||
::scobj::epson_pandp::sics_log 9 "::scobj::epson_pandp::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${robot_name}"
|
||||
::scobj::epson_pandp::sics_log 9 "No sctcontroller for epson_pandp"
|
||||
::scobj::epson_pandp::sics_log 1 "::scobj::epson_pandp::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${robot_name}"
|
||||
::scobj::epson_pandp::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${robot_name}
|
||||
} catch_message ]
|
||||
handle_exception ${catch_status} ${catch_message}
|
||||
}
|
||||
|
||||
namespace eval ::scobj::epson_pandp {
|
||||
namespace export debug_threshold
|
||||
namespace export debug_log
|
||||
namespace export sics_log
|
||||
namespace export mkDriver
|
||||
namespace export add_driver
|
||||
}
|
||||
|
||||
proc add_epson_pandp {name ip_address tcp_port robot_name} {
|
||||
set simulation_flag "[string tolower [SplitReply [environment_simulation]]]"
|
||||
::scobj::epson_pandp::add_driver ${name} "environment" "${simulation_flag}" ${ip_address} ${tcp_port} "${robot_name}"
|
||||
}
|
||||
|
||||
clientput "file evaluation of sct_epson_pandp.tcl"
|
||||
::scobj::epson_pandp::sics_log 9 "file evaluation of sct_epson_pandp.tcl"
|
||||
|
||||
proc ::scobj::epson_pandp::read_config {} {
|
||||
set catch_status [ catch {
|
||||
set ns "::scobj::epson_pandp"
|
||||
dict for {k u} $::config_dict {
|
||||
if { [dict exists $u "implementation"] } {
|
||||
set simulation_flag "[string tolower [SplitReply [environment_simulation]]]"
|
||||
set device_class "environment"
|
||||
if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } {
|
||||
continue
|
||||
}
|
||||
set enabled [string tolower [dict get $u "enabled"]]
|
||||
if { ! ([string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"]) } {
|
||||
continue
|
||||
}
|
||||
if { [dict exists $u "simulation_group"] } {
|
||||
set simulation_flag [SplitReply [[string tolower [dict get $u "simulation_group"]]]]
|
||||
}
|
||||
if { [dict exists $u "device_class"] } {
|
||||
set device_class "[dict get $u "device_class"]"
|
||||
}
|
||||
set name [dict get $u name]
|
||||
set implementation [dict get $u "implementation"]
|
||||
if { !([dict exists $::config_dict $implementation]) } {
|
||||
continue
|
||||
}
|
||||
set v [dict get $::config_dict $implementation]
|
||||
if { !([dict exists $v "driver"]) } {
|
||||
continue
|
||||
}
|
||||
if { [string equal -nocase [dict get $v "driver"] "epson_pandp"] } {
|
||||
if { ![string equal -nocase "${simulation_flag}" "false"] } {
|
||||
set asyncqueue "null"
|
||||
${ns}::sics_log 9 "simulation_flag=${simulation_flag} => using null asyncqueue"
|
||||
} elseif { [dict exists $v "asyncqueue"] } {
|
||||
set asyncqueue [dict get $v "asyncqueue"]
|
||||
if { [string equal -nocase ${asyncqueue} "sct"] } {
|
||||
set ip_address [dict get $v ip]
|
||||
set tcp_port [dict get $v port]
|
||||
}
|
||||
} else {
|
||||
if { [dict exists $v "asyncprotocol"] } {
|
||||
set asyncprotocol [dict get $v "asyncprotocol"]
|
||||
} else {
|
||||
set asyncprotocol ${name}_protocol
|
||||
MakeAsyncProtocol ${asyncprotocol}
|
||||
if { [dict exists $v "terminator"] } {
|
||||
${asyncprotocol} sendterminator "[dict get $v "terminator"]"
|
||||
${asyncprotocol} replyterminator "[dict get $v "terminator"]"
|
||||
}
|
||||
}
|
||||
set asyncqueue ${name}_queue
|
||||
set ip_address [dict get $v ip]
|
||||
set tcp_port [dict get $v port]
|
||||
MakeAsyncQueue ${asyncqueue} ${asyncprotocol} ${ip_address} ${tcp_port}
|
||||
if { [dict exists $v "timeout"] } {
|
||||
${asyncqueue} timeout "[dict get $v "timeout"]"
|
||||
}
|
||||
}
|
||||
set arg_list [list]
|
||||
set missing_list [list]
|
||||
foreach arg {robot_name} {
|
||||
if {[dict exists $u $arg]} {
|
||||
lappend arg_list "[dict get $u $arg]"
|
||||
} elseif {[dict exists $v $arg]} {
|
||||
lappend arg_list "[dict get $v $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"
|
||||
}
|
||||
if { [string equal -nocase ${asyncqueue} "sct"] } {
|
||||
${ns}::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} {*}$arg_list
|
||||
} else {
|
||||
${ns}::add_driver ${name} ${device_class} ${simulation_flag} "aqadapter" ${asyncqueue} {*}$arg_list
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch_message ]
|
||||
handle_exception ${catch_status} ${catch_message}
|
||||
}
|
||||
|
||||
if { [info exists ::config_dict] } {
|
||||
::scobj::epson_pandp::read_config
|
||||
} else {
|
||||
::scobj::epson_pandp::sics_log 5 "No config dict"
|
||||
}
|
||||
Reference in New Issue
Block a user