From bd4dfdee79dddf29a3e15cfa646386ab147dbe04 Mon Sep 17 00:00:00 2001 From: Douglas Clowes Date: Thu, 7 Aug 2014 09:42:47 +1000 Subject: [PATCH 01/10] Remove _trial_temp* directories and *.orig files from TARDIR --- site_ansto/instrument/deploySICS.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/site_ansto/instrument/deploySICS.sh b/site_ansto/instrument/deploySICS.sh index cd937a5a..1d26b95d 100755 --- a/site_ansto/instrument/deploySICS.sh +++ b/site_ansto/instrument/deploySICS.sh @@ -246,6 +246,10 @@ cat $SRCDIR/MANIFEST.TXT $SRCDIR/$INSTSRC/MANIFEST.TXT > $TEMPDIR/$DESTDIR/${NEW cd $TEMPDIR # remove any .svn directories rm -rf $(find $TARDIR -type d -name .svn) +# remove any unit test directories +find $TARDIR -type d -name _trial_temp\* -exec rm -rf {} \; +# remove any temporary .orig files +find $TARDIR -type f -name \*.orig -exec rm {} \; # remove any temporary editor files find $TARDIR -type f -name .\*.sw\? -exec rm {} \; # remove any editor backup files directories From 944902c9d4d02446dd352eac3b5c68602a6fe12d Mon Sep 17 00:00:00 2001 From: Ferdi Franceschini Date: Fri, 8 Aug 2014 09:19:11 +1000 Subject: [PATCH 02/10] 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 From 13003126a620d1de91c9b50e720aaaa1927fe1af Mon Sep 17 00:00:00 2001 From: Ferdi Franceschini Date: Fri, 8 Aug 2014 11:50:26 +1000 Subject: [PATCH 03/10] Use configured magnet name in OxfordSet commands. Also T3 is really pressure. --- .../magneticField/sct_oxford_labview.tcl | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) 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 5eef01c2..3d99cb1e 100644 --- a/site_ansto/instrument/config/environment/magneticField/sct_oxford_labview.tcl +++ b/site_ansto/instrument/config/environment/magneticField/sct_oxford_labview.tcl @@ -181,7 +181,7 @@ proc ::scobj::magnetic::rdTempStateFunc {basePath field} { array set paraArr $s2 hset $basePath/Temp_s1 $paraArr(T1) hset $basePath/Temp_s2 $paraArr(T2) - hset $basePath/Temp_s3 $paraArr(T3) + hset $basePath/Pressure_s3 $paraArr(T3) set logText "Displayed Temp : $paraArr(T1) $paraArr(T2) $paraArr(T3)" } @@ -254,7 +254,7 @@ proc ::scobj::magnetic::mkMagnetic {argList} { hfactory $hPath/Temp plain user text hfactory $hPath/Temp_s1 plain user float hfactory $hPath/Temp_s2 plain user float - hfactory $hPath/Temp_s3 plain user float + hfactory $hPath/Pressure_s3 plain user float #hfactory $hPath/Set_Sensor_Temp user float #hfactory $hPath/Set_Sensor_Channel user int @@ -305,7 +305,7 @@ proc ::scobj::magnetic::mkMagnetic {argList} { foreach {hdbPath klass control data nxsave mutable priv alias} [subst { /sics/$pa(NAME)/Temp_s1 NXsensor true true true true user magnetic_T1 /sics/$pa(NAME)/Temp_s2 NXsensor true true true true user magnetic_T2 - /sics/$pa(NAME)/Temp_s3 NXsensor true true true true user magnetic_T3 + /sics/$pa(NAME)/Pressure_s3 NXsensor true true true true user magnetic_P3 /sics/$pa(NAME)/magneticFieldCurrent NXsensor true true true true user magnetic_Field_Current /sics/$pa(NAME)/magneticFieldTesla NXsensor true true true true user magnetic_Field_Tesla /sics/$pa(NAME)/fieldSetPoint NXsensor true true true true user fieldSetPoint @@ -330,7 +330,7 @@ proc ::scobj::magnetic::mkMagnetic {argList} { # hset /sics/$fPath/start_temperature_s1 [hval /sics/$fPath/Temp_s1] # hset /sics/$fPath/start_temperature_s2 [hval /sics/$fPath/Temp_s2] -# hset /sics/$fPath/start_temperature_s3 [hval /sics/$fPath/Temp_s3] +# hset /sics/$fPath/start_temperature_s3 [hval /sics/$fPath/Pressure_s3] # } # proc ::histogram_memory::post_count "{fPath $pa(NAME)}" { @@ -338,10 +338,11 @@ proc ::scobj::magnetic::mkMagnetic {argList} { # hset /sics/$fPath/end_temperature_s1 [hval /sics/$fPath/Temp_s1] # hset /sics/$fPath/end_temperature_s2 [hval /sics/$fPath/Temp_s2] -# hset /sics/$fPath/end_temperature_s3 [hval /sics/$fPath/Temp_s3] +# hset /sics/$fPath/end_temperature_s3 [hval /sics/$fPath/Pressure_s3] # } set ::scobj::magnetic::sct_name $pa(SCTCONTROLLER) + set ::scobj::magnetic::magname $pa(NAME) hsetprop $hPath/field read ::scobj::magnetic::rqFieldFunc hsetprop $hPath/field rdFieldState ::scobj::magnetic::rdFieldStateFunc $hPath @@ -393,7 +394,7 @@ proc ::scobj::magnetic::mkMagnetic {argList} { # command is : OxfordSetField fieldValue P ; where "P" is an optinal parameter and if set will change # to posistent mode after changig the magnetic field proc OxfordSetField {{setPoint ""} {mode ""} args} { - set NAME "magnetic" + set NAME $::scobj::magnetic::magname if {$setPoint == ""} { if {$mode == ""} { broadcast "[hget /sample/$NAME/fieldSetPoint]" @@ -428,7 +429,7 @@ proc OxfordSetField {{setPoint ""} {mode ""} args} { # Assign the rate of the changing magnetic field; # This needs only to be set once unless required proc OxfordSetRate {{setRate ""} args} { - set NAME "magnetic" + set NAME $::scobj::magnetic::magname if {$setRate == ""} { broadcast "[hget /sample/$NAME/fieldSetRate]" } else { @@ -441,7 +442,7 @@ proc OxfordSetRate {{setRate ""} args} { # Querying/Setting the Heliox sample temperature proc OxfordSetHTemp {{temp ""} args} { - set NAME "magnetic" + set NAME $::scobj::magnetic::magname if {$temp == ""} { broadcast "[hget /sample/$NAME/HelioxTempSetPoint]" } else { @@ -462,7 +463,7 @@ proc OxfordSetHTemp {{temp ""} args} { # Querying/Setting the Diluxtion Sample temperature proc OxfordSetDTemp {{temp ""} args} { - set NAME "magnetic" + set NAME $::scobj::magnetic::magname if {$temp == ""} { broadcast "[hget /sample/$NAME/DilutTempSetPoint]" } else { From 8541f7cd902479c3f72caa9f08eb08889ad48ce4 Mon Sep 17 00:00:00 2001 From: Douglas Clowes Date: Fri, 15 Aug 2014 12:21:36 +1000 Subject: [PATCH 04/10] Remove extra makesctcontroller from Agilent --- site_ansto/instrument/config/environment/agilent_33220A.sct | 1 - site_ansto/instrument/config/environment/sct_agilent_33220A.tcl | 1 - 2 files changed, 2 deletions(-) diff --git a/site_ansto/instrument/config/environment/agilent_33220A.sct b/site_ansto/instrument/config/environment/agilent_33220A.sct index b731a821..6f8ba4e3 100644 --- a/site_ansto/instrument/config/environment/agilent_33220A.sct +++ b/site_ansto/instrument/config/environment/agilent_33220A.sct @@ -4,6 +4,5 @@ driver agilent_33220A = { class = environment simulation_group = environment_simulation code mkDriver = {%% - makesctcontroller $name $ip $port %%} } diff --git a/site_ansto/instrument/config/environment/sct_agilent_33220A.tcl b/site_ansto/instrument/config/environment/sct_agilent_33220A.tcl index 580bb24d..4cfaeac1 100644 --- a/site_ansto/instrument/config/environment/sct_agilent_33220A.tcl +++ b/site_ansto/instrument/config/environment/sct_agilent_33220A.tcl @@ -42,7 +42,6 @@ proc ::scobj::agilent_33220A::mkDriver { sct_controller name } { hsetprop ${scobj_hpath} data true 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} From da1751649111dc0677675688c6d6963404e39176 Mon Sep 17 00:00:00 2001 From: Douglas Clowes Date: Mon, 18 Aug 2014 11:20:44 +1000 Subject: [PATCH 05/10] Add wrapper_property and mkWrapper code for SCT wrappers --- site_ansto/instrument/util/gen_sct.py | 87 ++++++++++++++++----------- 1 file changed, 53 insertions(+), 34 deletions(-) diff --git a/site_ansto/instrument/util/gen_sct.py b/site_ansto/instrument/util/gen_sct.py index a42d3fe8..56bf65cf 100755 --- a/site_ansto/instrument/util/gen_sct.py +++ b/site_ansto/instrument/util/gen_sct.py @@ -80,6 +80,7 @@ reserved = { 'DEVICE' : 'DEVICE', 'PROTOCOL' : 'PROTOCOL', 'DRIVER_PROPERTY' : 'DRIVER_PROPERTY', + 'WRAPPER_PROPERTY' : 'WRAPPER_PROPERTY', 'CLASS' : 'CLASS', 'SIMULATION_GROUP' : 'SIMULATION_GROUP', 'DEBUG_THRESHOLD' : 'DEBUG_THRESHOLD', @@ -303,6 +304,7 @@ def p_driver_statement(p): | group | code | driver_property + | wrapper_property ''' p[0] = p[1] @@ -446,6 +448,12 @@ def p_driver_property(p): ''' p[0] = { 'DriverProperty' : ( p[2], p[4] ) } +def p_wrapper_property(p): + ''' + wrapper_property : WRAPPER_PROPERTY id_or_str EQUALS value + ''' + p[0] = { 'WrapperProperty' : ( p[2], p[4] ) } + def p_group_property(p): ''' group_property : GROUP_PROPERTY id_or_str EQUALS value @@ -794,6 +802,11 @@ def build_driver(MyDriver, TheTree): MyDriver['DriverProperty'] = {} MyDriver['DriverProperty'][item['DriverProperty'][0]] = item['DriverProperty'][1] continue + if 'WrapperProperty' in item: + if 'WrapperProperty' not in MyDriver: + MyDriver['WrapperProperty'] = {} + MyDriver['WrapperProperty'][item['WrapperProperty'][0]] = item['WrapperProperty'][1] + continue for key in item: MyDriver[key] = item[key] for item in MyDriver['Permlink']: @@ -1368,45 +1381,51 @@ def put_mkDriver(MyDriver): txt += [' set ns "[namespace current]"'] txt += [' set catch_status [ catch {'] txt += [''] - if len(MyDriver['Permlink']) > 0: - if 'make_args' in MyDriver and 'id' in MyDriver['make_args'].split(): - pass - else: - txt += [' set permlink_device_number [format "%02d" [incr ::scobj::permlink_device_counter]]'] - txt += [''] - if 'sobj_priv_type' in MyDriver: - priv_type = MyDriver['sobj_priv_type'].split() - ms_line = ' MakeSICSObj ${name} SCT_OBJECT %s %s' % (priv_type[0], priv_type[1]) - else: - ms_line = ' MakeSICSObj ${name} SCT_OBJECT' - txt += [ms_line] - txt += [''] - txt += [' sicslist setatt ${name} klass %s' % MyDriver['class']] - txt += [' sicslist setatt ${name} long_name ${name}'] - if 'DriverProperty' in MyDriver: - for key in MyDriver['DriverProperty']: - txt += [' sicslist setatt ${name} %s "%s"' % (key, MyDriver['DriverProperty'][key])] - txt += [''] - txt += [' set scobj_hpath /sics/${name}'] - - for group in sorted(MyDriver['Groups']): - txt += put_group(MyDriver, MyDriver['Groups'][group]) - - txt += [' hsetprop ${scobj_hpath} klass %s' % MyDriver['class']] - txt += [' hsetprop ${scobj_hpath} data true'] - txt += [' hsetprop ${scobj_hpath} debug_threshold %s' % str(MyDriver['debug_threshold'])] - if len(MyDriver['Deferred']) > 0: - txt += [' if {[string equal -nocase [SplitReply [%s]] "false"]} {' % MyDriver['simulation_group']] - for line in MyDriver['Deferred']: - txt += [' ' + line] - txt += [' }'] - func = 'mkDriver' + func = 'mkWrapper' if func in MyDriver['Funcs']: txt += ['# %s hook code starts' % func] txt += MyDriver['Funcs'][func]['text'] txt += ['# %s hook code ends' % func] else: - txt += ['# %s hook code goes here' % func] + if len(MyDriver['Permlink']) > 0: + if 'make_args' in MyDriver and 'id' in MyDriver['make_args'].split(): + pass + else: + txt += [' set permlink_device_number [format "%02d" [incr ::scobj::permlink_device_counter]]'] + txt += [''] + if 'sobj_priv_type' in MyDriver: + priv_type = MyDriver['sobj_priv_type'].split() + ms_line = ' MakeSICSObj ${name} SCT_OBJECT %s %s' % (priv_type[0], priv_type[1]) + else: + ms_line = ' MakeSICSObj ${name} SCT_OBJECT' + txt += [ms_line] + txt += [''] + txt += [' sicslist setatt ${name} klass %s' % MyDriver['class']] + txt += [' sicslist setatt ${name} long_name ${name}'] + if 'DriverProperty' in MyDriver: + for key in MyDriver['DriverProperty']: + txt += [' sicslist setatt ${name} %s "%s"' % (key, MyDriver['DriverProperty'][key])] + txt += [''] + txt += [' set scobj_hpath /sics/${name}'] + + for group in sorted(MyDriver['Groups']): + txt += put_group(MyDriver, MyDriver['Groups'][group]) + + txt += [' hsetprop ${scobj_hpath} klass %s' % MyDriver['class']] + txt += [' hsetprop ${scobj_hpath} data true'] + txt += [' hsetprop ${scobj_hpath} debug_threshold %s' % str(MyDriver['debug_threshold'])] + if len(MyDriver['Deferred']) > 0: + txt += [' if {[string equal -nocase [SplitReply [%s]] "false"]} {' % MyDriver['simulation_group']] + for line in MyDriver['Deferred']: + txt += [' ' + line] + txt += [' }'] + func = 'mkDriver' + if func in MyDriver['Funcs']: + txt += ['# %s hook code starts' % func] + txt += MyDriver['Funcs'][func]['text'] + txt += ['# %s hook code ends' % func] + else: + txt += ['# %s hook code goes here' % func] txt += [' } catch_message ]'] txt += [' handle_exception ${catch_status} ${catch_message}'] txt += ['}'] From ea9de2c6173b548dccdee19ccf8fda7f56add3ea Mon Sep 17 00:00:00 2001 From: Douglas Clowes Date: Fri, 15 Aug 2014 16:35:38 +1000 Subject: [PATCH 06/10] Add @TCL/@END code to gen_sct --- site_ansto/instrument/util/gen_sct.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/site_ansto/instrument/util/gen_sct.py b/site_ansto/instrument/util/gen_sct.py index 56bf65cf..7734ea71 100755 --- a/site_ansto/instrument/util/gen_sct.py +++ b/site_ansto/instrument/util/gen_sct.py @@ -156,6 +156,8 @@ tokens = [ 'ID', 'TCL_BEG', 'TCL_END', + 'AT_TCL', + 'AT_END', ] + list(reserved.values()) # @@ -167,6 +169,20 @@ t_LBRACE = r'{' t_RBRACE = r'}' t_SLASH = r'/' +def t_AT_TCL(t): + r'@TCL' + if Verbose: + print 'AT_TCL' + t.lexer.begin('tcl') + #return t + +def t_tcl_AT_END(t): + r'[ \t]*@END' + if Verbose: + print 'AT_END' + t.lexer.begin('INITIAL') + #return t + def t_TCL_BEG(t): r'{%%' if Verbose: @@ -513,6 +529,7 @@ def p_true_false(p): def p_code(p): ''' code : CODE code_type id_or_str EQUALS LBRACE code_block RBRACE + | CODE code_type id_or_str EQUALS LBRACE tcl_code_block RBRACE | CODE code_type id_or_str EQUALS TCL_BEG code_block TCL_END ''' p[0] = { 'Code' : { 'name' : p[3], 'type' : p[2], 'text' : p[6] }} @@ -532,6 +549,12 @@ def p_code_type(p): ''' p[0] = p[1] +def p_tcl_code_block(p): + ''' + tcl_code_block : AT_TCL code_block AT_END + ''' + p[0] = p[2] + def p_code_block(p): '''code_block : empty | code_block CODE_STRING From 2c8f1131f6d6bd665cd1f306b4b36e759ff39d6d Mon Sep 17 00:00:00 2001 From: Douglas Clowes Date: Mon, 18 Aug 2014 12:34:24 +1000 Subject: [PATCH 07/10] Add wrapper_property nosctcontroller = to gen_sct --- site_ansto/instrument/util/gen_sct.py | 33 +++++++++++++++------------ 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/site_ansto/instrument/util/gen_sct.py b/site_ansto/instrument/util/gen_sct.py index 7734ea71..049d036a 100755 --- a/site_ansto/instrument/util/gen_sct.py +++ b/site_ansto/instrument/util/gen_sct.py @@ -1474,22 +1474,25 @@ def put_postamble(MyDriver): txt += [' %s::sics_log 9 "add_%s ${name} ${IP} ${port} %s"' % (MyDriver['namespace'], MyDriver['name'], make_args)] else: txt += [' %s::sics_log 9 "add_%s ${name} ${IP} ${port}"' % (MyDriver['namespace'], MyDriver['name'])] - txt += [' if {[string equal -nocase [SplitReply [%s]] "false"]} {' % MyDriver['simulation_group']] - txt += [' if {[string equal -nocase "aqadapter" "${IP}"]} {'] - txt += [' %s::sics_log 9 "makesctcontroller sct_${name} aqadapter ${port}"' % MyDriver['namespace']] - txt += [' makesctcontroller sct_${name} aqadapter ${port}'] - txt += [' } else {'] - if 'protocol_args' in MyDriver: - protocol_args = MyDriver['protocol_args'].replace('\\', '\\\\').replace('"', '\\"') - txt += [' %s::sics_log 9 "makesctcontroller sct_${name} %s ${IP}:${port} %s"' % (MyDriver['namespace'], MyDriver['protocol'], protocol_args)] - txt += [' makesctcontroller sct_${name} %s ${IP}:${port} %s' % (MyDriver['protocol'], MyDriver['protocol_args'])] + if ('WrapperProperty' in MyDriver) and ('nosctcontroller' in MyDriver['WrapperProperty']): + txt += [' %s::sics_log 9 "No sctcontroller for %s"' % (MyDriver['namespace'], MyDriver['name'])] else: - txt += [' %s::sics_log 9 "makesctcontroller sct_${name} %s ${IP}:${port}"' % (MyDriver['namespace'], MyDriver['protocol'])] - txt += [' makesctcontroller sct_${name} %s ${IP}:${port}' % MyDriver['protocol']] - txt += [' }'] - txt += [' } else {'] - txt += [' %s::sics_log 9 "[%s] => No sctcontroller for %s"' % (MyDriver['namespace'], MyDriver['simulation_group'], MyDriver['name'])] - txt += [' }'] + txt += [' if {[string equal -nocase [SplitReply [%s]] "false"]} {' % MyDriver['simulation_group']] + txt += [' if {[string equal -nocase "aqadapter" "${IP}"]} {'] + txt += [' %s::sics_log 9 "makesctcontroller sct_${name} aqadapter ${port}"' % MyDriver['namespace']] + txt += [' makesctcontroller sct_${name} aqadapter ${port}'] + txt += [' } else {'] + if 'protocol_args' in MyDriver: + protocol_args = MyDriver['protocol_args'].replace('\\', '\\\\').replace('"', '\\"') + txt += [' %s::sics_log 9 "makesctcontroller sct_${name} %s ${IP}:${port} %s"' % (MyDriver['namespace'], MyDriver['protocol'], protocol_args)] + txt += [' makesctcontroller sct_${name} %s ${IP}:${port} %s' % (MyDriver['protocol'], MyDriver['protocol_args'])] + else: + txt += [' %s::sics_log 9 "makesctcontroller sct_${name} %s ${IP}:${port}"' % (MyDriver['namespace'], MyDriver['protocol'])] + txt += [' makesctcontroller sct_${name} %s ${IP}:${port}' % MyDriver['protocol']] + txt += [' }'] + txt += [' } else {'] + txt += [' %s::sics_log 9 "[%s] => No sctcontroller for %s"' % (MyDriver['namespace'], MyDriver['simulation_group'], MyDriver['name'])] + txt += [' }'] if 'make_args' in MyDriver: make_args = ' '.join(["${%s}"%arg for arg in MyDriver['make_args'].split()]) txt += [' %s::sics_log 1 "%s::mkDriver sct_${name} ${name} %s"' % (MyDriver['namespace'], MyDriver['namespace'], make_args)] From 6f5f2b69cf35005dd300f7147b8f937c7c94a6c3 Mon Sep 17 00:00:00 2001 From: Douglas Clowes Date: Mon, 18 Aug 2014 12:42:35 +1000 Subject: [PATCH 08/10] Make Agilent use mkWrapper --- .../config/environment/agilent_33220A.sct | 2 +- .../config/environment/sct_agilent_33220A.tcl | 13 ++----------- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/site_ansto/instrument/config/environment/agilent_33220A.sct b/site_ansto/instrument/config/environment/agilent_33220A.sct index 6f8ba4e3..35497eaa 100644 --- a/site_ansto/instrument/config/environment/agilent_33220A.sct +++ b/site_ansto/instrument/config/environment/agilent_33220A.sct @@ -3,6 +3,6 @@ driver agilent_33220A = { protocol = std class = environment simulation_group = environment_simulation - code mkDriver = {%% + code mkWrapper = {%% %%} } diff --git a/site_ansto/instrument/config/environment/sct_agilent_33220A.tcl b/site_ansto/instrument/config/environment/sct_agilent_33220A.tcl index 4cfaeac1..1f40f4f5 100644 --- a/site_ansto/instrument/config/environment/sct_agilent_33220A.tcl +++ b/site_ansto/instrument/config/environment/sct_agilent_33220A.tcl @@ -32,17 +32,8 @@ proc ::scobj::agilent_33220A::mkDriver { sct_controller 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} data true - hsetprop ${scobj_hpath} debug_threshold 5 -# mkDriver hook code starts -# mkDriver hook code ends +# mkWrapper hook code starts +# mkWrapper hook code ends } catch_message ] handle_exception ${catch_status} ${catch_message} } From 273c26cc220c5167b24ba4ff1d8de93b3e4734f7 Mon Sep 17 00:00:00 2001 From: Douglas Clowes Date: Mon, 18 Aug 2014 12:46:48 +1000 Subject: [PATCH 09/10] Add a wrapper for the green magnet --- .../magneticField/green_magnet_labview.sct | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 site_ansto/instrument/config/environment/magneticField/green_magnet_labview.sct diff --git a/site_ansto/instrument/config/environment/magneticField/green_magnet_labview.sct b/site_ansto/instrument/config/environment/magneticField/green_magnet_labview.sct new file mode 100644 index 00000000..0b042071 --- /dev/null +++ b/site_ansto/instrument/config/environment/magneticField/green_magnet_labview.sct @@ -0,0 +1,19 @@ +# vim: ts=8 sts=2 sw=2 expandtab autoindent smartindent nocindent +driver green_magnet_labview = { + wrapper_property nosctcontroller = true; + protocol = std + class = environment + simulation_group = environment_simulation + code mkWrapper = { +@TCL +# TCL code + ::scobj::green::mkGreen { + name "green_magnet" + IP 137.157.201.88 + PORT 5001 + tuning 1 + interval 3 + } +@END + } +} From 288be8f1c28728b3d1dbdc95961edf617399cce4 Mon Sep 17 00:00:00 2001 From: Douglas Clowes Date: Mon, 18 Aug 2014 12:48:01 +1000 Subject: [PATCH 10/10] Generate the green magnet wrapper TCL code --- .../sct_green_magnet_labview.tcl | 135 ++++++++++++++++++ 1 file changed, 135 insertions(+) create mode 100644 site_ansto/instrument/config/environment/magneticField/sct_green_magnet_labview.tcl diff --git a/site_ansto/instrument/config/environment/magneticField/sct_green_magnet_labview.tcl b/site_ansto/instrument/config/environment/magneticField/sct_green_magnet_labview.tcl new file mode 100644 index 00000000..b67de6e4 --- /dev/null +++ b/site_ansto/instrument/config/environment/magneticField/sct_green_magnet_labview.tcl @@ -0,0 +1,135 @@ +# Generated driver for green_magnet_labview +# vim: ft=tcl tabstop=8 softtabstop=2 shiftwidth=2 nocindent smartindent +# + +namespace eval ::scobj::green_magnet_labview { + set debug_threshold 5 +} + +proc ::scobj::green_magnet_labview::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/green_magnet_labview_[basename ${tc_root}].log" "a"] + set line "[clock format [clock seconds] -format "%T"] ${debug_string}" + puts ${fd} "${line}" + close ${fd} + } + } catch_message ] +} + +proc ::scobj::green_magnet_labview::sics_log {debug_level debug_string} { + set catch_status [ catch { + set debug_threshold ${::scobj::green_magnet_labview::debug_threshold} + if {${debug_level} >= ${debug_threshold}} { + sicslog "::scobj::green_magnet_labview::${debug_string}" + } + } catch_message ] +} + +proc ::scobj::green_magnet_labview::mkDriver { sct_controller name } { + ::scobj::green_magnet_labview::sics_log 9 "::scobj::green_magnet_labview::mkDriver for ${name}" + set ns "[namespace current]" + set catch_status [ catch { + +# mkWrapper hook code starts +# TCL code + ::scobj::green::mkGreen { + name "green_magnet" + IP 137.157.201.88 + PORT 5001 + tuning 1 + interval 3 + } +# mkWrapper hook code ends + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + +namespace eval ::scobj::green_magnet_labview { + namespace export debug_threshold + namespace export debug_log + namespace export sics_log + namespace export mkDriver +} + +proc add_green_magnet_labview {name IP port} { + set catch_status [ catch { + ::scobj::green_magnet_labview::sics_log 9 "add_green_magnet_labview ${name} ${IP} ${port}" + ::scobj::green_magnet_labview::sics_log 9 "No sctcontroller for green_magnet_labview" + ::scobj::green_magnet_labview::sics_log 1 "::scobj::green_magnet_labview::mkDriver sct_${name} ${name}" + ::scobj::green_magnet_labview::mkDriver sct_${name} ${name} + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + +clientput "file evaluation of sct_green_magnet_labview.tcl" +::scobj::green_magnet_labview::sics_log 9 "file evaluation of sct_green_magnet_labview.tcl" + +proc ::scobj::green_magnet_labview::read_config {} { + set catch_status [ catch { + set ns "::scobj::green_magnet_labview" + 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"] "green_magnet_labview"] } { + 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_green_magnet_labview ${name} ${IP} ${PORT} + } else { + add_green_magnet_labview ${name} "aqadapter" ${asyncqueue} + } + } + } + } + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + +if { [info exists ::config_dict] } { + ::scobj::green_magnet_labview::read_config +} else { + ::scobj::green_magnet_labview::sics_log 5 "No config dict" +}