From d5cde7c4f6bdd89c1d9c07251928d20b3e231f81 Mon Sep 17 00:00:00 2001 From: Ferdi Franceschini Date: Fri, 16 Feb 2007 16:43:59 +1100 Subject: [PATCH] Modifications for new util, config directory structure. r1498 | ffr | 2007-02-16 16:43:59 +1100 (Fri, 16 Feb 2007) | 2 lines --- .../hrpd/config/counter/counter.tcl | 1 + .../hipadaba/hipadaba_configuration.tcl | 63 ++ .../hrpd/config/hipadaba/hpaths.tcl | 48 ++ .../hrpd/config/hmm/anstohm_full.xml | 226 ++++++ .../hrpd/config/hmm/hmm_configuration.tcl | 398 +++++++++ .../config/motors/motor_configuration.tcl | 766 ++++++++++++++++++ .../instrument/hrpd/config/nexus/echidna.dic | 99 +++ .../hrpd/config/nexus/nxscripts.tcl | 148 ++++ .../instrument/hrpd/config/scan/echidna.hdd | 8 + .../instrument/hrpd/config/scan/scan.tcl | 130 +++ .../hrpd/script_validator/MANIFEST.TXT | 2 + .../{ => config/hmm}/hmm_configuration.tcl | 0 .../config/motors/motor_configuration.tcl | 256 ++++++ 13 files changed, 2145 insertions(+) create mode 100644 site_ansto/instrument/hrpd/config/counter/counter.tcl create mode 100644 site_ansto/instrument/hrpd/config/hipadaba/hipadaba_configuration.tcl create mode 100644 site_ansto/instrument/hrpd/config/hipadaba/hpaths.tcl create mode 100644 site_ansto/instrument/hrpd/config/hmm/anstohm_full.xml create mode 100644 site_ansto/instrument/hrpd/config/hmm/hmm_configuration.tcl create mode 100644 site_ansto/instrument/hrpd/config/motors/motor_configuration.tcl create mode 100644 site_ansto/instrument/hrpd/config/nexus/echidna.dic create mode 100644 site_ansto/instrument/hrpd/config/nexus/nxscripts.tcl create mode 100644 site_ansto/instrument/hrpd/config/scan/echidna.hdd create mode 100644 site_ansto/instrument/hrpd/config/scan/scan.tcl create mode 100644 site_ansto/instrument/hrpd/script_validator/MANIFEST.TXT rename site_ansto/instrument/hrpd/script_validator/{ => config/hmm}/hmm_configuration.tcl (100%) create mode 100644 site_ansto/instrument/hrpd/script_validator/config/motors/motor_configuration.tcl diff --git a/site_ansto/instrument/hrpd/config/counter/counter.tcl b/site_ansto/instrument/hrpd/config/counter/counter.tcl new file mode 100644 index 00000000..9bf1f362 --- /dev/null +++ b/site_ansto/instrument/hrpd/config/counter/counter.tcl @@ -0,0 +1 @@ +MakeCounter counter SIM -0.5 diff --git a/site_ansto/instrument/hrpd/config/hipadaba/hipadaba_configuration.tcl b/site_ansto/instrument/hrpd/config/hipadaba/hipadaba_configuration.tcl new file mode 100644 index 00000000..05ed50f6 --- /dev/null +++ b/site_ansto/instrument/hrpd/config/hipadaba/hipadaba_configuration.tcl @@ -0,0 +1,63 @@ +# Defines hashes which map SICS device object names to hipadaba paths +InstallHdb +hmake /graphics spy none +hsetprop /graphics type graphset +hmake /commands spy none +hsetprop /commands type commandset + +#TODO change this to hparts.tcl +source $cfPath(hipadaba)/hpaths.tcl +set instrument echidna +hmake /$instrument spy none +hsetprop /$instrument type instrument + +# Generate hipadaba nodes for the paths in the hpaths file +foreach hp $hpaths { + hmake /$instrument/$hp spy none; + hsetprop /$instrument/$hp type part; +} + +#--- admin +hattach /$instrument title title +hattach /$instrument/experiment sample description +hmake /$instrument/user spy none +hsetprop /$instrument/user type part +hattach /$instrument/user user name +hattach /$instrument/user email email +hattach /$instrument/user phone phone + +#--- Motors +foreach {obj name part} $motor_hpath { + hattach /$instrument/$part $obj $name + #TODO Only ignore node deletion errors for simulated motors + if [ catch {hdel /$instrument/$part/$name/axis} ] {} + if [ catch {hdel /$instrument/$part/$name/units} ] {} +} + +#--- Configurable Virtual Motors +foreach {obj name part master_obj} $cvirtmotor_hpath { + set path /$instrument/$part +# hattach /$instrument/$part $obj $name + hattach $path $obj $name + hchain $path/$name $path/$master_obj +} + +#------------- scan command +hsetprop /commands type part +hcommand /commands/scan hdb_hmscan +hsetprop /commands/scan type command +hsetprop /commands/scan priv user +hmake /commands/scan/scan_variable user text +hsetprop /commands/scan/scan_variable argtype drivable +hmake /commands/scan/scan_start user float +hsetprop /commands/scan/scan_start argtype float +hmake /commands/scan/scan_increment user float +hsetprop /commands/scan/scan_increment argtype float +hmake /commands/scan/NP user int +hsetprop /commands/scan/NP argtype int +hmake /commands/scan/mode user text +hsetprop /commands/scan/mode argtype text +hsetprop /commands/scan/mode values monitor,timer +hmake /commands/scan/preset user float +hsetprop /commands/scan/preset argtype float + diff --git a/site_ansto/instrument/hrpd/config/hipadaba/hpaths.tcl b/site_ansto/instrument/hrpd/config/hipadaba/hpaths.tcl new file mode 100644 index 00000000..f5c3f8cb --- /dev/null +++ b/site_ansto/instrument/hrpd/config/hipadaba/hpaths.tcl @@ -0,0 +1,48 @@ +set hpaths [list \ +experiment sample monochromator slits \ +slits/1 slits/2 detector detector/monitor detector/histmem ] + +# Maps devices (eg motors) to hipadaba paths. +# obj name path +set motor_hpath [list \ +ss1u top /slits/1 \ +ss1d bottom /slits/1 \ +ss1l left /slits/1 \ +ss1r right /slits/1 \ +ss2u ss2u /slits/2 \ +ss2d ss2d /slits/2 \ +ss2l ss2l /slits/2 \ +ss2r ss2r /slits/2 \ +som rotate /sample \ +schi chi /sample \ +sphi phi /sample \ +sx translate_x /sample \ +sy translate_y /sample \ +stth detector_rotate /sample \ +pcx pcx /monochromator \ +pcr pcr /monochromator \ +mom mom /monochromator \ +mchi mchi /monochromator \ +mphi mphi /monochromator \ +mx mx /monochromator \ +my my /monochromator \ +mtth mtth /monochromator ] + +# Configurable virtual motors +# obj name path master_obj +set cvirtmotor_hpath [list \ +ss1vg ss1vg /slits/1 top\ +ss1vo ss1vo /slits/1 top\ +ss1hg ss1hg /slits/1 right\ +ss1ho ss1ho /slits/1 right\ +ss2vg ss2vg /slits/2 ss2u\ +ss2vo ss2vo /slits/2 ss2u\ +ss2hg ss2hg /slits/2 ss2r\ +ss2ho ss2ho /slits/2 ss2r\ +sth sth /sample detector_rotate\ +mth mth /monochromator mtth] + +array set counter_hpath [ list \ +hm hm /detector/histmem \ +counter counter /detector/monitor ] + diff --git a/site_ansto/instrument/hrpd/config/hmm/anstohm_full.xml b/site_ansto/instrument/hrpd/config/hmm/anstohm_full.xml new file mode 100644 index 00000000..b039fbb8 --- /dev/null +++ b/site_ansto/instrument/hrpd/config/hmm/anstohm_full.xml @@ -0,0 +1,226 @@ + + + + + + + + + + + + + + + + + + + 0 + + + + + 127.5 126.5 + + + -0.5 0.5 + + + 0 200000 + + + + + + + 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 + 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 + 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 + 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 + 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 + 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 + 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 + 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 + 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 + 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 + 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 + 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 + 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 + 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 + 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 + 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 + + + + + 6 + 6 + 6 + 6 + 6 + 6 + 6 + 6 + 6 + 6 + 6 + 6 + 6 + 6 + 6 + 6 + + + + + + 1. 1. 1. 1. 1. 1. 1. 1. + 1. 1. 1. 1. 1. 1. 1. 1. + 1. 1. 1. 1. 1. 1. 1. 1. + 1. 1. 1. 1. 1. 1. 1. 1. + 1. 1. 1. 1. 1. 1. 1. 1. + 1. 1. 1. 1. 1. 1. 1. 1. + 1. 1. 1. 1. 1. 1. 1. 1. + 1. 1. 1. 1. 1. 1. 1. 1. + 1. 1. 1. 1. 1. 1. 1. 1. + 1. 1. 1. 1. 1. 1. 1. 1. + 1. 1. 1. 1. 1. 1. 1. 1. + 1. 1. 1. 1. 1. 1. 1. 1. + 1. 1. 1. 1. 1. 1. 1. 1. + 1. 1. 1. 1. 1. 1. 1. 1. + 1. 1. 1. 1. 1. 1. 1. 1. + 1. 1. 1. 1. 1. 1. 1. 1. + + + + + + 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. + 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. + 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. + 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. + 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. + 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. + 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. + 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. + 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. + 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. + 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. + 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. + 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. + 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. + 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. + 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. + + + + + + 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. + 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. + 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. + 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. + 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. + 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. + 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. + 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. + 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. + 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. + 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. + 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. + 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. + 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. + 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. + 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. + + + + + + 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 + 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 + 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 + 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 + 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 + 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 + 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 + 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 + 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 + 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 + 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 + 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 + 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 + 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 + 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 + 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 + + + + diff --git a/site_ansto/instrument/hrpd/config/hmm/hmm_configuration.tcl b/site_ansto/instrument/hrpd/config/hmm/hmm_configuration.tcl new file mode 100644 index 00000000..072a63c6 --- /dev/null +++ b/site_ansto/instrument/hrpd/config/hmm/hmm_configuration.tcl @@ -0,0 +1,398 @@ +# $Revision: 1.1 $ +# $Date: 2007-02-16 05:43:59 $ +# Author: Mark Lesha (mle@ansto.gov.au) +# Last revision by: $Author: ffr $ + +#------------------------------------------------------------------------- +# System: Histogram Server (sample) +#------------------------------------------------------------------------ + +############################################## +# Creating the histogram memories in SICS +############################################## + +# Make a histogram memory object hmm, allows control of the +# remote histogram server via http, and acquisition +# of histogram period data. +MakeHM hmm anstohttp +hmm configure hmaddress http://das1-echidna:8080 +hmm configure username spy +hmm configure password 007 +hmm configure hmDataPath ../HMData + + +############################################## +# Configuring the histogram server +############################################## + +# Procedure to read a single config (or any) file, return content as a string. +proc returnconfigfile {filename} { + set fh [open $filename] + set xml [read $fh] + #set xml [list [read $fh]] + clientput $xml value + close $fh + return $xml +} +Publish returnconfigfile User + +# Configure to upload a complete configuration to the histogram server. +# In this case it's the main config file plus the FAT, BAT and OAT files +# in the same direcory as the SICS executable (for this example). +# Alternatives: +# - A partial config could be uploaded instead - e.g. just the main config file, +# in that case the main config file points to a set of FAT, BAT OAT files +# located on the server. +# - The histogram server could configure itself from a config file set +# kept on the local file system (not automated presently, manual control only) +# - Or, no configuration at all could be uploaded, the +# histogram server can configure itself using its default config files. +hmm configure hmconfigscript "returnconfigfile $cfPath(hmm)/anstohm_full.xml" + +# Initialize the histogram server. +# This call to hmm init (with init 1 configured) causes the histogram server +# to be loaded with the specified configuration files. Subsequent inits (with init 0 configured) +# only cause specific histogram server FAT settings to be updated. +# If the histogram server's default configfiles are adequate, the init 1 stage can be skipped. +# Before configuring, make sure the server is stopped, since configuration +# during DAQ is not allowed. This requires init of the hmm object to level 0. +# +# Making sure the histogram server is stopped, so we can load configuration. +hmm configure init 0 +hmm init +hmm stop +# Load the configuration to the histogram server. +hmm configure init 1 +hmm init +# Restore the init level to 0, subesquent inits will only upload specified FAT settings to histogram server. +hmm configure init 0 + +############################################## +# Configuring the histogram memories in SICS +############################################## + +# Now issue stop to the server. +# This not only makes sure it's stopped, but lets us see certain configuration variables +# which get placed in the dictionary as part of the status checking done during the stop. +hmm stop + +# Here, define a function to let us read back the value of dictionary items from the hmm +# such as OAT dimensions. +proc hmmdictitemval {histomem dictitem} { + set resp [$histomem configure $dictitem] + set retn [lindex [split $resp " "] 2] + return $retn +} + +# Configure histogram dimensions, mode, etc. using the dictionary variables. +# For the dimensions, set the 'effective' OAT dimensions which are the +# histogram period dimensions. Do an init after to cause memory to be allocated. +hmm configure histmode transparent +hmm configure bank 0 +hmm configure rank 3 +hmm configure dim0 [hmmdictitemval hmm oat_nyc_eff] +hmm configure dim1 [hmmdictitemval hmm oat_nxc_eff] +hmm configure dim2 [hmmdictitemval hmm oat_ntc_eff] +hmm init + +############################################## +# Create beam monitor counter +# and histogram memory control object +# (ANSTO customized versions) +############################################## + +# Make and configure an ANSTO beam monitor counter. +MakeCounter bm anstomonitor [ params host "das1-echidna" port "30000" ] +bm SetExponent 0 + +# Make our special HMControl_ANSTO object with the bm controlling the hmm. +# This version can pause the histogram server after the count expires +# instead of just stopping it, so we can generate multiple datasets +# during a scan, or overlap data acquired at different scan stations. +# It can also terminate either on the counter or any of the histogram objects. +MakeHMControl_ANSTO hmc bm hmm + +############################################## +# Creating scans and creating/attaching +# associated objects such as motors to drive, +# extra counters etc. +############################################## + +# +# Define two scan objects which use the beam monitor counter. +# +# For hmscan, the hmc object uses the bm counter to control +# acquisition duration. In other words, the acquisition duration +# is controlled via SICS. This is fine if the duration doesn't +# need to be controlled to an accuracy of less than one second. +# The bm only allows control of acquisition duration based on +# elapsed time or number of monitor counts. +# +# For scan2, the histogram server controls acquisition duration. +# In addition to time or monitor count based termination conditions, +# the histogram server can be configured to terminate after a +# specific number of frames or periods have elapsed, or can be +# terminated in response to an external dataset signal. +# The accuracy of control of the acquisition duration is much higher +# (milliseconds versus hundreds of milliseconds). +# Also, the histogram server can be configured to extend acquisition +# so that only whole frames or periods are acquired. +# Termination condition is normally already configured via +# the histogram server's configuration files. +# If a static termination condition is already configured, +# scan2_runa can be called, with no termination condition required. +# But if the SICS user wants to dynamically commit the termination +# condition configuration to the histogram server, +# a wrapper function scan2_runb should be called instead. +# This allows the termination condition configuration to be written to +# the histogram server dynamically, under the control of SICS. +# The histogram server has a wider range of options for +# termination condition, and there are three termination condition +# arguments instead of the usual two for SICS counter objects. +# +# In both cases, we make the bm the master counter for the scan, +# so that bm statistics are acquired during the scan. +# +# 17/11/06 NOTE: The Beam Monitor is not yet interfaced directly to the +# Histogram Server. This means that for BM-controlled acquisitions, +# SICS needs to use the BM counter (i.e. use hmscan not scan2). +# +# EXAMPLES: For scan running over 5 stops and acquisition of 1 sec at each stop: +# hmscan run 5 timer 1 (termination controlled by the beam monitor) +# scan2_runb 5 TIME 100 IMMEDIATE (termination controlled by the histogram server) +# +MakeScanCommand hmscan bm $cfPath(scan)/echidna.hdd recover.bin +MakeScanCommand scan2 bm $cfPath(scan)/echidna.hdd recover.bin +# +# Call is: scan2_runa +proc scan2_runa {n} { +# The termination condition is ignored, because the +# histogram server controls the acquisition duration +# directly in this case. + scan2 run $n timer 0 +} +Publish scan2_runa User +# +# Call is: scan2_runb +proc scan2_runb {n count_method count_size count_stop} { +# Commit the termination conditions to the histogram server. +# hmm configure stores the values in the dictionary, +# then hmm init causes them to be sent to the histogram server. +# We just 'assume' they are successfully written. + hmm configure FAT_COUNT_METHOD $count_method + hmm configure FAT_COUNT_SIZE $count_size + hmm configure FAT_COUNT_STOP $count_stop + hmm init +# The termination condition is ignored, because the +# histogram server controls the acquisition duration +# directly in this case. So, use 'timer 0' here. + scan2 run $n timer 0 +} +Publish scan2_runb User + +# Simulated counter. No error rate. Required for technical reasons... +# This counter is used only to block execution till the bm count is actually reached, +# for the scan example using hmc and bm objects to control the acquisition duration from SICS. +MakeCounter blockctr SIM -1.0 +blockctr SetExponent 0 +blockctr SetMode timer +blockctr SetPreset 0 + +# Later on we can add some motors to drive... +#Motor som2 ASIM 0 100 -1.0 0.01 +#hmscan add som2 0 1 + +############################################## +# Support for using expanded histogram period +# to create interlaced/overlapped histograms +############################################## + +# Define an OAT offset variable to use with both scans: +# It is possible to effectively offset the histogram filler's +# OAT table by an arbitrary amount. For overlapped data acquisitions, we can +# configure an oversized histogram period using the EXPAND_OAT parameters +# in the FAT. Then at each scan stop, before acqisition commences the offset +# can be adjusted using the OFFSET_OAT paramters of the FAT. By progressively +# stepping the OFFSET_OAT, an overlapped image can be built up. +# The global variable oatoffset is defined for this purpose. +# During the scan, this variable is incremented and can be passed +# in to an argument of set_oat_offset to provide progressively +# increasing offset, producing an overlapped histogram. +# +global oatoffset +# +#Function to apply OAT offsets to the histogram server. +proc set_oat_offset {oatoff_x oatoff_y oatoff_t} { + hmm configure FAT_OFFSET_OAT_X $oatoff_x + hmm configure FAT_OFFSET_OAT_Y $oatoff_y + hmm configure FAT_OFFSET_OAT_T $oatoff_t + hmm init + return +} +Publish set_oat_offset User + +############################################## +# Support for data acquisition +############################################## + +# A simple procedure to read the histogram data through SICS +# and dump the data to a numbered file. +proc savehistodata {histomem filename} { + set fh [open $filename "w"] +# To get the whole memory, we don't need to specify the start or end arguments. +# But we need to specify the bank number, this sets the type of data to be read. +# + set histodata [$histomem get [hmmdictitemval $histomem bank]] +# clientput $histodata value + puts -nonewline $fh $histodata + close $fh + return +} + +############################################## +############################################## +## Scan Callback Procedures ## +############################################## +############################################## + +# The prepare callback gets called at the start of the scan. +# We use it to pause the histogram server, in order to commence the DAQ. +# This 'primes' the DAE also (i.e. device drivers reboot the hardware, +# buffering processes are started, etc.) +proc hs_prepare {scanobjectname userobjectname} { +#clientput "Enter prepare" value +# +# Before configuring the bm, do a short count. +# This will cause the counter to reconnect if it needs to... + bm count 0 timer +# Now configure the beam monitor counter for better performance. +# (Set a high counter sample rate to get better accuracy). + bm send set scan=1 + bm send set sample=1000 +# Make sure the histogram server is stopped, this guarantees DAQ not in progress already. + hmm stop +# Zero the OAT offsets (whether used or not). + global oatoffset + set oatoffset 0 + set_oat_offset 0 0 0 +# + stdscan prepare $scanobjectname $userobjectname +#clientput "hmm pause being done..." value +# Pause the histogram server, this primes the DAE for acqisition. + hmm pause +#clientput "Exit prepare" value + return +} +Publish hs_prepare User + +# The count_bm_controlled callback gets called at the start of dataset acquisition. +# We use it to perform the dataset acquisition, via the hmc object. +# Note we do NOT call stdscan count, since we don't need to run the bm counter twice. +proc hs_count_bm_controlled {scanobjectname userobjectname point mode preset} { +#clientput "Enter count" value +#stdscan count $scanobjectname $userobjectname $point $mode $preset +# Start the acquisition, runs till the beam monitor terminates +# and then enter paused mode (we have added fifth argument to allow this). +# In fact, execution proceeds immediately (the hmc call doesn't block). + hmc start $preset $mode pause +# Now call the simulated counter. This will cause execution to block +# till the hmc acquisition actually finishes. Otherwise, execution will +# charge on regardless and the finish callback function gets called +# before the last dataset acquisition has finished! + blockctr count 0 +#clientput "Exit count" value + return +} +Publish hs_count_bm_controlled User + +# The count_hs_controlled callback gets called at the start of dataset acquisition. +# We use it to perform the dataset acquisition, controlled by the histogram server. +# Note we do NOT call stdscan count, since we don't need to run the bm counter twice. +proc hs_count_hs_controlled {scanobjectname userobjectname point mode preset} { +#clientput "Enter count" value +#stdscan count $scanobjectname $userobjectname $point $mode $preset +# Start the acquisition, runs till the histogram server auto-terminates. +# This is done by specifying the termination object to be the histogram server, +# not the counter object (place a 1 in 6th argument to hmc object). +# The termination condition for the bm counter is just set to a large time period. +# After the acquisition terminates, the beam monitor therefore has the correct +# status reading and the 'Monitor' entry in the scan data table will be correct. + hmc start 1000000000 timer pause 1 +# Now call the simulated counter. This will cause execution to block +# till the hmc acquisition actually finishes. Otherwise, execution will +# charge on regardless and the finish callback function gets called +# before the last dataset acquisition has finished! + blockctr count 0 +#clientput "Exit count" value + return +} +Publish hs_count_hs_controlled User + +# The collect callback gets called at the end of the dataset acquisition. +# We can put stuff here to retrieve data collected at each scan point, +# and set up OAT offsets or other parameters that might need to be varied +# from point to point at the histogram server, ready for the next scan point. +# In this example, an increasing oatoffset variable is used to configure +# the histogram server's OAT offset in the x direction, to produce +# an overlapped histogram period acquisition. +# Other things might be done here including adjustment of termination +# condition based on beam monitor count. +# Code for adjusting ancillaries, moving secondary motion stages etc. etc. +# from point to point should probably be put into a drive callback function +# (but not in this example script). +proc hs_collect {scanobjectname userobjectname point} { +#clientput "Enter collect" value + set rslt [stdscan collect $scanobjectname $userobjectname $point] +# Apply an OAT offset in the x direction (e.g. along tube number axis). + global oatoffset + incr oatoffset + set_oat_offset $oatoffset 0 0 +# Checking the beam monitor +#clientput [bm send read] value +# At each scan point, read the total x-y histogram +# ans save it. This gets cleared at the start of +# each dataset (when restarting from paused state), +# so it represents the hstogram acquired per scan point. +#clientput "Exit collect" value + return +} +Publish hs_collect User + +# The finish callback gets called at the end of the scan. +# We use it to stop the histogram server, terminating the dataset. +proc hs_finish {scanobjectname userobjectname} { +#clientput "Enter finish" value + stdscan finish $scanobjectname $userobjectname +#clientput "hmm stop being done..." value + hmm stop +# Just in case someone expects zero OAT offsets later on ;) + set_oat_offset 0 0 0 +# Get and write the data from the main histogram to disk (filename "HistoData"). +# Sicne this is the first (and only) access to hmm data, it is retrieved from +# the server and we don't need to do hmm init first to force update hmm memory. +# hmm init + savehistodata hmm "../data/HistoData" +# +#clientput "Exit finish" value + return +} +Publish hs_finish User + +# Configure script mode, then we can configure all the scan callbacks. +# The scan list command can be used to check that the callbacks +# are properly defined. +# A different count callback is defined in the two cases. +# +hmscan configure script +#hmscan function prepare hs_prepare +hmscan function count hs_count_bm_controlled +hmscan function collect hs_collect +hmscan function finish hs_finish +# +scan2 configure script +#scan2 function prepare hs_prepare +scan2 function count hs_count_hs_controlled +scan2 function collect hs_collect +scan2 function finish hs_finish +# +# That's all, folks... diff --git a/site_ansto/instrument/hrpd/config/motors/motor_configuration.tcl b/site_ansto/instrument/hrpd/config/motors/motor_configuration.tcl new file mode 100644 index 00000000..92c2cda1 --- /dev/null +++ b/site_ansto/instrument/hrpd/config/motors/motor_configuration.tcl @@ -0,0 +1,766 @@ +# $Revision: 1.1 $ +# $Date: 2007-02-16 05:43:59 $ +# Author: Ferdi Franceschini (ffr@ansto.gov.au) +# Last revision by: $Author: ffr $ + +# START MOTOR CONFIGURATION + +set animal echidna +# Setup addresses of Galil DMC2280 controllers. +set dmc2280_controller1(host) mc1-$animal +set dmc2280_controller1(port) pmc1-$animal + +set dmc2280_controller2(host) mc2-$animal +set dmc2280_controller2(port) pmc2-$animal + +set dmc2280_controller3(host) mc3-$animal +set dmc2280_controller3(port) pmc3-$animal + +set dmc2280_controller4(host) mc4-$animal +set dmc2280_controller4(port) pmc4-$animal + +#Measured absolute encoder reading at home position +set mphi_Home 7413209 +set mchi_Home 7818834 +set my_Home 7781389 +set mx_Home 7580366 +set mom_Home 13442930 +set mtth_Home 11534660 +set pcx_Home 8345644 +set pcr_Home 6197934 +set sphi_Home 7924507 +set schi_Home 7542917 +set sy_Home 7626584 +set sx_Home 24029910 +set som_Home 24984596 +set stth_Home 14530407 + +#Measured or computed slit motor steps per millimetre +# 125 steps * 161:1 gears = 20125 +set slitStepRate 20125 + +#Measured slit gap, in units, after homing on limit switches +set ss1h_Gap 54.0 +set ss1v_Gap 207.5 +set ss2h_Gap 52.0 +set ss2v_Gap 203.4 + +set ss1r_Home [expr $ss1h_Gap/2*$slitStepRate] +set ss1l_Home [expr $ss1h_Gap/2*$slitStepRate] +set ss1u_Home [expr $ss1v_Gap/2*$slitStepRate] +set ss1d_Home [expr $ss1v_Gap/2*$slitStepRate] +set ss2r_Home [expr $ss2h_Gap/2*$slitStepRate] +set ss2l_Home [expr $ss2h_Gap/2*$slitStepRate] +set ss2u_Home [expr $ss2v_Gap/2*$slitStepRate] +set ss2d_Home [expr $ss2v_Gap/2*$slitStepRate] + +#Default upper and lower ranges for vertical slits +set vertSlitLowRange 25 +set vertSlitUpRange 100 + +#Default upper and lower ranges for horizontal slits +set horSlitLowRange 25 +set horSlitUpRange 25 + +# set movecount high to reduce the frequency of +# hnotify messages to a reasonable level +set move_count 100 + +# Run slit homing routines on controllers 3 and 4 +#if [catch {dmc_connect dmc2280_controller3} ] { +# dmc_sendCmd dmc2280_controller3 "XQ#HOME,1" +# dmc_close dmc2280_controller3 +#} +#if [catch {dmc_connect dmc2280_controller4} ] { +# dmc_sendCmd dmc2280_controller4 "XQ#HOME,1" +# dmc_close dmc2280_controller4 +#} + +############################ +# Motor Controller 1 +# Motor Controller 1 +# Motor Controller 1 +############################ +#:TP at HOME +# + +# Monochromator phi, Tilt 1, upper +Motor mphi DMC2280 [params \ + host $dmc2280_controller1(host)\ + port $dmc2280_controller1(port)\ + axis A\ + units degrees\ + hardlowerlim -15\ + hardupperlim 15\ + maxSpeed 1\ + maxAccel 1\ + maxDecel 1\ + stepsPerX -25000\ + absEnc 1\ + absEncHome $mphi_Home\ + cntsPerX -8192] +setHomeandRange -motor mphi -home 0 -lowrange 15 -uprange 15 +mphi speed 1 +mphi movecount $move_count +mphi precision 0.05 + +# Monochromator chi, Tilt 2, lower +Motor mchi DMC2280 [params \ + host $dmc2280_controller1(host)\ + port $dmc2280_controller1(port)\ + axis B\ + units degrees\ + hardlowerlim 75\ + hardupperlim 105\ + maxSpeed 1\ + maxAccel 1\ + maxDecel 1\ + stepsPerX 25000\ + absEnc 1\ + absEncHome $mchi_Home\ + cntsPerX 8192] +setHomeandRange -motor mchi -home 90 -lowrange 15 -uprange 15 +mchi speed 1 +mchi movecount $move_count +mchi precision 0.01 + +# Monochromator Trans 1, upper +Motor my DMC2280 [params \ + host $dmc2280_controller1(host)\ + port $dmc2280_controller1(port)\ + axis C\ + units mm\ + hardlowerlim -20\ + hardupperlim 20\ + maxSpeed 1\ + maxAccel 1\ + maxDecel 1\ + stepsPerX 25000\ + absEnc 1\ + absEncHome $my_Home\ + cntsPerX 8192] +setHomeandRange -motor my -home 0 -lowrange 20 -uprange 20 +my speed 1 +my movecount $move_count +my precision 0.01 + +# Monochromator Trans 2, lower +Motor mx DMC2280 [params \ + host $dmc2280_controller1(host)\ + port $dmc2280_controller1(port)\ + axis D\ + units mm\ + hardlowerlim -20\ + hardupperlim 20\ + maxSpeed 1\ + maxAccel 1\ + maxDecel 1\ + stepsPerX -25000\ + absEnc 1\ + absEncHome $mx_Home\ + cntsPerX -8192] +setHomeandRange -motor mx -home 0 -lowrange 20 -uprange 20 +mx speed 1 +mx movecount $move_count +mx precision 0.01 + +# Monochromator omega, rotate +Motor mom DMC2280 [params \ + host $dmc2280_controller1(host)\ + port $dmc2280_controller1(port)\ + axis E\ + units degrees\ + hardlowerlim -180\ + hardupperlim 180\ + maxSpeed 1\ + maxAccel 1\ + maxDecel 1\ + stepsPerX -12500\ + absEnc 1\ + absEncHome $mom_Home\ + cntsPerX -4096] +setHomeandRange -motor mom -home 0 -lowrange 180 -uprange 180 +mom speed 1 +mom movecount $move_count +mom precision 0.01 + +# Monochromator two-theta, flight-tube rotate +Motor mtth DMC2280 [params \ + host $dmc2280_controller1(host)\ + port $dmc2280_controller1(port)\ + axis F\ + units degrees\ + hardlowerlim 90\ + hardupperlim 137\ + maxSpeed 0.2\ + maxAccel 0.2\ + maxDecel 0.2\ + stepsPerX [expr 25000*18]\ + absEnc 1\ + absEncHome $mtth_Home\ + cntsPerX -93207] +mtth softlowerlim 90 +mtth softupperlim 137 +mtth home 90 +mtth speed 0.2 +mtth movecount $move_count +mtth accel 0.01 +mtth decel 0.01 +mtth precision 0.02 +mtth maxretry 10 +mtth failafter 10 +mtth blockage_check_interval 5 +# Primary Collimator Translation X +Motor pcx DMC2280 [params \ + host $dmc2280_controller1(host)\ + port $dmc2280_controller1(port)\ + axis G\ + units mm\ + hardlowerlim 0\ + hardupperlim 140\ + maxSpeed 10\ + maxAccel 1\ + maxDecel 1\ + stepsPerX [expr -25000/6]\ + absEnc 1\ + absEncHome $pcx_Home\ + cntsPerX [expr 8192/6]] +setHomeandRange -motor pcx -home 0 -lowrange 0 -uprange 140 +pcx speed 1 +pcx movecount $move_count +pcx precision 0.01 + +# Primary Collimator Rotation +Motor pcr DMC2280 [params \ + host $dmc2280_controller1(host)\ + port $dmc2280_controller1(port)\ + axis H\ + units degrees\ + hardlowerlim -10\ + hardupperlim 10\ + maxSpeed 0.1\ + maxAccel 0.1\ + maxDecel 0.1\ + stepsPerX [expr -25000/(360/100)]\ + absEnc 1\ + absEncHome $pcr_Home\ + cntsPerX [expr 8192/(360/100)]] +setHomeandRange -motor pcr -home 0 -lowrange 10 -uprange 10 +pcr speed 0.1 +pcr movecount $move_count +pcr precision 0.01 + +############################ +# Motor Controller 2 +# Motor Controller 2 +# Motor Controller 2 +############################ + +# Sample Tilt 1, upper, phi +Motor sphi DMC2280 [params \ + host $dmc2280_controller2(host)\ + port $dmc2280_controller2(port)\ + axis A\ + units degrees\ + hardlowerlim -20\ + hardupperlim 20\ + maxSpeed 1\ + maxAccel 1\ + maxDecel 1\ + stepsPerX -25000\ + absEnc 1\ + absEncHome $sphi_Home\ + cntsPerX -8192] +setHomeandRange -motor sphi -home 0 -lowrange 20 -uprange 20 +sphi speed 1 +sphi movecount $move_count +sphi precision 0.01 + +# Sample Tilt 2, lower, chi +Motor schi DMC2280 [params \ + host $dmc2280_controller2(host)\ + port $dmc2280_controller2(port)\ + axis B\ + units degrees\ + hardlowerlim 70\ + hardupperlim 110\ + maxSpeed 1\ + maxAccel 1\ + maxDecel 1\ + stepsPerX 25000\ + absEnc 1\ + absEncHome $schi_Home\ + cntsPerX 8192] +setHomeandRange -motor schi -home 90 -lowrange 20 -uprange 20 +schi speed 1 +schi movecount $move_count +schi precision 0.01 + +# Sample Trans 1, upper, y +Motor sy DMC2280 [params \ + host $dmc2280_controller2(host)\ + port $dmc2280_controller2(port)\ + axis C\ + units mm\ + hardlowerlim -20\ + hardupperlim 20\ + maxSpeed 1\ + maxAccel 1\ + maxDecel 1\ + stepsPerX 25000\ + absEnc 1\ + absEncHome $sy_Home\ + cntsPerX 8192] +setHomeandRange -motor sy -home 0 -lowrange 20 -uprange 20 +sy speed 1 +sy movecount $move_count +sy precision 0.01 + +# Sample Trans2, lower, x +Motor sx DMC2280 [params \ + host $dmc2280_controller2(host)\ + port $dmc2280_controller2(port)\ + axis D\ + units mm\ + hardlowerlim -20\ + hardupperlim 20\ + maxSpeed 1\ + maxAccel 1\ + maxDecel 1\ + stepsPerX -25000\ + absEnc 1\ + absEncHome $sx_Home\ + cntsPerX -8192] +setHomeandRange -motor sx -home 0 -lowrange 20 -uprange 20 +sx speed 1 +sx movecount $move_count +sx precision 0.01 + +# Sample Omega, rotate +Motor som DMC2280 [params \ + host $dmc2280_controller2(host)\ + port $dmc2280_controller2(port)\ + axis E\ + units degrees\ + hardlowerlim -142\ + hardupperlim 218\ + maxSpeed 1\ + maxAccel 1\ + maxDecel 1\ + stepsPerX 12500\ + absEnc 1\ + absEncHome $som_Home\ + cntsPerX 4096] +setHomeandRange -motor som -home 0 -lowrange 142 -uprange 218 +som speed 1 +som movecount $move_count +som precision 0.01 + +# Sample two-theta, detector rotate +Motor stth DMC2280 [params \ + host $dmc2280_controller2(host)\ + port $dmc2280_controller2(port)\ + axis F\ + units degrees\ + hardlowerlim -79\ + hardupperlim 77\ + maxSpeed 0.5\ + maxAccel 0.1\ + maxDecel 0.1\ + stepsPerX 125000\ + absEnc 1\ + absEncHome $stth_Home\ + cntsPerX -93207] +stth softlowerlim -77 +stth softupperlim 74 +stth home 0 +stth speed 0.5 +stth movecount $move_count +stth precision 0.01 +stth blockage_check_interval 2 + +############################ +# Motor Controller 3 +# Motor Controller 3 +# Motor Controller 3 +############################ +# + +# Monochromator Focusing (Ge) +#Motor mf1 DMC2280 [params \ +# host $dmc2280_controller3(host)\ +# port $dmc2280_controller3(port)\ +# axis A\ +# units degrees\ +# maxSpeed xxxx\ +# maxAccel xxxx\ +# maxDecel xxxx\ +# stepsPerX xxxx\ +# absEnc 1\ +# absEncHome $mf1_Home\ +# cntsPerX xxxx] +#setHomeandRange -motor mf1 -home 0 -lowrange 0 -uprange 360 +#mf1 speed 1 +#mfl movecount $move_count +#mf1 precision 0.01 + +# Slit 1, right +Motor ss1r DMC2280 [params \ + host $dmc2280_controller3(host)\ + port $dmc2280_controller3(port)\ + axis E\ + units mm\ + hardlowerlim -15\ + hardupperlim 35\ + maxSpeed 1\ + maxAccel 1\ + maxDecel 1\ + stepsPerX -$slitStepRate\ + motorHome $ss1r_Home] +setHomeandRange -motor ss1r -home 0 -lowrange $horSlitLowRange -uprange $horSlitUpRange +ss1r movecount $move_count + +# Slit 1, left +Motor ss1l DMC2280 [params \ + host $dmc2280_controller3(host)\ + port $dmc2280_controller3(port)\ + axis F\ + units mm\ + hardlowerlim -15\ + hardupperlim 35\ + maxSpeed 1\ + maxAccel 1\ + maxDecel 1\ + stepsPerX -$slitStepRate\ + motorHome $ss1l_Home] +setHomeandRange -motor ss1l -home 0 -lowrange $horSlitLowRange -uprange $horSlitUpRange +ss1l movecount $move_count + +# Slit 1, up +Motor ss1u DMC2280 [params \ + host $dmc2280_controller3(host)\ + port $dmc2280_controller3(port)\ + axis G\ + units mm\ + hardlowerlim -20\ + hardupperlim 100\ + maxSpeed 1\ + maxAccel 1\ + maxDecel 1\ + stepsPerX -$slitStepRate\ + motorHome $ss1u_Home] +setHomeandRange -motor ss1u -home 0 -lowrange $vertSlitLowRange -uprange $vertSlitUpRange +ss1u movecount $move_count + +# Slit 1, down +Motor ss1d DMC2280 [params \ + host $dmc2280_controller3(host)\ + port $dmc2280_controller3(port)\ + axis H\ + units mm\ + hardlowerlim -20\ + hardupperlim 100\ + maxSpeed 1\ + maxAccel 1\ + maxDecel 1\ + stepsPerX -$slitStepRate\ + motorHome $ss1d_Home] +setHomeandRange -motor ss1d -home 0 -lowrange $vertSlitLowRange -uprange $vertSlitUpRange +ss1d movecount $move_count + +############################ +# Motor Controller 4 +# Motor Controller 4 +# Motor Controller 4 +############################ +# + +# Little is known about the Eulerian Cradle +## Eulerian-phi +#Motor ephi DMC2280 [params \ +# host $dmc2280_controller4(host)\ +# port $dmc2280_controller4(port)\ +# axis A\ +# units degrees\ +# maxSpeed xxxx\ +# maxAccel xxxx\ +# maxDecel xxxx\ +# stepsPerX xxxx\ +# absEnc 1\ +# absEncHome $ephi_Home\ +# cntsPerX xxxx] +#setHomeandRange -motor ephi -home 0 -lowrange 180 -uprange 180 + +#Motor echi DMC2280 [params \ +# host $dmc2280_controller4(host)\ +# port $dmc2280_controller4(port)\ +# axis B\ +# units degrees\ +# maxSpeed xxxx\ +# maxAccel xxxx\ +# maxDecel xxxx\ +# stepsPerX xxxx\ +# absEnc 1\ +# absEncHome $echi_Home\ +# cntsPerX xxxx] +#setHomeandRange -motor echi -home 0 -lowrange 180 -uprange 180 + +# Slit 2, right +Motor ss2r DMC2280 [params \ + host $dmc2280_controller4(host)\ + port $dmc2280_controller4(port)\ + axis E\ + units mm\ + hardlowerlim -15\ + hardupperlim 35\ + maxSpeed 1\ + maxAccel 1\ + maxDecel 1\ + stepsPerX -$slitStepRate\ + motorHome $ss2r_Home] +setHomeandRange -motor ss2r -home 0 -lowrange $horSlitLowRange -uprange $horSlitUpRange +ss2r movecount $move_count + +# Slit 2, left +Motor ss2l DMC2280 [params \ + host $dmc2280_controller4(host)\ + port $dmc2280_controller4(port)\ + axis F\ + units mm\ + hardlowerlim -15\ + hardupperlim 35\ + maxSpeed 1\ + maxAccel 1\ + maxDecel 1\ + stepsPerX -$slitStepRate\ + motorHome $ss2l_Home] +setHomeandRange -motor ss2l -home 0 -lowrange $horSlitLowRange -uprange $horSlitUpRange +ss2l movecount $move_count + +# Slit 2, up +Motor ss2u DMC2280 [params \ + host $dmc2280_controller4(host)\ + port $dmc2280_controller4(port)\ + axis G\ + units mm\ + hardlowerlim -20\ + hardupperlim 100\ + maxSpeed 1\ + maxAccel 1\ + maxDecel 1\ + stepsPerX -$slitStepRate\ + motorHome $ss2u_Home] +setHomeandRange -motor ss2u -home 0 -lowrange $vertSlitLowRange -uprange $vertSlitUpRange +ss2u movecount $move_count + +# Slit 2, down +Motor ss2d DMC2280 [params \ + host $dmc2280_controller4(host)\ + port $dmc2280_controller4(port)\ + axis H\ + units mm\ + hardlowerlim -20\ + hardupperlim 100\ + maxSpeed 1\ + maxAccel 1\ + maxDecel 1\ + stepsPerX -$slitStepRate\ + motorHome $ss2d_Home] +setHomeandRange -motor ss2d -home 0 -lowrange $vertSlitLowRange -uprange $vertSlitUpRange +ss2d movecount $move_count + +proc mthGet {} { return [expr [SplitReply [mtth]]/2.0]} +proc mthSet {val} { return "mtth=[SplitReply [mtth]]"} +publish mthSet user +publish mthGet user +MakeConfigurableMotor mth +mth readscript mthGet +mth drivescript mthSet + +proc sthGet {} { return [expr [SplitReply [stth]]/2.0]} +proc sthSet {val} { return "stth=[SplitReply [stth]]"} +publish sthGet user +publish sthSet user +MakeConfigurableMotor sth +sth readscript sthGet +sth drivescript sthSet + +#-------------------------------------------------------- +proc ss1widthscript {val} { + set currentWidth [expr [SplitReply [ss1r]] + [SplitReply [ss1l]]] + set diff [expr $val - $currentWidth] + set newD1R [expr [SplitReply [ss1r]] + $diff/2] + set newD1L [expr [SplitReply [ss1l]] + $diff/2] + return "ss1r=$newD1R,ss1l=$newD1L" +} +publish ss1widthscript user + +#------------------------------------------------------- +proc ss1readwidth {} { + return [expr [SplitReply [ss1r]] + [SplitReply [ss1l]]] +} +publish ss1readwidth user +MakeConfigurableMotor ss1hg +ss1hg drivescript ss1widthscript +ss1hg readscript ss1readwidth + +#-------------------------------------------------------- +proc ss1horoffsetscript {val} { + set SR [SplitReply [ss1r]] + set SL [SplitReply [ss1l]] + set currentOffset [ expr $SR - ($SR + $SL)/2.0 ] + set diff [expr $val - $currentOffset] + set newD1R [expr $SR + $diff] + set newD1L [expr $SL - $diff] + return "ss1r=$newD1R,ss1l=$newD1L" +} +publish ss1horoffsetscript user + +#------------------------------------------------------- +proc ss1readhoroffset {} { + set SR [SplitReply [ss1r]] + return [ expr $SR - ($SR + [SplitReply [ss1l]])/2.0 ] +} +publish ss1readhoroffset user + +#------------------------------------------------------- +MakeConfigurableMotor ss1ho +ss1ho drivescript ss1horoffsetscript +ss1ho readscript ss1readhoroffset + +#----------------------------------------------------- +proc ss1heightscript {val} { + set currentWidth [expr [SplitReply [ss1u]] + [SplitReply [ss1d]]] + set diff [expr $val - $currentWidth] + set newD1B [expr [SplitReply [ss1d]] + $diff/2] + set newD1T [expr [SplitReply [ss1u]] + $diff/2] + return "ss1d=$newD1B,ss1u=$newD1T" +} +publish ss1heightscript user + +#------------------------------------------------------- +proc ss1readheight {} { + return [expr [SplitReply [ss1u]] + [SplitReply [ss1d]]] +} +publish ss1readheight user + +#--------------------------------------------------------- +MakeConfigurableMotor ss1vg +ss1vg drivescript ss1heightscript +ss1vg readscript ss1readheight + +#-------------------------------------------------------- +proc ss1vertoffsetscript {val} { + set SU [SplitReply [ss1u]] + set SD [SplitReply [ss1d]] + set currentOffset [ expr $SU - ($SU + $SD)/2.0 ] + set diff [expr $val - $currentOffset] + set newD1U [expr $SU + $diff] + set newD1D [expr $SD - $diff] + return "ss1u=$newD1U,ss1d=$newD1D" +} +publish ss1vertoffsetscript user + +#------------------------------------------------------- +proc ss1readvertoffset {} { + set SU [SplitReply [ss1u]] + return [ expr $SU - ($SU + [SplitReply [ss1d]])/2.0 ] +} +publish ss1readvertoffset user + +#------------------------------------------------------- +MakeConfigurableMotor ss1vo +ss1vo drivescript ss1vertoffsetscript +ss1vo readscript ss1readvertoffset +############################################### + + +#-------------------------------------------------------- +proc ss2widthscript {val} { + set currentWidth [expr [SplitReply [ss2r]] + [SplitReply [ss2l]]] + set diff [expr $val - $currentWidth] + set newD1R [expr [SplitReply [ss2r]] + $diff/2] + set newD1L [expr [SplitReply [ss2l]] + $diff/2] + return "ss2r=$newD1R,ss2l=$newD1L" +} +publish ss2widthscript user + +#------------------------------------------------------- +proc ss2readwidth {} { + return [expr [SplitReply [ss2r]] + [SplitReply [ss2l]]] +} +publish ss2readwidth user +MakeConfigurableMotor ss2hg +ss2hg drivescript ss2widthscript +ss2hg readscript ss2readwidth + +#-------------------------------------------------------- +proc ss2horoffsetscript {val} { + set SR [SplitReply [ss2r]] + set SL [SplitReply [ss2l]] + set currentOffset [ expr $SR - ($SR + $SL)/2.0 ] + set diff [expr $val - $currentOffset] + set newD1R [expr $SR + $diff] + set newD1L [expr $SL - $diff] + return "ss2r=$newD1R,ss2l=$newD1L" +} +publish ss2horoffsetscript user + +#------------------------------------------------------- +proc ss2readhoroffset {} { + set SR [SplitReply [ss2r]] + return [ expr $SR - ($SR + [SplitReply [ss2l]])/2.0 ] +} +publish ss2readhoroffset user + +#------------------------------------------------------- +MakeConfigurableMotor ss2ho +ss2ho drivescript ss2horoffsetscript +ss2ho readscript ss2readhoroffset + +#----------------------------------------------------- +proc ss2heightscript {val} { + set currentWidth [expr [SplitReply [ss2u]] + [SplitReply [ss2d]]] + set diff [expr $val - $currentWidth] + set newD1B [expr [SplitReply [ss2d]] + $diff/2] + set newD1T [expr [SplitReply [ss2u]] + $diff/2] + return "ss2d=$newD1B,ss2u=$newD1T" +} +publish ss2heightscript user + +#------------------------------------------------------- +proc ss2readheight {} { + return [expr [SplitReply [ss2u]] + [SplitReply [ss2d]]] +} +publish ss2readheight user + +#--------------------------------------------------------- +MakeConfigurableMotor ss2vg +ss2vg drivescript ss2heightscript +ss2vg readscript ss2readheight + +#-------------------------------------------------------- +proc ss2vertoffsetscript {val} { + set SU [SplitReply [ss2u]] + set SD [SplitReply [ss2d]] + set currentOffset [ expr $SU - ($SU + $SD)/2.0 ] + set diff [expr $val - $currentOffset] + set newD1U [expr $SU + $diff] + set newD1D [expr $SD - $diff] + return "ss2u=$newD1U,ss2d=$newD1D" +} +publish ss2vertoffsetscript user + +#------------------------------------------------------- +proc ss2readvertoffset {} { + set SU [SplitReply [ss2u]] + return [ expr $SU - ($SU + [SplitReply [ss2d]])/2.0 ] +} +publish ss2readvertoffset user + +#------------------------------------------------------- +MakeConfigurableMotor ss2vo +ss2vo drivescript ss2vertoffsetscript +ss2vo readscript ss2readvertoffset + +# END MOTOR CONFIGURATION diff --git a/site_ansto/instrument/hrpd/config/nexus/echidna.dic b/site_ansto/instrument/hrpd/config/nexus/echidna.dic new file mode 100644 index 00000000..cd9fb505 --- /dev/null +++ b/site_ansto/instrument/hrpd/config/nexus/echidna.dic @@ -0,0 +1,99 @@ +##NXDICT-1.0 +#---------------------------------------------------------------------------- +# +# DO NOT EDIT WHEN YOU DO NOT KNOW WHAT YOU ARE DOING! +# This file determines the placement of data items in the Powder NeXus +# data file. Your data may not be readable if this file is messed up. +# +# Mark Koennecke, May 2004 +#---------------------------------------------------------------------------- +entryName=entry1 +dataName=histogram +inst=instrument +detector=detector +monochromator=monochromator +thetadim=128 +scan_variable=scanvar +samplemotor=samplemotor +#---------- NXentry level +etitle=/$(entryName),NXentry/SDS title -type NX_CHAR +estart=/$(entryName),NXentry/SDS start_time -type NX_CHAR +eend=/$(entryName),NXentry/SDS end_time -type NX_CHAR +#----------------- NXinstrument +iname=/$(entryName),NXentry/$(inst),NXinstrument/SDS name -type NX_CHAR \ + -rank 1 -dim {132} + + +#----------------- NXmonitor +mmode=/$(entryName),NXentry/monitor,NXmonitor/SDS mode -type NX_CHAR +mpreset=/$(entryName),NXentry/monitor,NXmonitor/SDS preset -type NX_FLOAT32 +mdata=/$(entryName),NXentry/monitor,NXmonitor/SDS data -type NX_INT32 +mdistance=/$(entryName),NXentry/monitor,NXmonitor/SDS distance -type NX_FLOAT32 -attr {units,metre} + +#----------------- NXsource +sname=/$(entryName),NXentry/$(inst),NXinstrument/source,NXsource/SDS name \ + -type NX_CHAR -rank 1 +stype=/$(entryName),NXentry/$(inst),NXinstrument/source,NXsource/SDS type -type NX_CHAR -rank 1 +sprobe=/$(entryName),NXentry/$(inst),NXinstrument/source,NXsource/SDS probe -type NX_CHAR -rank 1 +#----------------- NXcrystal +clambda=/$(entryName),NXentry/$(inst),NXinstrument/monochromator_crystal,NXcrystal/SDS wavelength -type NX_FLOAT32 -attr {units,Angstrom} +ctype=/$(entryName),NXentry/$(inst),NXinstrument/monochromator_crystal,NXcrystal/SDS type -type NX_CHAR +#------------- counter +#-------------- Detector +# histogram data +dradius=/$(entryName),NXentry/$(inst),NXinstrument/$(detector),NXdetector/SDS distance -type NX_FLOAT32 +dtheta=/$(entryName),NXentry/$(inst),NXinstrument/$(detector),NXdetector/SDS polar_angle -type NX_FLOAT32 -LZW -rank 1 -dim {$(thetadim)} -attr {units,degree} + +dcounts=/$(entryName),NXentry/$(inst),NXinstrument/$(detector),NXdetector/SDS \ + data -type NX_INT32 -LZW -rank 2 -dim {$(dim0),$(dim1)} \ + -attr {signal,1} + +deff=/$(entryName),NXentry/$(inst),NXinstrument/$(detector),NXdetector/calibration,NXdata/SDS efficiency -type NX_INT32 -LZW -rank 2 -dim {$(dim0),$(dim1)} + +ddesc=/$(entryName),NXentry/$(inst),NXinstrument/$(detector),NXdetector/SDS description -type NX_CHAR + +dtype=/$(entryName),NXentry/$(inst),NXinstrument/$(detector),NXdetector/SDS type -type NX_CHAR + +dlayout=/$(entryName),NXentry/$(inst),NXinstrument/$(detector),NXdetector/SDS layout -type NX_CHAR +#--------------- NXmonochromator +mom=/$(entryName),NXentry/$(inst),NXinstrument/$(monochromator),NXmonochromator/mom,NXpositioner/SDS value -type NX_FLOAT32 -attr {units,degree} -attr {long_name,mom} +mchi=/$(entryName),NXentry/$(inst),NXinstrument/$(monochromator),NXmonochromator/mchi,NXpositioner/SDS value -type NX_FLOAT32 -attr {units,degree} -attr {long_name,mchi} +mphi=/$(entryName),NXentry/$(inst),NXinstrument/$(monochromator),NXmonochromator/mphi,NXpositioner/SDS value -type NX_FLOAT32 -attr {units,degree} -attr {long_name,mphi} +mx=/$(entryName),NXentry/$(inst),NXinstrument/$(monochromator),NXmonochromator/mx,NXpositioner/SDS value -type NX_FLOAT32 -attr {units,degree} -attr {long_name,mx} +my=/$(entryName),NXentry/$(inst),NXinstrument/$(monochromator),NXmonochromator/my,NXpositioner/SDS value -type NX_FLOAT32 -attr {units,degree} -attr {long_name,my} +mtth=/$(entryName),NXentry/$(inst),NXinstrument/$(monochromator),NXmonochromator/mtth,NXpositioner/SDS value -type NX_FLOAT32 -attr {units,degree} -attr {long_name,mtth} +mth=/$(entryName),NXentry/$(inst),NXinstrument/$(monochromator),NXmonochromator/mth,NXpositioner/SDS value -type NX_FLOAT32 -attr {units,degree} -attr {long_name,mth} +#--------------- NXsample +saname=/$(entryName),NXentry/sample,NXsample/SDS name -type NX_CHAR +sarot=/$(entryName),NXentry/sample,NXsample/SDS rotation_angle -type NX_FLOAT32 -attr {units,degree} +som=/$(entryName),NXentry/sample,NXsample/som,NXpositioner/SDS value -type NX_FLOAT32 -attr {units,degree} -attr {long_name,som} +schi=/$(entryName),NXentry/sample,NXsample/schi,NXpositioner/SDS value -type NX_FLOAT32 -attr {units,degree} -attr {long_name,schi} +sphi=/$(entryName),NXentry/sample,NXsample/sphi,NXpositioner/SDS value -type NX_FLOAT32 -attr {units,degree} -attr {long_name,sphi} +sx=/$(entryName),NXentry/sample,NXsample/sx,NXpositioner/SDS value -type NX_FLOAT32 -attr {units,degree} -attr {long_name,sx} +sy=/$(entryName),NXentry/sample,NXsample/sy,NXpositioner/SDS value -type NX_FLOAT32 -attr {units,degree} -attr {long_name,sy} +stth=/$(entryName),NXentry/sample,NXsample/stth,NXpositioner/SDS value -type NX_FLOAT32 -attr {units,degree} -attr {long_name,stth} +sth=/$(entryName),NXentry/sample,NXsample/sth,NXpositioner/SDS value -type NX_FLOAT32 -attr {units,degree} -attr {long_name,sth} +# Slit motors +ss1u=/$(entryName),NXentry/sample,NXsample/ss1u,NXpositioner/SDS value -type NX_FLOAT32 -attr {units,degree} -attr {long_name,ss1u} +ss1d=/$(entryName),NXentry/sample,NXsample/ss1d,NXpositioner/SDS value -type NX_FLOAT32 -attr {units,degree} -attr {long_name,ss1d} +ss1l=/$(entryName),NXentry/sample,NXsample/ss1l,NXpositioner/SDS value -type NX_FLOAT32 -attr {units,degree} -attr {long_name,ss1l} +ss1r=/$(entryName),NXentry/sample,NXsample/ss1r,NXpositioner/SDS value -type NX_FLOAT32 -attr {units,degree} -attr {long_name,ss1r} +ss1vg=/$(entryName),NXentry/sample,NXsample/ss1vg,NXpositioner/SDS value -type NX_FLOAT32 -attr {units,degree} -attr {long_name,ss1vg} +ss1vo=/$(entryName),NXentry/sample,NXsample/ss1vo,NXpositioner/SDS value -type NX_FLOAT32 -attr {units,degree} -attr {long_name,ss1vo} +ss1hg=/$(entryName),NXentry/sample,NXsample/ss1hg,NXpositioner/SDS value -type NX_FLOAT32 -attr {units,degree} -attr {long_name,ss1hg} +ss1ho=/$(entryName),NXentry/sample,NXsample/ss1ho,NXpositioner/SDS value -type NX_FLOAT32 -attr {units,degree} -attr {long_name,ss1ho} +ss2u=/$(entryName),NXentry/sample,NXsample/ss2u,NXpositioner/SDS value -type NX_FLOAT32 -attr {units,degree} -attr {long_name,ss2u} +ss2d=/$(entryName),NXentry/sample,NXsample/ss2d,NXpositioner/SDS value -type NX_FLOAT32 -attr {units,degree} -attr {long_name,ss2d} +ss2l=/$(entryName),NXentry/sample,NXsample/ss2l,NXpositioner/SDS value -type NX_FLOAT32 -attr {units,degree} -attr {long_name,ss2l} +ss2r=/$(entryName),NXentry/sample,NXsample/ss2r,NXpositioner/SDS value -type NX_FLOAT32 -attr {units,degree} -attr {long_name,ss2r} +ss2vg=/$(entryName),NXentry/sample,NXsample/ss2vg,NXpositioner/SDS value -type NX_FLOAT32 -attr {units,degree} -attr {long_name,ss2vg} +ss2vo=/$(entryName),NXentry/sample,NXsample/ss2vo,NXpositioner/SDS value -type NX_FLOAT32 -attr {units,degree} -attr {long_name,ss2vo} +ss2hg=/$(entryName),NXentry/sample,NXsample/ss2hg,NXpositioner/SDS value -type NX_FLOAT32 -attr {units,degree} -attr {long_name,ss2hg} +ss2ho=/$(entryName),NXentry/sample,NXsample/ss2ho,NXpositioner/SDS value -type NX_FLOAT32 -attr {units,degree} -attr {long_name,ss2ho} +#----------------NXdata ------------------------------------------------ +scandata=/$(entryName),NXentry/scan_data,NXdata/NXVGROUP +scanvar=/$(entryName),NXentry/scan_variable,NXdata/NXVGROUP +scanstep=/$(entryName),NXentry/scan_step,NXdata/SDS value -type NX_FLOAT32 -attr {units,degree} -attr {long_name,stepsize} +#histogram=/$(entryName),NXentry/histogram,NXdata/NXVGROUP +#scanvar=/$(entryName),NXentry/$(scan_variable),NXdata/NXVGROUP + diff --git a/site_ansto/instrument/hrpd/config/nexus/nxscripts.tcl b/site_ansto/instrument/hrpd/config/nexus/nxscripts.tcl new file mode 100644 index 00000000..ef4038bf --- /dev/null +++ b/site_ansto/instrument/hrpd/config/nexus/nxscripts.tcl @@ -0,0 +1,148 @@ +MakeNXScript +#nxscript createxml junk4.xml echidna.dic +proc getVal {msg} { + return [string trim [lindex [split $msg =] 1 ] ] +} + +proc newFileName {} { + sicsdatanumber incr; + set idNum [SplitReply [sicsdatanumber]]; + set dataPath [SplitReply [sicsdatapath]]; + set prefix [SplitReply [sicsdataprefix]]; + set postfix [SplitReply [sicsdatapostfix]]; + set isodate [lindex [split [sicstime] " "] 0]; + return [format "%s/%s_%s_%s%s" $dataPath $prefix $isodate $idNum $postfix]; +} + +proc nxcreatefile {{type nx.hdf}} { + global dataFileName nxFileOpen cfPath; + SicsDataPostFix .$type; + + array set nxmode [list nx.hdf create5 h5 create5 nx5 create5 xml createxml]; + set dataFileName [newFileName] + nxscript $nxmode($type) $dataFileName $cfPath(nexus)/echidna.dic; + set nxFileOpen true +} + + +proc nxreopenfile {} { + global dataFileName nxFileOpen cfPath; + nxscript reopen $dataFileName $cfPath(nexus)/echidna.dic; + set nxFileOpen true; +} + +proc nxclosefile {} { + global dataFileName nxFileOpen; + if {$nxFileOpen == true} { + nxscript close; + set nxFileOpen false; + set flist [split $dataFileName "/"]; + set fname [lindex $flist [expr [llength $flist] - 1] ]; + clientput "$fname updated" "event"; + } +} + +set dradius 1.25 +set ndect 128 +set tubedia 0.0254 +set pi 3.1415926 +#set angsep [expr $tubedia/$dradius *(180/$pi)] +set angsep 1.25 +# stthmin = (180 - (1.25*127))/2 +proc addnxentry {nxobj entryname scanVariable scanVarPos scanVarStep} { + global dradius ndect angsep; +putcommon $nxobj $entryname $scanVariable +putcrystal $nxobj +putmonitor $nxobj +putsample $nxobj + set scanVar_value [string trim [lindex [split [$scanVariable] =] 1]] + $nxobj putfloat $scanVariable $scanVar_value +# Add thetamin and stth to tharr(i) + set sampletwotheta [string trim [lindex [split [stth] =] 1]] + for {set i 0} {$i < $ndect} {incr i} { + set tharr($i) [expr ($i-63.5)*$angsep + $sampletwotheta] + } + $nxobj updatedictvar thetadim $ndect + $nxobj putarray dtheta tharr $ndect + $nxobj puttext dtype He-3 position sensitive detector, tube active length=335+/-5mm, tube diameter=25.4 +/- 0.8mm + $nxobj puttext ddesc 128 He-3 proportional counter detector tubes (GE Energy Reuter Stokes Inc. item=RS-P4-0814-217) + $nxobj putfloat dradius $dradius + $nxobj puttext dlayout area + $nxobj puthm dcounts hmm + $nxobj puthm deff hmm + $nxobj makelink scandata dcounts + $nxobj makelink scandata dtheta + $nxobj makelink scanvar $scanVariable + $nxobj putfloat scanstep $scanVarStep + +} + +proc bm_addnxentry {nxobj entryname scanVariable scanVarPos scanVarStep} { + global dradius ndect angsep; +putcommon $nxobj $entryname $scanVariable +putcrystal $nxobj +putmonitor $nxobj +putsample $nxobj + set scanVar_value [string trim [lindex [split [$scanVariable] =] 1]] + $nxobj putfloat $scanVariable $scanVar_value +# Add thetamin and stth to tharr(i) +# $nxobj puttext dtype He-3 position sensitive detector, tube active length=335+/-5mm, tube diameter=25.4 +/- 0.8mm +# $nxobj puttext ddesc 128 He-3 proportional counter detector tubes (GE Energy Reuter Stokes Inc. item=RS-P4-0814-217) +# $nxobj putfloat dradius $dradius + $nxobj puttext dlayout point + $nxobj makelink scandata mdata + $nxobj makelink scanvar $scanVariable + $nxobj putfloat scanstep $scanVarStep + +} + +proc putmonitor {nxobj} { + $nxobj puttext mmode [string trim [lindex [split [bm getmode] =] 1]] + $nxobj putfloat mpreset [string trim [lindex [split [bm getpreset] =] 1]] + $nxobj putint mdata [string trim [lindex [split [bm getcounts] =] 1]] + $nxobj putfloat mdistance [getVal [sics_bm_distance]] +} + +proc putsample {nxobj} { + $nxobj puttext saname [getVal [Sample]] +} +proc putcrystal {nxobj} { + $nxobj puttext ctype [sics_mono_crystal] +} +proc putcommon {nxobj entryName scanVariable} { + $nxobj updatedictvar entryName $entryName + $nxobj updatedictvar scan_variable $scanVariable + $nxobj puttext etitle [getVal [Title]] + $nxobj puttext iname [getVal [Instrument]] + +# NXsource + $nxobj puttext sname OPAL + $nxobj puttext stype Reactor Neutron Source + $nxobj puttext sprobe Neutron + putsamplemotors $nxobj + putslitmotors $nxobj + putmonomotors $nxobj +} + +proc putsamplemotors {nxobj} { + foreach motor { som schi sphi sx sy stth sth } { + $nxobj putfloat $motor [getVal [$motor] ]; + } +} + +proc putmonomotors {nxobj} { + foreach motor { mom mchi mphi mx my mtth mth } { + $nxobj putfloat $motor [getVal [$motor] ]; + } +} + +proc putslitmotors {nxobj} { + foreach motor {ss1u ss1d ss1l ss1r ss1vg ss1vo ss1hg ss1ho ss2u ss2d ss2l ss2r ss2vg ss2vo ss2hg ss2ho } { + $nxobj putfloat $motor [getVal [$motor] ]; + } +} + +publish nxcreatefile user +publish addnxentry user +publish bm_addnxentry user + diff --git a/site_ansto/instrument/hrpd/config/scan/echidna.hdd b/site_ansto/instrument/hrpd/config/scan/echidna.hdd new file mode 100644 index 00000000..1d74c7c0 --- /dev/null +++ b/site_ansto/instrument/hrpd/config/scan/echidna.hdd @@ -0,0 +1,8 @@ +##SICS ASCII at HRPD +*************************** HRPD SCAN File ******************************** +Original Filename = !!FILE!! +Title = !!VAR(Title)!! +User = !!VAR(User)!! +Sample Name = !!VAR(sample)!! +File Creation Date = !!DATE!! +**************************** DATA ****************************************** diff --git a/site_ansto/instrument/hrpd/config/scan/scan.tcl b/site_ansto/instrument/hrpd/config/scan/scan.tcl new file mode 100644 index 00000000..8e49190c --- /dev/null +++ b/site_ansto/instrument/hrpd/config/scan/scan.tcl @@ -0,0 +1,130 @@ +namespace eval scanCommand { +#MakeScanCommand escan counter echidna.hdd recover.bin +variable scanVariable scan_var scanVarStart 0 scanVarStep 1 + proc scan_prepare {sobj uobj} { + variable scanVarStart; + variable scanVarStep; + variable scanVariable; + + nxcreatefile; + nxscript updatedictvar entryName start; + nxscript puttext estart [sicstime]; + nxclosefile; +# stdscan prepare $sobj $uobj; + set vlist [split [$sobj getvarpar 0] = ]; + set scanVariable [string trim [lindex [split [lindex $vlist 0] . ] 1]]; + set scanVarStart [lindex $vlist 1]; + set scanVarStep [lindex $vlist 2]; + hs_prepare $sobj $uobj + } + + proc hm_scan_finish {sobj uobj} { + hs_finish $sobj $uobj; + nxreopenfile; + nxscript updatedictvar entryName stop; + nxscript puttext eend [sicstime]; + nxclosefile; + } + + proc bm_scan_finish {sobj uobj} { + stdscan finish $sobj $uobj; + nxreopenfile; + nxscript updatedictvar entryName stop; + nxscript puttext eend [sicstime]; + nxclosefile; + } +#proc hm_scan_finish {sobj uobj} { +# nxclosefile; +#} + +# Add an nxentry for the current scan point + proc nxaddpoint {sobj uobj pt} { + variable scanVarStart; + variable scanVarStep; + variable scanVariable; + set scanVarPos [expr $scanVarStart + $pt * $scanVarStep]; + nxreopenfile; + addnxentry nxscript scan_[format "%05d" $pt] $scanVariable $scanVarPos $scanVarStep; + nxclosefile + } + + proc donothing {args} {} + +proc bmcount {sobj uobj pt mode preset} { + bm setmode $mode + bm count $preset; +} + proc bm_scan_prepare {sobj uobj} { + variable scanVarStart; + variable scanVarStep; + variable scanVariable; + nxcreatefile; + nxscript updatedictvar entryName start; + nxscript puttext estart [sicstime]; + nxclosefile; + set vlist [split [$sobj getvarpar 0] = ]; + set scanVariable [string trim [lindex [split [lindex $vlist 0] . ] 1]]; + set scanVarStart [lindex $vlist 1]; + set scanVarStep [lindex $vlist 2]; + stdscan prepare $sobj $uobj; + } + proc bm_nxaddpoint {sobj uobj pt} { + variable scanVarStart; + variable scanVarStep; + variable scanVariable; + set scanVarPos [expr $scanVarStart + $pt * $scanVarStep]; + nxreopenfile; + bm_addnxentry nxscript scan_$pt $scanVariable $scanVarPos $scanVarStep; + nxclosefile + } +} + +publish ::scanCommand::scan_prepare user +publish ::scanCommand::hm_scan_finish user +publish ::scanCommand::nxaddpoint user +publish ::scanCommand::donothing user + +publish ::scanCommand::bm_scan_prepare user +publish ::scanCommand::bm_scan_finish user +publish ::scanCommand::bm_nxaddpoint user +publish ::scanCommand::donothing user +publish ::scanCommand::bmcount user + +#scan2 function writeheader ::scanCommand::donothing +#scan2 function writepoint ::scanCommand::nxaddpoint +#scan2 function prepare ::scanCommand::scan_prepare + +hmscan configure script +#hmscan function prepare hdbprepare +#hmscan function collect hdbcollect +hmscan function writeheader ::scanCommand::donothing +hmscan function writepoint ::scanCommand::nxaddpoint +hmscan function prepare ::scanCommand::scan_prepare +hmscan function finish ::scanCommand::hm_scan_finish + +# Wombat proc hdb_hmscan {scanvar scanstart scanincr scanend mode preset} { +proc hdb_hmscan {scanvar scanstart scanincr np mode preset} { + hmscan clear + hmscan configure script + + hmscan add $scanvar scanstart scanincr + set status [catch {hmscan run $np $mode $preset} msg] + hmscan configure soft + if {$status == 0} { + return $msg + } else { + error $msg + } +} + +publish hdb_hmscan user + +MakeScanCommand bmonscan bm $cfPath(scan)/echidna.hdd recover.bin +bmonscan configure script +bmonscan function writeheader ::scanCommand::donothing +bmonscan function writepoint ::scanCommand::bm_nxaddpoint +bmonscan function prepare ::scanCommand::bm_scan_prepare +bmonscan function count ::scanCommand::bmcount +bmonscan function finish ::scanCommand::bm_scan_finish + + diff --git a/site_ansto/instrument/hrpd/script_validator/MANIFEST.TXT b/site_ansto/instrument/hrpd/script_validator/MANIFEST.TXT new file mode 100644 index 00000000..b541f143 --- /dev/null +++ b/site_ansto/instrument/hrpd/script_validator/MANIFEST.TXT @@ -0,0 +1,2 @@ +sics_ports.tcl +config diff --git a/site_ansto/instrument/hrpd/script_validator/hmm_configuration.tcl b/site_ansto/instrument/hrpd/script_validator/config/hmm/hmm_configuration.tcl similarity index 100% rename from site_ansto/instrument/hrpd/script_validator/hmm_configuration.tcl rename to site_ansto/instrument/hrpd/script_validator/config/hmm/hmm_configuration.tcl diff --git a/site_ansto/instrument/hrpd/script_validator/config/motors/motor_configuration.tcl b/site_ansto/instrument/hrpd/script_validator/config/motors/motor_configuration.tcl new file mode 100644 index 00000000..530e1fd9 --- /dev/null +++ b/site_ansto/instrument/hrpd/script_validator/config/motors/motor_configuration.tcl @@ -0,0 +1,256 @@ +# !!- AUTOGENERATED FROM config/motors/motor_configuration.tcl -!! +# !!- DO NOT MODIFY -!! +# Fri 16 Feb 2007 16:19:31 EST + +publish setpos user +publish SplitReply user +Motor mphi SIM -15 15 -1.0 +mphi softlowerlim -15 +mphi softupperlim 15 +mphi movecount 100 +mphi precision 0.05 +Motor mchi SIM 75 105 -1.0 +mchi softlowerlim 75 +mchi softupperlim 105 +mchi movecount 100 +mchi precision 0.01 +Motor my SIM -20 20 -1.0 +my softlowerlim -20 +my softupperlim 20 +my movecount 100 +my precision 0.01 +Motor mx SIM -20 20 -1.0 +mx softlowerlim -20 +mx softupperlim 20 +mx movecount 100 +mx precision 0.01 +Motor mom SIM -180 180 -1.0 +mom softlowerlim -180 +mom softupperlim 180 +mom movecount 100 +mom precision 0.01 +Motor mtth SIM 90 137 -1.0 +mtth softlowerlim 90 +mtth softupperlim 137 +mtth movecount 100 +mtth precision 0.02 +mtth maxretry 10 +mtth failafter 10 +Motor pcx SIM 0 140 -1.0 +pcx softlowerlim 0 +pcx softupperlim 140 +pcx movecount 100 +pcx precision 0.01 +Motor pcr SIM -10 10 -1.0 +pcr softlowerlim -10 +pcr softupperlim 10 +pcr movecount 100 +pcr precision 0.01 +Motor sphi SIM -20 20 -1.0 +sphi softlowerlim -20 +sphi softupperlim 20 +sphi movecount 100 +sphi precision 0.01 +Motor schi SIM 70 110 -1.0 +schi softlowerlim 70 +schi softupperlim 110 +schi movecount 100 +schi precision 0.01 +Motor sy SIM -20 20 -1.0 +sy softlowerlim -20 +sy softupperlim 20 +sy movecount 100 +sy precision 0.01 +Motor sx SIM -20 20 -1.0 +sx softlowerlim -20 +sx softupperlim 20 +sx movecount 100 +sx precision 0.01 +Motor som SIM -142 218 -1.0 +som softlowerlim -142 +som softupperlim 218 +som movecount 100 +som precision 0.01 +Motor stth SIM -79 77 -1.0 +stth softlowerlim -77 +stth softupperlim 74 +stth movecount 100 +stth precision 0.01 +Motor ss1r SIM -15 35 -1.0 +ss1r softlowerlim -25 +ss1r softupperlim 25 +ss1r movecount 100 +Motor ss1l SIM -15 35 -1.0 +ss1l softlowerlim -25 +ss1l softupperlim 25 +ss1l movecount 100 +Motor ss1u SIM -20 100 -1.0 +ss1u softlowerlim -25 +ss1u softupperlim 100 +ss1u movecount 100 +Motor ss1d SIM -20 100 -1.0 +ss1d softlowerlim -25 +ss1d softupperlim 100 +ss1d movecount 100 +Motor ss2r SIM -15 35 -1.0 +ss2r softlowerlim -25 +ss2r softupperlim 25 +ss2r movecount 100 +Motor ss2l SIM -15 35 -1.0 +ss2l softlowerlim -25 +ss2l softupperlim 25 +ss2l movecount 100 +Motor ss2u SIM -20 100 -1.0 +ss2u softlowerlim -25 +ss2u softupperlim 100 +ss2u movecount 100 +Motor ss2d SIM -20 100 -1.0 +ss2d softlowerlim -25 +ss2d softupperlim 100 +ss2d movecount 100 +proc mthGet {} { return [expr [SplitReply [mtth]]/2.0]} +proc mthSet val { return "mtth=[SplitReply [mtth]]"} +publish mthSet user +publish mthGet user +MakeConfigurableMotor mth +mth readscript mthGet +mth drivescript mthSet +proc sthGet {} { return [expr [SplitReply [stth]]/2.0]} +proc sthSet val { return "stth=[SplitReply [stth]]"} +publish sthGet user +publish sthSet user +MakeConfigurableMotor sth +sth readscript sthGet +sth drivescript sthSet +proc ss1widthscript val { + set currentWidth [expr [SplitReply [ss1r]] + [SplitReply [ss1l]]] + set diff [expr $val - $currentWidth] + set newD1R [expr [SplitReply [ss1r]] + $diff/2] + set newD1L [expr [SplitReply [ss1l]] + $diff/2] + return "ss1r=$newD1R,ss1l=$newD1L" +} +publish ss1widthscript user +proc ss1readwidth {} { + return [expr [SplitReply [ss1r]] + [SplitReply [ss1l]]] +} +publish ss1readwidth user +MakeConfigurableMotor ss1hg +ss1hg drivescript ss1widthscript +ss1hg readscript ss1readwidth +proc ss1horoffsetscript val { + set SR [SplitReply [ss1r]] + set SL [SplitReply [ss1l]] + set currentOffset [ expr $SR - ($SR + $SL)/2.0 ] + set diff [expr $val - $currentOffset] + set newD1R [expr $SR + $diff] + set newD1L [expr $SL - $diff] + return "ss1r=$newD1R,ss1l=$newD1L" +} +publish ss1horoffsetscript user +proc ss1readhoroffset {} { + set SR [SplitReply [ss1r]] + return [ expr $SR - ($SR + [SplitReply [ss1l]])/2.0 ] +} +publish ss1readhoroffset user +MakeConfigurableMotor ss1ho +ss1ho drivescript ss1horoffsetscript +ss1ho readscript ss1readhoroffset +proc ss1heightscript val { + set currentWidth [expr [SplitReply [ss1u]] + [SplitReply [ss1d]]] + set diff [expr $val - $currentWidth] + set newD1B [expr [SplitReply [ss1d]] + $diff/2] + set newD1T [expr [SplitReply [ss1u]] + $diff/2] + return "ss1d=$newD1B,ss1u=$newD1T" +} +publish ss1heightscript user +proc ss1readheight {} { + return [expr [SplitReply [ss1u]] + [SplitReply [ss1d]]] +} +publish ss1readheight user +MakeConfigurableMotor ss1vg +ss1vg drivescript ss1heightscript +ss1vg readscript ss1readheight +proc ss1vertoffsetscript val { + set SU [SplitReply [ss1u]] + set SD [SplitReply [ss1d]] + set currentOffset [ expr $SU - ($SU + $SD)/2.0 ] + set diff [expr $val - $currentOffset] + set newD1U [expr $SU + $diff] + set newD1D [expr $SD - $diff] + return "ss1u=$newD1U,ss1d=$newD1D" +} +publish ss1vertoffsetscript user +proc ss1readvertoffset {} { + set SU [SplitReply [ss1u]] + return [ expr $SU - ($SU + [SplitReply [ss1d]])/2.0 ] +} +publish ss1readvertoffset user +MakeConfigurableMotor ss1vo +ss1vo drivescript ss1vertoffsetscript +ss1vo readscript ss1readvertoffset +proc ss2widthscript val { + set currentWidth [expr [SplitReply [ss2r]] + [SplitReply [ss2l]]] + set diff [expr $val - $currentWidth] + set newD1R [expr [SplitReply [ss2r]] + $diff/2] + set newD1L [expr [SplitReply [ss2l]] + $diff/2] + return "ss2r=$newD1R,ss2l=$newD1L" +} +publish ss2widthscript user +proc ss2readwidth {} { + return [expr [SplitReply [ss2r]] + [SplitReply [ss2l]]] +} +publish ss2readwidth user +MakeConfigurableMotor ss2hg +ss2hg drivescript ss2widthscript +ss2hg readscript ss2readwidth +proc ss2horoffsetscript val { + set SR [SplitReply [ss2r]] + set SL [SplitReply [ss2l]] + set currentOffset [ expr $SR - ($SR + $SL)/2.0 ] + set diff [expr $val - $currentOffset] + set newD1R [expr $SR + $diff] + set newD1L [expr $SL - $diff] + return "ss2r=$newD1R,ss2l=$newD1L" +} +publish ss2horoffsetscript user +proc ss2readhoroffset {} { + set SR [SplitReply [ss2r]] + return [ expr $SR - ($SR + [SplitReply [ss2l]])/2.0 ] +} +publish ss2readhoroffset user +MakeConfigurableMotor ss2ho +ss2ho drivescript ss2horoffsetscript +ss2ho readscript ss2readhoroffset +proc ss2heightscript val { + set currentWidth [expr [SplitReply [ss2u]] + [SplitReply [ss2d]]] + set diff [expr $val - $currentWidth] + set newD1B [expr [SplitReply [ss2d]] + $diff/2] + set newD1T [expr [SplitReply [ss2u]] + $diff/2] + return "ss2d=$newD1B,ss2u=$newD1T" +} +publish ss2heightscript user +proc ss2readheight {} { + return [expr [SplitReply [ss2u]] + [SplitReply [ss2d]]] +} +publish ss2readheight user +MakeConfigurableMotor ss2vg +ss2vg drivescript ss2heightscript +ss2vg readscript ss2readheight +proc ss2vertoffsetscript val { + set SU [SplitReply [ss2u]] + set SD [SplitReply [ss2d]] + set currentOffset [ expr $SU - ($SU + $SD)/2.0 ] + set diff [expr $val - $currentOffset] + set newD1U [expr $SU + $diff] + set newD1D [expr $SD - $diff] + return "ss2u=$newD1U,ss2d=$newD1D" +} +publish ss2vertoffsetscript user +proc ss2readvertoffset {} { + set SU [SplitReply [ss2u]] + return [ expr $SU - ($SU + [SplitReply [ss2d]])/2.0 ] +} +publish ss2readvertoffset user +MakeConfigurableMotor ss2vo +ss2vo drivescript ss2vertoffsetscript +ss2vo readscript ss2readvertoffset