esrf

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

STLOCAL.MAC
See other macros in category: All
Description:
    Standard macros which can be used independ. of hardware
Documentation:
    DESCRIPTION
    In stlocal.mac you will find a collection of utilities to :
    • edit macros
    • for writting and reading local help
    • print output to printer
    • save and recall a configuration
    • include the scan results in the data file
    • save automatically the state file
    • create and change the working directory
    • define a new data group, using free number
    • print tango error form the TANGO_ERR_STACK


    EXAMPLE
    emac mymacro (Calls your editor to modify mymacro)
    pon
    wa
    poff   (Prints all the motor positions to the printer)
    putconf mysetup2 (saves a configuration)
    getconf mysetup2 (recalls mysetup2)
    help local (shows local help)
    groupinit (globalvar,width,elemno) (inits the group and returns its number)
    ctu ( counts in a loop )
    


    SETUP
    No setup is necessary but you can change the editor with EDITOR="vi" if you do not want to use emacs

    ATTENTION
    This version of stlocal.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.

Macros:
    clscreen
    Usage: clscreen()
    To clear an terminal window. Instead of tty_cntl("cl") use clscreen ... it will not loose the lift.

    emac
    Usage: emac <macroname>
    Edit a macro with emacs or another editor if the variable EDITOR is asigned

    moredef
    Usage: moredef <macroname(s)>
    Like prdef but uses a pager like more to display the macro definition. You can define PAGER to change the page to less or something else.

    help
    Usage: help
    Redefines the help macro. You can get local help with help local

    pon
    Usage: pon
    switch the printer on, every thing on the screen will be sent to the printer until you type poff

    poff
    Usage: poff
    switch the printer off and print the screen output since the last pon command. 3/9/98 - MP - option o12 to reduce sligthly the output so that it fits in a page

    dump
    Usage: dump
    dump a window to the printer - works on HP

    putconf
    Usage: putconf [name]
    saves the current configuration file under the name [name]. If you do not give a name you will be asked for it

    getconf
    Usage: getconf [name]
    retrieves a saved configuration. The current configuration will be lost! If you do not give a name a list of all the saved configurations will be displayed and a name will be asked

    jdo
    Usage: jdo <macro>
    loads a macro from $(BLISSADM)/spec/macros

    udo
    Usage: udo <macro>
    loads a macro from $BLISSADM/local/spec/macros

    usersave
    Usage: usersave
    Saves the motor positions in a file called recover.mac and defines a macro recoverto recover them later.

    bench
    Usage: bench command
    Tells you the unix time the macro execution took

    cryforhelp
    Usage: cryforhelp [problem description]
    Sends a mail to the spec administrator and asks for help

    crysetup
    Usage: crysetup [beamline [mail-address [tel-number]]]
    Sets some global variables for the cryforhelp macro. The [beamline] is for information only. I mail-address is not given, the mail is sent to icntl@esrf.fr. The tel-number is given for information only

    resultlinesetup
    Usage: resultlinesetup
    Activates the saving of the scan results in the data file (`#R' line).

    saveall
    Usage: saveall [dummy-parameter]
    Saves the state file. The optional dummy parameter is internally used by the automatic saving feature activated by saveallsetup.

    saveallsetup
    Usage: saveallsetup [saving-time]
    Activates the automatic storage of the state file. The state file is saved to disk if the elapsed time since the last storage is longer than `saving-time' in seconds (defaulted to 5 minutes).

    chgwd
    Usage: chgwd
    Changes current directory to the SPEC working directory. The SPEC working directory is defaulted to $HOME/data and can be modified by newdir.

    newdir
    Usage: newdir [directory]
    Sets a new SPEC working directory. If the directory doesn't exist, the macro prompts the user before create it.

    newsession
    Usage: newsession
    Lets the user change the SPEC working directory and select a new file. This macro should be used instead of newfileif chgwdis executed by the startup macros.

    setup
    Usage: setup ["g"]
    Runs the setup editor and executes reconfigand the setup files if they exist.
    Two files contain the local setup: a global setup that is common to all SPEC versions in the same installation and a particular setup file that is independent for each version of SPEC. By default the editor loads the particular setup file. Whith the parameter `g' the global setup file is loaded.

    resetup
    Usage: resetup
    Executes the setup files if they exist.


    newwh
    Usage: newwh <macro_name> <motor> [<motor> ...]
    Lets the user define new `where' macros in an easy way. A macro called <macro_name> is internally defined that displays the positions of the specified motors. If <macro_name> is invoked with a parameter more detailed information is presented.

    newwu
    Usage: newwu <macro_name> <motor> [<motor> ...]
    Lets the user define new `where' macros in an easy way. A macro called <macro_name> is internally defined that displays the user positions of the specified motors. If <macro_name> is invoked with a parameter more detailed information is presented.

    warningsetup
    Usage: warningsetup <warningmacro> [<warningmacro> ...]
    Includes warning macros in prompt_mac. Warning macros display warning messages on the screen immediately before the prompt.
    For instance if a line warningsetup datawarningis included in your setup file, you will get amessage whenever no data file is selected.
    If you want to include your own warning macros, see simulwarning and datawarningas examples

    ondummy
    Usage: ondummy
    Changes the data file to a file called `dummy' in the current working directory. The name and the scan number of the previous data file is kept in memory and can be restored with offdummy.
    The macros ondummyand offdummyare provided as a fast way of switching files when one wants to run some scans (alignment checking, tests of command or macro files, ...) and don't want to fill up the data file with garbage.

    offdummy
    Usage: offdummy
    Restores the previous data file name if ondummywas used.

    offwiz
    Usage: offwiz
    Deactivates wizard mode set by onwiz. In replacement of the macro in standard.mac, as we use a user_offwiz macro. onwiz in standard.mac!

    config
    Usage: config [<motorgroup>]
    Redefinition of the standard configmacro to include motor groups and specGUI configuration. <BR> This macro uses the config_geo macro, as we still need to support so-called motor groups. They use a feature of SPEC where you can define geometries with linked config files. This is a misuse of this geometry feature, but it is still used on some beamlines :-(

    groupinit
    Usage: groupinit (group , points , width)


    newmac
    Usage: newmac
    Redefinition of the standard newmacmacro to make it compatible with the jtdo()function used in startup files.

    ctu
    Usage: ctu [count-time [sleep-time]]
    It performs a counting loop and updates the value of the counters on the screen.

    interpol
    Usage: interpol (arr, x, y, nb, val)
    This macro will use calculate an approximate y value for val. This approximation will simply be done by a linear interpolation of the table given with the first 3 parameters. Nb is the number of elements in the array. ( You can use array_read (file,arr) to read these values from a file)

    prun
    Usage: prun speccmd pipeop unixcmd
    executes speccmd and uses the pipeoperator to connect its output to a shell command. Ex.: prun prdef wa | sed -n -e '/loop/p' | wc or already more useful things like : prun prdef | grep user_

    more
    Usage: more [<file>]
    Display <file> or the datafile using `less'.

    shs
    Usage: shs [<scan_no>]
    Display the current scan ot <scan_no> using `less' with the current data file.

    pause_query
    Usage: pause_query
    Allows to pause in loops during macros or user macro files If defined (with cdef) in user_scan_loop it will allow users to stop temporarily execution of any scan. The key

    set_rel_lm
    Usage: set_rel_lm <mot1> <mot2> <lower limit Pos1-Pos2> <upper limit Pos1-Pos2>
    Define limits on the relative position of two motors. Pos1 - Pos2 must be in between the lower and upper limit.

    del_rel_lm
    Usage: del_rel_lm <mot1> <mot2>
    Deletes limits for relative position Mot1 - Mot2 defined with set_rel_lm

    mayneed
    Usage: mayneed (command, macrofile)
    If the command is not defined, loads the macrofile

    print_tango_err
    Usage: print_tango_err (keyword)
    This macro will print all the existing errors from the built-in associative array containing the complete error stack for a tango_io, tango_put and tango_get commands, generating an error - TANGO_ERR_STACK, sorted by keyword.
    Valid keywords are: "desc","origin", "reason" or "severity". If no keyword, "desc" will be printed.

    _mo_loop
    Usage: _mo_loop
    Macro to show arbitrary values, e.g. used with savemot and savecnt(saveload.mac) Make sure the calling macro uses variable "i" as the looper and "k" as the limit.

    px
    Usage: px
    print one value as hexadecimal

Internal Macros:
    localhelp
    Usage: localhelp
    [subject] used by help, Calls a shell script machelp (must be in your path)

    resultline
    Usage: resultline
    Prints the scan results in the data file

    resultlineunsetup
    Usage: resultlineunsetup
    Used to deactivate the result line saving set by resultlinesetup.

    saveallunsetup
    Usage: saveallunsetup
    Used to cancel the `saveall' feature by the unsetup procedure.

    resetup_end
    Usage: resetup_end
    Used by resetup.

    setup_tail
    Usage: setup_tail (<name>, [<parameter_string>])
    Macro function to be included in `xxxsetup' macros to implement the unsetup functionalities.
    When a `xxxsetup' macro is removed from one of the setup files, the macro `<name>unsetup' is invoked with the parameters contained in <parameter_string>. If <parameter_string> is omitted, the string "<name>" is user as only parameter for `<name>unsetup'.

    checkifmacro
    Usage: checkifmacro <macro> <first_word>
    Checks if a macro called <macro> that begins with <first_word> is already defined. If it is, the local variable `error' is set.

    newwhunsetup
    Usage: newwhunsetup "newwh<macro_name>" <macro_name>
    Undefines the macros created by newwh.

    _new_wh
    Usage: _new_wh <motor> [<motor> ...]
    Used by newwhto display the motor positions.

    newwuunsetup
    Usage: newwuunsetup "newwu<macro_name>" <macro_name>
    Undefines the macros created by newwu.

    _new_wu
    Usage: _new_wu <limits_flag> <dummy> <motor> [<motor> ...]
    Used by newwuto display only the motor user positions (not dial ones).

    warningunsetup
    Usage: warningunsetup
    Used to deactivate the warning macros by the automatic unsetup procedure.

    simulwarning
    Usage: simulwarning
    Warning macro that reminds the user that SPEC is in simulation mode. The macro name must be used as a parameter to warningsetup.

    datawarning
    Usage: datawarning
    Warning macro that reminds the user that there is no data file selected in SPEC. The macro name must be used as a parameter to warningsetup.
    This macro also displays a warning message if the data file is called dummy.

    config_geo
    Usage: config_geo [<motorgroup>]
    Handling of motor groups for the redefined configmacro. <BR> This macro is used by the ESRF specific config macro, as we still need to support so-called motor groups. They use a feature of SPEC where you can define geometries with linked config files. This is a misuse of this geometry feature, but it is still used on some beamlines :-(

    ostype
    Usage: ostype ([<machine>, [<stderr>]])
    This macro function returns a string describing the operating system of the computer called <machine>. The user must have permission to remote execution on <machine>. If the user has no permission or an error occurs the function returns -1. If <machine> is omitted or null, the function checks the local host.
    Current OS descriptions are: hp700, sun4, solarisandlinux.
    . It is possible to redirect the standard error stream by specifying a file or device in <stderr>.

    remcom
    Usage: remcom (<machine>, <command>, [<username>, [<stdout>, [<stderr>]]])
    This macro function tries to execute remotely <command> in the computer called <machine>. The user must have permission to remote execution on <machine>. If the <machine> is accessible and the user has the right permission the function returns 0, otherwise it returns -1.
    If <machine> is null, the function runs <command> on the local host.
    If <username> is not null the command is run as a different user in the remote computer.
    The standard output and standard error streams may be redirected by especifying not null values for <stdout> and/or <stderr> respectively.

Filename: stlocal.mac
Author: STLOCAL.MAC JK, with heavy modifications by HW for Spec release 6.00.07 with a revised standard.mac.
Last mod.: 10/11/2020 09:36 by witsch