A frequently required function of a user interface is the display of data arrays. CODESYS Visualization provides the element Table for this.
In the configuration of the element Table, enter an array variable in the property Data array. The array components are displayed in the rows and columns of the table.
Subsequent instructions describe an example of how an array of a structure is displayed in a table. As a preparation, create the MYSTRUCT
DUT and the declarations in the PLC_PRG
program.
TYPE MYSTRUCT :
STRUCT
iNo : INT;
bOnStock : BOOL;
strPartNumber : STRING;
END_STRUCT
END_TYPE
PROGRAM PLC_PRG
VAR
arrStruct : ARRAY[0..6] OF MYSTRUCT;
iSelectedColumn : INT;
END_VAR
Drag the Table visualization element to the visualization editor.
Assign the array variable arrStruct
to the Data array property.
⇒ The structure members are displayed as column headings and the array index as row headings.
Change the Number
).
Change the heading of column [1] to in stock
and column [2] to Part number
. Adjust the column width.
Assign a color to the
property.
Define the Row selection
.
In the PLC_PRG.iSelectedColumn
variable.
⇒ The following display results in online mode:
See also