#%TITLE% MYMOVE.MAC
#%NAME%
# Move macros for 4 circle diffractometer EMBL/ILL style
#
#%CATEGORY% Obsolete
#
#%DESCRIPTION%
# Some special macros to save typing when moving 4-cercle angles.
# Includes macros to work with a oscillation camera.
#%END%
#%UU% <2th> <th> <chi> <phi>
#%MDESC%
# Moves to the given angles. An angle can be specified as '='. In this
# case this angle will not be moved.
def pos '{
if ($# > 4)
{
printf ("Too much input\nCommand pos moves up to 4 angles\n")
exit
}
waitmove
get_angles
if ($#) {
printf ("Moving from: 2Th,Om,Ch,Ph: %7.2f %7.2f %7.2f %7.2f\n",A[0],A[1],A[2], A[3])
if ($# > 0){
if ("$1" != "=") A[0]=$1+0}
if ($# > 1){
if ("$2" != "=") A[1]=$2+0}
if ($# > 2){
if ("$3" != "=") A[2]=$3+0}
if ($# > 3){
if ("$4" != "=") A[3]=$4+0}
printf (" to: 2Th,Om,Ch,Ph: %7.2f %7.2f %7.2f %7.2f\n",A[0],A[1],A[2], A[3])
rdef cleanup "my_abort"
move_all
waitmove
printf ("done...\n")
undef cleanup
}
else
printf ("Currently at: 2Th,Om,Ch,Ph: %7.2f %7.2f %7.2f %7.2f\n",A[0],A[1],A[2], A[3])
}'
#%UU% <ang-name> <delta-angle> [speed]
#%MDESC%
# The m (move by delta angle) command takes ang-name and
# delta value (with optional speed)
def my_abort '{
waitmove
get_angles
printf ("INTERRUPTED: 2Th,Om,Ch,Ph: %7.2f %7.2f %7.2f %7.2f\n",A[0],A[1],A[2], A[3])
undef cleanup
}'
#############################################################################
# stack routine - allows one to stock upto 9 groups of 4 angles
# stack - on it's own - shows the 9 sets
# stack <n> puts CURRENT angles into stack position number n
# stack ini initialises all groups
#############################################################################
#%UU%
#%MDESC%
# stack routine - allows one to stock upto 9 groups of 4 angles
# on it's own - shows the 9 sets
#%UU% <n>
#%MDESC%
# puts CURRENT angles into stack position number n
#%UU% ini
#%MDESC%
# initialises all groups
#%UU% <start> <stop> <step> [time]
#%MDESC%
# The s macro is a simple scan command as in MAD. It takes angle name
# and 3 or 4 inputs.
# The s (simple scan) command takes angle name - start stop step <time>")
# Type can be centered or non centered.
def stack '{
global STACK_ANG_1 STACK_ANG_2 STACK_ANG_3 STACK_ANG_4 STACK_DEF
if ($# > 1)
{
printf ("Too much input\n")
printf ("The \"stack\" command takes one number or \"ini\"\n")
exit
}
if ($#)
{
if ("$1" == "ini")
{
printf ("Initialising the 9 angle-position stack\n")
for (uu=0;uu<9;uu++) STACK_DEF[uu]=0
exit
}
if ($1 > 9 || $1 <= 0)
{
printf ("INPUT ERROR: You have 9 \"stack\" positions\n")
}
else
{
waitmove
get_angles
uu=$1-1
if (STACK_DEF[uu] == 1)
{
printf ("Replace: 2Th,Om,Ch,Ph: %7.2f %7.2f %7.2f %7.2f in STACK pos %d\n By:",STACK_ANG_1[uu],STACK_ANG_2[uu],STACK_ANG_3[uu],STACK_ANG_4[uu],$1)
}
else
{
printf (" Stock:")
}
printf (" 2Th,Om,Ch,Ph: %7.2f %7.2f %7.2f %7.2f",A[0],A[1],A[2],A[3])
if (STACK_DEF[uu] == 0)
{
printf (" in STACK pos %d\n",$1)
}
STACK_ANG_1[uu]=A[0]
STACK_ANG_2[uu]=A[1]
STACK_ANG_3[uu]=A[2]
STACK_ANG_4[uu]=A[3]
STACK_DEF[uu]=1
}
}
else
{
for (uu=0;uu<9;uu++)
{
printf ("stack pos %d",uu+1)
if (STACK_DEF[uu] == 0)
{
printf (" undefined\n")
}
else
{
printf (" 2Th,Om,Ch,Ph: %7.2f %7.2f %7.2f %7.2f\n",STACK_ANG_1[uu],STACK_ANG_2[uu],STACK_ANG_3[uu],STACK_ANG_4[uu])
}
}
}
}'
###############################################################################
#%UU% <n>
#%MDESC%
# goes to the position specified in stack <n>
def goto '{
local uu
if ($# != 1)
{
printf ("The \"goto\" command takes one number - stack position number\n")
exit
}
uu=$1-1
if ($1 > 9 || $1 <= 0)
{
printf ("INPUT ERROR: You have 9 \"stack\" positions\n")
}
else if (STACK_DEF[uu] != 1)
{
printf ("Sorry, there is not an angle stocked in stack position %d\n",$1)
}
else
{
waitmove
pos "STACK_ANG_1[uu]" "STACK_ANG_2[uu]" "STACK_ANG_3[uu]" "STACK_ANG_4[uu]"
}
}'
###########################################################
# simple move macro - takes an angle name and a delta
def m '{
if ($# != 2 && $# != 3)
{
printf ("The m (move by delta angle) command takes ang-name and delta value (with optional speed)")
exit
}
else
{
_check0 "$1"
waitmove
get_angles
for (ii=0;ii<4;ii++)
{
if ("$1"==motor_mne(ii)) n=ii
}
dest=A[n]+$2
if ($# == 3)
{
was = motor_par (n, "velocity")
printf ("Modify speed from %d to %d \n",was,$3)
motor_par (n, "velocity", $3)
}
printf("Move %s from %8.3f to %8.3f",motor_mne(n),A[n],dest)
A[n]=dest
rdef cleanup "my_abort"
t=time()
move_all
waitmove
t=time()-t
printf ("\nFinished. took %5.1fs \n",t)
undef cleanup
get_angles
}
}'
##############################################################################
# s macro is a simple scan command as in MAD
# takes angle name and 3 or 4 inputs.
##############################################################################
def s '{
global SCAN_DEFAULT_COUNT
if ($# != 4 && $# != 5)
{
printf ("The s (simple scan) command takes angle name - start stop step <time>")
exit
}
else
{
_check0 "$1"
waitmove
get_angles
for (ii=0;ii<4;ii++)
{
if ("$1"==motor_mne(ii)) n=ii
}
if ("$2" != "=")
{
type=0
printf("NON-centered\n")
starta =$2+0
stopa = $3
}
else
{
type=1
printf("centered\n")
starta = A[n]-($3/2)
stopa = A[n]+($3/2)
save_ang = A[n]
}
if ($# == 5)
{
_ctime=$5
}
else
{
_ctime=SCAN_DEFAULT_COUNT
}
np = int (fabs(stopa-starta)/$4)
printf ("%d points in scan. Total time %7.1f mins\n",np+1,np*_ctime/60)
t=time()
printf ("shutter open\n")
shutopen
ascan $1 starta stopa np _ctime
printf ("shutter close\n")
shutclose
t=time()-t
printf ("\nFinished. took %5.1fmins \n",t/60)
if (type!=0)
{
printf ("return %s to %7.2f\n",motor_mne(n),save_ang)
mv $1 save_ang
waitmove
get_angles
}
}
}'
###############################################################################
#to setup scan_default_count
#%IU%
#%MDESC%
# Sets some default for the s scan command
def scan_default '
{
global SCAN_DEFAULT_COUNT
SCAN_DEFAULT_COUNT=getval("Default count for s (scan) command",SCAN_DEFAULT_COUNT)
}'
def test '{
if ($# != 2)
{
printf ("test macro, give ang name and destination")
exit
}
else
{
_check0 "$1"
waitmove
get_angles
for (ii=0;ii<4;ii++)
{
if ("$1"==motor_mne(ii)) n=ii
}
was = A[n]
A[n]=was + $2
printf ("starting %s moving from %7.2f to %7.2f\n",motor_mne(n),was,A[n])
move_all
t=time()
while (wait(0x21))
{
get_angles
printf ("%s : %7.2f\r",motor_mne(n),A[n])
}
t=time()-t
printf ("\nFinished. took %5.1fs \n",t)
}
}'
#%UU%
#%MDESC%
# Number of oscillations
# angle width
# Give run-up/run-down angle
#%UU% <angle-name> <start> <stop> <time>
#%MDESC%
def rock_setup '{
global ROCK_OSCILL ROCK_WIDTH ROCK_STEP
ROCK_OSCILL = getval("Number of oscillations ",ROCK_OSCILL)
ROCK_WIDTH = getval("angle width ",ROCK_WIDTH)
ROCK_RUNUP = getval("Give run-up/run-down angle",ROCK_RUNUP)
printf ("Total number of steps: %5d\n",(ROCK_WIDTH/ROCK_STEP+1)*ROCK_OSCILL)
}'
def rock '{
global ROCK_OSCILL ROCK_WIDTH ROCK_STEP
if ($# != 3)
{
printf ("rock macro takes angle name, start and time (secs).")
exit
}
else
{
_check0 "$1"
waitmove
get_angles
for (ii=0;ii<4;ii++)
{
if ("$1"==motor_mne(ii)) n=ii
}
npts =(ROCK_WIDTH/ROCK_STEP+1)*ROCK_OSCILL
lost=npts*.44
t_act = ($3-lost)/npts
printf ("number of steps %d at a counting time of %7.1f secs\n",npts,t_act)
printf ("set up %s starting angle %7.2f\n",motor_mne(n),$2)
mv $1 $2
waitmove
for (ii=0;ii<ROCK_OSCILL;ii++)
{
# even or odd? - backwards or forwards
if (int(ii/2)==(ii/2))
{
s $1 $2 $2+ROCK_WIDTH ROCK_STEP t_act
}
else
{
s $1 $2+ROCK_WIDTH $2 ROCK_STEP*-1 t_act
}
}
}
}'
def tonk'
{
for (;;)
{
printf ("open\n")
shutopen
sleep (1)
printf ("close\n")
shutclose
sleep(1
)
}
}'
def my_home '{
waitmove
get_angles
home $1
waitmove
get_angles
}'
#%UU% <angle-name> <start> <motor spped>
#%MDESC%
def slew '{
global ROCK_OSCILL ROCK_WIDTH ROCK_RUNUP
if ($# != 3 && $# != 2)
{
printf ("slew macro takes angle name, start and motor speed (secs).")
exit
}
else
{
_check0 "$1"
waitmove
get_angles
for (ii=0;ii<4;ii++)
{
if ("$1"==motor_mne(ii)) n=ii
}
was1 = motor_par (n, "velocity")
printf ("set up %s starting angle %7.2f at velocity %d\n",motor_mne(n),$2,was1)
mv $1 $2
waitmove
if ($# == 3)
{
speed $1 $3
}
start=$2
stop=$2+ROCK_WIDTH
t0=time()
printf ("Open the shutter\n")
shutopen
for (ii=0;ii<ROCK_OSCILL;ii++)
{
# even or odd? - backwards or forwards
if (int(ii/2)==(ii/2))
{
A[n]=stop
move_em
}
else
{
A[n]=start
move_em
}
while (wait(0x21))
{
sleep (.1)
t=time()-t0
get_angles
printf ("%5.1f %s : %7.2f\r",t,motor_mne(n),A[n])
}
}
printf ("\nclose the shutter\n")
t=time()-t0
printf ("\nFinished. took %5.1fs \n",t)
speed $1 was1
}
}'
def speed '{
if ($# == 1)
{
for (ii=0;ii<4;ii++)
{
if ("$1"==motor_mne(ii)) n=ii
}
was = motor_par (n, "velocity")
printf ("%s velocity %d\n","$1",was)
}
else if ($# == 2)
{
for (ii=0;ii<4;ii++)
{
if ("$1"==motor_mne(ii)) n=ii
}
was = motor_par (n, "velocity")
printf ("Modify %s speed from %d to %d \n",motor_mne(n),was,$2)
motor_par (n, "velocity", $2)
was = motor_par (n, "velocity")
if (was != $2)
{
printf ("Error: speed not altered from %d - limits in config\n",was)
exit
}
}
else
{
printf ("Change speed macro takes name and speed\n")
}
}'
def shutopen '{printf("I would normally be opening the shutter\n")}'
def shutclose '{printf("I would normally be closing the shutter\n")}'
#%MACROS%
#%IMACROS%
#%DEPENDENCIES%
# The file mymove.mac has to be read in !done by: startup script
#%AUTHOR%
# MYMOVE.MAC - JA 1.94
##%TOC%
|