Variable Class Definitions

The AppRoot.SRC file of each standard VTScada application defines a set of classes that tell the loader how to treat modules declared within AppRoot; this one is a page, that one is a tag.

A variable may be of a defined class if designated by the user. Variable classes are hexadecimal constants, primarily used as a means of grouping associated variables and may be defined as the user requires them. For example, each tag type is defined with a class, thereby making it possible for you to obtain a list of the tags of a certain type.

Variable classes are used by different parts of the code in different ways. In a script application, classes mean only what you define them to mean. In your custom modules of a standard application, you can create classes as needed to group variables. But use caution or avoid creating class definitions in a standard application's AppRoot.SRC file, where VTScada already assigns meaning to a number of class constants, not all of which are shown. (You are free to use the same values in your own modules.)

The class number may be added to the variable's declaration or to the declaration of a group of variables of the same class:

[
  FlowRate = 32 (0x0015);
  PNum (0x0015);
]

In this example, the first two variables have their class designated by the hexadecimal number 15 (0x0015). Because these two variables have the same class designation, they could have been grouped together as follows:

[
  Constant #PUMP = 0x0015;
  [(#PUMP) 
    FlowRate = 32;
    PNum;
  ]
]

In this example, the variable class for FlowRate and PNum is a constant called #PUMP whose value has been set at 0x0015 in a previous declaration statement. No matter which method is used, the class definition must be a constant whose value is between 0 and 65 535.

Example:

Each VTScada tag type has a class. This can be used to obtain a list of the tags of a certain type. For example:

If !Valid(MyClass); 
[
    { Get the Alarm Tag's class }
   MyClass = VariableClass(FindVariable("AlarmPriority", Code, 0, 0));
    { Find the array of variables that are members of that class }
   PriorityObjs = ListVars(ParentObject(Code), 
                           "*", MyClass, MyClass, 0, 0, 1, 0, 0);
]

If the above were to be added to any page (and the two variables declared), then in the Source Debugger you could examine that page module to find the array of PriorityObjs:

Result of the preceding code example

This example illustrates the use of class definitions. But, to achieve the same result, it would be better to use GetTagList() which is more powerful and takes into account realm/user filtering, etc