esrf

Beamline Instrument Software Support
SPEC Macro documentation: [ Macro Index | BCU Home ]

#%TITLE% MIRROR.MAC 
#%NAME%
#  Define height and angle pseudomotors for mirrors with 3 legs
#  (this macro set is probably overseded by tab3.mac)
#
#%CATEGORY% Positioning, Obsolete
#
#%DESCRIPTION%
#%PRE%        
#  __________motor1______motor2
#  ________________tilt
#  Two pseudo motors are introduced for a 3 leg mirror
#  height : defined as the mean value of motor1 and motor2 
#  angle  : defined as the difference of m1 and m2 devided by the
#           their horizontal distance (length) 
#%PRE%
#%EXAMPLE%
#%DL%
#%DT%  mirrorsetup am1 am2 amt amh ama .872 %DD%
#     Tell spec that motor1 is called am1, motor2 am2 , and the tilt
#     amt. The height is called amh and the angle ama. As the length
#     (or horizontal difference) is given in meters and the motor
#     values are defined as mm in spec config , the angle is in mrad. 
#%XDL%

def mirror_getangle '
A[$1]=(A[$3]-A[$2])/MIRROR_LEN[$1]
MIRROR_OLDPOS[$1]=A[$1]
'
def mirror_getheight '
A[$1]=(A[$2]+A[$3])/2
MIRROR_OLDPOS[$1]=A[$1]
'
def mirror_moveangle '
if (A[$1]!=MIRROR_OLDPOS[$1]) {
  A[$2]-=(A[$1]-MIRROR_OLDPOS[$1])/2*MIRROR_LEN[$1]
  A[$3]+=(A[$1]-MIRROR_OLDPOS[$1])/2*MIRROR_LEN[$1]
  }
'
def mirror_moveheight '
if (A[$1]!=MIRROR_OLDPOS[$1]) {
  A[$2]+=A[$1]-MIRROR_OLDPOS[$1]
  A[$3]+=A[$1]-MIRROR_OLDPOS[$1]
  }
'

# MCL 5/3/99

def mirror_setuser '{
 local delta
 delta = position2set - A[motor2set]

 if (motor2set == $1) {
   # height
   chg_offset($3,A[$3]+delta)
   chg_offset($4,A[$4]+delta)

 } else if (motor2set == $2) {
   #angle
   chg_offset($3,A[$3]-delta/2*MIRROR_LEN[$2])
   chg_offset($4,A[$4]+delta/2*MIRROR_LEN[$2])
print MIRROR_LEN[$2]
 } 
}'


def mirror_pdef '
  {
  cdef("user_checkall",sprintf("mirror_moveheight %s %s %s ;"\
	,MIRROR_MNAME[3],MIRROR_MNAME[0],MIRROR_MNAME[1]),MIRROR_MNAME[3],0x21)
  cdef("user_getpangles",sprintf("mirror_getheight %s %s %s ;"\
	,MIRROR_MNAME[3],MIRROR_MNAME[0],MIRROR_MNAME[1]),MIRROR_MNAME[3],0x11)
  cdef("user_checkall",sprintf("mirror_moveangle %s %s %s ;"\
	,MIRROR_MNAME[4],MIRROR_MNAME[0],MIRROR_MNAME[1]),MIRROR_MNAME[4],0x21)
  cdef("user_getpangles",sprintf("mirror_getangle %s %s %s ;"\
	,MIRROR_MNAME[4],MIRROR_MNAME[0],MIRROR_MNAME[1]),MIRROR_MNAME[4],0x11)
# MCL 5/3/99
  cdef("user_set",sprintf("mirror_setuser %s %s %s %s ;"\
        ,MIRROR_MNAME[3],MIRROR_MNAME[4],MIRROR_MNAME[0],MIRROR_MNAME[1])\
        ,MIRROR_MNAME[3],0x1)
  }
'

#%UU%  <motor1> <motor2> <tilt> <height> <angle> <length>
#%MDESC%

#    height and angle will be the pseudo motors
def mirrorsetup '
global MIRROR_MNAME MIRROR_OLDPOS MIRROR_LEN
MIRROR_MNAME[0]="$1"  # Motor1
MIRROR_MNAME[1]="$2"  # Motor2 
MIRROR_MNAME[2]="$3"  # Tilt
MIRROR_MNAME[3]="$4"  # Height
MIRROR_MNAME[4]="$5"  # Angle
MIRROR_LEN[$5]=$6
mirror_pdef
'
#%MACROS%
#%IMACROS%
#%DEPENDENCIES%
#  The file mirror.mac has to be loaded      ! done in idxxsetup.mac
#  (This file needs pseudo.mac stlocal.mac)
#%AUTHOR%
#  MIRROR.MAC  JK 2.94
#%TOC%