Tag Configuration Parameters

A tag template module must be configured with a set of formal parameters that correspond one-for-one to the fields of a table in the tag properties database. Each tag module begins by defining the tag's parameters within round parenthesis.

(
  Name        <:TagField("SQL_VARCHAR(255)", "Name",        0 ):> { Name of the tag   };
  Area        <:TagField("SQL_VARCHAR(255)", "Area",        1 ):> { Area of the tag   };
  Description <:TagField("SQL_PHRASEID",     "Description", 2 ):> { Description       };
  HelpKey     <:TagField("SQL_VARCHAR(255)", "Help Key",    3 ):> { HelpKey of the tag };
  Property1   <:TagField("SQL_VARCHAR(255)"):>;
  Property2   <:TagField("SQL_PHRASEID"):>;
)

It is instructive to compare this to any of the native VTScada types, which can be done by creating a new tag of any type using the Tag Browser, then examining its properties dialog. Or better, create the new type and then examine it using the Source Debugger.

You may add a new parameter to an existing tag by adding it to the end of the parameters section and assigning a matching parameter constant. Upon compiling the application and creating instances of the tag type, the new field will be added to the database.

For every parameter, a parameter constant definition must also be assigned. Note that the following code is taken from the declaration of variables, not the parameter list. These will be mentioned again in The Tag Variables Section.


   { The next block of constants defines the offset into the parameter list,
     starting from 0, for each of the parameters }
  Constant #Name        = 0;
  Constant #Area        = 1;
  Constant #Description = 2;
  Constant #HelpKey     = 3;
  Constant #Property1   = 4;
  Constant #Property2   = 5;

The first three parameters, Name, Area and Description are mandatory and must be exactly as shown in this example. "Name" must be the first parameter in the list. The others may be entered in either order, but you are advised to use the standard order of Name, Area, Description.

To define more parameters, use the example shown where each parameter is given a name, metadata defined as follows, an optional default value, and a comment describing the parameter's purpose.

Metadata examples from the Analog Status tag's parameter list:

UnscaledMax  <:TagField("SQL_DOUBLE",      "Unscaled Max", 7 ):> = 4095;
Units        <:TagField("SQL_PHRASEID",    "Units",        10):> = "PERCENTLABEL"; 

<: :> is the metadata operator. "TagField" is a structure with the following parts:

SQL data type, enclosed in quotation marks.

The data type should match a list of standard names (see list in the following topic). VTScada's Setup.INI file contains a block mapping those standard data type names to the actual data type names used by your ODBC compliant database program. This field is mandatory.

Note that the Name parameter must use the data type SQL_VARCHAR(255). Other text fields can use SQL_PHRASEID, SQL_VARCHAR(255) or SQL_LONGVARCHAR. While you might be tempted to use SQL_LONGVARCHAR for all, since all other fields can be expressions, it is helpful to type the parameter so that it gets cast appropriately, saving the need for casting in the Refresh module. For example, if the value is 0 and the type is SQL_INTEGER, then a 0 will be put into the tag parameter, whereas if the type is SQL_LONGVARCHAR, a "0" will be put into the parameter.

Values of any parameters of type SQL_BINARY will NOT be converted from the current Windows code page to UTF-8. These parameters are presumed to contain data where the bits are important rather than the characters, and any conversion would alter these.

The name of the field to be created in the database.

This is required only if the field name will differ from the parameter name. If not provided, then the field name in the database will be the same as the parameter definition. Note in the example from the Analog Status tag that the UnscaledMax parameter differs from the field name, "Unscaled Max". Field names may have spaces but parameter names cannot.

The column number of the field

Mentioned only for the sake of context when examining older examples. This parameter was required in versions of VTS prior to 8.0. Now, it defaults to the first unused index number, starting from 0. Note that the example from the Analog Status tag (which existed long before version 8.0) has this parameter, but the example created from a Context tag does not.

(Optional) Encryption flag

A Boolean that if TRUE, specifies that any value stored in this parameter should be encrypted.

(Optional) Avatar.

If the parameter resolves to an object, this names the variable where that object is stored. In practice, this is used only in I/O tags for the I/O device parameter, and then only if that type will be used to trigger alarms. For that specific case, the avatar should be set to "SitePoint".

(Optional) Moniker.

Label for the Avatar parameter, used for the graphical user interface. Typically, "IODeviceLabel" (referring to a Setup.INI label with that name), when the avatar is "SitePoint".

Default Value

You may assign a default value for any parameter by adding " = SomeValue" after the closing angle bracket. Repeating the example an Analog Status tag:

UnscaledMax <:TagField("SQL_DOUBLE",      "Unscaled Max", 7 ):> = 4095;
Units       <:TagField("SQL_PHRASEID",    "Units",        10):> = "PERCENTLABEL";

The default value may be a reference to a type of parent tag . For example, the DeviceTag parameter of an I/O tag will default to "*Driver". The Port parameter of a device driver will default to "*Port".

DeviceTag  <:TagField("SQL_VARCHAR(255)", "I/O Device Name", 3, FALSE, "SitePoint", "IODeviceLabel"):> = "*Driver";

Questionable

By default, new widgets that you create in the Idea Studio include a Tag Icon Marker. If your tag has a parameter named Questionable, and if the value of that parameter is set to TRUE, then operators will see a blinking question mark.

  Questionable <:TagField("SQL_DOUBLE", "Questionable Data"):> = 1
                      { Set to true when data is questionable          };