#%TITLE% CHECKAIR.MAC
#%NAME%
# Macros to handle motors with airpads
#%CATEGORY% Positioning
#%DESCRIPTION%
# This is a macro package which can be used for moving motors where an
# airpad has to be switched on before the move
# The airpad will be switched on every time the motor is moved. The
# macro will wait a certain time until the air is inflated and inform
# the user. Before displaying a prompt the airpad will be switched off
# again. During counting ( for example in scans) the air will be
# switched off. %BR%
# The air will just be switched off if it has been switched on before
# by the macro set. If the airpad has been switched on explicitly by
# the user (for example with the special beamline macro airpad_on)
# the air will stay inflated even during scans. %BR%
#%EXAMPLE%
#%DL%
# %DT% checkairsetup "ID10/airpad/0" ttm th2 %DD%
# This will setup the motors ttm and th2 to check if the air
# is inflated before attempting to move them
# %DT% move ttm 3 %DD%
# The airpad will be switched on , the motor moved and the airpad
# switched off again.
# %DT% ascan th2 0 10 10 1 %DD%
# The motor th2 will be scanned from 0 to 10 . The motor will only
# be moved after the air has been switched on. At each point the
# air will be switched off during counting
# %DT% airpad_on %DD%
# The airpad will be switched on
# %DT% ascan th2 0 10 10 1 %DD%
# The motor will be scanned again. The airpad will not! be switched
# off during counting because the user switched the air on himself.
# %DT% airpad_off %DD%
# The airpad will be switched off again
# %XDL%
#%END%
#%UU% [device] [motormne1] [motormne2] [..]
#%MDESC%
# declares the motor [motormne1] to be moved only if air is
# inflated. The device is the device name of the ICV192 digital
# output channel to control the airpad
def checkairsetup '
{
global CHECKAIRDEV CHECKAIRMOT CHECKAIRMNO CHECKAIROLD
if (!$#) {
CHECKAIRDEV = getval ("Device name for air pad DIO channel",CHECKAIRDEV)
CHECKAIRMNO = getval ("How many motors should be checked",CHECKAIRMNO)
for (uu=0;uu<CHECKAIRMNO;uu++) {
CHECKAIRMOT[uu] = getval (sprintf("Motor Mnemonic No %d",uu+1),\
CHECKAIRMOT[uu] )
}
}
else {
CHECKAIRDEV="$1"
CHECKAIRMOT[0]="$2" ; CHECKAIRMOT[1]="$3" ; CHECKAIRMOT[2]="$4" ;
CHECKAIRMOT[3]="$5" ; CHECKAIRMOT[4]="$6" ; CHECKAIRMOT[5]="$7" ;
CHECKAIRMOT[6]="$8" ; CHECKAIRMOT[7]="$9"
CHECKAIRMNO = $# -1
}
for (uu=0;uu<CHECKAIRMNO;uu++) {
cdef("user_checkall",sprintf("checkair %s ;",CHECKAIRMOT[uu]),\
CHECKAIRMOT[uu], 9)
cdef("user_getpangles",sprintf("checksavepos %s ;",CHECKAIRMOT[uu]),\
CHECKAIRMOT[uu], 9)
}
# Bricolage for id10
cdef("user_checkall","ttmfix_checkall ttm mono ; checkair ttm;","ttm",1)
for (uu=0;uu<MOTORS;uu++) {
CHECKAIROLD[uu]=-9999.999
}
cdef("user_prepcount","checkoff\n","check",0)
cdef("prompt_mac","checkoff\n","check",0)
}'
#%IU%
#%MDESC% Waits for motor to stop and switches air off if we switched it on.
def checkoff '
waitmove
checkswitchairoff
'
#%IU% <motor>
#%MDESC%
# checks if <motor> will move, air is switched on and switches it on
# if necessary. Will to be done before the move.
def checkair '
global ISONAIR
if (CHECKAIROLD[$1] != A[$1]) {
checkifonair
if (!ISONAIR) {
printf ("Warning: Motor %s can only be moved if air is inflated\n",motor_name($1))
printf ("Air will be switched on now ..\n")
checkswitchairon
}
}
'
#%IU%
#%MDESC%
# Reads device and puts result in boolean ISONAIR
def checkifonair '
ISONAIR = (esrf_io(CHECKAIRDEV,"DevReadValue") != 3)
'
#%IU% <motor>
#%MDESC%
# Saves old position for <motor>
def checksavepos '
global CHECKAIROLD
CHECKAIROLD[$1]=A[$1]
'
#%IU% <motor>
#%MDESC%
# Switches air on and remembers that we did it
def checkswitchairon '
global CHECKSWITCHEDON
CHECKSWITCHEDON=1
airpad_on
'
#%UU%
#%MDESC%
# switches the air on
def airpad_on '
esrf_io(CHECKAIRDEV,"DevOpen")
printf ("Waiting until air is inflated ..")
sleep(3)
printf ("done\n")
checkifonair
if (!ISONAIR) {
print "PANIC: Air is not inflated - Emergency STOP\n"
exit
}
'
#%IU% <motor>
#%MDESC%
# Switches air off if we switched it on internally
def checkswitchairoff '
if (CHECKSWITCHEDON) {
sleep(1)
airpad_off
}
'
#%UU%
#%MDESC%
# switches the air off
def airpad_off '
{
esrf_io(CHECKAIRDEV,"DevClose")
printf ("Waiting until air is off ..")
sleep(.5)
printf ("done\n")
CHECKSWITCHEDON=0
checkifonair
if (ISONAIR) {
print "PANIC: Air is still inflated - Emergency STOP\n"
exit
}
}'
#%MACROS%
#%IMACROS%
#%ATTENTION%
# The check if air is inflated is not really done. The only thing
# which is checked is the status of the digital output on the
# icv196 card. You should check if everything is working with
# airpad-on and airpad-off
#%DEPENDENCIES%
#%UL%
#%LI% Switching the air off is implemented with the new hook macros
# hooks have been put into : user_getpangles and prompt_mac
# Checking the air is implemented as pseudo-motors
#%LI% The file checkair.mac has to be read in !done by: startup script
# (this file needs: hook.mac stchanges.mac pseudo.mac)
#%XUL%
#%AUTHOR%
# JK 10.93
#%TOC%
|