From c1b5b558f0654e6ca8aa8d824b21e307ad60da2c Mon Sep 17 00:00:00 2001 From: Ferdi Franceschini Date: Tue, 15 Jul 2014 10:56:27 +1000 Subject: [PATCH] Make all sct drivers. --- .../config/chopper/sct_astrium_chopper.tcl | 67 +++++---- .../bilby/config/motors/sct_shutters.tcl | 65 +++++---- .../bilby/config/motors/sct_tank.tcl | 67 +++++---- .../config/environment/sct_hiden_xcs.tcl | 127 ++++++++++-------- .../config/environment/sct_huber_pilot.tcl | 71 +++++----- .../config/environment/sct_isotech_ps.tcl | 67 +++++---- .../config/environment/sct_nhq_200.tcl | 75 ++++++----- .../config/environment/sct_omron_hldc.tcl | 67 +++++---- .../temperature/sct_julabo_lh45_gen.tcl | 95 +++++++------ .../temperature/sct_lakeshore_218.tcl | 65 +++++---- .../temperature/sct_lakeshore_m370.tcl | 27 ++-- .../temperature/sct_mercury_base.tcl | 97 +++++++------ .../temperature/sct_mercury_level.tcl | 87 +++++++----- .../temperature/sct_mercury_pres.tcl | 93 +++++++------ .../temperature/sct_mercury_scpi.tcl | 101 ++++++++------ .../temperature/sct_mercury_temp.tcl | 93 +++++++------ .../temperature/sct_mercury_valve.tcl | 91 ++++++++----- .../temperature/sct_pfeiffer_hg.tcl | 85 +++++++----- .../environment/temperature/sct_west4100.tcl | 27 ++-- .../config/source/sct_reactor_status.tcl | 67 +++++---- 20 files changed, 882 insertions(+), 652 deletions(-) diff --git a/site_ansto/instrument/bilby/config/chopper/sct_astrium_chopper.tcl b/site_ansto/instrument/bilby/config/chopper/sct_astrium_chopper.tcl index 9ccd49a5..e537f5bb 100644 --- a/site_ansto/instrument/bilby/config/chopper/sct_astrium_chopper.tcl +++ b/site_ansto/instrument/bilby/config/chopper/sct_astrium_chopper.tcl @@ -132,7 +132,7 @@ proc ::scobj::astrium_chopper::rdValue {tc_root} { sct oldval ${data} sct update ${data} sct utime readtime - } + } return ${nextState} } catch_message ] handle_exception ${catch_status} ${catch_message} @@ -200,7 +200,7 @@ proc ::scobj::astrium_chopper::readState {tc_root} { sct oldval ${data} sct update ${data} sct utime readtime - } + } return ${nextState} } catch_message ] handle_exception ${catch_status} ${catch_message} @@ -567,14 +567,17 @@ clientput "file evaluation of sct_astrium_chopper.tcl" proc ::scobj::astrium_chopper::read_config {} { set catch_status [ catch { set ns "::scobj::astrium_chopper" - dict for {k v} $::config_dict { - if { [dict exists $v "implementation"] } { - if { !([dict exists $v "name"] && [dict exists $v "enabled"]) } { + dict for {k u} $::config_dict { + if { [dict exists $u "implementation"] } { + if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } { continue } - set name [dict get $v name] - set enabled [string tolower [dict get $v "enabled"]] - set implementation [dict get $v "implementation"] + set enabled [string tolower [dict get $u "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"] if { !([dict exists $::config_dict $implementation]) } { continue } @@ -583,31 +586,37 @@ proc ::scobj::astrium_chopper::read_config {} { continue } if { [string equal -nocase [dict get $v "driver"] "astrium_chopper"] } { - if { [string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"] } { - if { ![string equal -nocase [SplitReply [chopper_simulation]] "false"] } { - set asyncqueue "null" - ${ns}::sics_log 9 "[chopper_simulation] => using null asyncqueue" - } elseif { [dict exists $v "asyncqueue"] } { - set asyncqueue [dict get $v "asyncqueue"] - } 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 + if { ![string equal -nocase [SplitReply [chopper_simulation]] "false"] } { + set asyncqueue "null" + ${ns}::sics_log 9 "[chopper_simulation] => using null asyncqueue" + } elseif { [dict exists $v "asyncqueue"] } { + set asyncqueue [dict get $v "asyncqueue"] + if { [string equal -nocase ${asyncqueue} "sct"] } { 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"]" + } + } 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 [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"]" + } + } + if { [string equal -nocase ${asyncqueue} "sct"] } { + add_astrium_chopper ${name} ${IP} ${PORT} + } else { add_astrium_chopper ${name} "aqadapter" ${asyncqueue} } } diff --git a/site_ansto/instrument/bilby/config/motors/sct_shutters.tcl b/site_ansto/instrument/bilby/config/motors/sct_shutters.tcl index 6dd435fa..64fe832b 100644 --- a/site_ansto/instrument/bilby/config/motors/sct_shutters.tcl +++ b/site_ansto/instrument/bilby/config/motors/sct_shutters.tcl @@ -127,7 +127,7 @@ proc ::scobj::shutters::read_switch_pair {tc_root} { sct oldval ${data} sct update ${data} sct utime readtime - } + } return ${nextState} } catch_message ] handle_exception ${catch_status} ${catch_message} @@ -305,14 +305,17 @@ clientput "file evaluation of sct_shutters.tcl" proc ::scobj::shutters::read_config {} { set catch_status [ catch { set ns "::scobj::shutters" - dict for {k v} $::config_dict { - if { [dict exists $v "implementation"] } { - if { !([dict exists $v "name"] && [dict exists $v "enabled"]) } { + dict for {k u} $::config_dict { + if { [dict exists $u "implementation"] } { + if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } { continue } - set name [dict get $v name] - set enabled [string tolower [dict get $v "enabled"]] - set implementation [dict get $v "implementation"] + set enabled [string tolower [dict get $u "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"] if { !([dict exists $::config_dict $implementation]) } { continue } @@ -321,31 +324,37 @@ proc ::scobj::shutters::read_config {} { continue } if { [string equal -nocase [dict get $v "driver"] "shutters"] } { - if { [string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"] } { - if { ![string equal -nocase [SplitReply [motor_simulation]] "false"] } { - set asyncqueue "null" - ${ns}::sics_log 9 "[motor_simulation] => using null asyncqueue" - } elseif { [dict exists $v "asyncqueue"] } { - set asyncqueue [dict get $v "asyncqueue"] - } 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 + if { ![string equal -nocase [SplitReply [motor_simulation]] "false"] } { + set asyncqueue "null" + ${ns}::sics_log 9 "[motor_simulation] => using null asyncqueue" + } elseif { [dict exists $v "asyncqueue"] } { + set asyncqueue [dict get $v "asyncqueue"] + if { [string equal -nocase ${asyncqueue} "sct"] } { 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"]" + } + } 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 [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"]" + } + } + if { [string equal -nocase ${asyncqueue} "sct"] } { + add_shutters ${name} ${IP} ${PORT} + } else { add_shutters ${name} "aqadapter" ${asyncqueue} } } diff --git a/site_ansto/instrument/bilby/config/motors/sct_tank.tcl b/site_ansto/instrument/bilby/config/motors/sct_tank.tcl index 5ae2c9b9..08f2bd51 100644 --- a/site_ansto/instrument/bilby/config/motors/sct_tank.tcl +++ b/site_ansto/instrument/bilby/config/motors/sct_tank.tcl @@ -122,7 +122,7 @@ proc ::scobj::tank::read_pos {tc_root} { sct oldval ${data} sct update ${data} sct utime readtime - } + } return ${nextState} } catch_message ] handle_exception ${catch_status} ${catch_message} @@ -171,7 +171,7 @@ proc ::scobj::tank::read_switch {tc_root} { sct oldval ${data} sct update ${data} sct utime readtime - } + } return ${nextState} } catch_message ] handle_exception ${catch_status} ${catch_message} @@ -340,14 +340,17 @@ clientput "file evaluation of sct_tank.tcl" proc ::scobj::tank::read_config {} { set catch_status [ catch { set ns "::scobj::tank" - dict for {k v} $::config_dict { - if { [dict exists $v "implementation"] } { - if { !([dict exists $v "name"] && [dict exists $v "enabled"]) } { + dict for {k u} $::config_dict { + if { [dict exists $u "implementation"] } { + if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } { continue } - set name [dict get $v name] - set enabled [string tolower [dict get $v "enabled"]] - set implementation [dict get $v "implementation"] + set enabled [string tolower [dict get $u "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"] if { !([dict exists $::config_dict $implementation]) } { continue } @@ -356,31 +359,37 @@ proc ::scobj::tank::read_config {} { continue } if { [string equal -nocase [dict get $v "driver"] "tank"] } { - if { [string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"] } { - if { ![string equal -nocase [SplitReply [motor_simulation]] "false"] } { - set asyncqueue "null" - ${ns}::sics_log 9 "[motor_simulation] => using null asyncqueue" - } elseif { [dict exists $v "asyncqueue"] } { - set asyncqueue [dict get $v "asyncqueue"] - } 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 + if { ![string equal -nocase [SplitReply [motor_simulation]] "false"] } { + set asyncqueue "null" + ${ns}::sics_log 9 "[motor_simulation] => using null asyncqueue" + } elseif { [dict exists $v "asyncqueue"] } { + set asyncqueue [dict get $v "asyncqueue"] + if { [string equal -nocase ${asyncqueue} "sct"] } { 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"]" + } + } 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 [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"]" + } + } + if { [string equal -nocase ${asyncqueue} "sct"] } { + add_tank ${name} ${IP} ${PORT} + } else { add_tank ${name} "aqadapter" ${asyncqueue} } } diff --git a/site_ansto/instrument/config/environment/sct_hiden_xcs.tcl b/site_ansto/instrument/config/environment/sct_hiden_xcs.tcl index 32f05421..3dca8897 100644 --- a/site_ansto/instrument/config/environment/sct_hiden_xcs.tcl +++ b/site_ansto/instrument/config/environment/sct_hiden_xcs.tcl @@ -250,19 +250,19 @@ proc ::scobj::hiden_xcs::no_op {tc_root nextState cmd_str} { proc ::scobj::hiden_xcs::pid_flow {tc_root sp pv} { set catch_status [ catch { debug_log ${tc_root} 1 "pid_flow tc_root=${tc_root} sct=[sct] pv=${pv} sp=${sp}" - sct pid_error [expr ${sp} - ${pv}] - set p_value [expr [sct pid_pvalue] * [sct pid_error]] - set d_value [expr [sct pid_dvalue] * (${pv} - [sct oldval])] + sct pid_error [expr {${sp} - ${pv}}] + set p_value [expr {[sct pid_pvalue] * [sct pid_error]}] + set d_value [expr {[sct pid_dvalue] * (${pv} - [sct oldval])}] sct pid_deriv [sct pid_error] - sct pid_integ [expr [sct pid_integ] + [sct pid_error]] + sct pid_integ [expr {[sct pid_integ] + [sct pid_error]}] if { [sct pid_integ] > [sct pid_imax] } { sct pid_integ [sct pid_imax] } if { [sct pid_integ] < -[sct pid_imax] } { sct pid_integ -[sct pid_imax] } - set i_value [expr [sct pid_ivalue] * [sct pid_integ]] - set pid [expr ${p_value} + ${i_value} + ${d_value}] + set i_value [expr {[sct pid_ivalue] * [sct pid_integ]}] + set pid [expr {${p_value} + ${i_value} + ${d_value}}] # pid_flow hook code starts foreach node [list ${tc_root}/analog/sp1 ${tc_root}/analog/sp2] { if { !([hpropexists ${node} bias_flow] && [hgetpropval ${node} bias_flow] == ${pid}) } { @@ -285,19 +285,19 @@ proc ::scobj::hiden_xcs::pid_flow {tc_root sp pv} { proc ::scobj::hiden_xcs::pid_humidity {tc_root sp pv} { set catch_status [ catch { debug_log ${tc_root} 1 "pid_humidity tc_root=${tc_root} sct=[sct] pv=${pv} sp=${sp}" - sct pid_error [expr ${sp} - ${pv}] - set p_value [expr [sct pid_pvalue] * [sct pid_error]] - set d_value [expr [sct pid_dvalue] * (${pv} - [sct oldval])] + sct pid_error [expr {${sp} - ${pv}}] + set p_value [expr {[sct pid_pvalue] * [sct pid_error]}] + set d_value [expr {[sct pid_dvalue] * (${pv} - [sct oldval])}] sct pid_deriv [sct pid_error] - sct pid_integ [expr [sct pid_integ] + [sct pid_error]] + sct pid_integ [expr {[sct pid_integ] + [sct pid_error]}] if { [sct pid_integ] > [sct pid_imax] } { sct pid_integ [sct pid_imax] } if { [sct pid_integ] < -[sct pid_imax] } { sct pid_integ -[sct pid_imax] } - set i_value [expr [sct pid_ivalue] * [sct pid_integ]] - set pid [expr ${p_value} + ${i_value} + ${d_value}] + set i_value [expr {[sct pid_ivalue] * [sct pid_integ]}] + set pid [expr {${p_value} + ${i_value} + ${d_value}}] # pid_humidity hook code starts set sign 1 foreach node [list ${tc_root}/analog/sp1 ${tc_root}/analog/sp2] { @@ -339,7 +339,7 @@ proc ::scobj::hiden_xcs::rdValue {tc_root} { sct oldval ${data} sct update ${data} sct utime readtime - } + } return ${nextState} } catch_message ] handle_exception ${catch_status} ${catch_message} @@ -389,7 +389,7 @@ proc ::scobj::hiden_xcs::read_all_data {tc_root} { sct oldval ${data} sct update ${data} sct utime readtime - } + } return ${nextState} } catch_message ] handle_exception ${catch_status} ${catch_message} @@ -430,7 +430,7 @@ proc ::scobj::hiden_xcs::read_digital {tc_root} { sct oldval ${data} sct update ${data} sct utime readtime - } + } return ${nextState} } catch_message ] handle_exception ${catch_status} ${catch_message} @@ -456,7 +456,7 @@ proc ::scobj::hiden_xcs::read_flow {tc_root} { sct oldval ${data} sct update ${data} sct utime readtime - } + } return ${nextState} } catch_message ] handle_exception ${catch_status} ${catch_message} @@ -507,7 +507,7 @@ proc ::scobj::hiden_xcs::read_sixteen {tc_root} { sct oldval ${data} sct update ${data} sct utime readtime - } + } return ${nextState} } catch_message ] handle_exception ${catch_status} ${catch_message} @@ -558,7 +558,7 @@ proc ::scobj::hiden_xcs::read_twelve {tc_root} { sct oldval ${data} sct update ${data} sct utime readtime - } + } return ${nextState} } catch_message ] handle_exception ${catch_status} ${catch_message} @@ -1050,7 +1050,6 @@ proc ::scobj::hiden_xcs::mkDriver { sct_controller name id } { if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { ${sct_controller} poll ${scobj_hpath}/flow/sensor 1 ${sct_controller} write ${scobj_hpath}/flow/setpoint - ansto_makesctdrive ${name}_flow_setpoint ${scobj_hpath}/flow/setpoint ${scobj_hpath}/flow/sensor ${sct_controller} } else { ::scobj::hiden_xcs::sics_log 9 "[environment_simulation] => No poll/write for hiden_xcs" } @@ -1109,12 +1108,15 @@ proc ::scobj::hiden_xcs::mkDriver { sct_controller name id } { if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { ${sct_controller} poll ${scobj_hpath}/humidity/sensor 1 ${sct_controller} write ${scobj_hpath}/humidity/setpoint - ansto_makesctdrive ${name}_humidity_setpoint ${scobj_hpath}/humidity/setpoint ${scobj_hpath}/humidity/sensor ${sct_controller} } else { ::scobj::hiden_xcs::sics_log 9 "[environment_simulation] => No poll/write for hiden_xcs" } hsetprop ${scobj_hpath} klass environment hsetprop ${scobj_hpath} debug_threshold 5 + if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + ansto_makesctdrive ${name}_flow_setpoint ${scobj_hpath}/flow/setpoint ${scobj_hpath}/flow/sensor ${sct_controller} + ansto_makesctdrive ${name}_humidity_setpoint ${scobj_hpath}/humidity/setpoint ${scobj_hpath}/humidity/sensor ${sct_controller} + } # mkDriver hook code starts # mkDriver hook code ends } catch_message ] @@ -1154,14 +1156,17 @@ clientput "file evaluation of sct_hiden_xcs.tcl" proc ::scobj::hiden_xcs::read_config {} { set catch_status [ catch { set ns "::scobj::hiden_xcs" - dict for {k v} $::config_dict { - if { [dict exists $v "implementation"] } { - if { !([dict exists $v "name"] && [dict exists $v "enabled"]) } { + dict for {k u} $::config_dict { + if { [dict exists $u "implementation"] } { + if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } { continue } - set name [dict get $v name] - set enabled [string tolower [dict get $v "enabled"]] - set implementation [dict get $v "implementation"] + set enabled [string tolower [dict get $u "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"] if { !([dict exists $::config_dict $implementation]) } { continue } @@ -1170,40 +1175,52 @@ proc ::scobj::hiden_xcs::read_config {} { continue } if { [string equal -nocase [dict get $v "driver"] "hiden_xcs"] } { - if { [string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"] } { - if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } { - set asyncqueue "null" - ${ns}::sics_log 9 "[environment_simulation] => using null asyncqueue" - } elseif { [dict exists $v "asyncqueue"] } { - set asyncqueue [dict get $v "asyncqueue"] - } 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 + if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } { + set asyncqueue "null" + ${ns}::sics_log 9 "[environment_simulation] => using null asyncqueue" + } elseif { [dict exists $v "asyncqueue"] } { + set asyncqueue [dict get $v "asyncqueue"] + if { [string equal -nocase ${asyncqueue} "sct"] } { 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"]" + } + } 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 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 asyncqueue ${name}_queue + 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} { + 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"] } { + add_hiden_xcs ${name} ${IP} ${PORT} {*}$arg_list + } else { add_hiden_xcs ${name} "aqadapter" ${asyncqueue} {*}$arg_list } } diff --git a/site_ansto/instrument/config/environment/sct_huber_pilot.tcl b/site_ansto/instrument/config/environment/sct_huber_pilot.tcl index 4b91c45a..52e6f55f 100644 --- a/site_ansto/instrument/config/environment/sct_huber_pilot.tcl +++ b/site_ansto/instrument/config/environment/sct_huber_pilot.tcl @@ -200,7 +200,7 @@ proc ::scobj::huber_pilot::rdStatus {tc_root} { sct oldval ${data} sct update ${data} sct utime readtime - } + } return ${nextState} } catch_message ] handle_exception ${catch_status} ${catch_message} @@ -249,7 +249,7 @@ proc ::scobj::huber_pilot::rdTemp {tc_root} { sct oldval ${data} sct update ${data} sct utime readtime - } + } return ${nextState} } catch_message ] handle_exception ${catch_status} ${catch_message} @@ -414,12 +414,14 @@ proc ::scobj::huber_pilot::mkDriver { sct_controller name } { ${sct_controller} poll ${scobj_hpath}/Loop1/vTmpActive 1 ${sct_controller} poll ${scobj_hpath}/Loop1/vTmpMode 1 ${sct_controller} write ${scobj_hpath}/Loop1/setpoint - ansto_makesctdrive ${name}_Loop1_setpoint ${scobj_hpath}/Loop1/setpoint ${scobj_hpath}/Loop1/sensor_int ${sct_controller} } else { ::scobj::huber_pilot::sics_log 9 "[environment_simulation] => No poll/write for huber_pilot" } hsetprop ${scobj_hpath} klass environment hsetprop ${scobj_hpath} debug_threshold 1 + if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + ansto_makesctdrive ${name}_Loop1_setpoint ${scobj_hpath}/Loop1/setpoint ${scobj_hpath}/Loop1/sensor_int ${sct_controller} + } # mkDriver hook code goes here } catch_message ] handle_exception ${catch_status} ${catch_message} @@ -458,14 +460,17 @@ clientput "file evaluation of sct_huber_pilot.tcl" proc ::scobj::huber_pilot::read_config {} { set catch_status [ catch { set ns "::scobj::huber_pilot" - dict for {k v} $::config_dict { - if { [dict exists $v "implementation"] } { - if { !([dict exists $v "name"] && [dict exists $v "enabled"]) } { + dict for {k u} $::config_dict { + if { [dict exists $u "implementation"] } { + if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } { continue } - set name [dict get $v name] - set enabled [string tolower [dict get $v "enabled"]] - set implementation [dict get $v "implementation"] + set enabled [string tolower [dict get $u "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"] if { !([dict exists $::config_dict $implementation]) } { continue } @@ -474,31 +479,37 @@ proc ::scobj::huber_pilot::read_config {} { continue } if { [string equal -nocase [dict get $v "driver"] "huber_pilot"] } { - if { [string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"] } { - if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } { - set asyncqueue "null" - ${ns}::sics_log 9 "[environment_simulation] => using null asyncqueue" - } elseif { [dict exists $v "asyncqueue"] } { - set asyncqueue [dict get $v "asyncqueue"] - } 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 + if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } { + set asyncqueue "null" + ${ns}::sics_log 9 "[environment_simulation] => using null asyncqueue" + } elseif { [dict exists $v "asyncqueue"] } { + set asyncqueue [dict get $v "asyncqueue"] + if { [string equal -nocase ${asyncqueue} "sct"] } { 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"]" + } + } 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 [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"]" + } + } + if { [string equal -nocase ${asyncqueue} "sct"] } { + add_huber_pilot ${name} ${IP} ${PORT} + } else { add_huber_pilot ${name} "aqadapter" ${asyncqueue} } } diff --git a/site_ansto/instrument/config/environment/sct_isotech_ps.tcl b/site_ansto/instrument/config/environment/sct_isotech_ps.tcl index 9df15015..fe4088f6 100644 --- a/site_ansto/instrument/config/environment/sct_isotech_ps.tcl +++ b/site_ansto/instrument/config/environment/sct_isotech_ps.tcl @@ -107,7 +107,7 @@ proc ::scobj::isotech_ps::rdValue {tc_root} { sct oldval ${data} sct update ${data} sct utime readtime - } + } return ${nextState} } catch_message ] handle_exception ${catch_status} ${catch_message} @@ -145,7 +145,7 @@ proc ::scobj::isotech_ps::read_relay {tc_root} { sct oldval ${data} sct update ${data} sct utime readtime - } + } return ${nextState} } catch_message ] handle_exception ${catch_status} ${catch_message} @@ -345,14 +345,17 @@ clientput "file evaluation of sct_isotech_ps.tcl" proc ::scobj::isotech_ps::read_config {} { set catch_status [ catch { set ns "::scobj::isotech_ps" - dict for {k v} $::config_dict { - if { [dict exists $v "implementation"] } { - if { !([dict exists $v "name"] && [dict exists $v "enabled"]) } { + dict for {k u} $::config_dict { + if { [dict exists $u "implementation"] } { + if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } { continue } - set name [dict get $v name] - set enabled [string tolower [dict get $v "enabled"]] - set implementation [dict get $v "implementation"] + set enabled [string tolower [dict get $u "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"] if { !([dict exists $::config_dict $implementation]) } { continue } @@ -361,31 +364,37 @@ proc ::scobj::isotech_ps::read_config {} { continue } if { [string equal -nocase [dict get $v "driver"] "isotech_ps"] } { - if { [string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"] } { - if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } { - set asyncqueue "null" - ${ns}::sics_log 9 "[environment_simulation] => using null asyncqueue" - } elseif { [dict exists $v "asyncqueue"] } { - set asyncqueue [dict get $v "asyncqueue"] - } 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 + if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } { + set asyncqueue "null" + ${ns}::sics_log 9 "[environment_simulation] => using null asyncqueue" + } elseif { [dict exists $v "asyncqueue"] } { + set asyncqueue [dict get $v "asyncqueue"] + if { [string equal -nocase ${asyncqueue} "sct"] } { 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"]" + } + } 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 [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"]" + } + } + if { [string equal -nocase ${asyncqueue} "sct"] } { + add_isotech_ps ${name} ${IP} ${PORT} + } else { add_isotech_ps ${name} "aqadapter" ${asyncqueue} } } diff --git a/site_ansto/instrument/config/environment/sct_nhq_200.tcl b/site_ansto/instrument/config/environment/sct_nhq_200.tcl index 46e3c84b..fe1ce39e 100644 --- a/site_ansto/instrument/config/environment/sct_nhq_200.tcl +++ b/site_ansto/instrument/config/environment/sct_nhq_200.tcl @@ -180,7 +180,7 @@ proc ::scobj::nhq_200::rdCurrent {tc_root} { sct oldval ${data} sct update ${data} sct utime readtime - } + } return ${nextState} } catch_message ] handle_exception ${catch_status} ${catch_message} @@ -206,7 +206,7 @@ proc ::scobj::nhq_200::rdValue {tc_root} { sct oldval ${data} sct update ${data} sct utime readtime - } + } return ${nextState} } catch_message ] handle_exception ${catch_status} ${catch_message} @@ -239,7 +239,7 @@ proc ::scobj::nhq_200::rdVoltage {tc_root} { sct oldval ${data} sct update ${data} sct utime readtime - } + } return ${nextState} } catch_message ] handle_exception ${catch_status} ${catch_message} @@ -484,7 +484,6 @@ proc ::scobj::nhq_200::mkDriver { sct_controller name } { ${sct_controller} write ${scobj_hpath}/ch1/i_trip ${sct_controller} write ${scobj_hpath}/ch1/v_ramp ${sct_controller} write ${scobj_hpath}/ch1/v_sp - ansto_makesctdrive ${name}_ch1_v_sp ${scobj_hpath}/ch1/v_sp ${scobj_hpath}/ch1/voltage ${sct_controller} } else { ::scobj::nhq_200::sics_log 9 "[environment_simulation] => No poll/write for nhq_200" } @@ -661,12 +660,15 @@ proc ::scobj::nhq_200::mkDriver { sct_controller name } { ${sct_controller} write ${scobj_hpath}/ch2/i_trip ${sct_controller} write ${scobj_hpath}/ch2/v_ramp ${sct_controller} write ${scobj_hpath}/ch2/v_sp - ansto_makesctdrive ${name}_ch2_v_sp ${scobj_hpath}/ch2/v_sp ${scobj_hpath}/ch2/voltage ${sct_controller} } else { ::scobj::nhq_200::sics_log 9 "[environment_simulation] => No poll/write for nhq_200" } hsetprop ${scobj_hpath} klass environment hsetprop ${scobj_hpath} debug_threshold 1 + if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + ansto_makesctdrive ${name}_ch1_v_sp ${scobj_hpath}/ch1/v_sp ${scobj_hpath}/ch1/voltage ${sct_controller} + ansto_makesctdrive ${name}_ch2_v_sp ${scobj_hpath}/ch2/v_sp ${scobj_hpath}/ch2/voltage ${sct_controller} + } # mkDriver hook code goes here } catch_message ] handle_exception ${catch_status} ${catch_message} @@ -705,14 +707,17 @@ clientput "file evaluation of sct_nhq_200.tcl" proc ::scobj::nhq_200::read_config {} { set catch_status [ catch { set ns "::scobj::nhq_200" - dict for {k v} $::config_dict { - if { [dict exists $v "implementation"] } { - if { !([dict exists $v "name"] && [dict exists $v "enabled"]) } { + dict for {k u} $::config_dict { + if { [dict exists $u "implementation"] } { + if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } { continue } - set name [dict get $v name] - set enabled [string tolower [dict get $v "enabled"]] - set implementation [dict get $v "implementation"] + set enabled [string tolower [dict get $u "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"] if { !([dict exists $::config_dict $implementation]) } { continue } @@ -721,31 +726,37 @@ proc ::scobj::nhq_200::read_config {} { continue } if { [string equal -nocase [dict get $v "driver"] "nhq_200"] } { - if { [string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"] } { - if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } { - set asyncqueue "null" - ${ns}::sics_log 9 "[environment_simulation] => using null asyncqueue" - } elseif { [dict exists $v "asyncqueue"] } { - set asyncqueue [dict get $v "asyncqueue"] - } 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 + if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } { + set asyncqueue "null" + ${ns}::sics_log 9 "[environment_simulation] => using null asyncqueue" + } elseif { [dict exists $v "asyncqueue"] } { + set asyncqueue [dict get $v "asyncqueue"] + if { [string equal -nocase ${asyncqueue} "sct"] } { 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"]" + } + } 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 [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"]" + } + } + if { [string equal -nocase ${asyncqueue} "sct"] } { + add_nhq_200 ${name} ${IP} ${PORT} + } else { add_nhq_200 ${name} "aqadapter" ${asyncqueue} } } diff --git a/site_ansto/instrument/config/environment/sct_omron_hldc.tcl b/site_ansto/instrument/config/environment/sct_omron_hldc.tcl index b04e62cb..50254576 100644 --- a/site_ansto/instrument/config/environment/sct_omron_hldc.tcl +++ b/site_ansto/instrument/config/environment/sct_omron_hldc.tcl @@ -117,7 +117,7 @@ proc ::scobj::omron_hldc::read_id {tc_root} { sct oldval ${data} sct update ${data} sct utime readtime - } + } return ${nextState} } catch_message ] handle_exception ${catch_status} ${catch_message} @@ -160,7 +160,7 @@ proc ::scobj::omron_hldc::read_mm {tc_root} { sct oldval ${data} sct update ${data} sct utime readtime - } + } return ${nextState} } catch_message ] handle_exception ${catch_status} ${catch_message} @@ -272,14 +272,17 @@ clientput "file evaluation of sct_omron_hldc.tcl" proc ::scobj::omron_hldc::read_config {} { set catch_status [ catch { set ns "::scobj::omron_hldc" - dict for {k v} $::config_dict { - if { [dict exists $v "implementation"] } { - if { !([dict exists $v "name"] && [dict exists $v "enabled"]) } { + dict for {k u} $::config_dict { + if { [dict exists $u "implementation"] } { + if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } { continue } - set name [dict get $v name] - set enabled [string tolower [dict get $v "enabled"]] - set implementation [dict get $v "implementation"] + set enabled [string tolower [dict get $u "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"] if { !([dict exists $::config_dict $implementation]) } { continue } @@ -288,31 +291,37 @@ proc ::scobj::omron_hldc::read_config {} { continue } if { [string equal -nocase [dict get $v "driver"] "omron_hldc"] } { - if { [string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"] } { - if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } { - set asyncqueue "null" - ${ns}::sics_log 9 "[environment_simulation] => using null asyncqueue" - } elseif { [dict exists $v "asyncqueue"] } { - set asyncqueue [dict get $v "asyncqueue"] - } 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 + if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } { + set asyncqueue "null" + ${ns}::sics_log 9 "[environment_simulation] => using null asyncqueue" + } elseif { [dict exists $v "asyncqueue"] } { + set asyncqueue [dict get $v "asyncqueue"] + if { [string equal -nocase ${asyncqueue} "sct"] } { 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"]" + } + } 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 [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"]" + } + } + if { [string equal -nocase ${asyncqueue} "sct"] } { + add_omron_hldc ${name} ${IP} ${PORT} + } else { add_omron_hldc ${name} "aqadapter" ${asyncqueue} } } diff --git a/site_ansto/instrument/config/environment/temperature/sct_julabo_lh45_gen.tcl b/site_ansto/instrument/config/environment/temperature/sct_julabo_lh45_gen.tcl index 1a0f42a8..441631f5 100644 --- a/site_ansto/instrument/config/environment/temperature/sct_julabo_lh45_gen.tcl +++ b/site_ansto/instrument/config/environment/temperature/sct_julabo_lh45_gen.tcl @@ -643,14 +643,17 @@ clientput "file evaluation of sct_julabo_lh45_gen.tcl" proc ::scobj::julabo_lh45_gen::read_config {} { set catch_status [ catch { set ns "::scobj::julabo_lh45_gen" - dict for {k v} $::config_dict { - if { [dict exists $v "implementation"] } { - if { !([dict exists $v "name"] && [dict exists $v "enabled"]) } { + dict for {k u} $::config_dict { + if { [dict exists $u "implementation"] } { + if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } { continue } - set name [dict get $v name] - set enabled [string tolower [dict get $v "enabled"]] - set implementation [dict get $v "implementation"] + set enabled [string tolower [dict get $u "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"] if { !([dict exists $::config_dict $implementation]) } { continue } @@ -659,49 +662,53 @@ proc ::scobj::julabo_lh45_gen::read_config {} { continue } if { [string equal -nocase [dict get $v "driver"] "julabo_lh45_gen"] } { - if { [string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"] } { - if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } { - set asyncqueue "null" - ${ns}::sics_log 9 "[environment_simulation] => using null asyncqueue" - } elseif { [dict exists $v "asyncqueue"] } { - set asyncqueue [dict get $v "asyncqueue"] - if { [string equal -nocase ${asyncqueue} "sct"] } { - set IP [dict get $v ip] - set 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 + if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } { + set asyncqueue "null" + ${ns}::sics_log 9 "[environment_simulation] => using null asyncqueue" + } elseif { [dict exists $v "asyncqueue"] } { + set asyncqueue [dict get $v "asyncqueue"] + if { [string equal -nocase ${asyncqueue} "sct"] } { 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] - foreach arg {id ctrl_sensor tol} { - 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" - } - } - if { [string equal -nocase ${asyncqueue} "sct"] } { - add_julabo_lh45_gen ${name} ${IP} ${PORT} {*}$arg_list + } else { + if { [dict exists $v "asyncprotocol"] } { + set asyncprotocol [dict get $v "asyncprotocol"] } else { - add_julabo_lh45_gen ${name} "aqadapter" ${asyncqueue} {*}$arg_list + 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 [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 ctrl_sensor tol} { + 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"] } { + add_julabo_lh45_gen ${name} ${IP} ${PORT} {*}$arg_list + } else { + add_julabo_lh45_gen ${name} "aqadapter" ${asyncqueue} {*}$arg_list } } } diff --git a/site_ansto/instrument/config/environment/temperature/sct_lakeshore_218.tcl b/site_ansto/instrument/config/environment/temperature/sct_lakeshore_218.tcl index a5dfd21c..88a5c78a 100644 --- a/site_ansto/instrument/config/environment/temperature/sct_lakeshore_218.tcl +++ b/site_ansto/instrument/config/environment/temperature/sct_lakeshore_218.tcl @@ -127,7 +127,7 @@ proc ::scobj::lakeshore_218::rdValue {tc_root} { sct oldval ${data} sct update ${data} sct utime readtime - } + } return ${nextState} } catch_message ] handle_exception ${catch_status} ${catch_message} @@ -338,14 +338,17 @@ clientput "file evaluation of sct_lakeshore_218.tcl" proc ::scobj::lakeshore_218::read_config {} { set catch_status [ catch { set ns "::scobj::lakeshore_218" - dict for {k v} $::config_dict { - if { [dict exists $v "implementation"] } { - if { !([dict exists $v "name"] && [dict exists $v "enabled"]) } { + dict for {k u} $::config_dict { + if { [dict exists $u "implementation"] } { + if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } { continue } - set name [dict get $v name] - set enabled [string tolower [dict get $v "enabled"]] - set implementation [dict get $v "implementation"] + set enabled [string tolower [dict get $u "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"] if { !([dict exists $::config_dict $implementation]) } { continue } @@ -354,31 +357,37 @@ proc ::scobj::lakeshore_218::read_config {} { continue } if { [string equal -nocase [dict get $v "driver"] "lakeshore_218"] } { - if { [string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"] } { - if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } { - set asyncqueue "null" - ${ns}::sics_log 9 "[environment_simulation] => using null asyncqueue" - } elseif { [dict exists $v "asyncqueue"] } { - set asyncqueue [dict get $v "asyncqueue"] - } 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 + if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } { + set asyncqueue "null" + ${ns}::sics_log 9 "[environment_simulation] => using null asyncqueue" + } elseif { [dict exists $v "asyncqueue"] } { + set asyncqueue [dict get $v "asyncqueue"] + if { [string equal -nocase ${asyncqueue} "sct"] } { 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"]" + } + } 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 [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"]" + } + } + if { [string equal -nocase ${asyncqueue} "sct"] } { + add_lakeshore_218 ${name} ${IP} ${PORT} + } else { add_lakeshore_218 ${name} "aqadapter" ${asyncqueue} } } diff --git a/site_ansto/instrument/config/environment/temperature/sct_lakeshore_m370.tcl b/site_ansto/instrument/config/environment/temperature/sct_lakeshore_m370.tcl index f9fd6a91..85f56563 100644 --- a/site_ansto/instrument/config/environment/temperature/sct_lakeshore_m370.tcl +++ b/site_ansto/instrument/config/environment/temperature/sct_lakeshore_m370.tcl @@ -27,7 +27,7 @@ proc ::scobj::lakeshore_m370::sics_log {debug_level debug_string} { } catch_message ] } -proc ::scobj::lakeshore_m370::mkDriver { sct_controller name tol} { +proc ::scobj::lakeshore_m370::mkDriver { sct_controller name tol } { ::scobj::lakeshore_m370::sics_log 9 "::scobj::lakeshore_m370::mkDriver ${sct_controller} ${name} ${tol}" set ns "[namespace current]" set catch_status [ catch { @@ -80,21 +80,20 @@ clientput "file evaluation of sct_lakeshore_m370.tcl" proc ::scobj::lakeshore_m370::read_config {} { set catch_status [ catch { set ns "::scobj::lakeshore_m370" - dict for {k v} $::config_dict { - if { [dict exists $v "implementation"] } { - if { !([dict exists $v "name"] && [dict exists $v "enabled"]) } { + dict for {k u} $::config_dict { + if { [dict exists $u "implementation"] } { + if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } { continue } - set enabled [string tolower [dict get $v "enabled"]] + set enabled [string tolower [dict get $u "enabled"]] if { ! ([string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"]) } { continue } - set name [dict get $v name] - set implementation [dict get $v "implementation"] + set name [dict get $u name] + set implementation [dict get $u "implementation"] if { !([dict exists $::config_dict $implementation]) } { continue } - set arg_list [list] set v [dict get $::config_dict $implementation] if { !([dict exists $v "driver"]) } { continue @@ -128,15 +127,21 @@ proc ::scobj::lakeshore_m370::read_config {} { ${asyncqueue} timeout "[dict get $v "timeout"]" } } - set arg_list [list] + set arg_list [list] + set missing_list [list] foreach arg {tol} { - if {[dict exists $v $arg]} { + 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" - error "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"] } { add_lakeshore_m370 ${name} ${IP} ${PORT} {*}$arg_list } else { diff --git a/site_ansto/instrument/config/environment/temperature/sct_mercury_base.tcl b/site_ansto/instrument/config/environment/temperature/sct_mercury_base.tcl index ff9dacb7..4d9e5e7a 100644 --- a/site_ansto/instrument/config/environment/temperature/sct_mercury_base.tcl +++ b/site_ansto/instrument/config/environment/temperature/sct_mercury_base.tcl @@ -180,7 +180,7 @@ proc ::scobj::mercury_base::rdText {tc_root} { sct oldval ${data} sct update ${data} sct utime readtime - } + } return ${nextState} } catch_message ] handle_exception ${catch_status} ${catch_message} @@ -212,7 +212,7 @@ proc ::scobj::mercury_base::rdValue {tc_root} { sct oldval ${data} sct update ${data} sct utime readtime - } + } return ${nextState} } catch_message ] handle_exception ${catch_status} ${catch_message} @@ -350,7 +350,6 @@ proc ::scobj::mercury_base::mkDriver { sct_controller name id tol } { ${sct_controller} poll ${scobj_hpath}/Loop1/sensor 1 ${sct_controller} poll ${scobj_hpath}/Loop1/setpoint 5 ${sct_controller} write ${scobj_hpath}/Loop1/setpoint - ansto_makesctdrive ${name}_Loop1_setpoint ${scobj_hpath}/Loop1/setpoint ${scobj_hpath}/Loop1/sensor ${sct_controller} } else { ::scobj::mercury_base::sics_log 9 "[environment_simulation] => No poll/write for mercury_base" } @@ -427,7 +426,6 @@ proc ::scobj::mercury_base::mkDriver { sct_controller name id tol } { ${sct_controller} poll ${scobj_hpath}/Loop2/sensor 1 ${sct_controller} poll ${scobj_hpath}/Loop2/setpoint 5 ${sct_controller} write ${scobj_hpath}/Loop2/setpoint - ansto_makesctdrive ${name}_Loop2_setpoint ${scobj_hpath}/Loop2/setpoint ${scobj_hpath}/Loop2/sensor ${sct_controller} } else { ::scobj::mercury_base::sics_log 9 "[environment_simulation] => No poll/write for mercury_base" } @@ -504,12 +502,16 @@ proc ::scobj::mercury_base::mkDriver { sct_controller name id tol } { ${sct_controller} poll ${scobj_hpath}/Loop3/sensor 1 ${sct_controller} poll ${scobj_hpath}/Loop3/setpoint 5 ${sct_controller} write ${scobj_hpath}/Loop3/setpoint - ansto_makesctdrive ${name}_Loop3_setpoint ${scobj_hpath}/Loop3/setpoint ${scobj_hpath}/Loop3/sensor ${sct_controller} } else { ::scobj::mercury_base::sics_log 9 "[environment_simulation] => No poll/write for mercury_base" } hsetprop ${scobj_hpath} klass environment hsetprop ${scobj_hpath} debug_threshold 5 + if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + ansto_makesctdrive ${name}_Loop1_setpoint ${scobj_hpath}/Loop1/setpoint ${scobj_hpath}/Loop1/sensor ${sct_controller} + ansto_makesctdrive ${name}_Loop2_setpoint ${scobj_hpath}/Loop2/setpoint ${scobj_hpath}/Loop2/sensor ${sct_controller} + ansto_makesctdrive ${name}_Loop3_setpoint ${scobj_hpath}/Loop3/setpoint ${scobj_hpath}/Loop3/sensor ${sct_controller} + } # mkDriver hook code goes here } catch_message ] handle_exception ${catch_status} ${catch_message} @@ -548,14 +550,17 @@ clientput "file evaluation of sct_mercury_base.tcl" proc ::scobj::mercury_base::read_config {} { set catch_status [ catch { set ns "::scobj::mercury_base" - dict for {k v} $::config_dict { - if { [dict exists $v "implementation"] } { - if { !([dict exists $v "name"] && [dict exists $v "enabled"]) } { + dict for {k u} $::config_dict { + if { [dict exists $u "implementation"] } { + if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } { continue } - set name [dict get $v name] - set enabled [string tolower [dict get $v "enabled"]] - set implementation [dict get $v "implementation"] + set enabled [string tolower [dict get $u "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"] if { !([dict exists $::config_dict $implementation]) } { continue } @@ -564,40 +569,52 @@ proc ::scobj::mercury_base::read_config {} { continue } if { [string equal -nocase [dict get $v "driver"] "mercury_base"] } { - if { [string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"] } { - if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } { - set asyncqueue "null" - ${ns}::sics_log 9 "[environment_simulation] => using null asyncqueue" - } elseif { [dict exists $v "asyncqueue"] } { - set asyncqueue [dict get $v "asyncqueue"] - } 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 + if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } { + set asyncqueue "null" + ${ns}::sics_log 9 "[environment_simulation] => using null asyncqueue" + } elseif { [dict exists $v "asyncqueue"] } { + set asyncqueue [dict get $v "asyncqueue"] + if { [string equal -nocase ${asyncqueue} "sct"] } { 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"]" + } + } 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 arg_list [list] - foreach arg {id tol} { - 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 asyncqueue ${name}_queue + 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]} { + 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"] } { + add_mercury_base ${name} ${IP} ${PORT} {*}$arg_list + } else { add_mercury_base ${name} "aqadapter" ${asyncqueue} {*}$arg_list } } diff --git a/site_ansto/instrument/config/environment/temperature/sct_mercury_level.tcl b/site_ansto/instrument/config/environment/temperature/sct_mercury_level.tcl index ed0c4d4a..f4f8dcd9 100644 --- a/site_ansto/instrument/config/environment/temperature/sct_mercury_level.tcl +++ b/site_ansto/instrument/config/environment/temperature/sct_mercury_level.tcl @@ -107,7 +107,7 @@ proc ::scobj::mercury_level::rdValue {tc_root} { sct oldval ${data} sct update ${data} sct utime readtime - } + } return ${nextState} } catch_message ] handle_exception ${catch_status} ${catch_message} @@ -225,14 +225,17 @@ clientput "file evaluation of sct_mercury_level.tcl" proc ::scobj::mercury_level::read_config {} { set catch_status [ catch { set ns "::scobj::mercury_level" - dict for {k v} $::config_dict { - if { [dict exists $v "implementation"] } { - if { !([dict exists $v "name"] && [dict exists $v "enabled"]) } { + dict for {k u} $::config_dict { + if { [dict exists $u "implementation"] } { + if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } { continue } - set name [dict get $v name] - set enabled [string tolower [dict get $v "enabled"]] - set implementation [dict get $v "implementation"] + set enabled [string tolower [dict get $u "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"] if { !([dict exists $::config_dict $implementation]) } { continue } @@ -241,40 +244,52 @@ proc ::scobj::mercury_level::read_config {} { continue } if { [string equal -nocase [dict get $v "driver"] "mercury_level"] } { - if { [string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"] } { - if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } { - set asyncqueue "null" - ${ns}::sics_log 9 "[environment_simulation] => using null asyncqueue" - } elseif { [dict exists $v "asyncqueue"] } { - set asyncqueue [dict get $v "asyncqueue"] - } 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 + if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } { + set asyncqueue "null" + ${ns}::sics_log 9 "[environment_simulation] => using null asyncqueue" + } elseif { [dict exists $v "asyncqueue"] } { + set asyncqueue [dict get $v "asyncqueue"] + if { [string equal -nocase ${asyncqueue} "sct"] } { 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"]" + } + } 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 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 asyncqueue ${name}_queue + 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} { + 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"] } { + add_mercury_level ${name} ${IP} ${PORT} {*}$arg_list + } else { add_mercury_level ${name} "aqadapter" ${asyncqueue} {*}$arg_list } } diff --git a/site_ansto/instrument/config/environment/temperature/sct_mercury_pres.tcl b/site_ansto/instrument/config/environment/temperature/sct_mercury_pres.tcl index 36f16976..1d4d1211 100644 --- a/site_ansto/instrument/config/environment/temperature/sct_mercury_pres.tcl +++ b/site_ansto/instrument/config/environment/temperature/sct_mercury_pres.tcl @@ -180,7 +180,7 @@ proc ::scobj::mercury_pres::rdText {tc_root} { sct oldval ${data} sct update ${data} sct utime readtime - } + } return ${nextState} } catch_message ] handle_exception ${catch_status} ${catch_message} @@ -212,7 +212,7 @@ proc ::scobj::mercury_pres::rdValue {tc_root} { sct oldval ${data} sct update ${data} sct utime readtime - } + } return ${nextState} } catch_message ] handle_exception ${catch_status} ${catch_message} @@ -345,12 +345,14 @@ proc ::scobj::mercury_pres::mkDriver { sct_controller name id tol } { ${sct_controller} poll ${scobj_hpath}/Loop8/sensor 1 ${sct_controller} poll ${scobj_hpath}/Loop8/setpoint 5 ${sct_controller} write ${scobj_hpath}/Loop8/setpoint - ansto_makesctdrive ${name}_Loop8_setpoint ${scobj_hpath}/Loop8/setpoint ${scobj_hpath}/Loop8/sensor ${sct_controller} } else { ::scobj::mercury_pres::sics_log 9 "[environment_simulation] => No poll/write for mercury_pres" } hsetprop ${scobj_hpath} klass environment hsetprop ${scobj_hpath} debug_threshold 5 + if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + ansto_makesctdrive ${name}_Loop8_setpoint ${scobj_hpath}/Loop8/setpoint ${scobj_hpath}/Loop8/sensor ${sct_controller} + } # mkDriver hook code goes here } catch_message ] handle_exception ${catch_status} ${catch_message} @@ -389,14 +391,17 @@ clientput "file evaluation of sct_mercury_pres.tcl" proc ::scobj::mercury_pres::read_config {} { set catch_status [ catch { set ns "::scobj::mercury_pres" - dict for {k v} $::config_dict { - if { [dict exists $v "implementation"] } { - if { !([dict exists $v "name"] && [dict exists $v "enabled"]) } { + dict for {k u} $::config_dict { + if { [dict exists $u "implementation"] } { + if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } { continue } - set name [dict get $v name] - set enabled [string tolower [dict get $v "enabled"]] - set implementation [dict get $v "implementation"] + set enabled [string tolower [dict get $u "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"] if { !([dict exists $::config_dict $implementation]) } { continue } @@ -405,40 +410,52 @@ proc ::scobj::mercury_pres::read_config {} { continue } if { [string equal -nocase [dict get $v "driver"] "mercury_pres"] } { - if { [string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"] } { - if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } { - set asyncqueue "null" - ${ns}::sics_log 9 "[environment_simulation] => using null asyncqueue" - } elseif { [dict exists $v "asyncqueue"] } { - set asyncqueue [dict get $v "asyncqueue"] - } 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 + if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } { + set asyncqueue "null" + ${ns}::sics_log 9 "[environment_simulation] => using null asyncqueue" + } elseif { [dict exists $v "asyncqueue"] } { + set asyncqueue [dict get $v "asyncqueue"] + if { [string equal -nocase ${asyncqueue} "sct"] } { 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"]" + } + } 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 arg_list [list] - foreach arg {id tol} { - 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 asyncqueue ${name}_queue + 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]} { + 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"] } { + add_mercury_pres ${name} ${IP} ${PORT} {*}$arg_list + } else { add_mercury_pres ${name} "aqadapter" ${asyncqueue} {*}$arg_list } } diff --git a/site_ansto/instrument/config/environment/temperature/sct_mercury_scpi.tcl b/site_ansto/instrument/config/environment/temperature/sct_mercury_scpi.tcl index d9b33c18..ca49ac1e 100644 --- a/site_ansto/instrument/config/environment/temperature/sct_mercury_scpi.tcl +++ b/site_ansto/instrument/config/environment/temperature/sct_mercury_scpi.tcl @@ -180,7 +180,7 @@ proc ::scobj::mercury_scpi::rdText {tc_root} { sct oldval ${data} sct update ${data} sct utime readtime - } + } return ${nextState} } catch_message ] handle_exception ${catch_status} ${catch_message} @@ -212,7 +212,7 @@ proc ::scobj::mercury_scpi::rdValue {tc_root} { sct oldval ${data} sct update ${data} sct utime readtime - } + } return ${nextState} } catch_message ] handle_exception ${catch_status} ${catch_message} @@ -421,7 +421,6 @@ proc ::scobj::mercury_scpi::mkDriver { sct_controller name id permlink tol valve ${sct_controller} poll ${scobj_hpath}/Loop1/sensor 1 ${sct_controller} poll ${scobj_hpath}/Loop1/setpoint 5 ${sct_controller} write ${scobj_hpath}/Loop1/setpoint - ansto_makesctdrive ${name}_Loop1_setpoint ${scobj_hpath}/Loop1/setpoint ${scobj_hpath}/Loop1/sensor ${sct_controller} } else { ::scobj::mercury_scpi::sics_log 9 "[environment_simulation] => No poll/write for mercury_scpi" } @@ -498,7 +497,6 @@ proc ::scobj::mercury_scpi::mkDriver { sct_controller name id permlink tol valve ${sct_controller} poll ${scobj_hpath}/Loop2/sensor 1 ${sct_controller} poll ${scobj_hpath}/Loop2/setpoint 5 ${sct_controller} write ${scobj_hpath}/Loop2/setpoint - ansto_makesctdrive ${name}_Loop2_setpoint ${scobj_hpath}/Loop2/setpoint ${scobj_hpath}/Loop2/sensor ${sct_controller} } else { ::scobj::mercury_scpi::sics_log 9 "[environment_simulation] => No poll/write for mercury_scpi" } @@ -575,7 +573,6 @@ proc ::scobj::mercury_scpi::mkDriver { sct_controller name id permlink tol valve ${sct_controller} poll ${scobj_hpath}/Loop3/sensor 1 ${sct_controller} poll ${scobj_hpath}/Loop3/setpoint 5 ${sct_controller} write ${scobj_hpath}/Loop3/setpoint - ansto_makesctdrive ${name}_Loop3_setpoint ${scobj_hpath}/Loop3/setpoint ${scobj_hpath}/Loop3/sensor ${sct_controller} } else { ::scobj::mercury_scpi::sics_log 9 "[environment_simulation] => No poll/write for mercury_scpi" } @@ -652,7 +649,6 @@ proc ::scobj::mercury_scpi::mkDriver { sct_controller name id permlink tol valve ${sct_controller} poll ${scobj_hpath}/Loop4/sensor 1 ${sct_controller} poll ${scobj_hpath}/Loop4/setpoint 5 ${sct_controller} write ${scobj_hpath}/Loop4/setpoint - ansto_makesctdrive ${name}_Loop4_setpoint ${scobj_hpath}/Loop4/setpoint ${scobj_hpath}/Loop4/sensor ${sct_controller} } else { ::scobj::mercury_scpi::sics_log 9 "[environment_simulation] => No poll/write for mercury_scpi" } @@ -700,12 +696,18 @@ proc ::scobj::mercury_scpi::mkDriver { sct_controller name id permlink tol valve if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { ${sct_controller} poll ${scobj_hpath}/Valve/sensor 5 ${sct_controller} write ${scobj_hpath}/Valve/setpoint - ansto_makesctdrive ${name}_Valve_setpoint ${scobj_hpath}/Valve/setpoint ${scobj_hpath}/Valve/sensor ${sct_controller} } else { ::scobj::mercury_scpi::sics_log 9 "[environment_simulation] => No poll/write for mercury_scpi" } hsetprop ${scobj_hpath} klass environment hsetprop ${scobj_hpath} debug_threshold 5 + if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + ansto_makesctdrive ${name}_Loop1_setpoint ${scobj_hpath}/Loop1/setpoint ${scobj_hpath}/Loop1/sensor ${sct_controller} + ansto_makesctdrive ${name}_Loop2_setpoint ${scobj_hpath}/Loop2/setpoint ${scobj_hpath}/Loop2/sensor ${sct_controller} + ansto_makesctdrive ${name}_Loop3_setpoint ${scobj_hpath}/Loop3/setpoint ${scobj_hpath}/Loop3/sensor ${sct_controller} + ansto_makesctdrive ${name}_Loop4_setpoint ${scobj_hpath}/Loop4/setpoint ${scobj_hpath}/Loop4/sensor ${sct_controller} + ansto_makesctdrive ${name}_Valve_setpoint ${scobj_hpath}/Valve/setpoint ${scobj_hpath}/Valve/sensor ${sct_controller} + } # mkDriver hook code goes here } catch_message ] handle_exception ${catch_status} ${catch_message} @@ -744,14 +746,17 @@ clientput "file evaluation of sct_mercury_scpi.tcl" proc ::scobj::mercury_scpi::read_config {} { set catch_status [ catch { set ns "::scobj::mercury_scpi" - dict for {k v} $::config_dict { - if { [dict exists $v "implementation"] } { - if { !([dict exists $v "name"] && [dict exists $v "enabled"]) } { + dict for {k u} $::config_dict { + if { [dict exists $u "implementation"] } { + if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } { continue } - set name [dict get $v name] - set enabled [string tolower [dict get $v "enabled"]] - set implementation [dict get $v "implementation"] + set enabled [string tolower [dict get $u "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"] if { !([dict exists $::config_dict $implementation]) } { continue } @@ -760,40 +765,52 @@ proc ::scobj::mercury_scpi::read_config {} { continue } if { [string equal -nocase [dict get $v "driver"] "mercury_scpi"] } { - if { [string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"] } { - if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } { - set asyncqueue "null" - ${ns}::sics_log 9 "[environment_simulation] => using null asyncqueue" - } elseif { [dict exists $v "asyncqueue"] } { - set asyncqueue [dict get $v "asyncqueue"] - } 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 + if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } { + set asyncqueue "null" + ${ns}::sics_log 9 "[environment_simulation] => using null asyncqueue" + } elseif { [dict exists $v "asyncqueue"] } { + set asyncqueue [dict get $v "asyncqueue"] + if { [string equal -nocase ${asyncqueue} "sct"] } { 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"]" + } + } 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 arg_list [list] - foreach arg {id permlink tol valve_tol} { - 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 asyncqueue ${name}_queue + 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 permlink tol valve_tol} { + 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"] } { + add_mercury_scpi ${name} ${IP} ${PORT} {*}$arg_list + } else { add_mercury_scpi ${name} "aqadapter" ${asyncqueue} {*}$arg_list } } diff --git a/site_ansto/instrument/config/environment/temperature/sct_mercury_temp.tcl b/site_ansto/instrument/config/environment/temperature/sct_mercury_temp.tcl index c2bacdd5..923e653d 100644 --- a/site_ansto/instrument/config/environment/temperature/sct_mercury_temp.tcl +++ b/site_ansto/instrument/config/environment/temperature/sct_mercury_temp.tcl @@ -180,7 +180,7 @@ proc ::scobj::mercury_temp::rdText {tc_root} { sct oldval ${data} sct update ${data} sct utime readtime - } + } return ${nextState} } catch_message ] handle_exception ${catch_status} ${catch_message} @@ -212,7 +212,7 @@ proc ::scobj::mercury_temp::rdValue {tc_root} { sct oldval ${data} sct update ${data} sct utime readtime - } + } return ${nextState} } catch_message ] handle_exception ${catch_status} ${catch_message} @@ -350,12 +350,14 @@ proc ::scobj::mercury_temp::mkDriver { sct_controller name id tol } { ${sct_controller} poll ${scobj_hpath}/Loop4/sensor 1 ${sct_controller} poll ${scobj_hpath}/Loop4/setpoint 5 ${sct_controller} write ${scobj_hpath}/Loop4/setpoint - ansto_makesctdrive ${name}_Loop4_setpoint ${scobj_hpath}/Loop4/setpoint ${scobj_hpath}/Loop4/sensor ${sct_controller} } else { ::scobj::mercury_temp::sics_log 9 "[environment_simulation] => No poll/write for mercury_temp" } hsetprop ${scobj_hpath} klass environment hsetprop ${scobj_hpath} debug_threshold 5 + if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + ansto_makesctdrive ${name}_Loop4_setpoint ${scobj_hpath}/Loop4/setpoint ${scobj_hpath}/Loop4/sensor ${sct_controller} + } # mkDriver hook code goes here } catch_message ] handle_exception ${catch_status} ${catch_message} @@ -394,14 +396,17 @@ clientput "file evaluation of sct_mercury_temp.tcl" proc ::scobj::mercury_temp::read_config {} { set catch_status [ catch { set ns "::scobj::mercury_temp" - dict for {k v} $::config_dict { - if { [dict exists $v "implementation"] } { - if { !([dict exists $v "name"] && [dict exists $v "enabled"]) } { + dict for {k u} $::config_dict { + if { [dict exists $u "implementation"] } { + if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } { continue } - set name [dict get $v name] - set enabled [string tolower [dict get $v "enabled"]] - set implementation [dict get $v "implementation"] + set enabled [string tolower [dict get $u "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"] if { !([dict exists $::config_dict $implementation]) } { continue } @@ -410,40 +415,52 @@ proc ::scobj::mercury_temp::read_config {} { continue } if { [string equal -nocase [dict get $v "driver"] "mercury_temp"] } { - if { [string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"] } { - if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } { - set asyncqueue "null" - ${ns}::sics_log 9 "[environment_simulation] => using null asyncqueue" - } elseif { [dict exists $v "asyncqueue"] } { - set asyncqueue [dict get $v "asyncqueue"] - } 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 + if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } { + set asyncqueue "null" + ${ns}::sics_log 9 "[environment_simulation] => using null asyncqueue" + } elseif { [dict exists $v "asyncqueue"] } { + set asyncqueue [dict get $v "asyncqueue"] + if { [string equal -nocase ${asyncqueue} "sct"] } { 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"]" + } + } 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 arg_list [list] - foreach arg {id tol} { - 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 asyncqueue ${name}_queue + 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]} { + 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"] } { + add_mercury_temp ${name} ${IP} ${PORT} {*}$arg_list + } else { add_mercury_temp ${name} "aqadapter" ${asyncqueue} {*}$arg_list } } diff --git a/site_ansto/instrument/config/environment/temperature/sct_mercury_valve.tcl b/site_ansto/instrument/config/environment/temperature/sct_mercury_valve.tcl index bd4280b3..73944488 100644 --- a/site_ansto/instrument/config/environment/temperature/sct_mercury_valve.tcl +++ b/site_ansto/instrument/config/environment/temperature/sct_mercury_valve.tcl @@ -180,7 +180,7 @@ proc ::scobj::mercury_valve::rdValue {tc_root} { sct oldval ${data} sct update ${data} sct utime readtime - } + } return ${nextState} } catch_message ] handle_exception ${catch_status} ${catch_message} @@ -299,12 +299,14 @@ proc ::scobj::mercury_valve::mkDriver { sct_controller name id valve_tol } { if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { ${sct_controller} poll ${scobj_hpath}/Valve/sensor 5 ${sct_controller} write ${scobj_hpath}/Valve/setpoint - ansto_makesctdrive ${name}_Valve_setpoint ${scobj_hpath}/Valve/setpoint ${scobj_hpath}/Valve/sensor ${sct_controller} } else { ::scobj::mercury_valve::sics_log 9 "[environment_simulation] => No poll/write for mercury_valve" } hsetprop ${scobj_hpath} klass environment hsetprop ${scobj_hpath} debug_threshold 5 + if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + ansto_makesctdrive ${name}_Valve_setpoint ${scobj_hpath}/Valve/setpoint ${scobj_hpath}/Valve/sensor ${sct_controller} + } # mkDriver hook code goes here } catch_message ] handle_exception ${catch_status} ${catch_message} @@ -343,14 +345,17 @@ clientput "file evaluation of sct_mercury_valve.tcl" proc ::scobj::mercury_valve::read_config {} { set catch_status [ catch { set ns "::scobj::mercury_valve" - dict for {k v} $::config_dict { - if { [dict exists $v "implementation"] } { - if { !([dict exists $v "name"] && [dict exists $v "enabled"]) } { + dict for {k u} $::config_dict { + if { [dict exists $u "implementation"] } { + if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } { continue } - set name [dict get $v name] - set enabled [string tolower [dict get $v "enabled"]] - set implementation [dict get $v "implementation"] + set enabled [string tolower [dict get $u "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"] if { !([dict exists $::config_dict $implementation]) } { continue } @@ -359,40 +364,52 @@ proc ::scobj::mercury_valve::read_config {} { continue } if { [string equal -nocase [dict get $v "driver"] "mercury_valve"] } { - if { [string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"] } { - if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } { - set asyncqueue "null" - ${ns}::sics_log 9 "[environment_simulation] => using null asyncqueue" - } elseif { [dict exists $v "asyncqueue"] } { - set asyncqueue [dict get $v "asyncqueue"] - } 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 + if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } { + set asyncqueue "null" + ${ns}::sics_log 9 "[environment_simulation] => using null asyncqueue" + } elseif { [dict exists $v "asyncqueue"] } { + set asyncqueue [dict get $v "asyncqueue"] + if { [string equal -nocase ${asyncqueue} "sct"] } { 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"]" + } + } 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 arg_list [list] - foreach arg {id valve_tol} { - 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 asyncqueue ${name}_queue + 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 valve_tol} { + 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"] } { + add_mercury_valve ${name} ${IP} ${PORT} {*}$arg_list + } else { add_mercury_valve ${name} "aqadapter" ${asyncqueue} {*}$arg_list } } diff --git a/site_ansto/instrument/config/environment/temperature/sct_pfeiffer_hg.tcl b/site_ansto/instrument/config/environment/temperature/sct_pfeiffer_hg.tcl index ea5b211d..623d8fa5 100644 --- a/site_ansto/instrument/config/environment/temperature/sct_pfeiffer_hg.tcl +++ b/site_ansto/instrument/config/environment/temperature/sct_pfeiffer_hg.tcl @@ -60,7 +60,7 @@ proc ::scobj::pfeiffer_hg::ack_enq {tc_root} { sct oldval ${data} sct update ${data} sct utime readtime - } + } return ${nextState} } catch_message ] handle_exception ${catch_status} ${catch_message} @@ -197,19 +197,19 @@ proc ::scobj::pfeiffer_hg::noResponse {tc_root} { proc ::scobj::pfeiffer_hg::pid_pressure {tc_root sp pv} { set catch_status [ catch { debug_log ${tc_root} 1 "pid_pressure tc_root=${tc_root} sct=[sct] pv=${pv} sp=${sp}" - sct pid_error [expr ${sp} - ${pv}] - set p_value [expr [sct pid_pvalue] * [sct pid_error]] - set d_value [expr [sct pid_dvalue] * (${pv} - [sct oldval])] + sct pid_error [expr {${sp} - ${pv}}] + set p_value [expr {[sct pid_pvalue] * [sct pid_error]}] + set d_value [expr {[sct pid_dvalue] * (${pv} - [sct oldval])}] sct pid_deriv [sct pid_error] - sct pid_integ [expr [sct pid_integ] + [sct pid_error]] + sct pid_integ [expr {[sct pid_integ] + [sct pid_error]}] if { [sct pid_integ] > [sct pid_imax] } { sct pid_integ [sct pid_imax] } if { [sct pid_integ] < -[sct pid_imax] } { sct pid_integ -[sct pid_imax] } - set i_value [expr [sct pid_ivalue] * [sct pid_integ]] - set pid [expr ${p_value} + ${i_value} + ${d_value}] + set i_value [expr {[sct pid_ivalue] * [sct pid_integ]}] + set pid [expr {${p_value} + ${i_value} + ${d_value}}] # pid_pressure hook code starts if { [hpropexists [sct] pid_control] } { set co [hgetpropval [sct] pid_control] @@ -249,7 +249,7 @@ proc ::scobj::pfeiffer_hg::rdValue {tc_root} { sct oldval ${data} sct update ${data} sct utime readtime - } + } return ${nextState} } catch_message ] handle_exception ${catch_status} ${catch_message} @@ -289,7 +289,7 @@ proc ::scobj::pfeiffer_hg::readPR1 {tc_root} { sct oldval ${data} sct update ${data} sct utime readtime - } + } return ${nextState} } catch_message ] handle_exception ${catch_status} ${catch_message} @@ -446,12 +446,14 @@ proc ::scobj::pfeiffer_hg::mkDriver { sct_controller name } { if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { ${sct_controller} poll ${scobj_hpath}/pressure/sensor 1 ${sct_controller} write ${scobj_hpath}/pressure/setpoint - ansto_makesctdrive ${name}_pressure_setpoint ${scobj_hpath}/pressure/setpoint ${scobj_hpath}/pressure/sensor ${sct_controller} } else { ::scobj::pfeiffer_hg::sics_log 9 "[environment_simulation] => No poll/write for pfeiffer_hg" } hsetprop ${scobj_hpath} klass environment hsetprop ${scobj_hpath} debug_threshold 5 + if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + ansto_makesctdrive ${name}_pressure_setpoint ${scobj_hpath}/pressure/setpoint ${scobj_hpath}/pressure/sensor ${sct_controller} + } # mkDriver hook code starts hsetprop ${scobj_hpath}/pressure/sensor read ${ns}::sendPR1 ${scobj_hpath} ack_enq {PR1} hsetprop ${scobj_hpath}/pressure/sensor ack_enq ${ns}::ack_enq ${scobj_hpath} @@ -493,14 +495,17 @@ clientput "file evaluation of sct_pfeiffer_hg.tcl" proc ::scobj::pfeiffer_hg::read_config {} { set catch_status [ catch { set ns "::scobj::pfeiffer_hg" - dict for {k v} $::config_dict { - if { [dict exists $v "implementation"] } { - if { !([dict exists $v "name"] && [dict exists $v "enabled"]) } { + dict for {k u} $::config_dict { + if { [dict exists $u "implementation"] } { + if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } { continue } - set name [dict get $v name] - set enabled [string tolower [dict get $v "enabled"]] - set implementation [dict get $v "implementation"] + set enabled [string tolower [dict get $u "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"] if { !([dict exists $::config_dict $implementation]) } { continue } @@ -509,31 +514,37 @@ proc ::scobj::pfeiffer_hg::read_config {} { continue } if { [string equal -nocase [dict get $v "driver"] "pfeiffer_hg"] } { - if { [string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"] } { - if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } { - set asyncqueue "null" - ${ns}::sics_log 9 "[environment_simulation] => using null asyncqueue" - } elseif { [dict exists $v "asyncqueue"] } { - set asyncqueue [dict get $v "asyncqueue"] - } 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 + if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } { + set asyncqueue "null" + ${ns}::sics_log 9 "[environment_simulation] => using null asyncqueue" + } elseif { [dict exists $v "asyncqueue"] } { + set asyncqueue [dict get $v "asyncqueue"] + if { [string equal -nocase ${asyncqueue} "sct"] } { 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"]" + } + } 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 [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"]" + } + } + if { [string equal -nocase ${asyncqueue} "sct"] } { + add_pfeiffer_hg ${name} ${IP} ${PORT} + } else { add_pfeiffer_hg ${name} "aqadapter" ${asyncqueue} } } diff --git a/site_ansto/instrument/config/environment/temperature/sct_west4100.tcl b/site_ansto/instrument/config/environment/temperature/sct_west4100.tcl index 0933f6cf..e65bc7a5 100644 --- a/site_ansto/instrument/config/environment/temperature/sct_west4100.tcl +++ b/site_ansto/instrument/config/environment/temperature/sct_west4100.tcl @@ -27,7 +27,7 @@ proc ::scobj::west4100::sics_log {debug_level debug_string} { } catch_message ] } -proc ::scobj::west4100::mkDriver { sct_controller name IP dev_id} { +proc ::scobj::west4100::mkDriver { sct_controller name IP dev_id } { ::scobj::west4100::sics_log 9 "::scobj::west4100::mkDriver ${sct_controller} ${name} ${IP} ${dev_id}" set ns "[namespace current]" set catch_status [ catch { @@ -80,21 +80,20 @@ clientput "file evaluation of sct_west4100.tcl" proc ::scobj::west4100::read_config {} { set catch_status [ catch { set ns "::scobj::west4100" - dict for {k v} $::config_dict { - if { [dict exists $v "implementation"] } { - if { !([dict exists $v "name"] && [dict exists $v "enabled"]) } { + dict for {k u} $::config_dict { + if { [dict exists $u "implementation"] } { + if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } { continue } - set enabled [string tolower [dict get $v "enabled"]] + set enabled [string tolower [dict get $u "enabled"]] if { ! ([string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"]) } { continue } - set name [dict get $v name] - set implementation [dict get $v "implementation"] + set name [dict get $u name] + set implementation [dict get $u "implementation"] if { !([dict exists $::config_dict $implementation]) } { continue } - set arg_list [list] set v [dict get $::config_dict $implementation] if { !([dict exists $v "driver"]) } { continue @@ -128,15 +127,21 @@ proc ::scobj::west4100::read_config {} { ${asyncqueue} timeout "[dict get $v "timeout"]" } } - set arg_list [list] + set arg_list [list] + set missing_list [list] foreach arg {IP dev_id} { - if {[dict exists $v $arg]} { + 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" - error "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"] } { add_west4100 ${name} ${IP} ${PORT} {*}$arg_list } else { diff --git a/site_ansto/instrument/config/source/sct_reactor_status.tcl b/site_ansto/instrument/config/source/sct_reactor_status.tcl index aa1558bb..62b4a7c4 100644 --- a/site_ansto/instrument/config/source/sct_reactor_status.tcl +++ b/site_ansto/instrument/config/source/sct_reactor_status.tcl @@ -136,7 +136,7 @@ proc ::scobj::reactor_status::rdAll {tc_root} { sct oldval ${data} sct update ${data} sct utime readtime - } + } return ${nextState} } catch_message ] handle_exception ${catch_status} ${catch_message} @@ -162,7 +162,7 @@ proc ::scobj::reactor_status::rdValue {tc_root} { sct oldval ${data} sct update ${data} sct utime readtime - } + } return ${nextState} } catch_message ] handle_exception ${catch_status} ${catch_message} @@ -344,14 +344,17 @@ clientput "file evaluation of sct_reactor_status.tcl" proc ::scobj::reactor_status::read_config {} { set catch_status [ catch { set ns "::scobj::reactor_status" - dict for {k v} $::config_dict { - if { [dict exists $v "implementation"] } { - if { !([dict exists $v "name"] && [dict exists $v "enabled"]) } { + dict for {k u} $::config_dict { + if { [dict exists $u "implementation"] } { + if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } { continue } - set name [dict get $v name] - set enabled [string tolower [dict get $v "enabled"]] - set implementation [dict get $v "implementation"] + set enabled [string tolower [dict get $u "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"] if { !([dict exists $::config_dict $implementation]) } { continue } @@ -360,31 +363,37 @@ proc ::scobj::reactor_status::read_config {} { continue } if { [string equal -nocase [dict get $v "driver"] "reactor_status"] } { - if { [string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"] } { - if { ![string equal -nocase [SplitReply [opal_simulation]] "false"] } { - set asyncqueue "null" - ${ns}::sics_log 9 "[opal_simulation] => using null asyncqueue" - } elseif { [dict exists $v "asyncqueue"] } { - set asyncqueue [dict get $v "asyncqueue"] - } 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 + if { ![string equal -nocase [SplitReply [opal_simulation]] "false"] } { + set asyncqueue "null" + ${ns}::sics_log 9 "[opal_simulation] => using null asyncqueue" + } elseif { [dict exists $v "asyncqueue"] } { + set asyncqueue [dict get $v "asyncqueue"] + if { [string equal -nocase ${asyncqueue} "sct"] } { 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"]" + } + } 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 [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"]" + } + } + if { [string equal -nocase ${asyncqueue} "sct"] } { + add_reactor_status ${name} ${IP} ${PORT} + } else { add_reactor_status ${name} "aqadapter" ${asyncqueue} } }