The TagGen template is an XML file that uses proprietary tags and attributes to specify the fields of input and output databases, and define filters and transformation rules that create tags from existing database fields.
The basic structure of the XML file is as follows:
<?xml version="1.0"?>
<template>
<param name="parameter">
</param>
<input name="variable" file="variable.dbf">
</input>
<output name="trend" file="trend.dbf" filter="">
</output>
</template>
This outline template specifies no parameters, takes input from the variable.dbf database and outputs the results to the trend.dbf database. The <template>
tag is the root tag of the template document and need to be present.
Within the <template>
tag are three sections:
<param>
This is an optional section you can use to specify string constants that can be referred to in other sections of the template. For example:
<param name="parameters">
<string name="MyIODevice">DISK_PLC</string>
</param>
In this example the variable MyIODevice is given the value DISK_PLC.
The <param>
tag has a name attribute. You can use any name provided that it uniquely identifies the section within the XML file. This section name is used when referring to variables from other sections of the file. See Referencing variables.
Strings defined here are displayed in the Additional Tag Generation Configuration dialog when templates are selected. It is possible to define strings that are otherwise not used in the template to specify version or revision information in order to track template modifications.
<input>
The <input>
section specifies the name of the database and the fields that are used for processing into tags. There needs to be only one input section in the XML file. For example:
<input name="variable" file="variable.dbf">
<field name="name"></field>
<field name="type"></field>
<field name="unit" load="true">{parameter.IODevice}</field>
<field name="custom"></field>
<array name="taginfo">{ToProperty('{custom}', '=', ';')}</ array>
<string name="alarminfo">{variable.taginfo[VJA]}</string>
<string name="trendinfo">{variable.taginfo[VJT]}</string>
</input>
This example identifies four fields from the variable.dbf
database: name, type, unit and custom. These fields are used later in the file. The input section loads only rows where the unit field matches the value of the IODevice variable in the parameter section. This helps improve performance by avoiding the processing of irrelevant rows.
An array is created called taginfo that contains key value pairs based on the value of the custom field. If the custom field value was "VJA=Alarm;VJT=Trend", then an array is created containing the values taginfo[VJA] = "Alarm" and taginfo[VJT] = "Trend".
Two string variables are created based on the values of the taginfo array.
<output>
The <output>
section defines the output database, the processing to be done on the input fields and the respective output fields to be generated. There can be many output sections in the XML file. The output section can specify the same database file as the input section if necessary. For example:
<output name="digalm" file="digalm.dbf" filter="'{variable.alarminfo}=VJA' AND '{variable.type}=DIGITAL'">
<field name="tag">{variable.name}_ALARM</field>
<field name="name">{variable.name}_ALARM</field>
<field name="var_a" key="true">{variable.name}</field>
<field name="taggenlink" load="true">{parameter.IODevice}</ field>
</output>
In this example, fields are written to the digalm.dbf
database. Output processing only occurs for the current row if the input row relates to a digital alarm. That is, if the alarminfo variable from the input section has the value of "VJA" and the type field from the input database is "DIGITAL. The tag and name fields are given the value name_ALARM.
Curly braces are usually used for substitutions to replace pre-defined texts with tag properties. To use curly brace characters as normal characters, use double curly braces which will be exceptionally converted to singular ones to express curly braces. Round brackets are not regarded as special characters when used in tags other than <calculator> tag.
Example
<output name="digalm" file="digalm.dbf" filter=" ( '{variable.alarminfo1}=VJA' OR '{variable.alarminfo2}=VJA' ) AND '{variable.type}=DIGITAL'" desc="Generate digital alarm tags from input digital variable tags">
<field name="tag">{variable.name}_ALARM</field>
<field name="name">{variable.name}_ALARM</field>
<field name="var_a" key="true">{variable.name}</field>
<field name="taggenlink" load="true">{parameter.IODevice}</field>
<field name="comment">{{Testing1}}</field>
</output>
Proprietary tags used in the template are described in XML template tags. See Sample XML Templates for more comprehensive examples.
Published June 2018