Script Tags

Not counted towards your tag license limit.

Script tags monitor the value of another tag and pass that value to a module (VTScada script code). The module performs a calculation (whatever you program it to do) and sets the script tag's value to the result.

A module is a block of VTScada scripting code - a small program. You will need to have some familiarity with the VTScada scripting language to make use of a Script tag.

The module for a script tag must have two parameters, as follows:

(
   PointObj { object value of AI to monitor };
   ScriptObj { Script Object };
)

PointObj is the tag whose value is monitored and used by the Script tag. This matches the first field, "In Tag Scope" found in the Execute tab of the Script tag's configuration panel.

ScriptObj is used internally to link to your script tag. Whatever calculation is performed in your module must assign a value to ScriptObj\value. This enables the module to pass its calculated value back to your Script tag.

Example:

The following module will perform a first order filter on the value of a given Analog Status tag. A first order filter takes 90% of the old value and 10% of the new, thus dampening out sudden changes. It is designed to run the calculation every two seconds rather than on change, therefore if the status tag's value changes from one value to another and stays there, the script tag's value will eventually match the new value.

{============================ Filter Module ===================================}
{ This module is used to do a First order Filter of an input point }
{ Current Value = .1 * new value + .9 * previous value }
{ The result is stored into the script point's value variable }
{==============================================================================}
(
   PointObj { object value of Analog Status to monitor (input) };
   ScriptObj { Script tag object (output) };
)
[ { Local variable }
  PreviousValue { Previous Value };
]
Filtering [
   { ..every two seconds... }
   If AbsTime(1, 2, 0);
   [
      { Ensure there is a valid value first time through }
      PreviousValue = PickValid(PreviousValue, PointObj\Value);
      { Work out filtered value and assign that to the script tag }
      ScriptObj\Value = .1 * PointObj\Value + .9 * PreviousValue;
      { Save for next time }
      PreviousValue = ScriptObj\Value;
   ]
]
{ End of Filter Module }

This module would be stored in your application folder, perhaps as FILTER.SRC.

As with all VTScada modules, it must be declared in your application's AppRoot.SRC file. The declaration links a module file to a name (variable) that VTScada can use. The declaration must be added to the PLUGINS section of AppRoot.SRC and would look similar to the following:

[ (PLUGINS)       {===== Modules added to other base system modules =====}
   Filter module FILTER.SRC;
]

Finally, when configuring your Script tag, you would put name of the Analog Status tag to monitor in the In Tag Scope field, and the declared variable, "Filter" in the Launched Module field.

Script tag properties: Execute tab

The Execute tab of the Script tag properties folder contains the properties required to identify the tag in which the script is to be executed, and the name of the script to be used.

In Tag Scope

The In Tag Scope field enables you to specify the tag whose value will be used by your script module. Use the browser button to select the tag that will provide a value to be passed to the Launched Module

Launched Module

Provide the declared name of the module this Script tag will run. (See notes in the introduction of this topic). The name to enter here must be the variable that you declared in the application's AppRoot.SRC file, for the module that will calculate a value for this Script tag.