Create or Assign Tag Widgets

VTScada provides an extensive selection of widgets that you may use with your tags. You can also write a custom widget for a tag if none of the built-in methods meet your needs. If creating a custom widget, start first with the Idea Studio. Write code only if absolutely necessary.

 

To use the tag widgets provided by VTScada, declare them in the [ (GRAPHICS)] class of your tag module. Note that you must use the declared name of the widget rather than the display name, which may vary. For example, the Pie Chart widget is declared as Meter20. A complete list of the available widgets can be found in Widgets List for Programmers.

The following example is a portion of the widgets declared in the Analog Status tag. Note that the first, Draw, is a submodule of the tag rather than a shared module.

  [ (GRAPHICS)
    Draw        Module     { Standard Draw Module for this point       };
    Shared TopBar;
    Shared RightBar;
    Shared LeftBar;
    Shared BottomBar;
    Shared Number;
    Shared DrawText;
    Shared Meter1;
    Shared Meter2;
    Shared Meter3;
    Shared Meter4;
    Shared Compass1;
    Shared AnimatedBitmap;
    Shared TwoColorBar;
    Shared ColorFill;
  ]

Note for Style-Tag Aware Widgets

The Status Color Indicator widgets and Indicator Light widgets are typically used to display a tag's value using the colors defined in the Digitals tab of the associated Style Settings tag. But, for tags in the ports group, drivers group, the Modem tag and the SMS Appliance tag, these widgets take the tag's value to represent an error state, and use the colors defined in the Errors tab of the style tag.

To inform the widget that your tag's value should be interpreted as an error indicator rather than a status value, you should add the following three parameters to the tag.

ValueIsErrorStatus

Boolean. Set TRUE to treat the tag's value as an error status condition and to use the No Error and Error colors of the Style Settings tag.

ValueIsErrorAbove

Numeric. This is the value above which the tag will be treated as being in error. Defaults to 0.

ValueIsErrorBelow

Numeric. This is the value below which the tag will be treated as being in error. Defaults to 0.

To add expression support to a widget:

Often a tag widget variable X that can be a tag or a constant will be set in steady-state with PickValid(). Graphic calls then use X directly as an input. This won't work if X is extended to allow expressions, as Start() is a subroutine. Instead, introduce a new variable (for example, Xdata) and base the graphics on that. Then add new code similar to the following:

If Watch( 1, X );
[
\ExpressionManager\SafeAssign( &Xdata, ValueType(X) == 7 { Object } ? 
   X : ValueType(X) == 4 { Text } ? \ExpressionManager\Start(X, Self, Self) : X );
]

Finally, make sure that there is a PTypeToggle in the Panel module for X, and ensure that the PTypeToggle is called with the EnableExpressions argument set to 1.