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 401527b9..c959e923 100644 --- a/site_ansto/instrument/config/environment/temperature/sct_lakeshore_m370.tcl +++ b/site_ansto/instrument/config/environment/temperature/sct_lakeshore_m370.tcl @@ -27,24 +27,23 @@ proc ::scobj::lakeshore_m370::sics_log {debug_level debug_string} { } catch_message ] } -proc ::scobj::lakeshore_m370::mkDriver { sct_controller name device_class simulation_flag ip_address tcp_port id tol } { - ::scobj::lakeshore_m370::sics_log 9 "::scobj::lakeshore_m370::mkDriver ${sct_controller} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${tol}" +proc ::scobj::lakeshore_m370::mkDriver { sct_controller name id tol} { + ::scobj::lakeshore_m370::sics_log 9 "::scobj::lakeshore_m370::mkDriver ${sct_controller} ${name} ${id} ${tol}" set ns "[namespace current]" set catch_status [ catch { - MakeSICSObj ${name} SCT_OBJECT user float + MakeSICSObj ${name} SCT_OBJECT user none - sicslist setatt ${name} klass ${device_class} + sicslist setatt ${name} klass environment sicslist setatt ${name} long_name ${name} set scobj_hpath /sics/${name} - hsetprop ${scobj_hpath} klass ${device_class} - hsetprop ${scobj_hpath} data true + hsetprop ${scobj_hpath} klass environment hsetprop ${scobj_hpath} debug_threshold 5 # mkDriver hook code starts ::scobj::lakeshore_370::mk_sct_driver $sct_controller environment $name $tol - hsetprop ${scobj_hpath}/setpoint permlink data_set T[format "%02d" ${id}]SP01 - hsetprop ${scobj_hpath}/setpoint @description T[format "%02d" ${id}]SP01 + hsetprop ${scobj_hpath}/Loop1/setpoint permlink data_set T[format "%02d" ${id}]SP01 + hsetprop ${scobj_hpath}/Loop1/setpoint @description T[format "%02d" ${id}]SP01 hsetprop ${scobj_hpath}/Sensor/value permlink data_set T[format "%02d" ${id}]S01 hsetprop ${scobj_hpath}/Sensor/value @description T[format "%02d" ${id}]S01 # mkDriver hook code ends @@ -52,37 +51,31 @@ proc ::scobj::lakeshore_m370::mkDriver { sct_controller name device_class simula handle_exception ${catch_status} ${catch_message} } -proc ::scobj::lakeshore_m370::add_driver {name device_class simulation_flag ip_address tcp_port id tol} { - set catch_status [ catch { - ::scobj::lakeshore_m370::sics_log 9 "::scobj::lakeshore_m370::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${tol}" - if {[string equal -nocase "${simulation_flag}" "false"]} { - if {[string equal -nocase "aqadapter" "${ip_address}"]} { - ::scobj::lakeshore_m370::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}" - makesctcontroller sct_${name} aqadapter ${tcp_port} - } else { - ::scobj::lakeshore_m370::sics_log 9 "makesctcontroller sct_${name} std ${ip_address}:${tcp_port}" - makesctcontroller sct_${name} std ${ip_address}:${tcp_port} - } - } else { - ::scobj::lakeshore_m370::sics_log 9 "simulation_flag={simulation_flag} => No sctcontroller for lakeshore_m370" - } - ::scobj::lakeshore_m370::sics_log 1 "::scobj::lakeshore_m370::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${tol}" - ::scobj::lakeshore_m370::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${tol} - } catch_message ] - handle_exception ${catch_status} ${catch_message} -} - namespace eval ::scobj::lakeshore_m370 { namespace export debug_threshold namespace export debug_log namespace export sics_log namespace export mkDriver - namespace export add_driver } -proc add_lakeshore_m370 {name ip_address tcp_port id tol} { - set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" - ::scobj::lakeshore_m370::add_driver ${name} "environment" "${simulation_flag}" ${ip_address} ${tcp_port} "${id}" "${tol}" +proc add_lakeshore_m370 {name IP port id tol} { + set catch_status [ catch { + ::scobj::lakeshore_m370::sics_log 9 "add_lakeshore_m370 ${name} ${IP} ${port} ${tol}" + if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + if {[string equal -nocase "aqadapter" "${IP}"]} { + ::scobj::lakeshore_m370::sics_log 9 "makesctcontroller sct_${name} aqadapter ${port}" + makesctcontroller sct_${name} aqadapter ${port} + } else { + ::scobj::lakeshore_m370::sics_log 9 "makesctcontroller sct_${name} std ${IP}:${port}" + makesctcontroller sct_${name} std ${IP}:${port} + } + } else { + ::scobj::lakeshore_m370::sics_log 9 "[environment_simulation] => No sctcontroller for lakeshore_m370" + } + ::scobj::lakeshore_m370::sics_log 1 "::scobj::lakeshore_m370::mkDriver sct_${name} ${name} ${id} ${tol}" + ::scobj::lakeshore_m370::mkDriver sct_${name} ${name} ${id} ${tol} + } catch_message ] + handle_exception ${catch_status} ${catch_message} } clientput "file evaluation of sct_lakeshore_m370.tcl" @@ -91,41 +84,42 @@ 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 u} $::config_dict { - if { [dict exists $u "implementation"] } { - set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" - set device_class "environment" - if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } { + dict for {k v} $::config_dict { + if { [dict exists $v "implementation"] } { + if { !([dict exists $v "name"] && [dict exists $v "enabled"]) } { continue } - set enabled [string tolower [dict get $u "enabled"]] + set enabled [string tolower [dict get $v "enabled"]] if { ! ([string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"]) } { continue } - if { [dict exists $u "simulation_group"] } { - set simulation_flag [SplitReply [[string tolower [dict get $u "simulation_group"]]]] - } - if { [dict exists $u "device_class"] } { - set device_class "[dict get $u "device_class"]" - } - set name [dict get $u name] - set implementation [dict get $u "implementation"] + set name [dict get $v name] + set implementation [dict get $v "implementation"] if { !([dict exists $::config_dict $implementation]) } { continue } + set arg_list [list] + foreach arg {id} { + if {[dict exists $v $arg]} { + lappend arg_list "[dict get $v $arg]" + } else { + ${ns}::sics_log 9 "Missing configuration value $arg" + error "Missing configuration value $arg" + } + } set v [dict get $::config_dict $implementation] if { !([dict exists $v "driver"]) } { continue } if { [string equal -nocase [dict get $v "driver"] "lakeshore_m370"] } { - if { ![string equal -nocase "${simulation_flag}" "false"] } { + if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } { set asyncqueue "null" - ${ns}::sics_log 9 "simulation_flag=${simulation_flag} => using null asyncqueue" + ${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_address [dict get $v ip] - set tcp_port [dict get $v port] + set IP [dict get $v ip] + set PORT [dict get $v port] } } else { if { [dict exists $v "asyncprotocol"] } { @@ -139,32 +133,25 @@ proc ::scobj::lakeshore_m370::read_config {} { } } set asyncqueue ${name}_queue - set ip_address [dict get $v ip] - set tcp_port [dict get $v port] - MakeAsyncQueue ${asyncqueue} ${asyncprotocol} ${ip_address} ${tcp_port} + set IP [dict get $v ip] + set PORT [dict get $v port] + MakeAsyncQueue ${asyncqueue} ${asyncprotocol} ${IP} ${PORT} if { [dict exists $v "timeout"] } { ${asyncqueue} timeout "[dict get $v "timeout"]" } } - set arg_list [list] - set missing_list [list] - foreach arg {id tol} { - if {[dict exists $u $arg]} { - lappend arg_list "[dict get $u $arg]" - } elseif {[dict exists $v $arg]} { + foreach arg {tol} { + if {[dict exists $v $arg]} { lappend arg_list "[dict get $v $arg]" } else { ${ns}::sics_log 9 "Missing configuration value $arg" - lappend missing_list $arg + error "Missing configuration value $arg" } } - if { [llength $missing_list] > 0 } { - error "$name is missing configuration values $missing_list" - } if { [string equal -nocase ${asyncqueue} "sct"] } { - ${ns}::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} {*}$arg_list + add_lakeshore_m370 ${name} ${IP} ${PORT} {*}$arg_list } else { - ${ns}::add_driver ${name} ${device_class} ${simulation_flag} "aqadapter" ${asyncqueue} {*}$arg_list + add_lakeshore_m370 ${name} "aqadapter" ${asyncqueue} {*}$arg_list } } }