esrf

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

MONOCHK.MAC
See other macros in category: Tools
Description:
    Checks monochromator tuning and machine current intensity during scans.
Documentation:
    DESCRIPTION
    When activated (onmonochk), the mono intensity is monitored and if it goes down below a certain threshold, the on-going scan stops temporarily while a "ghost" scan (line up scan of ghscans.mac) re-align the mono on its maximum of intensity. After what the previous ongoing scan resumes. If it appears that the mono intensity loss is due to a beam loss, the on-going scan stops as well and SPEC waits for the beam is back before realigning the mono and continuing the scan.

    SETUP
    It is possible to adapt the feature to particular needs, by defining 3 user macros :
    user_scan_mono
    called before each ghost line up scan of the mono when the _monochk() has detected it needs to be re-aligned. ("return 0" to skip the line-up and return to chk_beam directly.)
    user_lineup
    called after each re-alignement of the mono.
    user_beam_is_back
    called after beam recovery and before pre-scanning the mono. ("return 1" to skip the pre-scan and return to chk_beam directly.)


    DEPENDENCIES
    that macro uses ghscans.mac, menu.mac and pseudo.mac.

Macros:
    monochksetup
    Usage: monochksetup [mon] [mthr] [time] [io] [iothr] [mot] [max] [mag] [steps] [plot] [sleep] [time2] [mag2] [steps2]
    macros initialisation and parameters setting.
    [mon]  : mnemonic of the counter that monitors the mono intensity. 
    [mthr] : mono intensity high threshold in percent of maximum of intensity.    
    [time] : integration time for measuring the intensity and scanning the mono.
    [io]   : mnemonic of the counter that monitors the machine current. 
    [iothr]: machine current low threshold in percent of normal current.
    [mot]  : mnemonic of the monochromator motor to be lined up.  
    [max]  : "CEN|COM|PK" line up at what is specified (PK means max of peak).   
    [mag]  : line up scan magnitude.
    [steps]: line up scan number of intervals.
    [plot] : line up scan plot filter number.
    [sleep]: stabilization time after beam is back.
    [TIME2]: integration time for pre-scanning the mono (after beam is back).
    [MAG2] : pre-scan magnitude.
    [STEPS2]:pre-scan number of intervals.
    
     
    If no mnemonic is specified as machine current monitor, the "beam check" activity is disabled. If no motor or no monochromatic beam monitor are specified, the "mono check" activity cannot be activated. global MCK_LOG MCK_LOG=1

    offmonochk
    Usage: offmonochk
    Disables the mono and beam checking features.

    onmonochk
    Usage: onmonochk [counting_interval]
    Enables the mono and beam checking features.
    Note that the "beam check" is only activated if a machine current monitor has been specified in monochksetup. The macro measures the monitor rate and estimates the type of monitor device (analog or integrating). It uses by default the integration time given at setup.


Internal Macros:
    monochkunsetup
    Usage: monochkunsetup
    setup service. Gets rid of monochk software.

    _monochk_chkpar
    Usage: _monochk_chkpar
    Sets default values and checks all the parameters are properly set to allow "mono check" feature activation or not.

    _monochk_defmac
    Usage: _monochk_defmac
    Defines internal macros from the setup parameters.

    _monochk_cleanup
    Usage: _monochk_cleanup
    Cleanup service. Disables mono and beam checking features.

    _monochk_menu
    Usage: _monochk_menu
    Setup menu.

    _onmonochk
    Usage: _onmonochk
    Activates the mono and beam checking features. This macro is called from within onmonochk.

    _monochk
    Usage: _monochk ()
    HERE IS THE CORE OF THE MONO CHECK ACTIVITY, hooked to chk_beam standard macro. It decides what to do in case of intensity loss. It is called after each counting of a scan. If the mono rate goes below its threshold, the macro first check the machine current. If the beam appears to be lost, (current monitor below its threshold), the macro waits till it is back, and then wait for a stabilisation period, before doing a pre scan and then the line-up scan on the mono. Then the foreground scan resumes. If the mono intensity is too low, but the machine current is high enough, the macro lines the mono up on its maximum of intensity before continuing the foreground scan. The thresholds are re-adjusted each time the mono is moved (done by _monochk_threshold).
    It is possible to adapt that "mono check" feature to particular needs, by defining 3 user macros :
    user_scan_mono
    called before each ghost line up scan of the mono when the _monochk() has detected it needs to be re-aligned. ("return 0" to skip the line-up and return to chk_beam directly.)
    user_lineup
    called after each re-alignement of the mono.
    user_beam_is_back
    called after beam recovery and before pre-scanning the mono. ("return 1" to skip the pre-scan and return to chk_beam directly.)


    _monochk_threshold
    Usage: _monochk_threshold
    If the mono was moved and its monitor rate just measured is high enough (at least 80 percent of old threshold), that macro re-adjusts the thresholds. It is hooked to user_getcounts.

    _monochk_beamlost
    Usage: _monochk_beamlost ()
    Checks machine current.

    _monochk_beam
    Usage: _monochk_beam ()
    Checks machine current. Called from _monochk_beamlost ().

    _monochk_log
    Usage: _monochk_log (msg)
    Writes message to logfile. Do "MCK_LOG=0" to switch off the logging. File name is e.g. "/tmp/fourc_monochk_Apr1998".

    _monochk_logon
    Usage: _monochk_logon
    Sets logfile on.

    _monochk_logoff
    Usage: _monochk_logoff
    Closes logfile.

Filename: monochk.mac
Author: monochk.mac - M.-Claire LAGIER. - 30 th June 1997. # - May 4 16:41:15 METDST 1998 REV 1.19;
Last mod.: 12/08/2008 16:00 by rey