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.
The ID tab of every tag includes the same common elements: Name, Area, Description, and Help ID.
Name:
Uniquely identifies each tag in the application. If the tag is a child of another, the parent names will be displayed in a separate area before the name field.
You may right-click on the tag's name to add or remove a conditional start expression.
Area
The area field is used to group similar tags together. By defining an area, you make it possible to:
- Filter for particular tag groups when searching in the tag browser
- Link dial-out alarm rosters to Alarm tags having a particular area
- Limit the number of tags loaded upon startup.
- Filter the alarm display to show only certain areas.
- Filter tag selection by area when building reports
When working with Parent-Child tag structures, the area property of all child tags will automatically match the configured area of a parent. Naturally, you can change any tag's area as required. In the case of a child tag, the field background will turn yellow to indicate that you have applied an override. (Orange in the case of user-defined types. Refer to Configuration Field Colors)
To use the area field effectively, you might consider setting the same Area for each I/O driver and its related I/O tags to group all the tags representing the equipment processes installed at each I/O device. You might also consider naming the Area property for the physical location of the tag (i.e. a station or name of a landmark near the location of the I/O device). For serial port or Roster tags, you might configure the Area property according to the purpose of each tag, such as System or Communications.
You may define as many areas as you wish and you may leave the area blank for some tags (note that for Modem tags that are to be used with the Alarm Notification System, it is actually required that the area field be left blank).
To define a new area, type the name in the field. It will immediately be added. To use an existing area, use the drop-down list feature. Re-typing an existing area name is not recommended since a typo or misspelling will result in a second area being created.
There is no tool to remove an area name from VTScada since such a tool is unnecessary. An area definition will exist as long as any tag uses it and will stop existing when no tag uses it (following the next re-start).
Description
Tag names tend to be brief. The description field provides a way to give each tag a human-friendly note describing its purpose. While not mandatory, the description is highly recommended.
Tag descriptions are displayed in the tag browser, in the list of tags to be selected for a report and also on-screen when the operator holds the pointer over the tag’s widget. For installations that use the Alarm Notification System, the description will be spoken when identifying the tag that caused the alarm.
The description field will store up to 65,500 characters, but this will exceed the practical limits of what can be displayed on-screen.
This note is relevant only to those with a multilingual user interface:
When editing any textual parameter (description, area, engineering units...) always work in the phrase editor. Any changes made directly to the textual parameter will result in a new phrase being created rather than the existing phrase being changed.
In a unilingual application this makes no difference, but in a multilingual application it is regarded as poor practice.
Help Search Key
Used only by those who have created their own CHM-format context sensitive help files to accompany their application.
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.
Script tags monitor the value of another tag and allow the execution of a script when the monitored tag's value changes. The widgets associated with Script tags enable you to display the value of the completed script.
The following widgets are available to Script tags: