diff --git a/site_ansto/instrument/config/environment/sct_agilent_33220A.tcl b/site_ansto/instrument/config/environment/sct_agilent_33220A.tcl new file mode 100644 index 00000000..e0668a36 --- /dev/null +++ b/site_ansto/instrument/config/environment/sct_agilent_33220A.tcl @@ -0,0 +1,146 @@ +# Generated driver for agilent_33220A +# vim: ft=tcl tabstop=8 softtabstop=2 shiftwidth=2 nocindent smartindent +# + +namespace eval ::scobj::agilent_33220A { + set debug_threshold 5 +} + +proc ::scobj::agilent_33220A::debug_log {tc_root debug_level debug_string} { + set catch_status [ catch { + set debug_threshold [hgetpropval ${tc_root} debug_threshold] + if {${debug_level} >= ${debug_threshold}} { + set fd [open "../log/agilent_33220A_[basename ${tc_root}].log" "a"] + set line "[clock format [clock seconds] -format "%T"] ${debug_string}" + puts ${fd} "${line}" + close ${fd} + } + } catch_message ] +} + +proc ::scobj::agilent_33220A::sics_log {debug_level debug_string} { + set catch_status [ catch { + set debug_threshold ${::scobj::agilent_33220A::debug_threshold} + if {${debug_level} >= ${debug_threshold}} { + sicslog "::scobj::agilent_33220A::${debug_string}" + } + } catch_message ] +} + +proc ::scobj::agilent_33220A::mkDriver { sct_controller name } { + ::scobj::agilent_33220A::sics_log 9 "::scobj::agilent_33220A::mkDriver for ${name}" + set ns "[namespace current]" + set catch_status [ catch { + + MakeSICSObj ${name} SCT_OBJECT + + sicslist setatt ${name} klass environment + sicslist setatt ${name} long_name ${name} + + set scobj_hpath /sics/${name} + hsetprop ${scobj_hpath} klass environment + hsetprop ${scobj_hpath} debug_threshold 5 +# mkDriver hook code starts + makesctcontroller $name $ip $port +# mkDriver hook code ends + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + +namespace eval ::scobj::agilent_33220A { + namespace export debug_threshold + namespace export debug_log + namespace export sics_log + namespace export mkDriver +} + +proc add_agilent_33220A {name IP port} { + set catch_status [ catch { + ::scobj::agilent_33220A::sics_log 9 "add_agilent_33220A ${name} ${IP} ${port}" + if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + if {[string equal -nocase "aqadapter" "${IP}"]} { + ::scobj::agilent_33220A::sics_log 9 "makesctcontroller sct_${name} aqadapter ${port}" + makesctcontroller sct_${name} aqadapter ${port} + } else { + ::scobj::agilent_33220A::sics_log 9 "makesctcontroller sct_${name} std ${IP}:${port}" + makesctcontroller sct_${name} std ${IP}:${port} + } + } else { + ::scobj::agilent_33220A::sics_log 9 "[environment_simulation] => No sctcontroller for agilent_33220A" + } + ::scobj::agilent_33220A::sics_log 1 "::scobj::agilent_33220A::mkDriver sct_${name} ${name}" + ::scobj::agilent_33220A::mkDriver sct_${name} ${name} + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + +clientput "file evaluation of sct_agilent_33220A.tcl" +::scobj::agilent_33220A::sics_log 9 "file evaluation of sct_agilent_33220A.tcl" + +proc ::scobj::agilent_33220A::read_config {} { + set catch_status [ catch { + set ns "::scobj::agilent_33220A" + 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 $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 + } + set v [dict get $::config_dict $implementation] + if { !([dict exists $v "driver"]) } { + continue + } + if { [string equal -nocase [dict get $v "driver"] "agilent_33220A"] } { + 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 + 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_agilent_33220A ${name} ${IP} ${PORT} + } else { + add_agilent_33220A ${name} "aqadapter" ${asyncqueue} + } + } + } + } + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + +if { [info exists ::config_dict] } { + ::scobj::agilent_33220A::read_config +} else { + ::scobj::agilent_33220A::sics_log 5 "No config dict" +} diff --git a/site_ansto/instrument/config/environment/sct_keithley_m2700.tcl b/site_ansto/instrument/config/environment/sct_keithley_m2700.tcl new file mode 100644 index 00000000..6f278a2a --- /dev/null +++ b/site_ansto/instrument/config/environment/sct_keithley_m2700.tcl @@ -0,0 +1,161 @@ +# Generated driver for keithley_m2700 +# vim: ft=tcl tabstop=8 softtabstop=2 shiftwidth=2 nocindent smartindent +# + +namespace eval ::scobj::keithley_m2700 { + set debug_threshold 5 +} + +proc ::scobj::keithley_m2700::debug_log {tc_root debug_level debug_string} { + set catch_status [ catch { + set debug_threshold [hgetpropval ${tc_root} debug_threshold] + if {${debug_level} >= ${debug_threshold}} { + set fd [open "../log/keithley_m2700_[basename ${tc_root}].log" "a"] + set line "[clock format [clock seconds] -format "%T"] ${debug_string}" + puts ${fd} "${line}" + close ${fd} + } + } catch_message ] +} + +proc ::scobj::keithley_m2700::sics_log {debug_level debug_string} { + set catch_status [ catch { + set debug_threshold ${::scobj::keithley_m2700::debug_threshold} + if {${debug_level} >= ${debug_threshold}} { + sicslog "::scobj::keithley_m2700::${debug_string}" + } + } catch_message ] +} + +proc ::scobj::keithley_m2700::mkDriver { sct_controller name id datype tol } { + ::scobj::keithley_m2700::sics_log 9 "::scobj::keithley_m2700::mkDriver ${sct_controller} ${name} ${id} ${datype} ${tol}" + set ns "[namespace current]" + set catch_status [ catch { + + MakeSICSObj ${name} SCT_OBJECT user float + + sicslist setatt ${name} klass environment + sicslist setatt ${name} long_name ${name} + + set scobj_hpath /sics/${name} + hsetprop ${scobj_hpath} klass environment + hsetprop ${scobj_hpath} debug_threshold 5 +# mkDriver hook code starts + mk_sct_keithley_2700 $sct_controller environment $name $tol $id $datype +# mkDriver hook code ends + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + +namespace eval ::scobj::keithley_m2700 { + namespace export debug_threshold + namespace export debug_log + namespace export sics_log + namespace export mkDriver +} + +proc add_keithley_m2700 {name IP port id datype tol} { + set catch_status [ catch { + ::scobj::keithley_m2700::sics_log 9 "add_keithley_m2700 ${name} ${IP} ${port} ${id} ${datype} ${tol}" + if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + if {[string equal -nocase "aqadapter" "${IP}"]} { + ::scobj::keithley_m2700::sics_log 9 "makesctcontroller sct_${name} aqadapter ${port}" + makesctcontroller sct_${name} aqadapter ${port} + } else { + ::scobj::keithley_m2700::sics_log 9 "makesctcontroller sct_${name} std ${IP}:${port}" + makesctcontroller sct_${name} std ${IP}:${port} + } + } else { + ::scobj::keithley_m2700::sics_log 9 "[environment_simulation] => No sctcontroller for keithley_m2700" + } + ::scobj::keithley_m2700::sics_log 1 "::scobj::keithley_m2700::mkDriver sct_${name} ${name} ${id} ${datype} ${tol}" + ::scobj::keithley_m2700::mkDriver sct_${name} ${name} ${id} ${datype} ${tol} + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + +clientput "file evaluation of sct_keithley_m2700.tcl" +::scobj::keithley_m2700::sics_log 9 "file evaluation of sct_keithley_m2700.tcl" + +proc ::scobj::keithley_m2700::read_config {} { + set catch_status [ catch { + set ns "::scobj::keithley_m2700" + 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 $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 + } + set v [dict get $::config_dict $implementation] + if { !([dict exists $v "driver"]) } { + continue + } + if { [string equal -nocase [dict get $v "driver"] "keithley_m2700"] } { + 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 + 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 datype 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_keithley_m2700 ${name} ${IP} ${PORT} {*}$arg_list + } else { + add_keithley_m2700 ${name} "aqadapter" ${asyncqueue} {*}$arg_list + } + } + } + } + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + +if { [info exists ::config_dict] } { + ::scobj::keithley_m2700::read_config +} else { + ::scobj::keithley_m2700::sics_log 5 "No config dict" +} diff --git a/site_ansto/instrument/config/environment/sct_protekmm.tcl b/site_ansto/instrument/config/environment/sct_protekmm.tcl index b7acc976..9c8581cb 100644 --- a/site_ansto/instrument/config/environment/sct_protekmm.tcl +++ b/site_ansto/instrument/config/environment/sct_protekmm.tcl @@ -27,8 +27,8 @@ proc ::scobj::protekmm::sics_log {debug_level debug_string} { } catch_message ] } -proc ::scobj::protekmm::mkDriver { sct_controller name } { - ::scobj::protekmm::sics_log 9 "::scobj::protekmm::mkDriver for ${name}" +proc ::scobj::protekmm::mkDriver { sct_controller name id datype } { + ::scobj::protekmm::sics_log 9 "::scobj::protekmm::mkDriver ${sct_controller} ${name} ${id} ${datype}" set ns "[namespace current]" set catch_status [ catch { @@ -41,7 +41,7 @@ proc ::scobj::protekmm::mkDriver { sct_controller name } { hsetprop ${scobj_hpath} klass environment hsetprop ${scobj_hpath} debug_threshold 5 # mkDriver hook code starts - MakeProtek $name $sct_controller + MakeProtek $name $sct_controller $id $datype # mkDriver hook code ends } catch_message ] handle_exception ${catch_status} ${catch_message} @@ -54,9 +54,9 @@ namespace eval ::scobj::protekmm { namespace export mkDriver } -proc add_protekmm {name IP port} { +proc add_protekmm {name IP port id datype} { set catch_status [ catch { - ::scobj::protekmm::sics_log 9 "add_protekmm ${name} ${IP} ${port}" + ::scobj::protekmm::sics_log 9 "add_protekmm ${name} ${IP} ${port} ${id} ${datype}" if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { if {[string equal -nocase "aqadapter" "${IP}"]} { ::scobj::protekmm::sics_log 9 "makesctcontroller sct_${name} aqadapter ${port}" @@ -68,8 +68,8 @@ proc add_protekmm {name IP port} { } else { ::scobj::protekmm::sics_log 9 "[environment_simulation] => No sctcontroller for protekmm" } - ::scobj::protekmm::sics_log 1 "::scobj::protekmm::mkDriver sct_${name} ${name}" - ::scobj::protekmm::mkDriver sct_${name} ${name} + ::scobj::protekmm::sics_log 1 "::scobj::protekmm::mkDriver sct_${name} ${name} ${id} ${datype}" + ::scobj::protekmm::mkDriver sct_${name} ${name} ${id} ${datype} } catch_message ] handle_exception ${catch_status} ${catch_message} } @@ -80,14 +80,17 @@ clientput "file evaluation of sct_protekmm.tcl" proc ::scobj::protekmm::read_config {} { set catch_status [ catch { set ns "::scobj::protekmm" - 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 } @@ -96,41 +99,54 @@ proc ::scobj::protekmm::read_config {} { continue } if { [string equal -nocase [dict get $v "driver"] "protekmm"] } { - 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"]" + } + } 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"]" } } - if { [string equal -nocase ${asyncqueue} "sct"] } { - add_protekmm ${name} ${IP} ${PORT} - } else { - add_protekmm ${name} "aqadapter" ${asyncqueue} + 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 datype} { + 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_protekmm ${name} ${IP} ${PORT} {*}$arg_list + } else { + add_protekmm ${name} "aqadapter" ${asyncqueue} {*}$arg_list + } } } } diff --git a/site_ansto/instrument/config/environment/temperature/sct_eurotherm_m2000.tcl b/site_ansto/instrument/config/environment/temperature/sct_eurotherm_m2000.tcl new file mode 100644 index 00000000..c443fa26 --- /dev/null +++ b/site_ansto/instrument/config/environment/temperature/sct_eurotherm_m2000.tcl @@ -0,0 +1,161 @@ +# Generated driver for eurotherm_m2000 +# vim: ft=tcl tabstop=8 softtabstop=2 shiftwidth=2 nocindent smartindent +# + +namespace eval ::scobj::eurotherm_m2000 { + set debug_threshold 5 +} + +proc ::scobj::eurotherm_m2000::debug_log {tc_root debug_level debug_string} { + set catch_status [ catch { + set debug_threshold [hgetpropval ${tc_root} debug_threshold] + if {${debug_level} >= ${debug_threshold}} { + set fd [open "../log/eurotherm_m2000_[basename ${tc_root}].log" "a"] + set line "[clock format [clock seconds] -format "%T"] ${debug_string}" + puts ${fd} "${line}" + close ${fd} + } + } catch_message ] +} + +proc ::scobj::eurotherm_m2000::sics_log {debug_level debug_string} { + set catch_status [ catch { + set debug_threshold ${::scobj::eurotherm_m2000::debug_threshold} + if {${debug_level} >= ${debug_threshold}} { + sicslog "::scobj::eurotherm_m2000::${debug_string}" + } + } catch_message ] +} + +proc ::scobj::eurotherm_m2000::mkDriver { sct_controller name id datype dev_id tol } { + ::scobj::eurotherm_m2000::sics_log 9 "::scobj::eurotherm_m2000::mkDriver ${sct_controller} ${name} ${id} ${datype} ${dev_id} ${tol}" + set ns "[namespace current]" + set catch_status [ catch { + + MakeSICSObj ${name} SCT_OBJECT user float + + sicslist setatt ${name} klass environment + sicslist setatt ${name} long_name ${name} + + set scobj_hpath /sics/${name} + hsetprop ${scobj_hpath} klass environment + hsetprop ${scobj_hpath} debug_threshold 5 +# mkDriver hook code starts + mk_sct_eurotherm_et2000 sct_controller environment $name $dev_id $tol $id $datype +# mkDriver hook code ends + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + +namespace eval ::scobj::eurotherm_m2000 { + namespace export debug_threshold + namespace export debug_log + namespace export sics_log + namespace export mkDriver +} + +proc add_eurotherm_m2000 {name IP port id datype dev_id tol} { + set catch_status [ catch { + ::scobj::eurotherm_m2000::sics_log 9 "add_eurotherm_m2000 ${name} ${IP} ${port} ${id} ${datype} ${dev_id} ${tol}" + if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + if {[string equal -nocase "aqadapter" "${IP}"]} { + ::scobj::eurotherm_m2000::sics_log 9 "makesctcontroller sct_${name} aqadapter ${port}" + makesctcontroller sct_${name} aqadapter ${port} + } else { + ::scobj::eurotherm_m2000::sics_log 9 "makesctcontroller sct_${name} std ${IP}:${port}" + makesctcontroller sct_${name} std ${IP}:${port} + } + } else { + ::scobj::eurotherm_m2000::sics_log 9 "[environment_simulation] => No sctcontroller for eurotherm_m2000" + } + ::scobj::eurotherm_m2000::sics_log 1 "::scobj::eurotherm_m2000::mkDriver sct_${name} ${name} ${id} ${datype} ${dev_id} ${tol}" + ::scobj::eurotherm_m2000::mkDriver sct_${name} ${name} ${id} ${datype} ${dev_id} ${tol} + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + +clientput "file evaluation of sct_eurotherm_m2000.tcl" +::scobj::eurotherm_m2000::sics_log 9 "file evaluation of sct_eurotherm_m2000.tcl" + +proc ::scobj::eurotherm_m2000::read_config {} { + set catch_status [ catch { + set ns "::scobj::eurotherm_m2000" + 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 $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 + } + set v [dict get $::config_dict $implementation] + if { !([dict exists $v "driver"]) } { + continue + } + if { [string equal -nocase [dict get $v "driver"] "eurotherm_m2000"] } { + 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 + 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 datype dev_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_eurotherm_m2000 ${name} ${IP} ${PORT} {*}$arg_list + } else { + add_eurotherm_m2000 ${name} "aqadapter" ${asyncqueue} {*}$arg_list + } + } + } + } + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + +if { [info exists ::config_dict] } { + ::scobj::eurotherm_m2000::read_config +} else { + ::scobj::eurotherm_m2000::sics_log 5 "No config dict" +} diff --git a/site_ansto/instrument/config/environment/temperature/sct_lakeshore_m370.tcl b/site_ansto/instrument/config/environment/temperature/sct_lakeshore_m370.tcl new file mode 100644 index 00000000..f9fd6a91 --- /dev/null +++ b/site_ansto/instrument/config/environment/temperature/sct_lakeshore_m370.tcl @@ -0,0 +1,156 @@ +# Generated driver for lakeshore_m370 +# vim: ft=tcl tabstop=8 softtabstop=2 shiftwidth=2 nocindent smartindent +# + +namespace eval ::scobj::lakeshore_m370 { + set debug_threshold 5 +} + +proc ::scobj::lakeshore_m370::debug_log {tc_root debug_level debug_string} { + set catch_status [ catch { + set debug_threshold [hgetpropval ${tc_root} debug_threshold] + if {${debug_level} >= ${debug_threshold}} { + set fd [open "../log/lakeshore_m370_[basename ${tc_root}].log" "a"] + set line "[clock format [clock seconds] -format "%T"] ${debug_string}" + puts ${fd} "${line}" + close ${fd} + } + } catch_message ] +} + +proc ::scobj::lakeshore_m370::sics_log {debug_level debug_string} { + set catch_status [ catch { + set debug_threshold ${::scobj::lakeshore_m370::debug_threshold} + if {${debug_level} >= ${debug_threshold}} { + sicslog "::scobj::lakeshore_m370::${debug_string}" + } + } catch_message ] +} + +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 { + + MakeSICSObj ${name} SCT_OBJECT user float + + sicslist setatt ${name} klass environment + sicslist setatt ${name} long_name ${name} + + set scobj_hpath /sics/${name} + hsetprop ${scobj_hpath} klass environment + hsetprop ${scobj_hpath} debug_threshold 5 +# mkDriver hook code starts + mk_sct_driver $sct_controller environment $name $tol +# mkDriver hook code ends + } 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 +} + +proc add_lakeshore_m370 {name IP port 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} ${tol}" + ::scobj::lakeshore_m370::mkDriver sct_${name} ${name} ${tol} + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + +clientput "file evaluation of sct_lakeshore_m370.tcl" +::scobj::lakeshore_m370::sics_log 9 "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"]) } { + continue + } + set enabled [string tolower [dict get $v "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"] + if { !([dict exists $::config_dict $implementation]) } { + continue + } + set arg_list [list] + 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 [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 + 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 {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_lakeshore_m370 ${name} ${IP} ${PORT} {*}$arg_list + } else { + add_lakeshore_m370 ${name} "aqadapter" ${asyncqueue} {*}$arg_list + } + } + } + } + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + +if { [info exists ::config_dict] } { + ::scobj::lakeshore_m370::read_config +} else { + ::scobj::lakeshore_m370::sics_log 5 "No config dict" +} diff --git a/site_ansto/instrument/config/environment/temperature/sct_ls336.tcl b/site_ansto/instrument/config/environment/temperature/sct_ls336.tcl new file mode 100644 index 00000000..8d4dc858 --- /dev/null +++ b/site_ansto/instrument/config/environment/temperature/sct_ls336.tcl @@ -0,0 +1,161 @@ +# Generated driver for ls336 +# vim: ft=tcl tabstop=8 softtabstop=2 shiftwidth=2 nocindent smartindent +# + +namespace eval ::scobj::ls336 { + set debug_threshold 5 +} + +proc ::scobj::ls336::debug_log {tc_root debug_level debug_string} { + set catch_status [ catch { + set debug_threshold [hgetpropval ${tc_root} debug_threshold] + if {${debug_level} >= ${debug_threshold}} { + set fd [open "../log/ls336_[basename ${tc_root}].log" "a"] + set line "[clock format [clock seconds] -format "%T"] ${debug_string}" + puts ${fd} "${line}" + close ${fd} + } + } catch_message ] +} + +proc ::scobj::ls336::sics_log {debug_level debug_string} { + set catch_status [ catch { + set debug_threshold ${::scobj::ls336::debug_threshold} + if {${debug_level} >= ${debug_threshold}} { + sicslog "::scobj::ls336::${debug_string}" + } + } catch_message ] +} + +proc ::scobj::ls336::mkDriver { sct_controller name id datype tol1 tol2 } { + ::scobj::ls336::sics_log 9 "::scobj::ls336::mkDriver ${sct_controller} ${name} ${id} ${datype} ${tol1} ${tol2}" + set ns "[namespace current]" + set catch_status [ catch { + + MakeSICSObj ${name} SCT_OBJECT + + sicslist setatt ${name} klass environment + sicslist setatt ${name} long_name ${name} + + set scobj_hpath /sics/${name} + hsetprop ${scobj_hpath} klass environment + hsetprop ${scobj_hpath} debug_threshold 5 +# mkDriver hook code starts + ::scobj::ls336::mk_sct_lakeshore_336 $sct_controller environment $name $id $datype $tol1 $tol2 0 +# mkDriver hook code ends + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + +namespace eval ::scobj::ls336 { + namespace export debug_threshold + namespace export debug_log + namespace export sics_log + namespace export mkDriver +} + +proc add_ls336 {name IP port id datype {tol1 1.0} {tol2 1.0}} { + set catch_status [ catch { + ::scobj::ls336::sics_log 9 "add_ls336 ${name} ${IP} ${port} ${id} ${datype} ${tol1} ${tol2}" + if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + if {[string equal -nocase "aqadapter" "${IP}"]} { + ::scobj::ls336::sics_log 9 "makesctcontroller sct_${name} aqadapter ${port}" + makesctcontroller sct_${name} aqadapter ${port} + } else { + ::scobj::ls336::sics_log 9 "makesctcontroller sct_${name} std ${IP}:${port}" + makesctcontroller sct_${name} std ${IP}:${port} + } + } else { + ::scobj::ls336::sics_log 9 "[environment_simulation] => No sctcontroller for ls336" + } + ::scobj::ls336::sics_log 1 "::scobj::ls336::mkDriver sct_${name} ${name} ${id} ${datype} ${tol1} ${tol2}" + ::scobj::ls336::mkDriver sct_${name} ${name} ${id} ${datype} ${tol1} ${tol2} + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + +clientput "file evaluation of sct_ls336.tcl" +::scobj::ls336::sics_log 9 "file evaluation of sct_ls336.tcl" + +proc ::scobj::ls336::read_config {} { + set catch_status [ catch { + set ns "::scobj::ls336" + 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 $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 + } + set v [dict get $::config_dict $implementation] + if { !([dict exists $v "driver"]) } { + continue + } + if { [string equal -nocase [dict get $v "driver"] "ls336"] } { + 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 + 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 datype tol1 tol2} { + 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_ls336 ${name} ${IP} ${PORT} {*}$arg_list + } else { + add_ls336 ${name} "aqadapter" ${asyncqueue} {*}$arg_list + } + } + } + } + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + +if { [info exists ::config_dict] } { + ::scobj::ls336::read_config +} else { + ::scobj::ls336::sics_log 5 "No config dict" +} diff --git a/site_ansto/instrument/config/environment/temperature/sct_ls340.tcl b/site_ansto/instrument/config/environment/temperature/sct_ls340.tcl new file mode 100644 index 00000000..bf33673a --- /dev/null +++ b/site_ansto/instrument/config/environment/temperature/sct_ls340.tcl @@ -0,0 +1,161 @@ +# Generated driver for ls340 +# vim: ft=tcl tabstop=8 softtabstop=2 shiftwidth=2 nocindent smartindent +# + +namespace eval ::scobj::ls340 { + set debug_threshold 5 +} + +proc ::scobj::ls340::debug_log {tc_root debug_level debug_string} { + set catch_status [ catch { + set debug_threshold [hgetpropval ${tc_root} debug_threshold] + if {${debug_level} >= ${debug_threshold}} { + set fd [open "../log/ls340_[basename ${tc_root}].log" "a"] + set line "[clock format [clock seconds] -format "%T"] ${debug_string}" + puts ${fd} "${line}" + close ${fd} + } + } catch_message ] +} + +proc ::scobj::ls340::sics_log {debug_level debug_string} { + set catch_status [ catch { + set debug_threshold ${::scobj::ls340::debug_threshold} + if {${debug_level} >= ${debug_threshold}} { + sicslog "::scobj::ls340::${debug_string}" + } + } catch_message ] +} + +proc ::scobj::ls340::mkDriver { sct_controller name id datype tol1 tol2 } { + ::scobj::ls340::sics_log 9 "::scobj::ls340::mkDriver ${sct_controller} ${name} ${id} ${datype} ${tol1} ${tol2}" + set ns "[namespace current]" + set catch_status [ catch { + + MakeSICSObj ${name} SCT_OBJECT + + sicslist setatt ${name} klass environment + sicslist setatt ${name} long_name ${name} + + set scobj_hpath /sics/${name} + hsetprop ${scobj_hpath} klass environment + hsetprop ${scobj_hpath} debug_threshold 5 +# mkDriver hook code starts + ::scobj::ls340::mk_sct_lakeshore_340 $sct_controller environment $name $id $datype $tol1 $tol2 0 +# mkDriver hook code ends + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + +namespace eval ::scobj::ls340 { + namespace export debug_threshold + namespace export debug_log + namespace export sics_log + namespace export mkDriver +} + +proc add_ls340 {name IP port id datype {tol1 1.0} {tol2 1.0}} { + set catch_status [ catch { + ::scobj::ls340::sics_log 9 "add_ls340 ${name} ${IP} ${port} ${id} ${datype} ${tol1} ${tol2}" + if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + if {[string equal -nocase "aqadapter" "${IP}"]} { + ::scobj::ls340::sics_log 9 "makesctcontroller sct_${name} aqadapter ${port}" + makesctcontroller sct_${name} aqadapter ${port} + } else { + ::scobj::ls340::sics_log 9 "makesctcontroller sct_${name} std ${IP}:${port}" + makesctcontroller sct_${name} std ${IP}:${port} + } + } else { + ::scobj::ls340::sics_log 9 "[environment_simulation] => No sctcontroller for ls340" + } + ::scobj::ls340::sics_log 1 "::scobj::ls340::mkDriver sct_${name} ${name} ${id} ${datype} ${tol1} ${tol2}" + ::scobj::ls340::mkDriver sct_${name} ${name} ${id} ${datype} ${tol1} ${tol2} + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + +clientput "file evaluation of sct_ls340.tcl" +::scobj::ls340::sics_log 9 "file evaluation of sct_ls340.tcl" + +proc ::scobj::ls340::read_config {} { + set catch_status [ catch { + set ns "::scobj::ls340" + 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 $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 + } + set v [dict get $::config_dict $implementation] + if { !([dict exists $v "driver"]) } { + continue + } + if { [string equal -nocase [dict get $v "driver"] "ls340"] } { + 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 + 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 datype tol1 tol2} { + 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_ls340 ${name} ${IP} ${PORT} {*}$arg_list + } else { + add_ls340 ${name} "aqadapter" ${asyncqueue} {*}$arg_list + } + } + } + } + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + +if { [info exists ::config_dict] } { + ::scobj::ls340::read_config +} else { + ::scobj::ls340::sics_log 5 "No config dict" +} diff --git a/site_ansto/instrument/config/environment/temperature/sct_nprvasm2.tcl b/site_ansto/instrument/config/environment/temperature/sct_nprvasm2.tcl new file mode 100644 index 00000000..a5d27553 --- /dev/null +++ b/site_ansto/instrument/config/environment/temperature/sct_nprvasm2.tcl @@ -0,0 +1,161 @@ +# Generated driver for nprvasm2 +# vim: ft=tcl tabstop=8 softtabstop=2 shiftwidth=2 nocindent smartindent +# + +namespace eval ::scobj::nprvasm2 { + set debug_threshold 5 +} + +proc ::scobj::nprvasm2::debug_log {tc_root debug_level debug_string} { + set catch_status [ catch { + set debug_threshold [hgetpropval ${tc_root} debug_threshold] + if {${debug_level} >= ${debug_threshold}} { + set fd [open "../log/nprvasm2_[basename ${tc_root}].log" "a"] + set line "[clock format [clock seconds] -format "%T"] ${debug_string}" + puts ${fd} "${line}" + close ${fd} + } + } catch_message ] +} + +proc ::scobj::nprvasm2::sics_log {debug_level debug_string} { + set catch_status [ catch { + set debug_threshold ${::scobj::nprvasm2::debug_threshold} + if {${debug_level} >= ${debug_threshold}} { + sicslog "::scobj::nprvasm2::${debug_string}" + } + } catch_message ] +} + +proc ::scobj::nprvasm2::mkDriver { sct_controller name tol } { + ::scobj::nprvasm2::sics_log 9 "::scobj::nprvasm2::mkDriver ${sct_controller} ${name} ${tol}" + set ns "[namespace current]" + set catch_status [ catch { + + MakeSICSObj ${name} SCT_OBJECT + + sicslist setatt ${name} klass environment + sicslist setatt ${name} long_name ${name} + + set scobj_hpath /sics/${name} + hsetprop ${scobj_hpath} klass environment + hsetprop ${scobj_hpath} debug_threshold 5 +# mkDriver hook code starts + mk_sct_newport_rva sct_${name} environment $name $tol +# mkDriver hook code ends + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + +namespace eval ::scobj::nprvasm2 { + namespace export debug_threshold + namespace export debug_log + namespace export sics_log + namespace export mkDriver +} + +proc add_nprvasm2 {name IP port {tol 1.0}} { + set catch_status [ catch { + ::scobj::nprvasm2::sics_log 9 "add_nprvasm2 ${name} ${IP} ${port} ${tol}" + if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + if {[string equal -nocase "aqadapter" "${IP}"]} { + ::scobj::nprvasm2::sics_log 9 "makesctcontroller sct_${name} aqadapter ${port}" + makesctcontroller sct_${name} aqadapter ${port} + } else { + ::scobj::nprvasm2::sics_log 9 "makesctcontroller sct_${name} std ${IP}:${port}" + makesctcontroller sct_${name} std ${IP}:${port} + } + } else { + ::scobj::nprvasm2::sics_log 9 "[environment_simulation] => No sctcontroller for nprvasm2" + } + ::scobj::nprvasm2::sics_log 1 "::scobj::nprvasm2::mkDriver sct_${name} ${name} ${tol}" + ::scobj::nprvasm2::mkDriver sct_${name} ${name} ${tol} + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + +clientput "file evaluation of sct_nprvasm2.tcl" +::scobj::nprvasm2::sics_log 9 "file evaluation of sct_nprvasm2.tcl" + +proc ::scobj::nprvasm2::read_config {} { + set catch_status [ catch { + set ns "::scobj::nprvasm2" + 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 $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 + } + set v [dict get $::config_dict $implementation] + if { !([dict exists $v "driver"]) } { + continue + } + if { [string equal -nocase [dict get $v "driver"] "nprvasm2"] } { + 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 + 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 {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_nprvasm2 ${name} ${IP} ${PORT} {*}$arg_list + } else { + add_nprvasm2 ${name} "aqadapter" ${asyncqueue} {*}$arg_list + } + } + } + } + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + +if { [info exists ::config_dict] } { + ::scobj::nprvasm2::read_config +} else { + ::scobj::nprvasm2::sics_log 5 "No config dict" +} diff --git a/site_ansto/instrument/config/environment/temperature/sct_watlow_mpm.tcl b/site_ansto/instrument/config/environment/temperature/sct_watlow_mpm.tcl new file mode 100644 index 00000000..132762fd --- /dev/null +++ b/site_ansto/instrument/config/environment/temperature/sct_watlow_mpm.tcl @@ -0,0 +1,161 @@ +# Generated driver for watlow_mpm +# vim: ft=tcl tabstop=8 softtabstop=2 shiftwidth=2 nocindent smartindent +# + +namespace eval ::scobj::watlow_mpm { + set debug_threshold 5 +} + +proc ::scobj::watlow_mpm::debug_log {tc_root debug_level debug_string} { + set catch_status [ catch { + set debug_threshold [hgetpropval ${tc_root} debug_threshold] + if {${debug_level} >= ${debug_threshold}} { + set fd [open "../log/watlow_mpm_[basename ${tc_root}].log" "a"] + set line "[clock format [clock seconds] -format "%T"] ${debug_string}" + puts ${fd} "${line}" + close ${fd} + } + } catch_message ] +} + +proc ::scobj::watlow_mpm::sics_log {debug_level debug_string} { + set catch_status [ catch { + set debug_threshold ${::scobj::watlow_mpm::debug_threshold} + if {${debug_level} >= ${debug_threshold}} { + sicslog "::scobj::watlow_mpm::${debug_string}" + } + } catch_message ] +} + +proc ::scobj::watlow_mpm::mkDriver { sct_controller name id datype dev_id tol } { + ::scobj::watlow_mpm::sics_log 9 "::scobj::watlow_mpm::mkDriver ${sct_controller} ${name} ${id} ${datype} ${dev_id} ${tol}" + set ns "[namespace current]" + set catch_status [ catch { + + MakeSICSObj ${name} SCT_OBJECT user float + + sicslist setatt ${name} klass environment + sicslist setatt ${name} long_name ${name} + + set scobj_hpath /sics/${name} + hsetprop ${scobj_hpath} klass environment + hsetprop ${scobj_hpath} debug_threshold 5 +# mkDriver hook code starts + mk_sct_watlow_pm $sct_controller environment $name $dev_id $tol $id $datype +# mkDriver hook code ends + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + +namespace eval ::scobj::watlow_mpm { + namespace export debug_threshold + namespace export debug_log + namespace export sics_log + namespace export mkDriver +} + +proc add_watlow_mpm {name IP port id datype dev_id tol} { + set catch_status [ catch { + ::scobj::watlow_mpm::sics_log 9 "add_watlow_mpm ${name} ${IP} ${port} ${id} ${datype} ${dev_id} ${tol}" + if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + if {[string equal -nocase "aqadapter" "${IP}"]} { + ::scobj::watlow_mpm::sics_log 9 "makesctcontroller sct_${name} aqadapter ${port}" + makesctcontroller sct_${name} aqadapter ${port} + } else { + ::scobj::watlow_mpm::sics_log 9 "makesctcontroller sct_${name} std ${IP}:${port}" + makesctcontroller sct_${name} std ${IP}:${port} + } + } else { + ::scobj::watlow_mpm::sics_log 9 "[environment_simulation] => No sctcontroller for watlow_mpm" + } + ::scobj::watlow_mpm::sics_log 1 "::scobj::watlow_mpm::mkDriver sct_${name} ${name} ${id} ${datype} ${dev_id} ${tol}" + ::scobj::watlow_mpm::mkDriver sct_${name} ${name} ${id} ${datype} ${dev_id} ${tol} + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + +clientput "file evaluation of sct_watlow_mpm.tcl" +::scobj::watlow_mpm::sics_log 9 "file evaluation of sct_watlow_mpm.tcl" + +proc ::scobj::watlow_mpm::read_config {} { + set catch_status [ catch { + set ns "::scobj::watlow_mpm" + 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 $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 + } + set v [dict get $::config_dict $implementation] + if { !([dict exists $v "driver"]) } { + continue + } + if { [string equal -nocase [dict get $v "driver"] "watlow_mpm"] } { + 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 + 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 datype dev_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_watlow_mpm ${name} ${IP} ${PORT} {*}$arg_list + } else { + add_watlow_mpm ${name} "aqadapter" ${asyncqueue} {*}$arg_list + } + } + } + } + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + +if { [info exists ::config_dict] } { + ::scobj::watlow_mpm::read_config +} else { + ::scobj::watlow_mpm::sics_log 5 "No config dict" +} diff --git a/site_ansto/instrument/config/environment/temperature/sct_watlow_mrm.tcl b/site_ansto/instrument/config/environment/temperature/sct_watlow_mrm.tcl new file mode 100644 index 00000000..03ecb75c --- /dev/null +++ b/site_ansto/instrument/config/environment/temperature/sct_watlow_mrm.tcl @@ -0,0 +1,161 @@ +# Generated driver for watlow_mrm +# vim: ft=tcl tabstop=8 softtabstop=2 shiftwidth=2 nocindent smartindent +# + +namespace eval ::scobj::watlow_mrm { + set debug_threshold 5 +} + +proc ::scobj::watlow_mrm::debug_log {tc_root debug_level debug_string} { + set catch_status [ catch { + set debug_threshold [hgetpropval ${tc_root} debug_threshold] + if {${debug_level} >= ${debug_threshold}} { + set fd [open "../log/watlow_mrm_[basename ${tc_root}].log" "a"] + set line "[clock format [clock seconds] -format "%T"] ${debug_string}" + puts ${fd} "${line}" + close ${fd} + } + } catch_message ] +} + +proc ::scobj::watlow_mrm::sics_log {debug_level debug_string} { + set catch_status [ catch { + set debug_threshold ${::scobj::watlow_mrm::debug_threshold} + if {${debug_level} >= ${debug_threshold}} { + sicslog "::scobj::watlow_mrm::${debug_string}" + } + } catch_message ] +} + +proc ::scobj::watlow_mrm::mkDriver { sct_controller name id datype dev_id tol } { + ::scobj::watlow_mrm::sics_log 9 "::scobj::watlow_mrm::mkDriver ${sct_controller} ${name} ${id} ${datype} ${dev_id} ${tol}" + set ns "[namespace current]" + set catch_status [ catch { + + MakeSICSObj ${name} SCT_OBJECT user float + + sicslist setatt ${name} klass environment + sicslist setatt ${name} long_name ${name} + + set scobj_hpath /sics/${name} + hsetprop ${scobj_hpath} klass environment + hsetprop ${scobj_hpath} debug_threshold 5 +# mkDriver hook code starts + mk_sct_watlow_rm $sct_controller environment $name $dev_id $tol $id $datype +# mkDriver hook code ends + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + +namespace eval ::scobj::watlow_mrm { + namespace export debug_threshold + namespace export debug_log + namespace export sics_log + namespace export mkDriver +} + +proc add_watlow_mrm {name IP port id datype dev_id tol} { + set catch_status [ catch { + ::scobj::watlow_mrm::sics_log 9 "add_watlow_mrm ${name} ${IP} ${port} ${id} ${datype} ${dev_id} ${tol}" + if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + if {[string equal -nocase "aqadapter" "${IP}"]} { + ::scobj::watlow_mrm::sics_log 9 "makesctcontroller sct_${name} aqadapter ${port}" + makesctcontroller sct_${name} aqadapter ${port} + } else { + ::scobj::watlow_mrm::sics_log 9 "makesctcontroller sct_${name} std ${IP}:${port}" + makesctcontroller sct_${name} std ${IP}:${port} + } + } else { + ::scobj::watlow_mrm::sics_log 9 "[environment_simulation] => No sctcontroller for watlow_mrm" + } + ::scobj::watlow_mrm::sics_log 1 "::scobj::watlow_mrm::mkDriver sct_${name} ${name} ${id} ${datype} ${dev_id} ${tol}" + ::scobj::watlow_mrm::mkDriver sct_${name} ${name} ${id} ${datype} ${dev_id} ${tol} + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + +clientput "file evaluation of sct_watlow_mrm.tcl" +::scobj::watlow_mrm::sics_log 9 "file evaluation of sct_watlow_mrm.tcl" + +proc ::scobj::watlow_mrm::read_config {} { + set catch_status [ catch { + set ns "::scobj::watlow_mrm" + 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 $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 + } + set v [dict get $::config_dict $implementation] + if { !([dict exists $v "driver"]) } { + continue + } + if { [string equal -nocase [dict get $v "driver"] "watlow_mrm"] } { + 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 + 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 datype dev_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_watlow_mrm ${name} ${IP} ${PORT} {*}$arg_list + } else { + add_watlow_mrm ${name} "aqadapter" ${asyncqueue} {*}$arg_list + } + } + } + } + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + +if { [info exists ::config_dict] } { + ::scobj::watlow_mrm::read_config +} else { + ::scobj::watlow_mrm::sics_log 5 "No config dict" +} diff --git a/site_ansto/instrument/config/environment/temperature/sct_watlow_mst4.tcl b/site_ansto/instrument/config/environment/temperature/sct_watlow_mst4.tcl new file mode 100644 index 00000000..cfabdd2a --- /dev/null +++ b/site_ansto/instrument/config/environment/temperature/sct_watlow_mst4.tcl @@ -0,0 +1,161 @@ +# Generated driver for watlow_mst4 +# vim: ft=tcl tabstop=8 softtabstop=2 shiftwidth=2 nocindent smartindent +# + +namespace eval ::scobj::watlow_mst4 { + set debug_threshold 5 +} + +proc ::scobj::watlow_mst4::debug_log {tc_root debug_level debug_string} { + set catch_status [ catch { + set debug_threshold [hgetpropval ${tc_root} debug_threshold] + if {${debug_level} >= ${debug_threshold}} { + set fd [open "../log/watlow_mst4_[basename ${tc_root}].log" "a"] + set line "[clock format [clock seconds] -format "%T"] ${debug_string}" + puts ${fd} "${line}" + close ${fd} + } + } catch_message ] +} + +proc ::scobj::watlow_mst4::sics_log {debug_level debug_string} { + set catch_status [ catch { + set debug_threshold ${::scobj::watlow_mst4::debug_threshold} + if {${debug_level} >= ${debug_threshold}} { + sicslog "::scobj::watlow_mst4::${debug_string}" + } + } catch_message ] +} + +proc ::scobj::watlow_mst4::mkDriver { sct_controller name id datype dev_id tol } { + ::scobj::watlow_mst4::sics_log 9 "::scobj::watlow_mst4::mkDriver ${sct_controller} ${name} ${id} ${datype} ${dev_id} ${tol}" + set ns "[namespace current]" + set catch_status [ catch { + + MakeSICSObj ${name} SCT_OBJECT user float + + sicslist setatt ${name} klass environment + sicslist setatt ${name} long_name ${name} + + set scobj_hpath /sics/${name} + hsetprop ${scobj_hpath} klass environment + hsetprop ${scobj_hpath} debug_threshold 5 +# mkDriver hook code starts + mk_sct_watlow_st $sct_controller environment $name $dev_id $tol $id $datype +# mkDriver hook code ends + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + +namespace eval ::scobj::watlow_mst4 { + namespace export debug_threshold + namespace export debug_log + namespace export sics_log + namespace export mkDriver +} + +proc add_watlow_mst4 {name IP port id datype dev_id tol} { + set catch_status [ catch { + ::scobj::watlow_mst4::sics_log 9 "add_watlow_mst4 ${name} ${IP} ${port} ${id} ${datype} ${dev_id} ${tol}" + if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + if {[string equal -nocase "aqadapter" "${IP}"]} { + ::scobj::watlow_mst4::sics_log 9 "makesctcontroller sct_${name} aqadapter ${port}" + makesctcontroller sct_${name} aqadapter ${port} + } else { + ::scobj::watlow_mst4::sics_log 9 "makesctcontroller sct_${name} std ${IP}:${port}" + makesctcontroller sct_${name} std ${IP}:${port} + } + } else { + ::scobj::watlow_mst4::sics_log 9 "[environment_simulation] => No sctcontroller for watlow_mst4" + } + ::scobj::watlow_mst4::sics_log 1 "::scobj::watlow_mst4::mkDriver sct_${name} ${name} ${id} ${datype} ${dev_id} ${tol}" + ::scobj::watlow_mst4::mkDriver sct_${name} ${name} ${id} ${datype} ${dev_id} ${tol} + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + +clientput "file evaluation of sct_watlow_mst4.tcl" +::scobj::watlow_mst4::sics_log 9 "file evaluation of sct_watlow_mst4.tcl" + +proc ::scobj::watlow_mst4::read_config {} { + set catch_status [ catch { + set ns "::scobj::watlow_mst4" + 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 $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 + } + set v [dict get $::config_dict $implementation] + if { !([dict exists $v "driver"]) } { + continue + } + if { [string equal -nocase [dict get $v "driver"] "watlow_mst4"] } { + 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 + 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 datype dev_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_watlow_mst4 ${name} ${IP} ${PORT} {*}$arg_list + } else { + add_watlow_mst4 ${name} "aqadapter" ${asyncqueue} {*}$arg_list + } + } + } + } + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + +if { [info exists ::config_dict] } { + ::scobj::watlow_mst4::read_config +} else { + ::scobj::watlow_mst4::sics_log 5 "No config dict" +} diff --git a/site_ansto/instrument/config/environment/temperature/sct_west4100.tcl b/site_ansto/instrument/config/environment/temperature/sct_west4100.tcl new file mode 100644 index 00000000..0933f6cf --- /dev/null +++ b/site_ansto/instrument/config/environment/temperature/sct_west4100.tcl @@ -0,0 +1,156 @@ +# Generated driver for west4100 +# vim: ft=tcl tabstop=8 softtabstop=2 shiftwidth=2 nocindent smartindent +# + +namespace eval ::scobj::west4100 { + set debug_threshold 5 +} + +proc ::scobj::west4100::debug_log {tc_root debug_level debug_string} { + set catch_status [ catch { + set debug_threshold [hgetpropval ${tc_root} debug_threshold] + if {${debug_level} >= ${debug_threshold}} { + set fd [open "../log/west4100_[basename ${tc_root}].log" "a"] + set line "[clock format [clock seconds] -format "%T"] ${debug_string}" + puts ${fd} "${line}" + close ${fd} + } + } catch_message ] +} + +proc ::scobj::west4100::sics_log {debug_level debug_string} { + set catch_status [ catch { + set debug_threshold ${::scobj::west4100::debug_threshold} + if {${debug_level} >= ${debug_threshold}} { + sicslog "::scobj::west4100::${debug_string}" + } + } catch_message ] +} + +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 { + + MakeSICSObj ${name} SCT_OBJECT + + sicslist setatt ${name} klass environment + sicslist setatt ${name} long_name ${name} + + set scobj_hpath /sics/${name} + hsetprop ${scobj_hpath} klass environment + hsetprop ${scobj_hpath} debug_threshold 5 +# mkDriver hook code starts + ::environment::temperature::mkwest400 $name $IP $dev_id +# mkDriver hook code ends + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + +namespace eval ::scobj::west4100 { + namespace export debug_threshold + namespace export debug_log + namespace export sics_log + namespace export mkDriver +} + +proc add_west4100 {name IP port dev_id} { + set catch_status [ catch { + ::scobj::west4100::sics_log 9 "add_west4100 ${name} ${IP} ${port} ${IP} ${dev_id}" + if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + if {[string equal -nocase "aqadapter" "${IP}"]} { + ::scobj::west4100::sics_log 9 "makesctcontroller sct_${name} aqadapter ${port}" + makesctcontroller sct_${name} aqadapter ${port} + } else { + ::scobj::west4100::sics_log 9 "makesctcontroller sct_${name} std ${IP}:${port}" + makesctcontroller sct_${name} std ${IP}:${port} + } + } else { + ::scobj::west4100::sics_log 9 "[environment_simulation] => No sctcontroller for west4100" + } + ::scobj::west4100::sics_log 1 "::scobj::west4100::mkDriver sct_${name} ${name} ${IP} ${dev_id}" + ::scobj::west4100::mkDriver sct_${name} ${name} ${IP} ${dev_id} + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + +clientput "file evaluation of sct_west4100.tcl" +::scobj::west4100::sics_log 9 "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"]) } { + continue + } + set enabled [string tolower [dict get $v "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"] + if { !([dict exists $::config_dict $implementation]) } { + continue + } + set arg_list [list] + set v [dict get $::config_dict $implementation] + if { !([dict exists $v "driver"]) } { + continue + } + if { [string equal -nocase [dict get $v "driver"] "west4100"] } { + 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 + 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 {IP dev_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" + } + } + if { [string equal -nocase ${asyncqueue} "sct"] } { + add_west4100 ${name} ${IP} ${PORT} {*}$arg_list + } else { + add_west4100 ${name} "aqadapter" ${asyncqueue} {*}$arg_list + } + } + } + } + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + +if { [info exists ::config_dict] } { + ::scobj::west4100::read_config +} else { + ::scobj::west4100::sics_log 5 "No config dict" +} diff --git a/site_ansto/instrument/sans/config/environment/sct_antonparr_MCR500.tcl b/site_ansto/instrument/sans/config/environment/sct_antonparr_MCR500.tcl new file mode 100644 index 00000000..bd93bd8c --- /dev/null +++ b/site_ansto/instrument/sans/config/environment/sct_antonparr_MCR500.tcl @@ -0,0 +1,110 @@ +# Generated driver for antonparr_MCR500 +# vim: ft=tcl tabstop=8 softtabstop=2 shiftwidth=2 nocindent smartindent +# + +namespace eval ::scobj::antonparr_MCR500 { + set debug_threshold 5 +} + +proc ::scobj::antonparr_MCR500::debug_log {tc_root debug_level debug_string} { + set catch_status [ catch { + set debug_threshold [hgetpropval ${tc_root} debug_threshold] + if {${debug_level} >= ${debug_threshold}} { + set fd [open "../log/antonparr_MCR500_[basename ${tc_root}].log" "a"] + set line "[clock format [clock seconds] -format "%T"] ${debug_string}" + puts ${fd} "${line}" + close ${fd} + } + } catch_message ] +} + +proc ::scobj::antonparr_MCR500::sics_log {debug_level debug_string} { + set catch_status [ catch { + set debug_threshold ${::scobj::antonparr_MCR500::debug_threshold} + if {${debug_level} >= ${debug_threshold}} { + sicslog "::scobj::antonparr_MCR500::${debug_string}" + } + } catch_message ] +} + +proc ::scobj::antonparr_MCR500::mkDriver { speed_name torque_name tol settle } { + ::scobj::antonparr_MCR500::sics_log 9 "::scobj::antonparr_MCR500::mkDriver ${speed_name} ${torque_name} ${tol} ${settle}" + set ns "[namespace current]" + set catch_status [ catch { + +# mkDriver hook code starts + add_rheo $speed_name $tol $settle + add_rheo $torque_name $tol $settle +# mkDriver hook code ends + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + +namespace eval ::scobj::antonparr_MCR500 { + namespace export debug_threshold + namespace export debug_log + namespace export sics_log + namespace export mkDriver +} + +proc add_antonparr_MCR500 {speed_name torque_name tol settle} { + set catch_status [ catch { + ::scobj::antonparr_MCR500::sics_log 9 "add_antonparr_MCR500 ${speed_name} ${torque_name} ${tol} ${settle}" + ::scobj::antonparr_MCR500::sics_log 1 "::scobj::antonparr_MCR500::mkDriver ${speed_name} ${torque_name} ${tol} ${settle}" + ::scobj::antonparr_MCR500::mkDriver ${speed_name} ${torque_name} ${tol} ${settle} + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + +clientput "file evaluation of sct_antonparr_MCR500.tcl" +::scobj::antonparr_MCR500::sics_log 9 "file evaluation of sct_antonparr_MCR500.tcl" + +proc ::scobj::antonparr_MCR500::read_config {} { + set catch_status [ catch { + set ns "::scobj::antonparr_MCR500" + dict for {k u} $::config_dict { + if { [dict exists $u "implementation"] } { + if { ![dict exists $u "enabled"] } { + continue + } + set enabled [string tolower [dict get $u "enabled"]] + if { ! ([string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"]) } { + continue + } + set implementation [dict get $u "implementation"] + if { !([dict exists $::config_dict $implementation]) } { + continue + } + set v [dict get $::config_dict $implementation] + if { !([dict exists $v "driver"]) } { + continue + } + if { [string equal -nocase [dict get $v "driver"] "antonparr_MCR500"] } { + set arg_list [list] + set missing_list [list] + foreach arg {speed_name torque_name tol settle} { + 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 "Rheometer is missing configuration values $missing_list" + } + add_antonparr_MCR500 {*}$arg_list + } + } + } + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + +if { [info exists ::config_dict] } { + ::scobj::antonparr_MCR500::read_config +} else { + ::scobj::antonparr_MCR500::sics_log 5 "No config dict" +}