Using Structured Data Types to Group Internal Values
Structured Data Types allow you to group internal values (values that are used by the program but are not written to an item in the database). This means that when you create a data structure, you create a custom data type that contains several internal values. You can then refer to these values in your Logic program by referencing the data structure.
NOTE: You cannot use structured data types for direct variables (values that need to be written to items in the ClearSCADA database).
The main advantages of structured data types is that they allow you to group internal values and they reduce the number of variables you need to define.
When you create a data structure, you need to define the values that are to be grouped within STRUCT and END_STRUCT keywords. The STRUCT and END_STRUCT keywords have to be defined within the TYPE and END_TYPE definition.
You should list the values that you want to be grouped in the data structure within the STRUCT and END_STRUCT keywords. As with other value definitions, you need to enter the name of the value, then a colon (:), then define the type of value. Each value has to be separated by a semi-colon (;).
TYPE <data structure name>:
STRUCT
<value name>:<value type>;
<value name>:<value type>;
<value name>:<value type>;
END_STRUCT;
END_TYPE
NOTE: The TYPE, STRUCT, value definitions, END STRUCT, and END_TYPE need to be defined outside (and before) the PROGRAM block.
When you have defined the data structures, you need to add them to the VAR variables list. To do this, simply create a variable name for the value and then use the name of the data structure when you define the type of value. You need to define each data structure as a variable (unless 'nested' data structures are used—we will explain these later in this section):
VAR
<Variable name>:<data structure name>;
<Variable name>:<data structure name>;
<Variable name>:<data structure name>;
END_VAR
When you have defined the VAR variables list, you can refer to the values included in the data structures. To do this, use the following format when referencing a value in your Logic program:
<Variable name>.<value name>
As with many of the Logic structures, it is easier to understand the concepts and the formatting by referring to an example. The example in this section uses data structures to group the values that can be used for pumps in the water industry. It shows:
- How data structures can be used to group values
- How data structures need to be defined
- How data structures need to be added as variables in the VAR list