esrf

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

#%TITLE% newfocusmotortype.mac
#%NAME% 
#   Macros to select the motor type for NewFocus 8753
#
#%CATEGORY% Positioning
#
#%DESCRIPTION%
# Use this macro to set the motor type in a NewFocus picomotor controller type
# 8753. It can be "0" for Standard Picomotor; "1" for Tiny Picomotor.
# %BR%
# Commands are :
#%PRE%
# Query Motor Type
#                 Syntax TYP [<driver>] [<motor>]
# Argument Driver: A1 to A31
# Motor: 0, 1, or 2
# Response "0" for Standard Picomotor; "1" for Tiny Picomotor
# Example >typ a1 0
# 0
# >
# Set Motor Type
#                  Syntax TYP <driver> <motor>=<type>
# Argument Driver: A1 to A31
# Motor: 0, 1, or 2
# Type: 0 = Standard Picomotor, 1 = Tiny Picomotor
# Example Set motor 0 on driver A1 to Tiny motor type:
# >typ a1 0=1
# >
# When done issue a SAV command to retain the values across power cycles.
#%PRE%
# SPEC commands to use (from http://www.certif.com/hardware/newfocus_8753.html):
#%DL%
#%DT%
#   motor_par(motor, "send", cmd)
#%DD%
#    Sends the string cmd to the New Focus channel associated with motor.
#%DT%
#    motor_par(motor, "read", cmd)    
#%DD%
# Sends the string cmd to the New Focus channel associated with motor , as above, and returns a string containing the response. 
#%XDL%
#
#%LOG%
# Modifications history:
# 05/07/2007 Creation 
#
# %END%


#%UU% mne [type]
#%MDESC% Returns the motor type corresponding to the motor mnemonic %B%mne%B%.
# If %B%type%B% is given, sets the type to type.
def newfocusmotortype '{
  local num, mod, chan, type
  num =  motor_num("$1") # always convert to num
  if ( $# < 1) {
    print "Usage: newfocusmotortype mne"
    print "Usage: newfocusmotortype mne toggle"
    print "Usage: newfocusmotortype mne 1|tiny|TINY"
    print "Usage: newfocusmotortype mne 0|standard|STANDARD"
    exit
  }
  mod = motor_par(num, "module")
  mod = "A" mod
  chan = motor_par(num, "channel")
  local query
  query = "TYP " mod " " chan
  type = motor_par(num, "read", query)
  query = ""
  if ("$2" == "toggle") {
    query = "TYP " mod " " chan "=" ! type
  } else 
  if (($# == 2) && (("$2" == 0) || ("$2" == "standard") \
    || ("$2" == "Standard") || ("$2" == "STANDARD"))) {
    query = "TYP " mod " " chan "=" 0
  } else
  if (("$2" == 1) || ("$2" == "tiny") || ("$2" == "Tiny") || ("$2" == "TINY")) {
    query = "TYP " mod " " chan "=" 1
  }
  if ( query != "" ) {
    print "Motor type was", type ? "TINY" : "STANDARD"
    motor_par(num, "send", query)
    motor_par(num, "send", "SAV")
  }
  query = "TYP " mod " " chan
  print "Motor type is", type = motor_par(num, "read", query) ? "TINY" : "STANDARD"
}'

#%MACROS%
#%IMACROS%
#%TOC%
#%AUTHOR% BLISS / ESRF