esrf

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

PSEUDO.MAC
See other macros in category: All
Description:
    Utility macros to define pseudomotors
Documentation:
    DESCRIPTION
    Pseudo motors are a commonly used feature to implement motors in spec, which do not have actual hardware connected. An example could be the gap and offset motors for slits. In some cases, where you would like to use real hardware without writing c-code, you could also use the concept of pseudo motors. With the feature of Macro Hardware (type help mac_hdw at the spec prompt), there is no need to create new pseudo motors/counters. Please use the macro hardware feature for new implementations.

    EXAMPLE
    pseudodef piezo1 none piezo_move piezo_getangles none none none none 3 0
    Define a pseudo motor piezo1. Each time the user tries to move the piezo piezo_move is called. If the user wants to know the position of the piezo piezo_getangles is called. No action is taken on set ^c. The user parameters were 3 0 and could represent the channel on the corresponding DAC card.
    cpseudodef cnttim1 none cnt_move piezo_getangles none none none none 3 0
    Define a pseudo motor piezo1. Each time the user tries to move the piezo piezo_move is called. If the user wants to know the position of the piezo piezo_getangles is called. No action is taken on set ^c. The user parameters were 3 0 and could represent the channel on the corresponding DAC card.


    INTERNALS
    As updated moves and counting used the c-function wait directly, these waits had to be replaced by the new waitcheckcount ,... macros. These changes have been made:
    IN UTIL.MAC
    config user_waitall user_waitmove user_waitcount


    ATTENTION
    This version of pseudo.mac is to be used with SPEC version 6.00.07 and later! Many ESRF specific macros like mv, ct have been eliminated by improvements made to the standard macros in standard.mac. The effort to keep all ESRF functionality was quite big, but we need to be vigilant to eliminate errors. All old code has been kept in this file as comments, which should allow tracking errors.

    ATTENTION
    • Hitting ^c (so ^c twice) while the cleanup macro is running will undefine the cleanup macro (This will not erase your macro, it will just not be executed). Next time a motor is moved it is redefined again.
    • If you want SPEC to check for software limits, all the motor positions must be calculated before the move. (If you calculate the gap only in getangles, SPEC will not check for limits on the gap)


    DEPENDENCIES
    The file pseudo.mac has to be loaded. ! This is done in startup

Macros:
    pseudodef
    Usage: pseudodef <motormne> <checkmacro> <movemacro> <getanglemacro> <cleanupmacro> < config> <setdial> <finished> <userdata1> <userdata2>
    This macro defines a new pseudo-motor. The motor has to be configured and the controller set to NONE. Whenever a move_all is called the userdefined macro <checkmacro> will be called before and the <movemacro> afterwards. These macros will get three parameters. The first parameter will be the motor mnemonic, the second the string userdata1 and the third the string userdata2. The macro is responsible to move the motor to the position given in the global variable A[motornumber]. The userdata can be used to give some information to the macro (for example the device server name). In the same way the <getanglemacro> will have to fill the A[] array with the actual position of the motor. The <cleanup macro> will be called if the user hits ^c or some error condition occures (A limit is hit for example). The <config> macro will be called after the user called config. The <setdial> and <finished> macros are not yet fully implemented and will server future additions. If you do not want to wait in your macros until your move has finished (and then allow updated move commands), you can hook code in user_motorsrun that executes `return(1)' in case your move is not yet finished. While waiting your getangles macro will be called.

    pseudosdef
    Usage: pseudosdef <var-name>
    same as pseudodef , the input parameter is just a variable name

    pseudodel
    Usage: pseudodel [motormne] : A pseudomotor can be deleted with this macro


    pseudomotformula
    Usage: pseudomotformula <formula> <mot-to-calc> <depend-mot1> <depend-mot2> ...
    This macro can be used to define simple pseudo motors very easily. A pseudomotor like tlaue := piezo/38 could be implemented by
    pseudomotformula "A[piezo]/38" laue piezo
    and pseudomotformula "A[tlaue]*38" piezo laue

    cpseudodef
    Usage: cpseudodef <counter_mne> <precount> <postcount> <getcounts> <cleanup> <config> <userdata1> <userdata2>
    This macro defines a new pseudo-counter. The counter has to be configured and the controller set to NONE. Whenever a count_em macro is used (all the time spec wants to start a counter/timer) <precount> is called before starting the timer and <postcount> after. These macros will get three parameters. The first parameter will be the counter number, the second the string userdata1 and the third the string userdata2. Normally the <precount> or <postcount> macro will start your timer. In <getcounts> you have to fill the S[] array with the counts read from the counter/timer. S[sec := 0] should be the time in seconds. The userdata can be used to give some information to the macro (for example the device server name). The <cleanup> macro will be called if the user hits ^c or some error condition occures (A limit is hit for example). The <config> macro will be called after the user called config. If you do not want to wait in your macros until counting has finished (and in this allow updated count commands), you can hook code in user_countersrun that executes `return(1)' in case your count is not yet finished. While waiting your <pollcounts> macro will be called.

    cpseudosdef
    Usage: cpseudosdef <var-name>
    same as cpseudodef , the input parameter is just a variable name

    cpseudodel
    Usage: cpseudodel [countermne]
    A pseudomotor/counter can be deleted with this macro

Internal Macros:
    chk_count
    Usage: chk_count


    chk_move
    Usage: chk_move


    user_counters_run
    Usage: user_counters_run()


    user_motors_run
    Usage: user_motors_run()


    chk_beam
    Usage: chk_beam


    chk_beamf
    Usage: chk_beamf()


    _chk_beamc
    Usage: _chk_beamc


    user_setpos
    Usage: user_setpos


    user_waitall
    Usage: user_waitall


    user_waitmove
    Usage: user_waitmove


    user_waitcount
    Usage: user_waitcount


    move_poll
    Usage: move_poll


    _pseudodef
    Usage: _pseudodef


    pseudo_hook
    Usage: pseudo_hook


    pseudosdel
    Usage: pseudosdel


    pseudoshow
    Usage: pseudoshow


    pseudohack
    Usage: pseudohack


    _cpseudodef
    Usage: _cpseudodef


    cpseudosdel
    Usage: cpseudosdel


    cpseudoshow
    Usage: cpseudoshow


    pseudo_define_empty_stubs
    Usage: pseudo_define_empty_stubs


Filename: pseudo.mac
Author: JK 3.94 taken out all fprintf(PRINTER , Holger, 9.12.2004
Last mod.: 16/08/2013 11:57 by witsch