esrf

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


#%TITLE% emm.mac
#%NAME%
#  
#%CATEGORY%
#%DESCRIPTION%
#   Energy (KeV) Calculated Macro Motor.
#   The name of the macro motor MUST be "energy"
#   For each Macro Motor energy, 2 macros, "energy_to_angle(energy_val)" and
#   "angle_to_energy(angle_val)" should be written according to the
#   monochromator in use
#   Follower motors (using followmot.mac) are managed when energy is moved,
#   using real or calculated motors
#%EXAMPLE%
#%DL%
#%DT%XXXsetup%DD%
#%SETUP%
#%UL%  
#%LI% 
#%XUL%

#
#  energy <----------------> mono
#     |                       \
#     ----> followmot(s) <-----
#


#need followmot
need hg

hg_generate("emm")

#%IU% (<mne> <type> <unit> <module> <chan>)
#%MDESC%
#   Configuration macro of the Calculation Macro Motor energy
#
def emm_config(mne, type, unit, module, chan) '{
    local _dependant_followers _dependant_motors_list
    if (type == "ctrl") {
        print "Using EMM : Energy Macro Motor."
        return(0)
    }
    else if (type == "mot") {

        local _dependant_motors_list

        _dependant_followers   = followmot_getdependant()
        _dependant_motors_list = sprintf("mono energy %s", _dependant_followers)

        return (_dependant_motors_list)

    }
}'


#%UU% (<mot_num> <mode>)
#%MDESC%
#   Calculation macro of the Calculation Macro Motor energy
#    
def emm_calc(mot_num, mode) '{
    local _ene_num _mono_num _mono_pos
    local ene_newval

    _mono_num  = motor_num("mono")
    _ene_num   = motor_num("energy")


    if (mot_num == "..") {

    }

    if (mode == 0) {          # Sets (Virtual/Macro)-Motor energy.

        if (mot_num == _ene_num) {
            emm_dbg(sprintf("Calculates energy from mono angle %g", A[mono]))
            A[mot_num] = angle_to_energy(A[mono])

            ene_newval = A[mot_num]
        }
    } else if (mode == 1) {    # Sets real motors positions.

        ene_newval = A[_ene_num]

        # Mono movement.
        if (mot_num == _mono_num) {
            _mono_pos = energy_to_angle(A[_ene_num])
            emm_dbg(sprintf("new mono position = %s", _mono_pos))
            A[_mono_num] = _mono_pos
        }
    }

    # Follower(s) movement(s).
    followmot_move(ene_newval)
}'


#%MACROS%
#%IMACROS%
#%TOC%
#%DEPENDENCIES%
#%AUTHOR% C. Guilloud / G. Berruyer
#%END%