esrf

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

MACHINFO.MAC
See other macros in category: X-ray beam Accelerator
Description:
    Macros to access storage ring status information.
Documentation:
    DESCRIPTION
    This macro set allows you:
    • Include machine information in the data file.
    • Display machine information on the screen.
    • Use a counter to know the electron current of the Storage Ring.
    • Wait for the beam refill some seconds before the refill (michkon/off).
    The machine information consists of:
    • The electron current of the Storage Ring.
    • The status of the automatic mode: activated ('ON'), or not activated ('OFF'). And time left in automatic mode.
    • The state of the front end: 'OPEN', 'CLOSED' or 'ERROR'.
    • Readout of frontend interlocks and UHV valve (if present)
    • Time for next refill
    • The last message from the Control Room

    Once the misetup macro has been executed:
    • The above listed information is included in the headers of each scan.
    • It can be displayed on the screen by executing machinfo.
    • A counter named 'srcur' can be defined, which will display the storage ring current. If an error happens, the counter is loaded with -1.
    • A counter named 'sbcur' can be defined, which will display the single bunch current. If an error happens, the counter is loaded with -1.



    EXAMPLE
    misetup

    These lines will be included in your scan header:
      #UMI0 Current  AM  SH  U42_Gap  U42_Taper
      #UMI1  130.00  OFF  FE Open  29.99  0.02
      #UMI2  Refill in 7457 sec, Message: 17/10/2025-05:34 END OF RUN 25-8.
    
    The previous information is an example for an insertion device beamline and varies accordingly for a bending magnet beam
    Version: $Revision: 4.38 $

    DEPENDENCIES
    Functions here might use functions from ID_tango.mac

Macros:
    MI_debug
    Usage: MI_debug
    toggle debug mode for the present macros.

    misetup
    Usage: misetup
    No arguments!
    Initializes parameters to access the information from the machine.

    mistop
    Usage: mistop
    After this command spec will not longer read the machine info and it will not be included in the scan header anymore. With mistart you can switch the reading on again.

    machinfo
    Usage: machinfo
    Display machine information on the SPEC screen

    miread
    Usage: miread <mode?>
    Reads information from machine FE tango DS (as of April 2012)

    michkon
    Usage: michkon [<refill-time>] [<waittime>]
    Activates refill feature on chk_beam. <refill-time> is the time before a refill whithin scans will wait for refill if no parameter is given, a default of 15 seconds is set. Minimum value is 10 seconds. <waittime> is the time to wait once the beam is back. Allows to wait for the undulators to close, optic to heat up ...

    michkoff
    Usage: michkoff %MDESC Deactivates refill feature on chk_beam previously activated by michkon


    mi_set_automatic_mode
    Usage: mi_set_automatic_mode %MDESC Enables the automatic mode : FE will automatically re-open after a refill.


    mi_SR_Current
    Usage: mi_SR_Current ()
    Returns the synchrotron ring current in mA.

    mi_SR_Current_fast
    Usage: mi_SR_Current_fast ()
    Returns the synchrotron ring current in mA. (fast but less safe version)

    mi_festate
    Usage: mi_festate ()
    Returns the front end state as a string

    mi_intlck_pss
    Usage: mi_intlck_pss ()
    Returns non zero if PSS interlock is active

    mi_intlck_exp
    Usage: mi_intlck_exp ()
    Returns non zero if EXP interlock is active

    mi_intlck_fe
    Usage: mi_intlck_fe ()
    Returns non zero if FE interlock is active

    mi_intlck_hqps
    Usage: mi_intlck_hqps ()
    Returns non zero if HQPS interlock is active

    mi_automode
    Usage: mi_automode ()
    Returns non zero if automatic front end mode is on

    mi_autotime
    Usage: mi_autotime ()
    Returns the remaining time for automatic front end mode

    mi_autotime_str
    Usage: mi_autotime_str ()
    Returns the remaining time for automatic front end mode

    waitforrefill
    Usage: waitforrefill [<check_time> [<wait_time>]]
    waitforreffill can be used directly without a parameter, behaviour will then depend on previous michkon / michkoff. With a parameter, on/off is ignored and the wait is done with the value in the first argument. An additional parameter can be used to wait for <wait_time> seconds after beam is back (Ex: to wait for heating or end of cleanup).

    wait_for_beam
    Usage: wait_for_beam
    Waits machine not to be in Injection mode and frontend open.

    feopen
    Usage: feopen
    Open the frontend shutter from SPEC

    feclose
    Usage: feclose
    Close the frontend shutter from SPEC

    mioff
    Usage: mioff
    Disable all storage ring counters.


    mion
    Usage: mion
    Enable all storage ring counters.


Internal Macros:
    minfounsetup
    Usage: minfounsetup


    mistart
    Usage: mistart
    Adds machine info at the header of each scan

    mishow
    Usage: mishow


    __mi_tango_catch_error
    Usage: __mi_tango_catch_error


    __MI_error
    Usage: __MI_error (mesg)
    Attempts to write indentical error message only once in a while

    mi_Fheader
    Usage: mi_Fheader
    Macro that formats information for including it in the scan headers.

    _miIDshow
    Usage: _miIDshow
    Screen formatting for ID beamlines.

    _miIDpositions
    Usage: _miIDpositions()
    Return positions as a formatted string. as demanded by ID1/2

    mibody
    Usage: mibody(mode)
    macro to include start/stop on blmenu

    mi_refilltime
    Usage: mi_refilltime ()
    Returns the remaining time to refill.

    mi_message
    Usage: mi_message ()
    Returns the operator message.

    mi_lifetime
    Usage: mi_lifetime ()
    Returns the lifetime.

    mi_mode
    Usage: mi_mode ()
    Returns the operation mode as text: No mode validated, Injection, Beam Delivery

    mi_srmode
    Usage: mi_srmode ()
    Returns the mode as text: USM, MDT etc.

    ___fe_filling_mode
    Usage: ___fe_filling_mode (<flag>)
    Check if the accelerator filling mode.

    mi_chkbeam
    Usage: mi_chkbeam %MDESC chk_beam stuff


    mi_measure0
    Usage: mi_measure0
    mi_measure0 replaces mi_chkbeam. It loops until refill is finished. This is done without counting which avoids to trig counting cards and detectors.

    ___feopen
    Usage: ___feopen
    Open the frontend shutter from SPEC

    idopen
    Usage: idopen


    idclose
    Usage: idclose


    ___fe_state
    Usage: ___fe_state ()


    ___fe_pollfe
    Usage: ___fe_pollfe (<what>)
    Some complementary info:
    Attribute FE_State can deliver the following answers:
    "FE open", "FE closed", "FE fault", "FE disabled", "FE unknown"

    id_pollfe
    Usage: id_pollfe (<what>)
    <what> : state in {"close"; "open"}
    macro to replace possibly needed macro from the old id.mac

    ___fe_check
    Usage: ___fe_check (<flag>)
    Check if the front end is open. Open it if flag set.

    _check_fe
    Usage: _check_fe (<flag>)
    VINTAGE function to check if the front end is open. Open it if flag set.
    Only this old version is being used in other macros and they expect a numeric value to be returned according to the old taco DS.
    Old state values of the frontend were: 0 (unknown), 3 (close), 4(open), 17 (automatic), 23 (fault), 46 (disabled) or -1 iferror.

    SRCUR_config
    Usage: SRCUR_config (cnum, type, unit, mod, chan)


    Declare a counter controller:

    SCALERS   DEVICE   ADDR       <>MODE  NUM            <>TYPE
        YES    SRCUR                        2     Macro Counter
    
    No address is necessary, as it will be taken from misetup.

    Then create macro counters in a similar manner:

    Unit is index num of controller, channel 0 is for the storage ring current, 1 for single bunch current.
    Number   Name  Mnemonic   Device  Unit  Chan   <>Use As  Scale Factor      3  srcur     srcur  MAC_CNT     2     0    counter             1      4  sbcur     sbcur  MAC_CNT     2     1    counter             1
    Called by spec
    Note: the internal variable SRCUR_addr will not be used. Please use misetup.

    SRCUR_cmd
    Usage: SRCUR_cmd (cnum, attr, p1, p2, p3)
    Channel 0 will return the SR current and channel 1 the single bunch current.
    Called by spec
    Note: the internal variable SRCUR_addr will not be used. Please use misetup.

    _miidread
    Usage: _miidread
    Reading insertion devices from the old taco servers.

    _miidwrite
    Usage: _miidwrite
    scan header output with the old taco servers.

    _miidshow
    Usage: _miidshow
    Screen formatting for the old taco servers.

    id_state
    Usage: id_state ()
    Get state of all undulators
    function which copies behaviour of the old id_state() from the old id.mac
    Return the state of the frontend -> 0 (unknown), 3 (close), 4(open), 17 (automatic), 23 (fault), 46 (disabled) or -1 iferror.

    mi_get_mode
    Usage: mi_get_mode()


    mi_mode_is_USM
    Usage: mi_mode_is_USM()


Filename: machinfo.mac
Author: MACHINFO.MAC - HW, Jan 2012
Last mod.: 29/08/2023 09:54 by guilloud