esrf

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

INTLCK.MAC
See other macros in category: Generic I/O Other hardware
Description:
    Manages interlock instances in Wago controllers
Documentation:
    OVERVIEW
    The Wago controllers can implement interlock functionality by means of the isgmain utility (or one of its derivatives) that must be running in the controller. This utility can be configured to associate alarm relays (digital outputs) to a variable number of control signals (input/output channels). In this context each alarm relay with its associated control signals is what is called an \"interlock instance\".
    
     Each control signal of an interlock instance has a defined "alarm condition". 
     This condition is a defined logic value (ON or OFF) for digital signals and
     a value range (defined by MIN/MAX thresholds) for analog signals.
     Whenever one of the control signal reaches an alarm condition, the interlock
     instance goes into "tripped" state and the alarm relay switches to the alarm
     position. 
     By default the alarm position is OFF (relay open) but this can be inverted
     in the configuration of the interlock instance.
    
    
     One can configure more than one interlock instance in a Wago controller.
     The controller stores the configuration in its internal non-volatile memory
     and is completely autonomous: as long it is switched on, the configured
     interlock functions are active.
    
    
     The configuration is also stored in a ASCII file in the host computer.
     This makes easy create or modify the configuration by means of an text
     editor, before uploading it into the controller.
     The macro intlck allows displaying and changing the configuration
     file as well as managing the configuration of the interlock instances in
     the controller itself.
    
    
     In the configuration file each instance is declared by a "relay line"
     (begining by the literal "relay" keyword) and must be followed by as many
     "control channel lines" as needed.
     The syntax is as follows:
    
    relay line:
    relay <outrelay> [<iflags>] [name <string>] [# comments ...]
    control channel line:
    <chan> <chtype> [<min> <max>] [<chflags>] [# comments ...]
    <outrelay> is the channel descriptor for the alarm relay. It should be the logical name declared in the device server. Conventional subarray syntax is accepted (e.g. psalarm[2]).
    
     The instance flags <iflags> is optional and can be any combination of the
     literal keywords INVERTED, STICKY and NOFORCE separated by whitespaces.
    By default the alarm relay is normally ON (closed) and switches OFF (opens) when the instance trips. This behaviour can be inverted with the INVERTED flag.
    If the alarm condition disappears after the instance has tripped, by default the trip state is automatically cleared and the alarm relay switches back to the normal position. If the STICKY flag is set, the trip state is not cleared until the interlock instance is reset from the host computer (see intlckreset).
    By default when there is no alarm condition, the alarm relay is forced to the normal position and cannot be switched externally. The NOFORCE flag relaxes this constraint. In any case when the instance trips, the relay is always forced into the alarm state.
    
     <string> is an arbitrary description string that is stored in the
     controller for identification purposes. It is optional and must always be
     at the end of the line (before any optional comment).
    
    
     <chan> is the control channel descriptor. It should be the logical name
     declared in the device server.
     Conventional subarray syntax is accepted (e.g. temp[0]).
    
    
     The channel type <chtype> is a mandatory two-letter code that indicates
     the type of I/O channel. At least the following codes should be valid:
     IB (input bit), OB (output bit), IW (input word), OW (output word),
     TC (thermocouple), IV (input voltage), OV (output voltage).
    
    
     The thresholds <min> and <max> are mandatory for analog channels (IW, OW,
     IV, OV, TC) and define the alarm condition.
    By default the normal condition occurs when the analog signal is between the <min> and <max> values. When the signal is out of that range an alarm condition is met and the interlock instance trips.
    
     The channel flags <chflags> is an optional field and can be any
     combination of the literal keywords INVERTED and STICKY separated by
     whitespaces.
    The logic of alarm condition can be inverted with the INVERTED flag. By default digital control channels are normally ON and switch into alarm condition when they become OFF, and analog channels trip when their value is out of the min/max thresholds as explained above.

    
     The STICKY flag has the same function than when it is used as an instance
     flag, but in this case it is associated to a particular channel and only
     takes effect when this channel is the one that trips.
    
    
    
    

    EXAMPLE
    intlck
    Displays a summary of the current configuration
    intlck show wcid33a
    Displays the detailed configuration of the station wcid33a
    intlck reset wcid33a 1
    Resets the interlock instance #1 in wcid33a


    DEPENDENCIES
    This macroset uses the device server class Wagods and the utilities in the macro file wagocore.mac.
    Older methods used to communicate with the Wago controllers are not supported. jtdo("wagocore")

    SETUP
    The Wago controllers must be declared in the setup file by means of the wagosetup macro (see help in wagocore.mac). This requires that the the device server Wagods must be properly configured to access to the Wago controllers.
    The interlock configuration file uses the same logical names attributed in the device server configuration to the different input/output channels of the controllers.

Macros:
    intlck
    Usage: intlck [<action> [<wcname> [<instance>]]]
    Without arguments, this macro scans all the Wago controllers declared in the setup file and diplays an information summary concerning the interlock instances. If arguments are specified, the macro performs the corresponding actions. If there is more than one possible controller and its name is not passed as an argument, the macro prompts the user for the controller name. Some of the actions require SpecWizard privilegies. If spec is not in wizard mode, the user will be prompted for the Wizard's password.
    
     The possible actions/syntax are the following:
     
    intlck new [<wcname>]
    Creates a new configuration file for the controller <wcname>, opens the editor and optionally uploads the configuration into the controller.
    intlck edit [<wcname>]
    Opens an existing configuration file in the text editor and optionally uploads the configuration into the controller <wcname>.
    intlck show [<wcname>]
    Donwloads and displays the interlock configuration stored in the controller. If the configuration file differs, it is also displayed on the screen.
    intlck update [<wcname>]
    Uploads the content of the configuration file into the controller.
    intlck reset [<wcname> [<instance>]]
    Resets the selected interlock instance in the controller. Only useful when a controller trips in sticky mode. If there is more than one instance in the controller and the instance number is not specified as an argument, the macro prompts the user for it.


Internal Macros:
    intlck__loadtype
    Usage: intlck__loadtype(table)


    intlck__loadflag
    Usage: intlck__loadflag(table)


    intlck__select
    Usage: intlck__select(wcname)


    intlck__show
    Usage: intlck__show(wcname)


    intlck__newfile
    Usage: intlck__newfile(wcname)


    intlck__edit
    Usage: intlck__edit(wcname)
    Edit and upload the configuration file into the controller

    intlck__update
    Usage: intlck__update(wcname)
    Upload the configuration file into the controller

    intlck__instlbl
    Usage: intlck__instlbl(n)


    intlck__scan
    Usage: intlck__scan()


    intlck__cfgfile
    Usage: intlck__cfgfile(wcname)


    intlck__filename
    Usage: intlck__filename(filepath)


    intlck__reset
    Usage: intlck__reset (<wcname>, <inst>)
    Resets the instance controller (in case of sticky channels)

    intlck__loadcfg
    Usage: intlck__loadcfg (<wcname>, <cfgfile>, <cfgarr> [, <verbose>])
    Reads the interlock configuration contained in the file <cfgfile> and stores it in the array <cfgarr>. If the file cannot be read returns -2 and if there is any error returns -1. Otherwise returns the number of interlock instances read.

    intlck__upload
    Usage: intlck__upload (<wcname>, <cfgarr> [, <verbose>])
    Loads the interlock configuration stored in the array <cfgarr> into the Wago controller <wcname>. Any previous configuration in <wcname> is deleted. If there is any error returns -1. Otherwise returns the number of interlock instances configured.

    intlck__download
    Usage: intlck__download (<wcname>, <cfgarr> [, <verbose>])
    Reads the current configuration from the Wago controller <wcname> and stores it in the array <cfgarr>. If there is any error returns -1. Otherwise returns the number of interlock instances configured.

    intlck_trim
    Usage: intlck_trim (string)
    Return the given string without useless whitespaces.

    intlck__compcfg
    Usage: intlck__compcfg (<cfg1>, <cfg2>)
    Compares the interlock configurations stored in the associative arrays conf1[] and conf2[]. If there is any difference returns 1. If both configurations are identical this macro returns 0.

    intlck__showcfg
    Usage: intlck__showcfg (<wcname>, <cfgarr>)
    Displays the interlock configurations stored in the associative array cfgarr[].

Filename: intlck.mac
Author: P.Fajardo, (Original 4/2005). $Revision: 1.8 $ / $Date: 2016/12/12 13:59:33 $
Last mod.: 12/12/2016 14:59 by perez