1592 lines
54 KiB
Python
1592 lines
54 KiB
Python
#=================================================f=============================
|
|
# Macroname: site_f.mac
|
|
# ==========
|
|
#+
|
|
# $Date: 2009/05/27 15:52:34 $
|
|
# $Author: schlepuetz $
|
|
# $Source: /cvs/G/SPEC/local/X04SA/ES3/site_f.mac,v $
|
|
# $Revision: 1.13 $
|
|
# $Tag: $
|
|
#
|
|
# Description: Macro for declaring site-dependent macro functions. "site_f.mac"
|
|
# is automatically read and executed if SPEC is started for the
|
|
# first time or invoked with the -f ("fresh") option.
|
|
#
|
|
# Note: This is the version of "site_f.mac" specific to the ISSD (ES3)
|
|
# station of the X04SA beamline at SLS.
|
|
# For definitions and commands that need to be run at every
|
|
# startup of SPEC, see "site.mac".
|
|
#
|
|
# Installed location:
|
|
# $SLSBASE/sls/spec/local/X04SA/ES3/site_f.mac
|
|
# with a symbolic link from
|
|
# $SPECD/site_f.mac
|
|
# via the command:
|
|
# ln -s $SLSBASE/sls/spec/local/X04SA/ES3/site_f.mac $SPECD/site_f.mac
|
|
#
|
|
# Author: D. Maden (DM)
|
|
# Co-author(s): C.M. Schlepuetz (CS)
|
|
# Address: Surface Diffraction Station
|
|
# Materials Science Beamline X04SA
|
|
# Swiss Light Source (SLS)
|
|
# Paul Scherrer Institut
|
|
# CH - 5232 Villigen PSI
|
|
# Created: 2005/07/20
|
|
#
|
|
#-
|
|
# Macro definitions which are changed with respect to standard.mac:
|
|
# -----------------------------------------------------------------
|
|
# - home # include homing for epics motors as well
|
|
# - ascan # include scans with the hexapod - removed by MB
|
|
# - count_em # use the EPICS DCR508 scaler
|
|
# - count # expanded functionality used by other site-specific
|
|
# macros
|
|
# - ct # expanded functionality used by other site-specific
|
|
# macros
|
|
# - waitcount # include the EPICS DCR508 scaler
|
|
# - get_counts # include the EPICS DCR508 scaler
|
|
# - _timescan # include call to 'scan_tail' at the end
|
|
# - hklscan # ignore points with unphysical HKL values and continue
|
|
# - _hklline # ignore points with unphysical HKL values and continue
|
|
#
|
|
# New macro definitions:
|
|
# ----------------------
|
|
# - mvhkl # interactive call to 'br' so user can confirm move
|
|
# - recount # repeat exposure upon criteria in chk_counts
|
|
# - issd_scan_hdr_on # turn on ISSD header in data file
|
|
# - issd_scan_hdr_on # turn off ISSD header in data file
|
|
# - issd_filehead # writes the ISSD file header to the data file
|
|
# - issd_scan_head # writes the ISSD scan header to the data file
|
|
# - issd_scan_tail # writes the ISSD scan tail to the data file
|
|
#
|
|
# Chained macro definitions affected by site_f.mac:
|
|
# -----------------------------------------------
|
|
# - user_Fheader (in issd_scan_hdr_on, issd_scan_hdr_off)
|
|
# - user_scan_tail (in issd_scan_hdr_on, issd_scan_hdr_off)
|
|
# - cleanup_once (in ct)
|
|
#
|
|
# Global variables defined in site_f.mac:
|
|
# -------------------------------------
|
|
# SLSBASE, SLSCONFIG, SITE_F_DIR, COMMON_DIR
|
|
# COUNT_ID
|
|
#
|
|
# Change Log of site_f.mac:
|
|
# -----------------------
|
|
# 2009/02-03 (MB):
|
|
# - Commented out the ascan definition
|
|
# - Addded hex_on to
|
|
#
|
|
#
|
|
# 2005/10/10 (CS):
|
|
# - Added more header information and comments to the code
|
|
# - Added 'recount' macro
|
|
# - modified 'count' and 'ct' macros to improve functionality and readability
|
|
# - included many more X04SA specific macros to be read at startup
|
|
# - introduced the global variable COUNT_ID to store some sort of ID number for
|
|
# the last exposure (for image detectors, this should be the last image
|
|
# number)
|
|
# - call the H,K,L macros to assure the global variable Q is initialized.
|
|
#
|
|
# 2005/11/07 (CS):
|
|
# - reduced sleep time in waitcount to 0.05 seconds.
|
|
#
|
|
# 2005/11/09 (CS):
|
|
# - changed site.mac (which was read and executed every time SPEC is
|
|
# restarted) to (this) site_f.mac. This is only read and executed when SPEC
|
|
# is started for the first time or invoked with the -f ("fresh") option,
|
|
# thus preserving the current status of all macro definitions (including
|
|
# chained macros) when SPEC is started normally.
|
|
# (This used to cause problems with chained macros being overwritten by
|
|
# site.mac while the associated global variables where preserved. In the case
|
|
# of a fresh start, these global variables are also cleared, resulting in a
|
|
# consistent system.)
|
|
#
|
|
# 2005/12/13 (CS):
|
|
# - added a fourth treshold level for automatic filter and exposure time
|
|
# settings if auto.mac is available and auto mode is enabled in get_counts
|
|
#
|
|
# 2006/05/04 (CS):
|
|
# - added macro definitions for 'mvhkl' and 'umvhkl'.
|
|
# - added modified macro definition for 'hklscan' and '_hklline' which allow
|
|
# the skipping of unobtainable points in reciprocal space rather than
|
|
# aborting the scan completely.
|
|
# - load orient.mac at startup
|
|
# - Dave's hkldefs.mac and Christian's hklscans.mac are only loaded for specSD
|
|
# and specOptics
|
|
#
|
|
# 2006/08/08 (CS):
|
|
# - improved output of 'mvhkl' and 'umvhkl'.
|
|
# - load scanlist.mac at startup
|
|
# - added modified macro definition for '_timescan' which includes a call to
|
|
# 'scan_tail' at the end to enable execution of user-defined cleanup tasks.
|
|
#
|
|
# 2008/02/15 (CS):
|
|
# - load plot.mac at startup
|
|
#
|
|
# 2009/05/27 (MB):
|
|
# - Adding changes for EPICS implementation of motors and fixes for the
|
|
# hexapod:
|
|
# - commented out custom version of 'ascan'
|
|
# - added macro definitions 'home', '_ksepicsmotor', 'ksmotor'
|
|
# - Execute the parameter handling definitions from X12SA Oliver Bunk
|
|
# - issue 'hex_on' command at startup
|
|
#
|
|
# 2009/05/27 (CS):
|
|
# - load wigglercheck.mac on startup
|
|
#
|
|
#==============================================================================
|
|
#
|
|
#------------------------------------------------------------------------------
|
|
# Ensure that SLSBASE and SLSCONFIG are set.
|
|
# Then execute the common SLS macro file, if it can be found.
|
|
#
|
|
global SLSBASE, SLSCONFIG, SITE_F_DIR, COMMON_DIR
|
|
|
|
SLSBASE = ""
|
|
unix ("echo -n \$SLSBASE", SLSBASE)
|
|
|
|
SLSCONFIG = ""
|
|
unix ("echo -n \$SLSCONFIG", SLSCONFIG)
|
|
#
|
|
# Find directory containing site_f.mac. This involves
|
|
# the resolution of a symbolic link. Define
|
|
# SITE_F_DIR and COMMON_DIR accordingly.
|
|
_1 = "dummy"
|
|
unix (sprintf ("readlink %s/%s", SPECD, "site_f.mac"), _1)
|
|
if (_1 != "" ) {
|
|
SITE_F_DIR = "dummy"
|
|
unix (sprintf ("dirname %s", _1), SITE_F_DIR)
|
|
sscanf (SITE_F_DIR, "%s", SITE_F_DIR) # Remove trailing newline.
|
|
COMMON_DIR = "dummy"
|
|
unix (sprintf ("cd %s; cd ../../common; pwd", SITE_F_DIR), COMMON_DIR)
|
|
sscanf (COMMON_DIR, "%s", COMMON_DIR) # Remove trailing newline
|
|
} else {
|
|
SITE_F_DIR = sprintf ("%s/sls/spec/local/X04SA/ES3", SLSBASE)
|
|
COMMON_DIR = sprintf ("%s/sls/spec/local/common", SLSBASE)
|
|
}
|
|
|
|
file = sprintf ("%s/sls-common.mac", COMMON_DIR)
|
|
if (file_info (file, "-f")) {
|
|
DOFILE = file; qdofile (file)
|
|
}
|
|
|
|
#+
|
|
#==============================================================================
|
|
# This macro file contains the following macro definitions:
|
|
#-
|
|
#
|
|
#+
|
|
#------------------------------------------------------------------------------
|
|
# home - alternative version of standard home to allow
|
|
# homing of epics motors
|
|
#-
|
|
#
|
|
def home '
|
|
if ($# < 1 || $# > 3) {
|
|
eprint "Usage: home motor [+|-] [home_pos]"
|
|
exit
|
|
}
|
|
_check0 "$1"
|
|
waitmove
|
|
ifp { fprintf(PRINTER,"\n$*\n") }
|
|
|
|
if ("$1" == "phi"){
|
|
printf("Homing phi through EPICS...\n")
|
|
# Workaround to have relaiable operation
|
|
mvr phi 0.1
|
|
waitmove
|
|
epics_put("X04SA-ES3-XPS:PHI.HOMR", 1)
|
|
exit
|
|
}
|
|
if ("$1" == "oh"){
|
|
printf("Homing omegaH through EPICS...\n")
|
|
# Workaround to have relaiable operation
|
|
mvr oh 0.1
|
|
waitmove
|
|
epics_put("X04SA-ES3-XPS:OMEGAH.HOMR", 1)
|
|
exit
|
|
}
|
|
if ("$1" == "nu"){
|
|
printf("Homing nu through EPICS...\n")
|
|
# Workaround to have relaiable operation
|
|
mvr nu 0.1
|
|
waitmove
|
|
epics_put("X04SA-ES3-XPS:NU.HOMR", 1)
|
|
exit
|
|
}
|
|
if ("$1" == "ov"){
|
|
printf("Homing omegaV through EPICS...\n")
|
|
# Workaround to have relaiable operation
|
|
mvr ov 0.1
|
|
waitmove
|
|
epics_put("X04SA-ES3-XPS:OMEGAV.HOMR", 1)
|
|
exit
|
|
}
|
|
if ("$1" == "alp"){
|
|
printf("Homing alpha through EPICS...\n")
|
|
# Workaround to have relaiable operation
|
|
mvr alp 0.1
|
|
waitmove
|
|
epics_put("X04SA-ES3-XPS:ALPHA.HOMR", 1)
|
|
exit
|
|
}
|
|
if ("$1" == "del"){
|
|
printf("Homing delta through EPICS...\n")
|
|
# Workaround to have relaiable operation
|
|
mvr del 0.1
|
|
waitmove
|
|
epics_put("X04SA-ES3-XPS:DELTA.HOMR", 1)
|
|
exit
|
|
}
|
|
if ("$1" == "gam"){
|
|
printf("Homing gamma through EPICS...\n")
|
|
# Workaround to have relaiable operation
|
|
mvr gam 0.1
|
|
waitmove
|
|
epics_put("X04SA-ES3-XPS:GAMMA.HOMR", 1)
|
|
exit
|
|
}
|
|
if ("$1" == "xv"){
|
|
printf("Homing xV through EPICS...\n")
|
|
# Workaround to have relaiable operation
|
|
mvr xv 0.1
|
|
waitmove
|
|
epics_put("X04SA-ES3-XPS:XV.HOMR", 1)
|
|
exit
|
|
}
|
|
if ("$1" == "y1"){
|
|
printf("Homing y1 through EPICS...\n")
|
|
# Workaround to have relaiable operation
|
|
mvr y1 0.1
|
|
waitmove
|
|
epics_put("X04SA-ES3-XPS:Y1.HOMR", 1)
|
|
exit
|
|
}
|
|
if ("$1" == "y2"){
|
|
printf("Homing y2 through EPICS...\n")
|
|
# Workaround to have relaiable operation
|
|
mvr y2 0.1
|
|
waitmove
|
|
epics_put("X04SA-ES3-XPS:Y2.HOMR", 1)
|
|
exit
|
|
}
|
|
if ("$1" == "y3"){
|
|
printf("Homing y3 through EPICS...\n")
|
|
# Workaround to have relaiable operation
|
|
mvr y3 0.1
|
|
waitmove
|
|
epics_put("X04SA-ES3-XPS:Y3.HOMR", 1)
|
|
exit
|
|
}
|
|
if ("$1" == "trx"){
|
|
printf("Homing trx through EPICS...\n")
|
|
# Workaround to have relaiable operation
|
|
mvr trx 0.1
|
|
waitmove
|
|
epics_put("X04SA-ES3-XPS:TRX.HOMR", 1)
|
|
exit
|
|
}
|
|
if ("$1" == "hx"){
|
|
printf("Homing hx through EPICS...\n")
|
|
# Workaround to have relaiable operation
|
|
epics_put("X04SA-ES3-HXP:TRX.HOMR", 1)
|
|
exit
|
|
}
|
|
if ("$1" == "hy"){
|
|
printf("Homing hy through EPICS...\n")
|
|
# Workaround to have relaiable operation
|
|
epics_put("X04SA-ES3-HXP:TRY.HOMR", 1)
|
|
exit
|
|
}
|
|
if ("$1" == "hz"){
|
|
printf("Homing hz through EPICS...\n")
|
|
# Workaround to have relaiable operation
|
|
epics_put("X04SA-ES3-HXP:TRZ.HOMR", 1)
|
|
exit
|
|
}
|
|
if ("$1" == "hrox"){
|
|
printf("Homing hrox through EPICS...\n")
|
|
# Workaround to have relaiable operation
|
|
epics_put("X04SA-ES3-HXP:ROX.HOMR", 1)
|
|
exit
|
|
}
|
|
if ("$1" == "hroy"){
|
|
printf("Homing hroy through EPICS...\n")
|
|
# Workaround to have relaiable operation
|
|
epics_put("X04SA-ES3-HXP:ROY.HOMR", 1)
|
|
exit
|
|
}
|
|
if ("$1" == "hroz"){
|
|
printf("Homing hroz through EPICS...\n")
|
|
# Workaround to have relaiable operation
|
|
epics_put("X04SA-ES3-HXP:ROZ.HOMR", 1)
|
|
exit
|
|
}
|
|
else{
|
|
if ($# == 1)
|
|
chg_dial($1, "home")
|
|
else if ($# == 2) {
|
|
if ("$2" == "+")
|
|
chg_dial($1, "home+")
|
|
else if ("$2" == "-")
|
|
chg_dial($1, "home-")
|
|
else
|
|
chg_dial($1, "home", eval("$2+0"))
|
|
} else if ($# == 3) {
|
|
if ("$2" == "+")
|
|
chg_dial($1, "home+", $3)
|
|
else if ("$2" == "-")
|
|
chg_dial($1, "home-", $3)
|
|
else {
|
|
eprint "Usage: home motor [+|-] [home_pos]"
|
|
exit
|
|
}
|
|
}
|
|
}
|
|
|
|
move_poll
|
|
'
|
|
#+
|
|
#------------------------------------------------------------------------------
|
|
# ksmotor - kickstart an epicsmotor by going through the STOP PAUSE MOVE GO
|
|
# sequence
|
|
|
|
def _ksepicsmotor(motor)'{
|
|
ks_sleep_time = 0.5
|
|
|
|
epics_put(motor, 0)
|
|
sleep(ks_sleep_time)
|
|
epics_put(motor, 1)
|
|
sleep(ks_sleep_time)
|
|
epics_put(motor, 2)
|
|
sleep(ks_sleep_time)
|
|
epics_put(motor, 3)
|
|
}'
|
|
|
|
def ksmotor '{
|
|
|
|
if ($# != 1) {
|
|
eprint "Usage: ksmotor motor"
|
|
eprint "Used to kickstart a locked epics motor by doing an epics"
|
|
eprint "START STOP MOVE GO sequence which can unlock freezed motors"
|
|
exit
|
|
}
|
|
if ("$1" == "phi"){
|
|
_ksepicsmotor("X04SA-ES3-XPS:PHI.SPMG")
|
|
exit
|
|
}
|
|
if ("$1" == "oh"){
|
|
_ksepicsmotor("X04SA-ES3-XPS:OMEGAH.SPMG")
|
|
exit
|
|
}
|
|
if ("$1" == "nu"){
|
|
_ksepicsmotor("X04SA-ES3-XPS:NU.SPMG")
|
|
exit
|
|
}
|
|
if ("$1" == "ov"){
|
|
_ksepicsmotor("X04SA-ES3-XPS:OMEGAV.SPMG")
|
|
exit
|
|
}
|
|
if ("$1" == "alp"){
|
|
_ksepicsmotor("X04SA-ES3-XPS:ALPHA.SPMG")
|
|
exit
|
|
}
|
|
if ("$1" == "del"){
|
|
_ksepicsmotor("X04SA-ES3-XPS:DELTA.SPMG")
|
|
exit
|
|
}
|
|
if ("$1" == "gam"){
|
|
_ksepicsmotor("X04SA-ES3-XPS:GAMMA.SPMG")
|
|
exit
|
|
}
|
|
if ("$1" == "xv"){
|
|
_ksepicsmotor("X04SA-ES3-XPS:XV.SPMG")
|
|
exit
|
|
}
|
|
if ("$1" == "y1"){
|
|
_ksepicsmotor("X04SA-ES3-XPS:Y1.SPMG")
|
|
exit
|
|
}
|
|
if ("$1" == "y2"){
|
|
_ksepicsmotor("X04SA-ES3-XPS:Y2.SPMG")
|
|
exit
|
|
}
|
|
if ("$1" == "y3"){
|
|
_ksepicsmotor("X04SA-ES3-XPS:Y3.SPMG")
|
|
exit
|
|
}
|
|
if ("$1" == "trx"){
|
|
_ksepicsmotor("X04SA-ES3-XPS:TRX.SPMG")
|
|
exit
|
|
}
|
|
else{
|
|
eprint "Motor does not support kickstarting"
|
|
}
|
|
}'
|
|
|
|
#------------------------------------------------------------------------------
|
|
# ascan - alternative version of standard ascan to allow
|
|
# hexapod scans available too.
|
|
#-
|
|
#
|
|
#def ascan '{
|
|
# =====
|
|
#
|
|
# global _m, _s, _f, _n1, _ctime
|
|
#
|
|
# if ($# != 5) {
|
|
# eprint "Usage: ascan motor start finish intervals time"
|
|
# exit
|
|
# }
|
|
# print "Got here"
|
|
# if (("$1" == "xx") || \
|
|
# ("$1" == "yy") || \
|
|
# ("$1" == "zz") || \
|
|
# ("$1" == "uu") || \
|
|
# ("$1" == "vv") || \
|
|
# ("$1" == "ww")) {
|
|
# checkHexLim $1 $2 $3
|
|
# _m[0] = "$1"; _s[0] = $2; _f[0] = $3
|
|
# _n1 = int ($4); _ctime = $5
|
|
# _nm = 1
|
|
# _hexascan
|
|
# } else {
|
|
# _check0 "$1"
|
|
# _m[0] = $1; _s[0] = $2; _f[0] = $3
|
|
# _n1 = int ($4); _ctime = $5
|
|
# _nm = 1
|
|
# _ascan
|
|
# }
|
|
# }'
|
|
#
|
|
#+
|
|
#------------------------------------------------------------------------------
|
|
# count_em - lowest level counting macro. Modify the
|
|
# version in standard.mac to get it to use the
|
|
# EPICS DCR508 scaler.
|
|
#-
|
|
|
|
def count_em '{
|
|
# ========
|
|
local cnt_stat
|
|
|
|
# Mythen I0
|
|
while (epics_get ("X04SA-ES2-SD1:cam1:Acquire") != "Done") {
|
|
epics_put("X04SA-ES2-SD1:cam1:Acquire", "Done")
|
|
sleep(0.25)
|
|
}
|
|
|
|
COUNT_TIME = $#?($1):COUNT
|
|
user_precount
|
|
|
|
if (COUNT_TIME != 0) {
|
|
if (COUNT_TIME > 0) {
|
|
# MYTHEN
|
|
epics_put("X04SA-ES2-SD1:cam1:AcquireTime", COUNT_TIME)
|
|
epics_put("X04SA-ES2-SD1:cam1:ImageMode", "Single")
|
|
epics_put("X04SA-ES2-SD1:cam1:Acquire", "Acquire")
|
|
}else {
|
|
print "Preset monitor counting is not supported\!"
|
|
}
|
|
}
|
|
user_postcount
|
|
}'
|
|
|
|
#+
|
|
#------------------------------------------------------------------------------
|
|
# count - second lowest level count command.
|
|
# This version is slightly expanded with respect to
|
|
# the original definitio_asca_ascan in standard.mac:
|
|
# count_end, chk_counts, and chk_xray have been
|
|
# added to provide further flexibility
|
|
# regarding the use of various detectors.
|
|
#
|
|
# Note: count_em is something like a "count_start" and triggers the counting
|
|
# process but does not wait for its completion.
|
|
# The 'user_postcount' routine in 'count_em' is therefore more something
|
|
# like a "user_whilecount". The 'count_end' macro included in this
|
|
# definition of 'count' is intended to provide a real post-count
|
|
# facility.
|
|
# 'chk_counts' and 'chk_xray' can be used to verify whether the count
|
|
# process has delivered satisfactory data and whether the x-ray beam
|
|
# has been available and sufficiently intense during counting.
|
|
# 'chk_beam' is a slightly misleading name, its purpose is to terminate
|
|
# the counting process when all criteria for a successful count are
|
|
# met. This is done with the included 'break' statement which terminates
|
|
# the enclosing for-loop in 'count'
|
|
#-
|
|
|
|
def count '{
|
|
# =====
|
|
|
|
waitmove
|
|
if ($1) for (;;) {
|
|
count_em $1 # triggers the counting process
|
|
waitcount # waits for counting to finish
|
|
count_end # clean up after counting
|
|
get_counts # retrieve the counts from detectors
|
|
chk_xray # verify quality of xray
|
|
chk_counts # verify quality of counts
|
|
chk_beam # terminate this count loop
|
|
}
|
|
if (S[sec] && MON >= 0)
|
|
MON_RATE=S[MON]/S[sec]
|
|
}'
|
|
|
|
# define new count_end, chk_counts, and chk_xray macros:
|
|
def count_end 'user_count_end'
|
|
def chk_counts 'user_chk_counts'
|
|
def chk_xray 'user_chk_xray'
|
|
# use the EPICS DCR508 scaler
|
|
# initially, user_count_end, user_chk_counts, and user_chk_xray are empty:
|
|
def user_count_end '' # if used, this should be a chained macro definition
|
|
def user_chk_counts '' # if used, this should be a chained macro definition
|
|
def user_chk_xray '' # if used, this should be a chained macro definition
|
|
|
|
#+
|
|
#------------------------------------------------------------------------------
|
|
# ct - second lowest level count command - for manual count.
|
|
# This version is slightly expanded with respect to
|
|
# the original definition in standard.mac:
|
|
# count_end has been added to provide further
|
|
# flexibility regarding the use of various detectors.
|
|
#
|
|
# Note: See also the description of the modified 'count' command for more
|
|
# information.
|
|
#-
|
|
|
|
def ct '{
|
|
# ==
|
|
|
|
cdef("cleanup_once", "onp; show_cnts; offp; user_ct", "ct")
|
|
waitmove
|
|
count_em $1 # triggers the counting process
|
|
waitcount # waits for counting to finish
|
|
count_end # clean up after counting
|
|
cdef("cleanup_once", "", "ct", "delete")
|
|
onp; show_cnts; offp
|
|
user_ct
|
|
|
|
}'
|
|
|
|
#+
|
|
#------------------------------------------------------------------------------
|
|
# recount - allows to retake the last data point - useful when
|
|
# files (images) need to be overwritten. Include
|
|
# device-specific code in user_pre_recount and
|
|
# user_post_recount.
|
|
#
|
|
# Note: This is essentially a modified version of count
|
|
# without the check commands (chk_xray, chk_counts,
|
|
# and chk_beam) at the end.
|
|
#-
|
|
|
|
def recount '{
|
|
# =======
|
|
|
|
waitmove
|
|
user_pre_recount # should be a chained macro definition
|
|
count_em $1 # triggers the counting process
|
|
waitcount # waits for counting to finish
|
|
count_end # clean up after counting
|
|
get_counts # retrieve the counts from detectors
|
|
user_post_recount # should be a chained macro definition
|
|
}'
|
|
|
|
# initially, user_pre_recount and user_post_recount are empty.
|
|
def user_pre_recount ''
|
|
def user_post_recount ''
|
|
|
|
#+
|
|
#------------------------------------------------------------------------------
|
|
# waitcount - waits for counting to stop
|
|
#-
|
|
|
|
def waitcount '{
|
|
# =========
|
|
local cnt_stat
|
|
local i
|
|
|
|
user_waitcount
|
|
|
|
# MYTHEN
|
|
i = 0
|
|
while (epics_get ("X04SA-ES2-SD1:cam1:Acquire") != "Done") {
|
|
sleep (0.05)
|
|
i += 1
|
|
if (i * 0.05 >= COUNT_TIME * 2) {
|
|
print "MYTHEN Izero times out, status: " epics_get("X04SA-ES2-SD1:cam1:DetectorState_RBV")
|
|
break
|
|
}
|
|
}
|
|
}'
|
|
|
|
#+
|
|
#------------------------------------------------------------------------------
|
|
# get_counts - lowest level counter reading macro.
|
|
#-
|
|
|
|
def get_counts '{
|
|
# ==========
|
|
|
|
S[0] = epics_get ("X04SA-ES2-SD1:cam1:AcquireTime")
|
|
S[1] = epics_get ("X04SA-ES2-SD1:Stats5:Total_RBV")
|
|
# S[2] is detector counts from image.mac
|
|
S[3] = S[2] / COUNT_TIME / epics_get("X04SA-ES2-FI:TRANSM")
|
|
|
|
S[5] = epics_get ("X04SA-ES2-FI:TRANSM")
|
|
|
|
COUNT_ID++ # increment the exposure ID
|
|
|
|
# set threshold counts in case auto-level support is available
|
|
if ((whatis("AUTO_THRESH1") & 0x08000000) == 0) {
|
|
AUTO_THRESH1_COUNT = (S[2]>=AUTO_THRESH1)?S[2]:0
|
|
AUTO_THRESH2_COUNT = (S[2]>=AUTO_THRESH2)?S[2]:0
|
|
AUTO_THRESH3_COUNT = (S[2]>=AUTO_THRESH3)?S[2]:0
|
|
AUTO_THRESH4_COUNT = (S[2]>=AUTO_THRESH4)?S[2]:0
|
|
}
|
|
|
|
user_getcounts
|
|
}'
|
|
|
|
#+
|
|
#------------------------------------------------------------------------------
|
|
# mvhkl - modified version of \'br\' which displays the angle
|
|
# positions of the requested hkl-position first and asks
|
|
# for the users confirmation to move there before the
|
|
# movement is started.
|
|
#
|
|
# Usage:
|
|
# mvhkl <h> <k> <l>
|
|
# or mvhkl <h> <k> <l> auto
|
|
#
|
|
#-
|
|
def mvhkl '{
|
|
# =====
|
|
|
|
getangles
|
|
old_A = A
|
|
|
|
auto = 0
|
|
if ($# != 3) {
|
|
if (($# == 4) && ("$4" == "auto")) {
|
|
auto = 1
|
|
} else{
|
|
print "\aUsage:"
|
|
print " mvhkl <h> <k> <l>"
|
|
print " or mvhkl <h> <k> <l> auto"
|
|
exit
|
|
}
|
|
}
|
|
|
|
H = $1; K = $2; L = $3
|
|
|
|
# calcA returns 0 for success, -1 for unobtainable reflection
|
|
possible = !(-(calcA))
|
|
|
|
if(possible) {
|
|
if (auto != 1) {
|
|
for (i=0;i<_numgeo;i++) {
|
|
s = motor_name(mA[i])
|
|
printf ("%7s = %9.4f --> %9.4f\n", s, old_A[mA[i]], A[mA[i]])
|
|
}
|
|
ok = 1
|
|
ok = yesno ("Move to these values? ", ok)
|
|
} else{
|
|
ok = 1
|
|
}
|
|
if (ok) {
|
|
br $1 $2 $3
|
|
} else{
|
|
print "Move abandoned."
|
|
exit
|
|
}
|
|
}
|
|
}'
|
|
|
|
#+
|
|
#------------------------------------------------------------------------------
|
|
# umvhkl - modified version of \'ubr\' which displays the angle
|
|
# positions of the requested hkl-position first and asks
|
|
# for the users confirmation to move there before the
|
|
# movement is started.
|
|
#
|
|
# Usage:
|
|
# umvhkl <h> <k> <l>
|
|
# or umvhkl <h> <k> <l> auto
|
|
#
|
|
#-
|
|
|
|
def umvhkl '{
|
|
# ======
|
|
|
|
getangles
|
|
old_A = A
|
|
|
|
auto = 0
|
|
if ($# != 3) {
|
|
if (($# == 4) && ("$4" == "auto")) {
|
|
auto = 1
|
|
} else{
|
|
print "\aUsage:"
|
|
print " mvhkl <h> <k> <l>"
|
|
print " or mvhkl <h> <k> <l> auto"
|
|
exit
|
|
}
|
|
}
|
|
|
|
H = $1; K = $2; L = $3
|
|
|
|
# calcA returns 0 for success, -1 for unobtainable reflection
|
|
possible = !(-(calcA))
|
|
|
|
if(possible) {
|
|
if (auto != 1) {
|
|
for (i=0;i<_numgeo;i++) {
|
|
s = motor_name(mA[i])
|
|
printf ("%7s = %9.4f --> %9.4f\n", s, old_A[mA[i]], A[mA[i]])
|
|
}
|
|
ok = 1
|
|
ok = yesno ("Move to these values? ", ok)
|
|
} else {
|
|
ok = 1
|
|
}
|
|
if (ok) {
|
|
ubr $1 $2 $3
|
|
} else {
|
|
print "Move abandoned."
|
|
exit
|
|
}
|
|
}
|
|
}'
|
|
|
|
|
|
#+
|
|
#------------------------------------------------------------------------------
|
|
# _timescan - low-level timescan macro.
|
|
# Added call to 'scan_tail' in the end. For a normal
|
|
# time scan, which is usually ended by a Ctrl+C, this
|
|
# has no effect at all. However, 'loopscan' uses
|
|
# '_timescan' and terminates itself after a certain
|
|
# number of counting loops. The addition of 'scan_tail'
|
|
# to '_timescan' ensures that 'loopscan' performs the
|
|
# normal user-defined cleanup tasks for scans in the end
|
|
# (like closing scanlogs for example).
|
|
#-
|
|
|
|
def _timescan '
|
|
# =========
|
|
|
|
if ($# > 1) _ctime = $2; else _ctime = COUNT
|
|
if ($# > 2) _stime = $3; else _stime = 0
|
|
|
|
HEADING = sprintf("%s %g %g", HEADING, _ctime, _stime)
|
|
_cols = 1
|
|
_sx = 0; _fx= _ctime>0 ? 20*(_ctime + _stime + _sleep) : 5
|
|
X_L = "Time"
|
|
Y_L = cnt_name(DET)
|
|
_stype = 16
|
|
FPRNT="Time "
|
|
PPRNT=sprintf("%8.8s ", "Time")
|
|
VPRNT=sprintf("%9.9s ", "Time")
|
|
_n1 = int($1)
|
|
scan_head
|
|
_n1 = 0
|
|
def _scan_on \'{
|
|
local _time maxPTS shft
|
|
maxPTS = array_op("rows", SCAN_D)
|
|
shft = maxPTS/2
|
|
for (; int($1) == 0 || NPTS < int($1); NPTS++) {
|
|
if (NPTS - _n1 >= maxPTS){
|
|
SCAN_D[0:(maxPTS - shft - 1)][] = SCAN_D[shft:(maxPTS - 1)][]
|
|
_n1 += shft
|
|
}
|
|
_time = time()-TIME
|
|
FPRNT=sprintf("%g ",_time)
|
|
PPRNT=sprintf("%8.4g ",_time)
|
|
VPRNT=sprintf("%9.4f ",_time)
|
|
scan_loop
|
|
scan_data(NPTS-_n1, _time)
|
|
if (_time > _fx) {
|
|
local val
|
|
val = NPTS
|
|
# will cause scan_plot to refresh
|
|
NPTS = 0
|
|
_fx += 0.1 * (_fx - _sx)
|
|
_sx = SCAN_D[1][0]
|
|
scan_plot
|
|
NPTS = val
|
|
}
|
|
scan_plot
|
|
do_sleep _stime
|
|
}
|
|
scan_tail
|
|
}\'
|
|
TIME=time()
|
|
_scan_on
|
|
'
|
|
|
|
#+
|
|
#------------------------------------------------------------------------------
|
|
# hklscan - low-level reciprocal space scan macro.
|
|
# Modified such that the scan skips points corresponding
|
|
# to physically unobtainable reflections in reciprocal
|
|
# space without trying to move or count.
|
|
# This will reduce the number of errors due to aborted
|
|
# scans and prevents long series of several scans to
|
|
# crash out.
|
|
#-
|
|
|
|
def hklscan '
|
|
# =======
|
|
|
|
if ($# != 8) {
|
|
eprint "\
|
|
Usage: hklscan Hstart Hfinish Kstart Kfinish Lstart Lfinish intervals time"
|
|
exit
|
|
}
|
|
{
|
|
_s1 = $1; _f1 = $2; _s2 = $3; _f2 = $4; _s3 = $5; _f3 = $6
|
|
_n1 = int($7); _ctime = $8
|
|
}
|
|
|
|
if (_n1 <= 0) {
|
|
eprint "Intervals <= 0"
|
|
exit
|
|
}
|
|
HEADING = sprintf("hklscan %g %g %g %g %g %g %g %g", $1,$2,$3,\
|
|
$4,$5,$6,$7,$8)
|
|
_d1 = (_f1 - _s1)/_n1
|
|
_d2 = (_f2 - _s2)/_n1
|
|
_d3 = (_f3 - _s3)/_n1++
|
|
|
|
H=_f1; K=_f2; L=_f3
|
|
calcA; _bad_lim=0; _hkl_lim
|
|
if (_bad_lim) {
|
|
eprintf("(H K L = %g %g %g)\n",H,K,L)
|
|
exit
|
|
}
|
|
if (_pre_chk) {
|
|
local i
|
|
for (i=0;i<_n1;i++) {
|
|
H = _s1 + i*_d1
|
|
K = _s2 + i*_d2
|
|
L = _s3 + i*_d3
|
|
calcA
|
|
_bad_lim = 0
|
|
_hkl_lim
|
|
if (_bad_lim) {
|
|
eprintf("(H K L = %g %g %g)\n",H,K,L)
|
|
exit
|
|
}
|
|
}
|
|
}
|
|
_cols=3
|
|
if (_sav_geo_mot)
|
|
_cols += _numgeo
|
|
if (_d3)
|
|
{ X_L = "L"; _sx = _s3; _fx = _f3 }
|
|
else if (_d2)
|
|
{ X_L = "K"; _sx = _s2; _fx = _f2 }
|
|
else
|
|
{ X_L = "H"; _sx = _s1; _fx = _f1 }
|
|
Y_L = cnt_name(DET)
|
|
_stype = 2
|
|
FPRNT="H K L "
|
|
PPRNT=""
|
|
{
|
|
local i, s
|
|
for (i=0;i<_numgeo;i++) {
|
|
s = motor_name(mA[i])
|
|
PPRNT = PPRNT sprintf("%8.8s ",s)
|
|
if (_sav_geo_mot)
|
|
FPRNT = FPRNT s " "
|
|
}
|
|
}
|
|
VPRNT=sprintf("%10s %10s %10s ","H","K","L")
|
|
scan_head
|
|
def _scan_on \'
|
|
for (; NPTS < _n1; NPTS++) {
|
|
local i h_ca k_ca l_ca _bad_hkl
|
|
H = h_ca = _s1 + NPTS*_d1
|
|
K = k_ca = _s2 + NPTS*_d2
|
|
|
|
L = l_ca = _s3 + NPTS*_d3
|
|
get_angles;
|
|
_bad_hkl = calcA
|
|
_bad_lim = 0
|
|
_hkl_lim
|
|
if((_bad_hkl == 0) && (_bad_lim == 0)){
|
|
scan_move
|
|
FPRNT=sprintf("%g %g %g ",h_ca,k_ca,l_ca)
|
|
PPRNT=""
|
|
for (i=0;i<_numgeo;i++) {
|
|
PPRNT = PPRNT sprintf("%8.4f ",A[mA[i]])
|
|
if (_sav_geo_mot)
|
|
FPRNT = FPRNT sprintf("%.8g ",A[mA[i]])
|
|
}
|
|
VPRNT=sprintf("%10.5g %10.5g %10.5g ",h_ca,k_ca,l_ca)
|
|
scan_loop
|
|
scan_data(NPTS,_d3? l_ca:(_d2? k_ca:h_ca))
|
|
H=h_ca; K=k_ca; L=l_ca
|
|
scan_plot
|
|
}
|
|
else{
|
|
printf("(H, K, L = %g %g %g)\n",H,K,L)
|
|
}
|
|
}
|
|
scan_tail
|
|
\'
|
|
_scan_on
|
|
'
|
|
|
|
#+
|
|
#------------------------------------------------------------------------------
|
|
# _hklline - low-level reciprocal space scan macro.
|
|
# Modified such that the scan skips points corresponding
|
|
# to physically unobtainable reflections in reciprocal
|
|
# space without trying to move or count.
|
|
# This will reduce the number of errors due to aborted
|
|
# scans and prevents long series of several scans to
|
|
# crash out.
|
|
#
|
|
# Note: This macro is used in other reciprocal space scan macros like
|
|
# \'hkcircle\'.
|
|
#-
|
|
|
|
def _hklline '
|
|
# ========
|
|
|
|
{_const = $1; _s1 = $2; _f1 = $3; _n1 = int($4); _ctime = $5}
|
|
|
|
if (_n1 <= 0) {
|
|
eprint "Intervals <= 0"
|
|
exit
|
|
}
|
|
|
|
_d1 = (_f1 - _s1) / _n1++
|
|
_cols=4
|
|
if (_sav_geo_mot)
|
|
_cols += _numgeo
|
|
_sx = _s1; _fx = _f1
|
|
Y_L = cnt_name(DET)
|
|
_stype = 2
|
|
FPRNT=sprintf("%s H K L ",X_L)
|
|
PPRNT=""
|
|
{
|
|
local i, s
|
|
for (i=0;i<_numgeo;i++) {
|
|
s = motor_name(mA[i])
|
|
PPRNT = PPRNT sprintf("%8.8s ",s)
|
|
if (_sav_geo_mot)
|
|
FPRNT = FPRNT s " "
|
|
}
|
|
}
|
|
VPRNT=sprintf("%10s %10s %10s ","H","K","L")
|
|
|
|
{
|
|
local x
|
|
x = _f1
|
|
_hkl x
|
|
if ("$6" != "0")
|
|
$6
|
|
calcA
|
|
_bad_lim = 0
|
|
_hkl_lim
|
|
if (_bad_lim) {
|
|
eprintf("(H K L = %g %g %g)\n", H, K, L)
|
|
exit
|
|
}
|
|
}
|
|
if (_pre_chk) for (i=0; i<_n1; i++) {
|
|
local x
|
|
x = _s1 + i * _d1
|
|
_hkl x
|
|
if ("$6" != "0")
|
|
$6
|
|
calcA
|
|
_bad_lim = 0
|
|
_hkl_lim
|
|
if (_bad_lim) {
|
|
eprintf("(H K L = %g %g %g)\n", H, K, L)
|
|
exit
|
|
}
|
|
}
|
|
|
|
scan_head
|
|
def _scan_on \'
|
|
for (; NPTS < _n1; NPTS++) {
|
|
local i x h_ca k_ca l_ca
|
|
_x = _s1 + NPTS * _d1
|
|
_hkl _x
|
|
if ("$6" != "0")
|
|
$6
|
|
h_ca = H; k_ca = K; l_ca = L
|
|
get_angles;
|
|
if(calcA == 0){
|
|
scan_move
|
|
FPRNT=sprintf("%g %g %g %g ",_x,h_ca,k_ca,l_ca)
|
|
PPRNT=""
|
|
for (i=0;i<_numgeo;i++) {
|
|
PPRNT = PPRNT sprintf("%8.4f ",A[mA[i]])
|
|
if (_sav_geo_mot)
|
|
FPRNT = FPRNT sprintf("%.8g ",A[mA[i]])
|
|
}
|
|
VPRNT=sprintf("%10.5g %10.5g %10.5g ",h_ca,k_ca,l_ca)
|
|
scan_loop
|
|
scan_data(NPTS,_x)
|
|
H = h_ca; K = k_ca; L = l_ca
|
|
scan_plot
|
|
}
|
|
else{
|
|
printf("(H, K, L = %g %g %g)\n",H,K,L)
|
|
#printf("move not possible - skipped scan point\n")
|
|
}
|
|
}
|
|
scan_tail
|
|
\'
|
|
_scan_on
|
|
'
|
|
|
|
|
|
|
|
#+
|
|
#------------------------------------------------------------------------------
|
|
# issd_scan_hdr_on - redefine user scan macros to get the
|
|
# ISSD (In-Situ Surface Diffractometer)
|
|
# stuff included.
|
|
#-
|
|
|
|
def issd_scan_hdr_on '{
|
|
# ================
|
|
|
|
def user_filehead \'issd_filehead\'
|
|
if (DATAFILE != "") {
|
|
fprintf (DATAFILE, "#C ISSD scan headers turned on at %s\n", date())
|
|
user_filehead; off (DATAFILE); on ("tty")
|
|
}
|
|
|
|
undef user_Fheader
|
|
cdef ("user_Fheader", "issd_scan_head;", "key-0")
|
|
|
|
undef user_scan_tail
|
|
cdef ("user_scan_tail", "issd_scan_tail;", "key-0")
|
|
}'
|
|
|
|
#+
|
|
#------------------------------------------------------------------------------
|
|
# issd_scan_hdr_off - revert to normal scan macros.
|
|
#-
|
|
|
|
def issd_scan_hdr_off '{
|
|
# =================
|
|
|
|
def user_filehead \'\'
|
|
|
|
undef user_Fheader
|
|
cdef ("user_Fheader")
|
|
|
|
undef user_scan_tail
|
|
cdef ("user_scan_tail")
|
|
|
|
if (DATAFILE != "") {
|
|
fprintf (DATAFILE, "#C ISSD scan headers turned off at %s\n", date())
|
|
}
|
|
}'
|
|
|
|
#+
|
|
#------------------------------------------------------------------------------
|
|
# issd_filehead - write some ISSD stuff to the data file every
|
|
# time it is opened
|
|
#-
|
|
|
|
def issd_filehead '{
|
|
# =============
|
|
|
|
fprintf (DATAFILE, "#C ISSD header information\n")
|
|
fprintf (DATAFILE, "#C EPICS Channels \"#UE <prfx> <sfx0> <sfx1> ...\"\n")
|
|
fprintf (DATAFILE, "#UE ARIDI- PCT:CURRENT\n")
|
|
fprintf (DATAFILE, "#UE X04SA- ID-GAP:READ\n")
|
|
fprintf (DATAFILE, "#UE X04SA-FE- BM1:TRH.RBV BM1:TRV.RBV BM2:TRH.RBV BM2:TRV.RBV\n")
|
|
fprintf (DATAFILE, "#UE X04SA-OP- FI1:TR1.RBV FI2:TR1.RBV\n")
|
|
fprintf (DATAFILE, "#UE X04SA-OP-BM1 TRX.RBV TRY.RBV\n")
|
|
fprintf (DATAFILE, "#UE X04SA-OP-MOX1 ROX.RBV ROZ.RBV TRY.RBV\n")
|
|
fprintf (DATAFILE, "#UE X04SA-OP-MOX2 ROX.RBV ROY.RBV ROZ.RBV\n")
|
|
fprintf (DATAFILE, "#UE X04SA-OP-MOX2 TRX.RBV TRY.RBV TRYA.RBV TRYB.RBV TRYC.RBV TRYD.RBV\n")
|
|
fprintf (DATAFILE, "#UE X04SA-OP-BM2: TRX.RBV TRY.RBV\n")
|
|
fprintf (DATAFILE, "#UE X04SA-OP-MI1 TRX1.RBV TRY1.RBV TRY2.RBV TRY3.RBV\n")
|
|
fprintf (DATAFILE, "#UE X04SA-OP-MI2 TRY1.RBV TRY2.RBV TRY3.RBV TR3D.RBV TR3U.RBV\n")
|
|
fprintf (DATAFILE, "#UE X04SA-OP-BM3: TRX.RBV TRY.RBV\n")
|
|
fprintf (DATAFILE, "#UE X04SA-EH1- SH1:TR1.RBV SH1:TR2.RBV SV1:TR1.RBV SV1:TR2.RBV\n")
|
|
fprintf (DATAFILE, "#UE X04SA-EH2- SH1:TR1.RBV SV1:TR2.RBV SV1:TR1.RBV SH1:TR2.RBV\n")
|
|
fprintf (DATAFILE, "#UE X04SA-ES3- SH1:TR1.RBV SH1:TR2.RBV SV1:TR1.RBV SV1:TR2.RBV\n")
|
|
fprintf (DATAFILE, "#UE X04SA-ES3- SH2:TR1.RBV SH2:TR2.RBV SV2:TR1.RBV SV2:TR2.RBV\n")
|
|
fprintf (DATAFILE, "#UE X04SA-ES3- SH3:TR1.RBV SH3:TR2.RBV SV3:TR1.RBV SV3:TR2.RBV\n")
|
|
fprintf (DATAFILE, "#UE X04SA-ES3- FI1:SET FI2:SET FI3:SET FI4:SET FI5:SET FI6:SET FI7:SET FI8:SET\n")
|
|
fprintf (DATAFILE, "#UE X04SA-ES3- FI9:SET FI10:SET FI11:SET FI12:SET FI13:SET FI14:SET FI15:SET FI16:SET\n")
|
|
fprintf (DATAFILE, "#UE \"\" H K L LAMBDA\n")
|
|
}'
|
|
|
|
#+
|
|
#------------------------------------------------------------------------------
|
|
# issd_scan_head - scan header macro to put ISSD specific items
|
|
# into scan header.
|
|
#-
|
|
|
|
def issd_scan_head '{
|
|
# ==============
|
|
|
|
array my_arr[100]
|
|
local i, j
|
|
|
|
i = 0
|
|
my_arr[i] = epics_get ("ARIDI-PCT:CURRENT"); i++
|
|
my_arr[i] = epics_get ("X04SA-ID-GAP:READ"); i++
|
|
my_arr[i] = epics_get ("X04SA-FE-BM1:TRH.RBV"); i++
|
|
my_arr[i] = epics_get ("X04SA-FE-BM1:TRV.RBV"); i++
|
|
my_arr[i] = epics_get ("X04SA-FE-BM2:TRH.RBV"); i++
|
|
my_arr[i] = epics_get ("X04SA-FE-BM2:TRV.RBV"); i++
|
|
my_arr[i] = epics_get ("X04SA-OP-FI1:TR1.RBV"); i++
|
|
my_arr[i] = epics_get ("X04SA-OP-FI2:TR1.RBV"); i++
|
|
my_arr[i] = epics_get ("X04SA-OP-BM1:TRX.RBV"); i++
|
|
my_arr[i] = epics_get ("X04SA-OP-BM1:TRY.RBV"); i++
|
|
my_arr[i] = epics_get ("X04SA-OP-MOX1:ROX.RBV"); i++
|
|
my_arr[i] = epics_get ("X04SA-OP-MOX1:ROZ.RBV"); i++
|
|
my_arr[i] = epics_get ("X04SA-OP-MOX1:TRY.RBV"); i++
|
|
my_arr[i] = epics_get ("X04SA-OP-MOX2:ROX.RBV"); i++
|
|
my_arr[i] = epics_get ("X04SA-OP-MOX2:ROZ.RBV"); i++
|
|
my_arr[i] = epics_get ("X04SA-OP-MOX2:ROY.RBV"); i++
|
|
my_arr[i] = epics_get ("X04SA-OP-MOX2:TRX.RBV"); i++
|
|
my_arr[i] = epics_get ("X04SA-OP-MOX2:TRZ.RBV"); i++
|
|
my_arr[i] = epics_get ("X04SA-OP-MOX2:TRY.RBV"); i++
|
|
my_arr[i] = epics_get ("X04SA-OP-MOX2:TRYA.RBV"); i++
|
|
my_arr[i] = epics_get ("X04SA-OP-MOX2:TRYB.RBV"); i++
|
|
my_arr[i] = epics_get ("X04SA-OP-MOX2:TRYC.RBV"); i++
|
|
my_arr[i] = epics_get ("X04SA-OP-MOX2:TRYD.RBV"); i++
|
|
my_arr[i] = epics_get ("X04SA-OP-BM2:TRX.RBV"); i++
|
|
my_arr[i] = epics_get ("X04SA-OP-BM2:TRY.RBV"); i++
|
|
my_arr[i] = epics_get ("X04SA-OP-MI1:TRX1.RBV"); i++
|
|
my_arr[i] = epics_get ("X04SA-OP-MI1:TRY1.RBV"); i++
|
|
my_arr[i] = epics_get ("X04SA-OP-MI1:TRY2.RBV"); i++
|
|
my_arr[i] = epics_get ("X04SA-OP-MI1:TRY3.RBV"); i++
|
|
my_arr[i] = epics_get ("X04SA-OP-MI2:TRY1.RBV"); i++
|
|
my_arr[i] = epics_get ("X04SA-OP-MI2:TRY2.RBV"); i++
|
|
my_arr[i] = epics_get ("X04SA-OP-MI2:TRY3.RBV"); i++
|
|
my_arr[i] = epics_get ("X04SA-OP-MI2:TR3D.RBV"); i++
|
|
my_arr[i] = epics_get ("X04SA-OP-MI2:TR3U.RBV"); i++
|
|
my_arr[i] = epics_get ("X04SA-OP-BM3:TRX.RBV"); i++
|
|
my_arr[i] = epics_get ("X04SA-OP-BM3:TRY.RBV"); i++
|
|
my_arr[i] = epics_get ("X04SA-EH1-SH1:TR1.RBV"); i++
|
|
my_arr[i] = epics_get ("X04SA-EH1-SH1:TR2.RBV"); i++
|
|
my_arr[i] = epics_get ("X04SA-EH1-SV1:TR1.RBV"); i++
|
|
my_arr[i] = epics_get ("X04SA-EH1-SV1:TR2.RBV"); i++
|
|
my_arr[i] = epics_get ("X04SA-EH2-SH1:TR1.RBV"); i++
|
|
my_arr[i] = epics_get ("X04SA-EH2-SV1:TR2.RBV"); i++
|
|
my_arr[i] = epics_get ("X04SA-EH2-SV1:TR1.RBV"); i++
|
|
my_arr[i] = epics_get ("X04SA-EH2-SH1:TR2.RBV"); i++
|
|
my_arr[i] = epics_get ("X04SA-ES3-SH1:TR1.RBV"); i++
|
|
my_arr[i] = epics_get ("X04SA-ES3-SH1:TR2.RBV"); i++
|
|
my_arr[i] = epics_get ("X04SA-ES3-SV1:TR1.RBV"); i++
|
|
my_arr[i] = epics_get ("X04SA-ES3-SV1:TR2.RBV"); i++
|
|
my_arr[i] = epics_get ("X04SA-ES3-SH2:TR1.RBV"); i++
|
|
my_arr[i] = epics_get ("X04SA-ES3-SH2:TR2.RBV"); i++
|
|
my_arr[i] = epics_get ("X04SA-ES3-SV2:TR1.RBV"); i++
|
|
my_arr[i] = epics_get ("X04SA-ES3-SV2:TR2.RBV"); i++
|
|
my_arr[i] = epics_get ("X04SA-ES3-SH3:TR1.RBV"); i++
|
|
my_arr[i] = epics_get ("X04SA-ES3-SH3:TR2.RBV"); i++
|
|
my_arr[i] = epics_get ("X04SA-ES3-SV3:TR1.RBV"); i++
|
|
my_arr[i] = epics_get ("X04SA-ES3-SV3:TR2.RBV"); i++
|
|
my_arr[i] = epics_get ("X04SA-ES2-FI1:SET", "float"); i++
|
|
my_arr[i] = epics_get ("X04SA-ES2-FI2:SET", "float"); i++
|
|
my_arr[i] = epics_get ("X04SA-ES2-FI3:SET", "float"); i++
|
|
my_arr[i] = epics_get ("X04SA-ES2-FI4:SET", "float"); i++
|
|
my_arr[i] = epics_get ("X04SA-ES2-FI5:SET", "float"); i++
|
|
my_arr[i] = epics_get ("X04SA-ES2-FI6:SET", "float"); i++
|
|
my_arr[i] = epics_get ("X04SA-ES2-FI7:SET", "float"); i++
|
|
my_arr[i] = epics_get ("X04SA-ES2-FI8:SET", "float"); i++
|
|
my_arr[i] = epics_get ("X04SA-ES2-FI9:SET", "float"); i++
|
|
my_arr[i] = epics_get ("X04SA-ES2-FI10:SET", "float"); i++
|
|
my_arr[i] = epics_get ("X04SA-ES2-FI11:SET", "float"); i++
|
|
my_arr[i] = epics_get ("X04SA-ES2-FI12:SET", "float"); i++
|
|
my_arr[i] = epics_get ("X04SA-ES2-FI13:SET", "float"); i++
|
|
my_arr[i] = epics_get ("X04SA-ES2-FI14:SET", "float"); i++
|
|
my_arr[i] = epics_get ("X04SA-ES2-FI15:SET", "float"); i++
|
|
my_arr[i] = epics_get ("X04SA-ES2-FI16:SET", "float"); i++
|
|
my_arr[i] = epics_get ("X04SA-ES2-FI17:SET", "float"); i++
|
|
my_arr[i] = epics_get ("X04SA-ES2-FI18:SET", "float"); i++
|
|
my_arr[i] = epics_get ("X04SA-ES2-FI19:SET", "float"); i++
|
|
my_arr[i] = epics_get ("X04SA-ES2-FI20:SET", "float"); i++
|
|
my_arr[i] = epics_get ("X04SA-ES2-FI21:SET", "float"); i++
|
|
my_arr[i] = epics_get ("X04SA-ES2-FI22:SET", "float"); i++
|
|
my_arr[i] = epics_get ("X04SA-ES2-FI23:SET", "float"); i++
|
|
my_arr[i] = epics_get ("X04SA-ES2-FI24:SET", "float"); i++
|
|
my_arr[i] = Q["0"]; i++
|
|
my_arr[i] = Q["1"]; i++
|
|
my_arr[i] = Q["2"]; i++
|
|
my_arr[i] = Q["4"]; i++
|
|
for (j = 0; j < i; j = (j + 8)) {
|
|
str = sprintf ("#UH%d", j/8)
|
|
for (k = 0; ((k < 8) && ((j + k) < i)); k++)
|
|
str = sprintf ("%s %.5f", str, my_arr[j+k])
|
|
fprintf (DATAFILE, "%s\n", str)
|
|
}
|
|
}'
|
|
|
|
#+
|
|
#------------------------------------------------------------------------------
|
|
# issd_scan_tail - scan header macro to put ISSD specific items into
|
|
# tail of scan data.
|
|
#-
|
|
|
|
def issd_scan_tail '{
|
|
# ==============
|
|
|
|
array my_arr[10]
|
|
local i, j
|
|
|
|
i = 0
|
|
my_arr[i] = epics_get ("ARIDI-PCT:CURRENT"); i++
|
|
my_arr[i] = epics_get ("X04SA-ID-GAP:READ"); i++
|
|
|
|
fprintf (DATAFILE, sprintf ("#UT0 %.5f %.5f\n", my_arr[0], my_arr[1]))
|
|
}'
|
|
|
|
|
|
#==============================================================================
|
|
#-----------------------------------------------------------------------------#
|
|
# Execute macro definitions defined in additional macro files. #
|
|
#-----------------------------------------------------------------------------#
|
|
|
|
#--------------------------------------------------------
|
|
# Execute the Surface Diffraction help macro definitions
|
|
#
|
|
file = sprintf ("%s/sdHelp.mac", SITE_F_DIR)
|
|
if (file_info (file, "-f")) {
|
|
DOFILE = file; qdofile (file)
|
|
}
|
|
#------------------------------------------------------------
|
|
# Execute the additional orientation matrix macro definitions
|
|
#
|
|
file = sprintf ("%s/orient.mac", SITE_F_DIR)
|
|
if (file_info (file, "-f")) {
|
|
DOFILE = file; qdofile (file)
|
|
}
|
|
#-------------------------------------
|
|
# Execute the filter macro definitions
|
|
#
|
|
file = sprintf ("%s/filter.mac", SITE_F_DIR)
|
|
if (file_info (file, "-f")) {
|
|
DOFILE = file; qdofile (file)
|
|
}
|
|
#----------------------------------
|
|
# Execute the ccd macro definitions
|
|
#
|
|
file = sprintf ("%s/ccd.mac", SITE_F_DIR)
|
|
if (file_info (file, "-f")) {
|
|
DOFILE = file; qdofile (file)
|
|
}
|
|
#----------------------------------------------------
|
|
# Execute ccd macro definitions
|
|
#
|
|
file = sprintf ("%s/ccdscanlog.mac", SITE_F_DIR)
|
|
if (file_info (file, "-f")) {
|
|
DOFILE = file; qdofile (file)
|
|
}
|
|
#--------------------------------------
|
|
# Execute the hexapod macro definitions
|
|
#
|
|
file = sprintf ("%s/hexapod.mac", SITE_F_DIR)
|
|
if (file_info (file, "-f")) {
|
|
DOFILE = file; qdofile (file)
|
|
}
|
|
#--------------------------------------
|
|
# Execute the id gap macro definitions
|
|
#
|
|
file = sprintf ("%s/id.mac", SITE_F_DIR)
|
|
if (file_info (file, "-f")) {
|
|
DOFILE = file; qdofile (file)
|
|
}
|
|
#--------------------------------------
|
|
# Execute the slits macro definitions
|
|
#
|
|
file = sprintf ("%s/slits.mac", SITE_F_DIR)
|
|
if (file_info (file, "-f")) {
|
|
DOFILE = file; qdofile (file)
|
|
}
|
|
#-----------------------------------------------------
|
|
# Execute the PILATUS pixel detector macro definitions
|
|
#
|
|
file = sprintf ("%s/pixel.mac", SITE_F_DIR)
|
|
if (file_info (file, "-f")) {
|
|
DOFILE = file; qdofile (file)
|
|
}
|
|
#---------------------------------------------
|
|
# Execute the image analysis macro definitions
|
|
#
|
|
file = sprintf ("%s/image.mac", SITE_F_DIR)
|
|
if (file_info (file, "-f")) {
|
|
DOFILE = file; qdofile (file)
|
|
}
|
|
#--------------------------------------------------
|
|
# Execute the filter transmission and exposure time
|
|
# automatization macro definitions
|
|
#
|
|
file = sprintf ("%s/auto.mac", SITE_F_DIR)
|
|
if (file_info (file, "-f")) {
|
|
DOFILE = file; qdofile (file)
|
|
}
|
|
#--------------------------------------------------
|
|
# Execute the scanlist macro definitions
|
|
#
|
|
file = sprintf ("%s/scanlist.mac", SITE_F_DIR)
|
|
if (file_info (file, "-f")) {
|
|
DOFILE = file; qdofile (file)
|
|
}
|
|
#--------------------------------------------------
|
|
# Execute the scanlog macro definitions
|
|
#
|
|
file = sprintf ("%s/scanlog.mac", SITE_F_DIR)
|
|
if (file_info (file, "-f")) {
|
|
DOFILE = file; qdofile (file)
|
|
}
|
|
#--------------------------------------------------
|
|
# Execute the plot macro definitions
|
|
#
|
|
file = sprintf ("%s/plot.mac", SITE_F_DIR)
|
|
if (file_info (file, "-f")) {
|
|
DOFILE = file; qdofile (file)
|
|
}
|
|
#--------------------------------------------------
|
|
# Execute the shutter macro definitions
|
|
#
|
|
file = sprintf ("%s/shutter.mac", SITE_F_DIR)
|
|
if (file_info (file, "-f")) {
|
|
DOFILE = file; qdofile (file)
|
|
}
|
|
#--------------------------------------------------
|
|
# Execute the cyberstar macro definitions
|
|
#
|
|
file = sprintf ("%s/cyber.mac", SITE_F_DIR)
|
|
if (file_info (file, "-f")) {
|
|
DOFILE = file; qdofile (file)
|
|
}
|
|
#--------------------------------------------------
|
|
# Execute the beamblocker macro definitions
|
|
#
|
|
file = sprintf ("%s/beamblock.mac", SITE_F_DIR)
|
|
if (file_info (file, "-f")) {
|
|
DOFILE = file; qdofile (file)
|
|
}
|
|
#--------------------------------------------------
|
|
# Execute the SMS messaging service macro definitions
|
|
#
|
|
file = sprintf ("%s/sms.mac", SITE_F_DIR)
|
|
if (file_info (file, "-f")) {
|
|
DOFILE = file; qdofile (file)
|
|
}
|
|
#--------------------------------------------------
|
|
# Execute the surface diffraction startup macro definitions
|
|
#
|
|
file = sprintf ("%s/sdStartup.mac", SITE_F_DIR)
|
|
if (file_info (file, "-f")) {
|
|
DOFILE = file; qdofile (file)
|
|
}
|
|
#--------------------------------------------------
|
|
# Execute the move macro definitions
|
|
#
|
|
file = sprintf ("%s/move.mac", SITE_F_DIR)
|
|
if (file_info (file, "-f")) {
|
|
DOFILE = file; qdofile (file)
|
|
}
|
|
#--------------------------------------------------
|
|
# Execute the parameter handling definitions from X12SA Oliver Bunk
|
|
#
|
|
file = sprintf ("%s/parameter_handling.mac", SITE_F_DIR)
|
|
if (file_info (file, "-f")) {
|
|
DOFILE = file; qdofile (file)
|
|
}
|
|
#--------------------------------------------------
|
|
# Execute the wigglercheck macro definitions
|
|
#
|
|
file = sprintf ("%s/wigglercheck.mac", SITE_F_DIR)
|
|
if (file_info (file, "-f")) {
|
|
DOFILE = file; qdofile (file)
|
|
}
|
|
#--------------------------------------------------
|
|
# Execute the misc macro definitions
|
|
#
|
|
file = sprintf ("%s/misc.mac", SITE_F_DIR)
|
|
if (file_info (file, "-f")) {
|
|
DOFILE = file; qdofile (file)
|
|
}
|
|
|
|
#-------------------------------------------------------------------
|
|
# Load up some ESRF macros
|
|
#
|
|
file = sprintf ("/import%s/sls/spec/esrf/local/macros/xscans.mac", \
|
|
SLSBASE)
|
|
if (file_info (file, "-f")) {
|
|
qdofile (file)
|
|
} else {
|
|
file = sprintf ("%s/sls/spec/esrf/local/macros/xscans.mac", \
|
|
SLSBASE)
|
|
if (file_info (file, "-f")) {
|
|
qdofile (file)
|
|
} else {
|
|
printf ("\aWarning -- cannot find ESRF macros \"xscans.mac\".\n")
|
|
}
|
|
}
|
|
# - - - - - - - - - - - - - - - - -
|
|
file = sprintf ("/import%s/sls/spec/esrf/local/macros/lineup.mac", \
|
|
SLSBASE)
|
|
if (file_info (file, "-f")) {
|
|
qdofile (file)
|
|
} else {
|
|
file = sprintf ("%s/sls/spec/esrf/local/macros/lineup.mac", \
|
|
SLSBASE)
|
|
if (file_info (file, "-f")) {
|
|
qdofile (file)
|
|
} else {
|
|
printf ("\aWarning -- cannot find ESRF macros \"lineup.mac\".\n")
|
|
}
|
|
}
|
|
#-------------------------------------------------------------------
|
|
# For specSD and specOptics:
|
|
# Undefine the standard reciprocal space macros and
|
|
# execute the hand-made macro definitions.
|
|
#
|
|
if ((SPEC == "specSD") || (SPEC == "specOptics")) {
|
|
file = sprintf ("%s/hkldefs.mac", SITE_F_DIR)
|
|
if (file_info (file, "-f")) {
|
|
DOFILE = file; qdofile (file)
|
|
}
|
|
file = sprintf ("%s/hklscans.mac", SITE_F_DIR)
|
|
p file
|
|
if (file_info (file, "-f")) {
|
|
DOFILE = file; qdofile (file)
|
|
}
|
|
}
|
|
#--------------------------------------------------------
|
|
# For specOptics:
|
|
# Execute the Lakeshore macro definitions just for
|
|
# specOptics (used by Fabia for testing when pc3197
|
|
# is occupied).
|
|
#
|
|
if (SPEC == "specOptics") {
|
|
|
|
SITE_F_ES2DIR = "dummy"
|
|
unix (sprintf ("dirname %s", SITE_F_DIR), SITE_F_ES2DIR)
|
|
sscanf (SITE_F_ES2DIR, "%s", SITE_F_ES2DIR) # Remove trailing newline.
|
|
SITE_F_ES2DIR = SITE_F_ES2DIR "/ES2"
|
|
|
|
file = sprintf ("%s/lakeshore.mac", SITE_F_ES2DIR)
|
|
if (file_info (file, "-f")) {
|
|
DOFILE = file; qdofile (file)
|
|
}
|
|
|
|
file = sprintf ("%s/PDmisc.mac", SITE_F_ES2DIR)
|
|
if (file_info (file, "-f")) {
|
|
DOFILE = file; qdofile (file)
|
|
}
|
|
}
|
|
|
|
#==============================================================================
|
|
# Issue some commands at startup
|
|
#
|
|
global COUNT_ID # initiate global variable COUNT_ID which holds the
|
|
# ID number of the last exposure (for images, this
|
|
# should be set to the current image number in the
|
|
# get_counts routine)
|
|
COUNT_ID=1 # initialize COUNT_ID with a value of 1
|
|
|
|
H=0;K=0;L=0 # initialize the Q array to [0,0,0]
|
|
|
|
issd_scan_hdr_on # Make sure the ISSD headers are on by default.
|
|
printf ("\nISSD scan headers have been turned on.\n")
|
|
|
|
shon # activate automatic shutter control.
|
|
shcl # close the fast photon shutter.
|
|
printf("Fast photon shutter is in automatic mode. Type \'shStatus\' for info.\n")
|
|
|
|
# printf("\n")
|
|
|
|
autoInit # make sure auto-level global vars are initialized
|
|
|
|
cyberOn # Make sure the cyberstar point detector is activated
|
|
# and set some important global vars.
|
|
|
|
|
|
cvs_revision = "$Revision: 1.13 $"
|
|
cvs_revision = substr (cvs_revision, index (cvs_revision, " ") + 1)
|
|
cvs_revision = substr (cvs_revision, 0, index (cvs_revision, " ") - 1)
|
|
printf ("Revision %s of the X04SA/ES3 site_f.mac file has been executed.\n", cvs_revision)
|
|
|
|
if (SPEC == "s2d2") {
|
|
printf ("\a\n %s\n %s\n %s\n %s\n %s\n %s\n %s\n %s\n", \
|
|
"+-------------------------------------------------------+", \
|
|
"| Note on Motors for s2d2: s2d2 Name ISSD Name |", \
|
|
"| ======================= ========= ========= |", \
|
|
"| gam gamma |", \
|
|
"| del delta |", \
|
|
"| ** PROVISIONAL ** chi alpha |", \
|
|
"| phi omegaV |", \
|
|
"+-------------------------------------------------------+")
|
|
}
|
|
|
|
#+
|
|
#------------------------------------------------------------------------------
|
|
#-
|
|
#==============================================================================
|
|
#
|
|
#####################################################
|
|
# emacs setup: force text mode to get no help with #
|
|
# indentation and force use of spaces #
|
|
# when tabbing. #
|
|
# Local Variables: #
|
|
# mode:text #
|
|
# indent-tabs-mode:nil #
|
|
# End: #
|
|
#####################################################
|
|
#
|
|
# $Log: site_f.mac,v $
|
|
# Revision 1.13 2009/05/27 15:52:34 schlepuetz
|
|
# load wigglercheck on startup, updated changelog
|
|
#
|
|
# Revision 1.12 2009/05/27 15:00:41 bjorck
|
|
# Adding changes for EPICS implementation of motors and fixes for the hexapod
|
|
#
|
|
# Revision 1.11 2008/02/15 09:10:17 schlepuetz
|
|
# load plot.mac at startup
|
|
#
|
|
# Revision 1.10 2007/01/22 15:20:36 maden
|
|
# Add qdo of xscans.mac and lineup.mac
|
|
#
|
|
# Revision 1.9 2006/08/08 14:06:41 schlepuetz
|
|
# modified macro definition of _timescan to include a scan_tail at the end, improved mvhkl and umvhkl, load scanlist.mac at startup, updated header info
|
|
#
|
|
# Revision 1.8 2006/05/04 09:54:01 schlepuetz
|
|
# help text cosmetics...
|
|
#
|
|
# Revision 1.7 2006/05/04 09:47:09 schlepuetz
|
|
# added mvhkl,umvhkl,hklscan,_hklline macro defs; load orient.mac at startup
|
|
#
|
|
# Revision 1.6 2006/03/03 07:06:27 maden
|
|
# Rename lakeshore-by-Dante.mac
|
|
#
|
|
# Revision 1.5 2006/03/01 12:53:45 maden
|
|
# Add some specials for specOptics
|
|
#
|
|
# Revision 1.4 2006/03/01 11:00:27 maden
|
|
# Add a fourth treshold level for automatic filter ...
|
|
#
|
|
# Revision 1.3 2005/11/11 10:43:38 schlepuetz
|
|
# typo on line 18...
|
|
#
|
|
# Revision 1.2 2005/11/11 07:43:03 schlepuetz
|
|
# added hklscans.mac to be read at startup.
|
|
#
|
|
# Revision 1.1 2005/11/10 11:29:05 schlepuetz
|
|
# this is an identical copy of and replaces the old site.mac
|
|
#
|
|
#
|
|
#============================= End of $RCSfile: site_f.mac,v $ === |