Get Tags Displayed Using a Custom Widget
This topic is relevant only if you have created a custom-coded widget that displays tags that are not drawn as linked tag widgets, or not always drawn.
In order for VTScada to provide a Go To Page operation from the alarm page or tag browser, it must have a list of the tags on each page. This is also true if you are using the MIC thin client and need your tag to be included when toggling to the list view for a page.
VTScada will create a list of tags on a page by inspecting all linked tag widgets on that page, recursively. Any linked tag on that page, or within a widget also drawn on the page, will be included in the list. However, if a widget includes information related to a tag, but that tag is not drawn because it is outside a scroll area, or not drawn as a linked tag property, it will not be included in the list unless explicitly added using the GetDisplayedTags module.
You must write the code for this module yourself according to the format described in this topic.
- GetDisplayedTags must be added to your widget as a submodule and declared using that name.
- It takes no parameters.
- It returns an array of tags.
Example:
A widget that draws all the water supply tags in a system with next / previous buttons to scroll through multiple pages as shown following:
If the water supply tanks are drawn as Tag Widgets, the first 6 will be included, but the next 12 (on pages 2 and 3) won't be because they won't be caught when we get the recursive list of all linked tag widgets. A GetDisplayedTags module added to the widget ensures all 18 water supply tags are included in the list of tags drawn by the widget.
< {============================= GetDisplayedTags ==============================} { Used to specify an explicit list of tags displayed by this widget. This is } { necessary when there isn't enough space to draw all the tags at once. Tags } { drawn on other pages also need to be picked up for Go To Page operations. } {=============================================================================} GetDisplayedTags [ I { Counter }; Result { Return value }; ] GetDisplayedTags [ If 1; [ { Collect the results in a dictionary to account for empty parameters or duplicates } Result = Dictionary(); I = 0; WhileLoop(I < ArraySize(Tags), { Add this tag to the list } Result[Tags[I].Name] = 1; I++; ); { Return as an array of full tag names } Return(ListKeys(Result)); ] ] { End of GetDisplayedTags } >
Example 2
A parameterized widget that draws the Name, Area, Description and Value of the tags passed into up to 8 parameters named Tag1 through Tag8. The fields are drawn as GUIText elements, meaning there are no linked tag widgets in use.
The four tags displayed are not drawn using linked tag widgets therefore they will not be included in the recursive linked tag widget search. A GetDisplayedTags module is needed to ensure they are included in the list of tags for any page that draws this widget. This use case is commonly needed when tags are passed to widgets dynamically using parameters.
< {============================= GetDisplayedTags ==============================} { Used to specify an explicit list of tags displayed by this widget. This is } { necessary because the 8 selected tags aren't drawn as linked tag widgets. } {=============================================================================} GetDisplayedTags [ Result { Return value }; ] GetDisplayedTags [ If 1; [ { Collect the results in a dictionary to account for empty parameters or duplicates } Result = New(8); Result[0] = Tag1.Name; Result[1] = Tag2.Name; Result[2] = Tag3.Name; Result[3] = Tag4.Name; Result[4] = Tag5.Name; Result[5] = Tag6.Name; Result[6] = Tag7.Name; Result[7] = Tag8.Name; Return(\System.RemoveInvalids(Result)); ] ] { End of GetDisplayedTags } >