Modified to for new util, config directory structure.

r1497 | ffr | 2007-02-16 16:39:16 +1100 (Fri, 16 Feb 2007) | 2 lines
This commit is contained in:
Ferdi Franceschini
2007-02-16 16:39:16 +11:00
committed by Douglas Clowes
parent b76fa90814
commit 4654c4c9c7
24 changed files with 412 additions and 1717 deletions

View File

@@ -1,8 +1,3 @@
server_config.tcl
utility.tcl
troubleShoot.tcl
dmc2280_util.tcl
motorinfo.tcl
getDMCprog.tcl
putDMCprog.tcl
util
../../tcl/gumxml.tcl

View File

@@ -1,6 +1,6 @@
#!/bin/sh
# $Revision: 1.18 $
# $Date: 2007-02-12 01:01:02 $
# $Revision: 1.19 $
# $Date: 2007-02-16 05:34:41 $
# Author: Ferdi Franceschini (ffr@ansto.gov.au)
# Last revision by $Author: ffr $
@@ -152,6 +152,7 @@ fi
# Get list of files to copy
COMMON=$(for f in $(cat $SRCDIR/MANIFEST.TXT); do echo -n "$SRCDIR/$f "; done)
INSTSPEC=$(for f in $(cat $INSTSRC/MANIFEST.TXT); do echo -n "$INSTSRC/$f "; done)
SCRIPT_VALIDATOR=$(for f in $(cat $INSTSRC/script_validator/MANIFEST.TXT); do echo -n "$INSTSRC/script_validator/$f "; done)
mkdir -p $TEMPDIR/$DESTDIR/{batch,server,data,log,tmp}
cp -a --preserve=timestamps $COMMON $INSTSPEC $TEMPDIR/$DESTDIR/server
@@ -159,7 +160,7 @@ cp -a --preserve=timestamps ../SICServer $TEMPDIR/$DESTDIR/server
mkdir -p $TEMPDIR/$DESTDIR/script_validator/{batch,server,data,log,tmp}
cp -a --preserve=timestamps $COMMON $INSTSPEC $TEMPDIR/$DESTDIR/script_validator/server
cp --preserve=timestamps $INSTSRC/script_validator/* $TEMPDIR/$DESTDIR/script_validator/server
cp -a --preserve=timestamps $SCRIPT_VALIDATOR $TEMPDIR/$DESTDIR/script_validator/server
# Create a manifest of the files installed on the IC host
echo "Date: $(date -Iminutes)" > $TEMPDIR/$DESTDIR/server/MANIFEST.TXT

View File

@@ -1,15 +1,5 @@
sics_ports.tcl
echidna_configuration.tcl
motor_configuration.tcl
counter.tcl
hmm_configuration.tcl
scan.tcl
nxscripts.tcl
echidna.hdd
echidna.dic
troubleshoot_setup.tcl
hipadaba_configuration.tcl
hpaths.tcl
extraconfig.tcl
sim_configuration.tcl
hmm
config
util

View File

@@ -1,2 +1,4 @@
all: motor_configuration.tcl
../mksim_config.tcl -f motor_configuration.tcl > script_validator/motor_configuration.tcl
cfPath=config/motors
all: $(cfPath)/motor_configuration.tcl
../mksim_config.tcl -f $(cfPath)/motor_configuration.tcl > script_validator/$(cfPath)/motor_configuration.tcl

View File

@@ -1 +0,0 @@
MakeCounter counter SIM -0.5

View File

@@ -1,99 +0,0 @@
##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

View File

@@ -1,8 +0,0 @@
##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 ******************************************

View File

@@ -1,10 +1,10 @@
# $Revision: 1.13 $
# $Date: 2007-02-13 05:23:33 $
# $Revision: 1.14 $
# $Date: 2007-02-16 05:38:19 $
# Author: Ferdi Franceschini (ffr@ansto.gov.au)
# Last revision by: $Author: ffr $
#START SERVER CONFIGURATION SECTION
source dmc2280_util.tcl
source util/dmc2280/dmc2280_util.tcl
source sics_ports.tcl
source server_config.tcl
#END SERVER CONFIGURATION SECTION
@@ -23,14 +23,14 @@ VarMake sics_mono_crystal Text User
#MakeCounter simCtr SIM -1.0
#MakeScanCommand xxxscan simCtr echidna.hdd recover.bin
fileeval motor_configuration.tcl
fileeval $cfPath(motors)/motor_configuration.tcl
########
source hipadaba_configuration.tcl
source $cfPath(hipadaba)/hipadaba_configuration.tcl
source gumxml.tcl
#source counter.tcl
fileeval hmm_configuration.tcl
fileeval nxscripts.tcl
fileeval scan.tcl
fileeval $cfPath(hmm)/hmm_configuration.tcl
fileeval $cfPath(nexus)/nxscripts.tcl
fileeval $cfPath(scan)/scan.tcl
fileeval extraconfig.tcl

View File

@@ -1,63 +0,0 @@
# 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 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

View File

@@ -1,17 +0,0 @@
MakeHM hmc anstohmsim
#MakeHM hmc sim
set dim0 512
set dim1 128
hmc configure HistMode Normal
hmc configure OverFlowMode Ceil
hmc configure dim0 $dim0
hmc configure dim1 $dim1
hmc configure rank 2
hmc configure BinWidth 4
#hmc configure BinWidth 1
hmc preset 100.
hmc CountMode Timer
hmc configure Counter counter
hmc configure init 1
hmc init

View File

@@ -1,398 +0,0 @@
# $Revision: 1.5 $
# $Date: 2007-02-15 23:41:58 $
# 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 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 echidna.hdd recover.bin
MakeScanCommand scan2 bm echidna.hdd recover.bin
#
# Call is: scan2_runa <n>
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 <n>
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...

View File

@@ -1,48 +0,0 @@
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 ]

View File

@@ -1,766 +0,0 @@
# $Revision: 1.15 $
# $Date: 2007-02-12 00:56: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

View File

@@ -1,148 +0,0 @@
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;
SicsDataPostFix .$type;
array set nxmode [list nx.hdf create5 h5 create5 nx5 create5 xml createxml];
set dataFileName [newFileName]
nxscript $nxmode($type) $dataFileName echidna.dic;
set nxFileOpen true
}
proc nxreopenfile {} {
global dataFileName nxFileOpen;
nxscript reopen $dataFileName 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

View File

@@ -1,130 +0,0 @@
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 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

View File

@@ -1,11 +1,11 @@
# ECHIDNA troubleshooter setup
# $Revision: 1.3 $
# $Date: 2006-12-01 04:03:04 $
# $Revision: 1.1 $
# $Date: 2007-02-16 05:39:16 $
# Author: Ferdi Franceschini (ffr@ansto.gov.au)
# Last revision by $Author: dcl $
# Last revision by $Author: ffr $
set configFileName "hrpd/motor_configuration.tcl"
set configFileName "../../config/motors/motor_configuration.tcl"
# These subroutines should be installed on the controllers
set contSubs(dmc2280_controller1) "#AUTO #LIMSWI #SOLCTRL #TCPERR"

View File

@@ -14,7 +14,7 @@ proc unknown {args} {
puts $args;
}
}
source ../utility.tcl
source ../util/utility.tcl
# Duplicate any proc definitions
proc my_proc {args} {puts "proc $args"}

View File

@@ -1,17 +1,27 @@
# SICS common configuration
# $Revision: 1.12 $
# $Date: 2007-02-13 05:21:01 $
# $Revision: 1.13 $
# $Date: 2007-02-16 05:34:41 $
# Author: Ferdi Franceschini (ffr@ansto.gov.au)
# Last revision by $Author: ffr $
#set sicsroot /usr/local/sics
set sicsroot ../
set cfParent config
array set cfPath [list\
motors $cfParent/motors\
counter $cfParent/counter\
hmm $cfParent/hmm\
scan $cfParent/scan\
counter $cfParent/counter\
nexus $cfParent/nexus\
hipadaba $cfParent/hipadaba]
ServerOption LogFileBaseName $sicsroot/log/serverlog
installprotocolhandler
source utility.tcl
source util/utility.tcl
ServerOption statusfile $sicsroot/log/status.tcl
ServerOption RedirectFile $sicsroot/log/stdout

View File

@@ -0,0 +1,71 @@
# $Revision: 1.1 $
# $Date: 2007-02-16 05:36:38 $
# Author: Ferdi Franceschini (ffr@ansto.gov.au)
# Last revision by $Author: ffr $
# globals controller, channel
# Open a communications channel to a dmc2280 motor controller
# contName: controller name, eg dmc2280_controller1
# The host and port in the SICS configuration file will be used by default
proc dmc_connect {contName {host ""} {port ""}} {
upvar #0 $contName controller;
global channel;
if {$host == ""} {set host $controller(host)}
if {$port == ""} {set port $controller(port)}
if [catch {socket $host $port} con] {
error "Failed to connect to $contName IP($host) port($port)\n\
$con\n
Is the motor controller switched on? Are the network cables plugged in?\n
NOTE: You can only have a maximum of eight connections per motor controller.\n
If there are other programs (eg SICS) connected to the controller then all\n
of the available connections may have been used up."
}
set controller(socket) $con
set channel($contName) $con
set channel($con) $contName
set channel($controller(host)) $con
fconfigure $con -buffering line -translation crlf -blocking true
}
proc dmc_close {dmc_socket} {
close $dmc_socket;
}
# Send a dmc2280 command
proc dmc_sendCmd {dmc_socket cmd} {
global channel
set contName $channel($dmc_socket);
upvar #0 $contName controller
puts $dmc_socket $cmd
set status [read $dmc_socket 1]
if {$status == "?"} {
puts $dmc_socket "TC 1"
set status [read $dmc_socket 1]
if {$status == "?"} {
error "error: dmc command $cmd failed"
} else {
set dmcError [dmc_receive $dmc_socket]
set errInfo "DM2280 controller $contName
host $controller(host)
port $controller(port)"
error "DMC2280 ERROR $dmcError: when running command $cmd\n$errInfo"
}
} else {
return $status
}
}
# Receive a dmc2280 command
proc dmc_receive {dmc_socket} {
global channel
set contName $channel($dmc_socket);
upvar #0 $contName controller
gets $dmc_socket line
# Consume the following colon
read $dmc_socket 1
return $line
}

View File

@@ -0,0 +1,36 @@
#!/usr/bin/tclsh
# DMC2280 uses cont-Z (hex 1a) as the EOF char
# Usage:
# ./getDMCprog.tcl -host dmcIP -port dmcPort > dmcprog.txt
# To fetch the code from the dmc2280 controller at dmcIP and
# write it to dmcprog.txt, dmcPort should be 1034.
# Note: Your computer must be on the same NBI vlan as the dmc
# controller for this to work. However you can use ssh port
# forwarding to work remotely.
# On your computer run the following ssh command,
# ssh -L 1034:dmcIP:1034 sicsHostIP -lroot
# Then send the code with
# ./getDMCprog.tcl -host localhost -port 1034 > dmcprog.txt
array set args $argv
set con4 [socket $args(-host) $args(-port)]
fconfigure $con4 -buffering line -translation crlf -eofchar \x1a
proc Echo {chan } {
global forever
if {[eof $chan]} {
# A rude exit works best. Closing the socket and terminating the forever loop is unreliable
exit
#close $chan
#set forever done
} else {
puts [gets $chan]
}
}
fileevent $con4 readable [list Echo $con4]
puts $con4 UL
vwait forever

View File

@@ -0,0 +1,82 @@
package require Tk
proc unknown {args} {}
# Check that the current position matches the configured home position
proc checkHome {motor} {
global channel
upvar #0 $motor motName
upvar #0 ${motor}_status motStatus
set chan $channel($motName(host))
if {[info exists motName(absenc)] && $motName(absenc) == 1} {
dmc_sendCmd $chan "TP$motName(axis)"
set homeIndex absenchome
} else {
dmc_sendCmd $chan "TD$motName(axis)"
set homeIndex motorhome
}
set home [dmc_receive $chan]
set motStatus(position) $home
set motStatus(home) $motName($homeIndex)
if {$home == $motName($homeIndex)} {
set motStatus(homeTest) TEST_PASSED
} else {
set motStatus(homeTest) TEST_FAILED
}
return $motStatus(homeTest)
}
# This implementation of the "Motor" command stores the
# configured motor parameters in an array named
# after the motor.
proc Motor {name type par} {
global motors
upvar #0 $par arr
upvar #0 $name param_arr
upvar #0 ${name}_status status
array set param_arr [array get arr]
array set status [list position "" home "" upperLim "" lowerLim "" homeTest NOTDONE limitTest NOTDONE]
lappend motors $name
}
# Returns the test result status colour for the gui
proc color {status} {
switch $status {
TEST_PASSED {return green}
TEST_FAILED {return red}
default {return lightgrey}
}
}
# You can easily test the home position of individual motors
# with this gui
# Click on the button to run the checkHome command, the position
# (in encoder counts or motor steps) will be displayed with
# green if the configured home matches the reported position,
# red otherwise.
proc testgui {} {
package require Tk
global motors
toplevel .w
frame .w.top
foreach m $motors {
global ${m}_status
set info($m) [frame .w.top.f$m]
set testResult $info($m).e$m
button $info($m).$m -text $m -command "$testResult configure -background \[color \[checkHome $m\]\]"
entry $testResult -textvariable ${m}_status(position)
pack $info($m).$m -side left
pack $info($m).e$m -side left
}
set n 0
foreach m $motors {
set r [expr $n % 20]
set c [expr $n / 20]
grid $info($m) -row $r -column $c
incr n
}
pack .w.top
}

View File

@@ -0,0 +1,135 @@
#!/usr/bin/env tclsh
# $Revision: 1.1 $
# $Date: 2007-02-16 05:36:38 $
# Author: Ferdi Franceschini (ffr@ansto.gov.au)
# Last revision by $Author: ffr $
# Load troubleshooting setup
source dmc2280_util.tcl
source troubleshoot_setup.tcl
source motorinfo.tcl
if { $argc > 0 } {
set configFileName [lindex $argv 0]
}
# Use this to create an array of named parameters to initialise motors.
proc params {args} {
upvar 1 "" x;
if [info exists x] {unset x}
foreach {k v} $args {set x([string tolower $k]) $v}
}
namespace eval sics_config {
proc loadConfig {fName} {
variable ContList
if [info exists ContList] {unset ContList}
# Temporarily define unknown proc to skip undefined procs
rename ::unknown _unknown
proc ::unknown {args} {}
if [catch {uplevel #0 source $fName} errMsg] {
rename ::unknown ""
rename _unknown ::unknown
error $errMsg
} else {
rename ::unknown ""
rename _unknown ::unknown
}
if [catch {set ContList [uplevel #0 info vars dmc2280_controller*]} result] {error $result}
if {[llength $ContList] == 0} {error "Error: There are no dmc2280_controllerN(host/port) arrays in the $fName configuration file"}
#Add the controller to the sics_config namespace
foreach c $ContList {upvar #0 $c cont; puts "$c IP:port = $cont(host):$cont(port)"}
}
proc subExists {contName sub} {
upvar #0 $contName controller
if [catch {::dmc_sendCmd $controller(socket) "LS $sub,0"} errMsg] {
error "Subroutine $sub does not exist on controller $contName"
}
::dmc_receive $controller(socket)
}
# Returns -1 if thread is not running, line number if it is
proc checkThread {contName thnum} {
upvar #0 $contName controller
::dmc_sendCmd $controller(socket) "MG _XQ$thnum"
set reply [::dmc_receive $controller(socket) ]
if {$reply == -1} {
error "Thread $thnum not running on controller $contName"
}
return $reply
}
# GUI STUFF
package require Tk
variable ContList
global ldFrame
set ldFrameName ".loadFile"
set ldFrame(button) $ldFrameName.ldConf
set ldFrame(entry) $ldFrameName.ldEntry
proc ::guiLoadC {} {
::sics_config::loadConfig [eval $::sics_config::ldFrame(entry) get]
}
proc ::guiConnect {w cont} {
::dmc_connect $cont
$w configure -activebackground green
$w configure -background green
}
proc ::guiCheckSubs {w cont} {
global contSubs
foreach sub $contSubs($cont) {
::sics_config::subExists $cont $sub
}
$w configure -activebackground green
$w configure -background green
}
proc ::guiCheckThreads {w cont} {
global contThreads
foreach thr $contThreads($cont) {
::sics_config::checkThread $cont $thr
}
$w configure -activebackground green
$w configure -background green
}
frame $ldFrameName
pack $ldFrameName
button $ldFrame(button) -text "Load config" -command {guiLoadC; ::sics_config::mkGui}
entry $ldFrame(entry) -textvariable configFileName -width -1
pack $ldFrame(button) -side left
pack $ldFrame(entry) -side left
proc mkGui {} {
variable ContList
lappend Headings $ContList
frame .t -bg black
table .t $ContList
pack .t
testgui
}
proc table {w headings args} {
set r 0
foreach name $headings {
lappend Header [label $w.$name -text $name]
}
foreach name $headings {
lappend Connect [button $w.connect$name -text connect -command "guiConnect $w.connect$name $name"]
lappend CheckSubs [button $w.chkSubs$name -text "Check subs" -command "guiCheckSubs $w.chkSubs$name $name"]
lappend CheckThreads [button $w.chkThrs$name -text "Check threads" -command "guiCheckThreads $w.chkThrs$name $name"]
}
eval grid $Header -sticky news -padx 1 -pady 1
eval grid $Connect -sticky news -padx 1 -pady 1
eval grid $CheckSubs -sticky news -padx 1 -pady 1
eval grid $CheckThreads -sticky news -padx 1 -pady 1
}
}

View File

@@ -0,0 +1,51 @@
# Some useful functions for SICS configuration.
# $Revision: 1.1 $
# $Date: 2007-02-16 05:36:38 $
# Author: Ferdi Franceschini (ffr@ansto.gov.au)
# Last revision by $Author: ffr $
# Utility fucntion for setting the home and upper and lower
# limits for a motor
proc setHomeandRange {args} {
set usage "
Usage: setHomeandRange -motor motName -home homeVal -lowrange low -uprange high
eg
setHomeandRange -motor mchi -home 90 -lowrange 5 -uprange 7
this sets the home position to 90 degreess for motor mchi
with the lower limit at 85 and the upper limit at 97
"
if {$args == ""} {clientput $usage; return}
array set params $args
set motor $params(-motor)
set home $params(-home)
set lowlim [expr $home - $params(-lowrange)]
set uplim [expr $home + $params(-uprange)]
uplevel 1 "$motor softlowerlim $lowlim"
uplevel 1 "$motor softupperlim $uplim"
uplevel 1 "$motor home $home"
}
# Use this to create an array of named parameters to initialise motors.
proc params {args} {
upvar 1 "" x;
if [info exists x] {unset x}
foreach {k v} $args {set x([string tolower $k]) $v}
}
# Parse motor readings for virtual motor scripts.
proc SplitReply { text } {
set l [split $text =]
return [string trim [lindex $l 1]]
}
# Sets motor position reading to pos by adjusting the softzero
proc setpos {motor pos} {
set currPos [SplitReply [$motor]]
set oldZero [SplitReply [$motor softzero]]
set newZero [expr $currPos - $pos + $oldZero]
uplevel #0 "$motor softzero $newZero"
}
publish setpos user
publish SplitReply user