From 944902c9d4d02446dd352eac3b5c68602a6fe12d Mon Sep 17 00:00:00 2001 From: Ferdi Franceschini Date: Fri, 8 Aug 2014 09:19:11 +1000 Subject: [PATCH] Added sct wrapper to load legacy sct_oxford_labview.tcl driver. --- .../environment/magneticField/oxford12tlv.sct | 16 ++ .../magneticField/sct_oxford12tlv.tcl | 167 ++++++++++++++++++ .../magneticField/sct_oxford_labview.tcl | 131 ++------------ .../instrument/hipd/util/sics_config.ini | 1 + .../instrument/hipd/wombat_configuration.tcl | 1 + .../instrument/hrpd/echidna_configuration.tcl | 1 + .../instrument/hrpd/util/sics_config.ini | 1 + .../pelican/pelican_configuration.tcl | 1 + .../instrument/pelican/util/sics_config.ini | 4 +- .../instrument/rsd/kowari_configuration.tcl | 3 +- .../instrument/sans/util/sics_config.ini | 1 + 11 files changed, 209 insertions(+), 118 deletions(-) create mode 100644 site_ansto/instrument/config/environment/magneticField/oxford12tlv.sct create mode 100644 site_ansto/instrument/config/environment/magneticField/sct_oxford12tlv.tcl diff --git a/site_ansto/instrument/config/environment/magneticField/oxford12tlv.sct b/site_ansto/instrument/config/environment/magneticField/oxford12tlv.sct new file mode 100644 index 00000000..09f685d4 --- /dev/null +++ b/site_ansto/instrument/config/environment/magneticField/oxford12tlv.sct @@ -0,0 +1,16 @@ +# vim: ts=8 sts=2 sw=2 expandtab autoindent smartindent nocindent +driver oxford12tlv = { + protocol = std + class = environment + simulation_group = environment_simulation + add_args = 'id datype interval' + make_args = 'id datype interval' + code mkDriver = {%% + ::scobj::magnetic::mkMagnetic [subst { + NAME $name + SCTCONTROLLER $sct_controller + TUNING 1 + INTERVAL $interval + }] + %%} +} diff --git a/site_ansto/instrument/config/environment/magneticField/sct_oxford12tlv.tcl b/site_ansto/instrument/config/environment/magneticField/sct_oxford12tlv.tcl new file mode 100644 index 00000000..078152fc --- /dev/null +++ b/site_ansto/instrument/config/environment/magneticField/sct_oxford12tlv.tcl @@ -0,0 +1,167 @@ +# Generated driver for oxford12tlv +# vim: ft=tcl tabstop=8 softtabstop=2 shiftwidth=2 nocindent smartindent +# + +namespace eval ::scobj::oxford12tlv { + set debug_threshold 5 +} + +proc ::scobj::oxford12tlv::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/oxford12tlv_[basename ${tc_root}].log" "a"] + set line "[clock format [clock seconds] -format "%T"] ${debug_string}" + puts ${fd} "${line}" + close ${fd} + } + } catch_message ] +} + +proc ::scobj::oxford12tlv::sics_log {debug_level debug_string} { + set catch_status [ catch { + set debug_threshold ${::scobj::oxford12tlv::debug_threshold} + if {${debug_level} >= ${debug_threshold}} { + sicslog "::scobj::oxford12tlv::${debug_string}" + } + } catch_message ] +} + +proc ::scobj::oxford12tlv::mkDriver { sct_controller name id datype interval } { + ::scobj::oxford12tlv::sics_log 9 "::scobj::oxford12tlv::mkDriver ${sct_controller} ${name} ${id} ${datype} ${interval}" + 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} data true + hsetprop ${scobj_hpath} debug_threshold 5 +# mkDriver hook code starts + ::scobj::magnetic::mkMagnetic [subst { + NAME $name + SCTCONTROLLER $sct_controller + TUNING 1 + INTERVAL $interval + }] +# mkDriver hook code ends + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + +namespace eval ::scobj::oxford12tlv { + namespace export debug_threshold + namespace export debug_log + namespace export sics_log + namespace export mkDriver +} + +proc add_oxford12tlv {name IP port id datype interval} { + set catch_status [ catch { + ::scobj::oxford12tlv::sics_log 9 "add_oxford12tlv ${name} ${IP} ${port} ${id} ${datype} ${interval}" + if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + if {[string equal -nocase "aqadapter" "${IP}"]} { + ::scobj::oxford12tlv::sics_log 9 "makesctcontroller sct_${name} aqadapter ${port}" + makesctcontroller sct_${name} aqadapter ${port} + } else { + ::scobj::oxford12tlv::sics_log 9 "makesctcontroller sct_${name} std ${IP}:${port}" + makesctcontroller sct_${name} std ${IP}:${port} + } + } else { + ::scobj::oxford12tlv::sics_log 9 "[environment_simulation] => No sctcontroller for oxford12tlv" + } + ::scobj::oxford12tlv::sics_log 1 "::scobj::oxford12tlv::mkDriver sct_${name} ${name} ${id} ${datype} ${interval}" + ::scobj::oxford12tlv::mkDriver sct_${name} ${name} ${id} ${datype} ${interval} + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + +clientput "file evaluation of sct_oxford12tlv.tcl" +::scobj::oxford12tlv::sics_log 9 "file evaluation of sct_oxford12tlv.tcl" + +proc ::scobj::oxford12tlv::read_config {} { + set catch_status [ catch { + set ns "::scobj::oxford12tlv" + 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"] "oxford12tlv"] } { + 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 interval} { + 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_oxford12tlv ${name} ${IP} ${PORT} {*}$arg_list + } else { + add_oxford12tlv ${name} "aqadapter" ${asyncqueue} {*}$arg_list + } + } + } + } + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + +if { [info exists ::config_dict] } { + ::scobj::oxford12tlv::read_config +} else { + ::scobj::oxford12tlv::sics_log 5 "No config dict" +} diff --git a/site_ansto/instrument/config/environment/magneticField/sct_oxford_labview.tcl b/site_ansto/instrument/config/environment/magneticField/sct_oxford_labview.tcl index d9855ed8..5eef01c2 100644 --- a/site_ansto/instrument/config/environment/magneticField/sct_oxford_labview.tcl +++ b/site_ansto/instrument/config/environment/magneticField/sct_oxford_labview.tcl @@ -239,7 +239,6 @@ proc ::scobj::magnetic::mkMagnetic {argList} { set pa($KEY) $v } - MakeSICSObj $pa(NAME) SCT_OBJECT sicslist setatt $pa(NAME) klass environment sicslist setatt $pa(NAME) long_name $pa(NAME) @@ -342,7 +341,7 @@ proc ::scobj::magnetic::mkMagnetic {argList} { # hset /sics/$fPath/end_temperature_s3 [hval /sics/$fPath/Temp_s3] # } - makesctcontroller sct_magnetic std $pa(IP):$pa(PORT) + set ::scobj::magnetic::sct_name $pa(SCTCONTROLLER) hsetprop $hPath/field read ::scobj::magnetic::rqFieldFunc hsetprop $hPath/field rdFieldState ::scobj::magnetic::rdFieldStateFunc $hPath @@ -357,10 +356,10 @@ proc ::scobj::magnetic::mkMagnetic {argList} { hsetprop $hPath/DilutTempReading rdTempState ::scobj::magnetic::rdTempStateFunc $hPath "Dilut" if {[SplitReply [environment_simulation]]=="false"} { - sct_magnetic poll $hPath/field $pa(INTERVAL) - sct_magnetic poll $hPath/Temp $pa(INTERVAL) - sct_magnetic poll $hPath/HelioxTempReading $pa(INTERVAL) - sct_magnetic poll $hPath/DilutTempReading $pa(INTERVAL) + $pa(SCTCONTROLLER) poll $hPath/field $pa(INTERVAL) + $pa(SCTCONTROLLER) poll $hPath/Temp $pa(INTERVAL) + $pa(SCTCONTROLLER) poll $hPath/HelioxTempReading $pa(INTERVAL) + $pa(SCTCONTROLLER) poll $hPath/DilutTempReading $pa(INTERVAL) } hsetprop $hPath tuning $pa(TUNING) @@ -381,11 +380,11 @@ proc ::scobj::magnetic::mkMagnetic {argList} { hsetprop $hPath/set_magneticField checkReply ::scobj::magnetic::checkReplyFunc $hPath if {[SplitReply [environment_simulation]]=="false"} { - sct_magnetic write $hPath/set_rate - sct_magnetic write $hPath/set_magneticField - sct_magnetic write $hPath/set_DiluxTemp - sct_magnetic write $hPath/set_HelioxTemp - sct_magnetic write $hPath/set_HeaterSwitch + $pa(SCTCONTROLLER) write $hPath/set_rate + $pa(SCTCONTROLLER) write $hPath/set_magneticField + $pa(SCTCONTROLLER) write $hPath/set_DiluxTemp + $pa(SCTCONTROLLER) write $hPath/set_HelioxTemp + $pa(SCTCONTROLLER) write $hPath/set_HeaterSwitch } } } @@ -406,10 +405,10 @@ proc OxfordSetField {{setPoint ""} {mode ""} args} { if {$mode == ""} { set comm "setF $setPoint\r\n" - sct_magnetic send $comm + $::scobj::magnetic::sct_name send $comm } elseif {$mode == "P"} { set comm "setF $setPoint Pers\r\n" - sct_magnetic send $comm + $::scobj::magnetic::sct_name send $comm } else { broadcast "Wrong parameters being provided, check!" return @@ -436,7 +435,7 @@ proc OxfordSetRate {{setRate ""} args} { hset /sample/$NAME/fieldSetRate $setRate set comm "setR $setRate\r\n" - sct_magnetic send $comm + $::scobj::magnetic::sct_name send $comm } } @@ -449,7 +448,7 @@ proc OxfordSetHTemp {{temp ""} args} { #hset /sample/$NAME/HelioxTempSetPoint $temp set comm "setHelioxTemp $temp\r\n" - sct_magnetic send $comm + $::scobj::magnetic::sct_name send $comm #set num 0 #while { $num <= 40 && [expr abs([hval /sample/$NAME/HelioxTempSetPoint] - [hval /sample/$NAME/HelioxTempReading]) ] >= 0.001 } { @@ -470,7 +469,7 @@ proc OxfordSetDTemp {{temp ""} args} { hset /sample/$NAME/DilutTempSetPoint $temp set comm "setDilutTemp $temp\r\n" - sct_magnetic send $comm + $::scobj::magnetic::sct_name send $comm } } @@ -485,7 +484,7 @@ proc OxfordSetHS {mode} { } set comm "setHS [string toupper $mode]\r\n" - sct_magnetic send $comm + $::scobj::magnetic::sct_name send $comm broadcast "Wait 60 seconds for the operation to complete before reset the mode" } @@ -494,101 +493,3 @@ publish OxfordSetRate user publish OxfordSetHTemp user publish OxfordSetDTemp user publish OxfordSetHS user - -proc add_oxford_labview { name IP PORT {interval 5} } { - ::scobj::magnetic::mkMagnetic [subst { - name $name - IP $IP - PORT $PORT - tuning 1 - interval $interval - }] -} - -namespace eval ::scobj::oxford_labview { -set debug_threshold 5 -} -proc ::scobj::oxford_labview::sics_log {debug_level debug_string} { - set catch_status [ catch { - set debug_threshold ${::scobj::oxford_labview::debug_threshold} - if {${debug_level} >= ${debug_threshold}} { - sicslog "::scobj::oxford_labview::${debug_string}" - } - } catch_message ] -} - -clientput "file evaluation of sct_oxford_labview.tcl" -::scobj::oxford_labview::sics_log 9 "file evaluation of sct_oxford_labview.tcl" - -proc ::scobj::oxford_labview::read_config {} { - set catch_status [ catch { - set ns "::scobj::oxford_labview" - dict for {k v} $::config_dict { - if { [dict exists $v "implementation"] } { - if { !([dict exists $v "name"] && [dict exists $v "enabled"]) } { - continue - } - set name [dict get $v name] - set enabled [string tolower [dict get $v "enabled"]] - set implementation [dict get $v "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"] "oxford_labview"] } { - set driver [dict get $v driver] - ${ns}::sics_log 9 "Found ${name}: $driver" - 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 - ${ns}::sics_log 9 "${name}:${driver}: MakeAsyncProtocol ${asyncprotocol}" - 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] - ${ns}::sics_log 9 "${name}:${driver}: MakeAsyncQueue ${asyncqueue} ${asyncprotocol} ${IP} ${PORT}" - MakeAsyncQueue ${asyncqueue} ${asyncprotocol} ${IP} ${PORT} - if { [dict exists $v "timeout"] } { - ${asyncqueue} timeout "[dict get $v "timeout"]" - } - } - set arg_list [list] -# foreach arg {interval} { -# 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" -# } -# } - ${ns}::sics_log 9 "add_oxford_labview ${name} aqadapter ${asyncqueue} {*}$arg_list" - add_oxford_labview ${name} "aqadapter" ${asyncqueue} {*}$arg_list - } - } - } - } - } catch_message ] - handle_exception ${catch_status} ${catch_message} -} - -if { [info exists ::config_dict] } { - ::scobj::oxford_labview::read_config -} else { - ::scobj::oxford_labview::sics_log 5 "No config dict" -} diff --git a/site_ansto/instrument/hipd/util/sics_config.ini b/site_ansto/instrument/hipd/util/sics_config.ini index b51987bf..6e3403e8 100644 --- a/site_ansto/instrument/hipd/util/sics_config.ini +++ b/site_ansto/instrument/hipd/util/sics_config.ini @@ -103,6 +103,7 @@ implementation = normal_sample_stage name = sample_stage optype = motion_axis [12tmagnet_oxford] +asyncqueue = sct desc = "12 Tesla Oxford Magnet" driver = "oxford_labview" imptype = magnetic_field diff --git a/site_ansto/instrument/hipd/wombat_configuration.tcl b/site_ansto/instrument/hipd/wombat_configuration.tcl index 0459ad79..07290c1c 100644 --- a/site_ansto/instrument/hipd/wombat_configuration.tcl +++ b/site_ansto/instrument/hipd/wombat_configuration.tcl @@ -53,6 +53,7 @@ fileeval $cfPath(environment)/temperature/sct_qlink.tcl fileeval $cfPath(environment)/temperature/west400.tcl fileeval $cfPath(environment)/temperature/sct_west4100.tcl fileeval $cfPath(environment)/magneticField/sct_oxford_labview.tcl +fileeval $cfPath(environment)/magneticField/sct_oxford12tlv.tcl fileeval $cfPath(environment)/he3/sct_he3.tcl fileeval $cfPath(environment)/magneticField/sct_green_magnet.tcl fileeval $cfPath(hmm)/hmm_configuration.tcl diff --git a/site_ansto/instrument/hrpd/echidna_configuration.tcl b/site_ansto/instrument/hrpd/echidna_configuration.tcl index 53e296b6..b7a27da0 100644 --- a/site_ansto/instrument/hrpd/echidna_configuration.tcl +++ b/site_ansto/instrument/hrpd/echidna_configuration.tcl @@ -30,6 +30,7 @@ fileeval $cfPath(environment)/temperature/sct_eurotherm_2000.tcl fileeval $cfPath(environment)/sct_keithley_2700.tcl fileeval $cfPath(environment)/magneticField/sct_green_magnet.tcl fileeval $cfPath(environment)/magneticField/sct_oxford_labview.tcl +fileeval $cfPath(environment)/magneticField/sct_oxford12tlv.tcl fileeval $cfPath(environment)/sct_keithley_2700.tcl fileeval $cfPath(environment)/temperature/sct_lakeshore_336.tcl fileeval $cfPath(environment)/temperature/sct_lakeshore_340.tcl diff --git a/site_ansto/instrument/hrpd/util/sics_config.ini b/site_ansto/instrument/hrpd/util/sics_config.ini index 23c74376..3a98c09f 100644 --- a/site_ansto/instrument/hrpd/util/sics_config.ini +++ b/site_ansto/instrument/hrpd/util/sics_config.ini @@ -100,6 +100,7 @@ implementation = normal_sample_stage name = sample_stage optype = motion_axis [12tmagnet_oxford] +asyncqueue = sct desc = "12 Tesla Oxford Magnet" driver = "oxford_labview" imptype = magnetic_field diff --git a/site_ansto/instrument/pelican/pelican_configuration.tcl b/site_ansto/instrument/pelican/pelican_configuration.tcl index d035cf49..2598608d 100644 --- a/site_ansto/instrument/pelican/pelican_configuration.tcl +++ b/site_ansto/instrument/pelican/pelican_configuration.tcl @@ -56,6 +56,7 @@ fileeval $cfPath(environment)/temperature/sct_qlink.tcl fileeval $cfPath(environment)/temperature/west400.tcl fileeval $cfPath(environment)/temperature/sct_west4100.tcl fileeval $cfPath(environment)/magneticField/sct_oxford_labview.tcl +fileeval $cfPath(environment)/magneticField/sct_oxford12tlv.tcl fileeval $cfPath(environment)/he3/sct_he3.tcl fileeval $cfPath(environment)/magneticField/sct_green_magnet.tcl fileeval $cfPath(hmm)/hmm_configuration.tcl diff --git a/site_ansto/instrument/pelican/util/sics_config.ini b/site_ansto/instrument/pelican/util/sics_config.ini index 6ecdb579..53dfc3e2 100644 --- a/site_ansto/instrument/pelican/util/sics_config.ini +++ b/site_ansto/instrument/pelican/util/sics_config.ini @@ -89,9 +89,11 @@ implementation = normal_sample_stage name = sample_stage optype = motion_axis [12tmagnet_oxford] +asyncqueue = sct desc = "12 Tesla Oxford Magnet" -driver = "oxford_labview" +driver = "oxford12tlv" imptype = magnetic_field +interval = 5 ip = 10.157.205.3 port = 55001 diff --git a/site_ansto/instrument/rsd/kowari_configuration.tcl b/site_ansto/instrument/rsd/kowari_configuration.tcl index dd71e99f..0ef12ec1 100644 --- a/site_ansto/instrument/rsd/kowari_configuration.tcl +++ b/site_ansto/instrument/rsd/kowari_configuration.tcl @@ -29,9 +29,8 @@ fileeval $cfPath(environment)/temperature/sct_lakeshore_336.tcl fileeval $cfPath(environment)/temperature/sct_lakeshore_340.tcl fileeval $cfPath(environment)/temperature/sct_eurotherm_2000.tcl fileeval $cfPath(environment)/sct_protek_common.tcl -fileeval $cfPath(environment)/temperature/sct_oxford_itc.tcl -fileeval $cfPath(environment)/magneticField/sct_oxford_ips.tcl fileeval $cfPath(environment)/magneticField/sct_oxford_labview.tcl +fileeval $cfPath(environment)/magneticField/sct_oxford12tlv.tcl fileeval $cfPath(hmm)/hmm_configuration.tcl fileeval $cfPath(nexus)/nxscripts.tcl fileeval $cfPath(scan)/scan.tcl diff --git a/site_ansto/instrument/sans/util/sics_config.ini b/site_ansto/instrument/sans/util/sics_config.ini index 8a3356b0..7257c7a3 100644 --- a/site_ansto/instrument/sans/util/sics_config.ini +++ b/site_ansto/instrument/sans/util/sics_config.ini @@ -156,6 +156,7 @@ desc = "Load the ten position sample changer configuration" imptype = motion_axis [12tmagnet_oxford] +asyncqueue = sct desc = "12 Tesla Oxford Magnet" driver = "oxford_labview" imptype = magnetic_field