ConfigureTag Function Block

Help Contents

Introduction

The ConfigureTag Function Block applies new configuration to a Database Tag.

Functions and Function Blocks

The ConfigureTag Function Block is intended for use in a Program Tag that runs on the Fernhill SCADA Server. A Program Tag uses a continuous execution model, where the program code runs at a fixed interval. A program uses the function block to sample the state of the tag command as it executes.

If you want to change tag configuration from an Operator Action, use the ConfigureTag Function.

Syntax

The ConfigureTag Function Block has this syntax:

ConfigureTag(
        REQ:=Expression,
        TAGNAME:=Expression,
        CONFIG:=Expression,
        BUSY=>Variable-Reference,
        REQID=>Variable-Reference,
        DONE=>Variable-Reference,
        ERROR=>Variable-Reference,
        ERRORMSG=>Variable-Reference );

Note: All parameters are optional.

Parameters

Parameter Type Direction Description
REQ BOOL R_EDGE Input A rising edge triggers the configuration change.
TAGNAME WSTRING Input The name of the database tag to configure. This can be an absolute tag name, or a relative tag name. Relative tag names are resolved relative to the full name of the host program.
CONFIG STRING Input The new configuration to apply to the database tag.
BUSY BOOL Output Set to TRUE while the configuration change is in progress.
REQID UDINT Output A unique identifier associated with the configuration change.
DONE BOOL Output Set to TRUE for 1 execution after the configuration change has completed.
ERROR BOOL Output Set to TRUE if there was an error executing the configuration change.
ERRORMSG WSTRING Output If ERROR is TRUE, the reason why the configuration change failed.

CONFIG Parameter

The CONFIG input parameter is the configuration change to apply to the tag. This is a STRING value that can set 1 or more configuration properties in one operation. The syntax of the CONFIG input parameter is:

config-parameter ::= { property-and-value }

property-and-value ::= property ':=' value

property ::= <The name of the configuration property>

value ::=IEC 61131-3 Literal

NewConfiguration parameter examples:

  1. Change the URL property of a Scanner Tag:

    URL:='https://www.example.com/web-server-request'

  2. Enable historic storage on an Analog Data Point Tag:

    HistoricEnable:=TRUE

  3. Disable historic storage on an Analog Data Point Tag:

    HistoricEnable:=FALSE

Remarks

Once the configuration change begins, additional requests from the input signal REQ are ignored until the configuration change completes.

These timing diagrams show the relationship of the REQ, BUSY, DONE, and ERROR signals processing two requests. The first request completes with an error, the second request completes normally:

        +--------+     +-+ +------+
  REQ   |        |     | | |      |
      --+        +-----+ +-+      +------

        +------+       +------+
 BUSY   |      |       |      |
      --+      +-------+      +----------

               ++             ++
 DONE          ||             ||
      ---------++-------------++---------

               +-------+
ERROR          |       |
      ---------+       +-----------------

The BUSY signal is TRUE while the configuration change is in progress. The DONE signal is TRUE for 1 execution after the completion of the configuration change.

Examples

  1. Configure the URL property of a URL Scanner Tag before starting a refresh of the tag:
    Program Main
        Var
            (* Timer to trigger the action every 5 minutes *)
            ScanTimer : TON;
            
            (* A function block to configure the URL Scanner Tag *)
            ConfigureURLScanner : ConfigureTag;
            
            (* A function block to trigger a refresh of the URL scanner Tag *)
            RefreshURLScanner : TagRefresh;
        
            (* The latest URL *)
            URL : STRING;	
        End_Var
    
        Var_Temp
            (* Temporary variables used to calculate the URL *)
            URLTimestamp : DATE_AND_TIME;
    
            (* URL scanner tag name *)
            URLScannerTagName : WSTRING;
        End_Var
            
        (* Process the scan timer.  Interval = 5 minutes *)
        ScanTimer( IN:= NOT ScanTimer.Q, PT:=T#5m );
    
        (* Optimization: Only build the URL when we need to *)	
        IF ScanTimer.Q THEN
            
            (* Get the current time *)
            URLTimestamp := SysGetDateAndTime();
            
            (* Construct the URL based on the current time *)
            URL := CONCAT( 
                'https://www.example.com/GetResults_',
                FORMAT_DATE_TIME( URLTimestamp, 'yyyyMMddHHmm'),
                '.json' );
        END_IF
        
        (* Use a tag reference to get the URL Scanner tag name.
           This ensures the tag name is correctly refactored when tags are renamed or moved *)
        URLScannerTagName := %".URL Scanner.FullName";
        
        (* Function block to configure the URL property of the URL Scanner Tag
           Triggered when the ScanTimer completes *)
        ConfigureURLScanner( 
            REQ:=ScanTimer.Q,
            TAGNAME:=URLScannerTagName,
            CONFIG:=CONCAT("URL:='",URL,"'"));
        
        (* Function block to refresh the URL Scanner Tag
           Triggered when the URL Scanner tag has been configured *)
        RefreshURLScanner(
            REQ:=ConfigureURLScanner.DONE,
            TAGNAME:=URLScannerTagName );
    
    End_Program
    

Further Information

Database Function Blocks

To learn about other database function blocks.

Elementary Data Types

To learn about the different types supported by Fernhill SCADA.

Core Driver

To learn about other features of the Core Driver.

ConfigureTag Function

For a function to provide the equivalent feature in an Operator Action.

Glossary

For the meaning of terms used in Fernhill SCADA.