Files
x04sa-es3/script/spec/shutter.py
gac-x04sa 50ab665541 Startup
2018-10-18 18:13:05 +02:00

215 lines
6.2 KiB
Python

#==============================================================================
# Macroname: shutter.mac
# ===========
#+
# $Date: 2005/11/10 11:25:54 $
# $Author: schlepuetz $
# $Source: /cvs/G/SPEC/local/X04SA/ES3/shutter.mac,v $
# $Revision: 1.1 $
# $Tag: $
#
# Description: Commands to control the fast photon shutter.
#
# Note: This macro is based on a first working version by R. Herger
# and O. Bunk, December 2004.
#
# Authors: R. Herger (RH), O. Bunk (OB)
# Co-author(s): C. M. Schlepuetz (CS), Philip Willmott (PW)
# Address: Swiss Light Source (SLS)
# Paul Scherrer Institute
# CH - 5232 Villigen PSI
# Created: 2005/07/14
#
#-
#
# Chained macro definitions affected by this macro:
# -------------------------------------------------
# - user_precount
# - user_count_end
# - cleanup_always
#
# Change Log:
# -----------
#
# 06.11.2004 (CS):
# - modified the first original version to comply with naming and format
# conventions
# - shon has been adapted to work with the new 'count' command defined in
# site.mac. 'shcl' is now added 'user_count_end' instead of
# 'user_getcounts'.
# - implemented help-file support and wrote help texts.
#==============================================================================
#
global SHUTTER_MAC
#
SHUTTER_MAC = DOFILE # Save the name of this macro file.
# (Used for the help function).
#+
#==============================================================================
# This macro file contains the following commands:
#-
#
#+
#------------------------------------------------------------------------------
# shutterhelp - generates this help text. This is obtained by
# displaying the file shutter.txt, which should sit in the
# same directory as this macro file.
#-
# allow for misspelled help commands
def shHelp 'shutterhelp'
def shhelp 'shutterhelp'
def helpshutter 'shutterhelp'
def helpShutter 'shutterhelp'
def shutterHelp 'shutterhelp'
def shutterhelp '{
# ===========
unix (sprintf ("dirname %s", SHUTTER_MAC), _1)
ll = length (_1)
if (substr (_1, ll, 1) == "\n") _1 = substr (_1, 1, (ll - 1))
file = sprintf ("%s/shutter.txt", _1)
if (file_info (file, "-e")) {
unix (sprintf ("cat %s | less", file))
} else {
printf("\n Macros available in file shutter.mac ($Revision: 1.1 $):\n")
printf( " ==========="\n)
printf("\n")
printf(" shutterhelp - creates this help text\n")
printf(" shop - opens the fast shutter (alias: shopen)\n")
printf(" shcl - closes the fast shutter (alias: shclose)\n")
printf(" shStatus - display whether the shutter is open or closed\n")
printf(" shOn - activate automatic shutter opening and closing\n")
printf(" shOff - turn automatic shutter opening and closing off\n")
printf("\n")
}
}'
#+
#------------------------------------------------------------------------------
# shop - open the fast photon shutter
#-
def shOpen 'shop'
def shop'{
# ====
epics_put ("X04SA-ES3-SC:LEVEL", "On")
sleep(0.1)
}'
#+
#------------------------------------------------------------------------------
# shcl - close the fast photon shutter
#-
def shClose 'shcl'
def shcl'{
# ====
epics_put ("X04SA-ES3-SC:LEVEL", "Off")
}'
#+
#------------------------------------------------------------------------------
# shStatus - display the fast photon shutter status (OPEN or CLOSED)
#-
def shShow 'shStatus'
def shStatus'{
# ========
global SHUTTER_AUTO_IS_ON
if (epics_get("X04SA-ES3-SC:LEVEL")=="On"){
printf("Shutter OPEN\n")
} else {
printf("Shutter CLOSED\n")
}
if (SHUTTER_AUTO_IS_ON == 1){
printf("Automatic shutter opening is ON\n")
} else {
printf("Automatic shutter opening is OFF\n")
}
}'
#+
#------------------------------------------------------------------------------
# shOn - activate automatic shutter opening and closing.
# The shutter is opened just before an actual count command is
# executed and immediately closed again thereafter to prevent
# unnecessary sample irradiation.
#
# Note: In a case of any error (this includes also Ctrl-C interrupts), the
# fast photon shutter is always closed.
#-
def shon 'shOn'
def shOn '{
# ====
global SHUTTER_AUTO_IS_ON
SHUTTER_AUTO_IS_ON = 1
# add to user_precount (opening) and user_count_end (closing)
cdef("user_precount","shop; ","aaa_shutter_user_precount_key",0x10)
cdef("user_count_end","shcl; ","zzz_shutter_user_count_end_key",0x20)
# add shcl to cleanup_always to close in case of errors
cdef("cleanup_always","shcl; ","aaa_shutter_cleanup_key",0x10)
printf("Automatic shutter opening is ON\n")
}'
#+
#------------------------------------------------------------------------------
# shOff - turn automatic shutter opening and closing OFF.
# See shOn.
#-
def shoff 'shOff'
def shOff '{
# =====
global SHUTTER_AUTO_IS_ON
SHUTTER_AUTO_IS_ON = 0
# remove from user_precount and getcounts
cdef("user_precount","","aaa_shutter_user_precount_key","delete")
cdef("user_count_end","","zzz_shutter_user_count_end_key","delete")
cdef("cleanup_always","","aaa_shutter_cleanup_key","delete")
printf("Automatic shutter opening is OFF\n")
}'
#+
#------------------------------------------------------------------------------
#-
#==============================================================================
#
#####################################################
# 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: shutter.mac,v $
# Revision 1.1 2005/11/10 11:25:54 schlepuetz
# first tested version of this file
#
#
#============================= End of $RCSfile: shutter.mac,v $ ===