Optional Variables and Constants

ContextType:

Of particular note is the constant, ContextType. While not required, this is extremely useful when your tag definition is used as part of a parent-child tag structure. The context type declaration informs child tags of what type this is. For example, Alarm tags will automatically connect to the first *Numeric parent, Analog Input tags look for a parent of context type *Driver.

By specifying the context type of your tag, you make it possible to link your tag to the parent-child hierarchy, automatically. If your tag does not specify its ContextType explicitly, one will be created automatically, using the name of the tag.

Child tags are told what context type to use for a parameter by providing that value in the parameter definition. For example, in the Deadband tag's parameter list, you will find the following parameter declaration:

MonitoredValue <:TagField("SQL_LONGVARCHAR" ):> = "*Numeric"; 

In the list of constants for an Analog Status, Calculation, Digital Input, or other tag, you will find:

  Constant ContextType = "*Numeric";

(GROUPS) Declarations

Tag groups are collections of tag types that share some logical relationship. One example of a tag group is the Drivers group, which lists all of the I/O drivers in the system. Any tag can be a member of many groups. For example, the analog input tag type belongs both to the Analogs group (as it has an analog value), as well as to the Numeric group (as it has a numeric value).

Groups declaration of the Analog Input tag:

[ (GROUPS)
   Shared Numeric;
   Shared Analogs;
   Shared Trenders;
]

Groups declaration of the Context tag:

[ (GROUPS)
   Shared Container       { We are a container tag             };
]

One purpose of tag groups is to allow selection filtering, for example when using the Tag Browser or Historical Data Viewer. As another example, only members of the Containers group are shown in a Site List.

(GRAPHICS) Declarations

If your tag will be represented on screen by a widget, then you must specify which widgets can be used.

   { List of draw methods for this tag type }
  [ (GRAPHICS)
    Shared DrawAlarmList;
    Shared AlarmPriorityIndicatorBox;
    Shared AlarmPriorityIndicator;
  ]

#IS_CONTAINER

Declared as a constant and only for tags that are declared as part of the Container group, this property tells VTScada that these tags should always be shown in the Tag Browser tree.

Constant #IS_CONTAINER = True { Always show these tags in tag browser tree  };

PriorityLoad

Tags that contain this constant set to a value of 1, will be started before other tag types. Do not use without a clearly identified need.

PriorityReady

If a tag module has a PriorityLoad variable, it may optionally have a variable named PriorityReady as well. If PriorityReady is used, the tag loading code will wait until its value is set TRUE (non-zero) before starting any non-priority tag types.

Use PriorityReady with caution. Failure to ensure that its value is set TRUE will cause tag-loading to stop.

BuiltInAlarm:

Include and set true if the tag browser is to inform developers that this tag includes one or more built-in alarms.

Constant BuiltInAlarm = TRUE { Flag - TRUE if this tag has a built in alarm  };

DisplayAddress

Relevant only for I/O tags, if DisplayAddress is present, the Tag Browser is able to display the tag's configured I/O address. Because new types of tags have added to VTScada over many years, there is some variation in the name used for the I/O address field. By creating a variable with the name, DisplayAddress, and ensuring that it is always holds the current value of the I/O address, from whatever parameter stores that value for your tag, you can ensure that instances of your tag type display their I/O address in the Tag Browser.

IsOperable or IsOperable()

Either a Boolean or a module returning a Boolean. If using a module (common in the case that the variable isn't a flat FALSE), your module must check whether the instance of the tag is in fact able to operate when requested to do so from the Tag Browser. For example, with an I/O tag this would require a valid Write address. A Report tag would need a valid tag set, etc.

If the tag is Operable and if the currently signed-in user has whatever privileges are required, then the Tag Browser will contain an Operate option in the tag's right-click menu. Selecting that will trigger the DoOperate plugin for the tag.

SitePoint

The SitePoint variable is required only if an Avatar property was defined in the DeviceTag parameter. If so, then in the Main state of the tag, this property must be set to the object value of the device:

SitePoint = Scope(Root, DeviceTag);

Everything else

More variables will be required for local calculations, logging, built-in alarms, and other purposes. As an example, a partial list of variables from the Analog Status tag is provided:

{ Variables }
  RawValue       { Data value read from the IO                           };
  RawTS          { UTC Timestamp from NewData                            };
  SitePoint      { Object value of DeviceTag                             };
  OldSitePoint   { Previous value of SitePoint                           };
  Style          { Object value of the StyleSettings tag                 };
  Started = 0    { Let drawing methods know that Value has been restored.};
  DisplayAddress { Address for display in the Tag Browser                };
  QualityIssue   { TRUE if there is a data quality issue                 };