esrf

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

#%TITLE% ENERGY_LAMBDA.MAC
#%NAME% %B%energy_lambda.mac%B% - Energy/wavelenght Macro Motors
#%DESCRIPTION% Energy/wavelength macro motors positions, calculated from a mono
#angle. It assumes that the real motor is called %B%mono%B%.
#%END%

#%IU% (mne, type, unit, module, chan)
#%MDESC% Configure the energy macro motor.
def energy_config(mne, type, unit, module, chan)  '{
local i

  if (type == "ctrl")
    return

  if (type == "mot" ) {
    if ((motor_num(mono) == -1) || (motor_mne(motor_num(mono)) != "mono")) {  
      eprintf( "error while setting up %s (no motor mono found)\n", \
	motor_mne(mne))
      return ".error."
    }
    motor_par(mono,"energy",motor_mne(mne),"add")
    printf ("Using energy calculation on %s\n",motor_mne(mne))
    print "--> LAMBDA:",LAMBDA?LAMBDA:"unset!"

    return sprintf("mono")
  }
}'

#%IU% (mne, mode)
#%MDESC% Calculate the mono or energy position.
def energy_calc(mne, mode) '{
local enum

  if (mne == "..") return

  if (mode == 0) {
    # calculate energy from mono
    calcE
    if (LAMBDA == 0) A[mne] = 0
    else A[mne] = hc_over_e/LAMBDA 
  } else {
    # calculate mono from energy
    enum = motor_num(motor_par(mne, "energy"))
    calcM A[enum]
  }
}'

#%IU% (mne, type, unit, module, chan)
#%MDESC% Configure the energy macro motor.
def lambda_config(mne, type, unit, module, chan) '{

  if (type == "ctrl")
    return

  if (type == "mot" ) {
    if ((motor_num(mono) == -1) || (motor_mne(motor_num(mono)) != "mono")) {  
      eprintf( "error while setting up %s (no motor mono found)\n", \
	motor_mne(mne))
      return ".error."
    }
    motor_par(mono,"lambda",motor_mne(mne),"add")
    printf ("Using wavelength calculation on %s\n",motor_mne(mne))

    return sprintf("mono")
  }
}'

#%IU% (mne, mode)
#%MDESC% Calculate the mono or wavelength position.
def lambda_calc(mne, mode) '{
local lnum

  if (mne == "..") return

  if (mode == 0) {
    # calculate wavelength from mono
    calcE
    
    A[mne] = LAMBDA
  } else {
    lnum = motor_num(motor_par(mne, "lambda"))
    calcM (hc_over_e/A[lnum])
  }
}'

#%IMACROS%
#%MACROS%
#%TOC%
#%AUTHOR% A.Beteva/BLISS
#$Revision: 1.2 $$Date: 2017/02/07 15:46:45 $
#%END%
#%LOG%
#$Log: energy_lambda.mac,v $
#Revision 1.2  2017/02/07 15:46:45  claustre
#set energy to 0 if LAMBDA is null
#
#Revision 1.1  2012/11/28 15:45:49  beteva
#Initial revision
#