Configuring and Multiplying Visualization Elements as Templates

A table for displaying data arrays can also be created in the following way. You duplicate a single element having at least one property that is described by a structured variable. The single element is configured as a “template” for this and duplicated with a command

You can use the Visualization ‣ Multiply Visu Element command to display array data. The command multiplies a template element to create an element of the same type for each array component. The layout of the new elements in the visualization is one-dimensional as a row or column, or two-dimensional as a table.

To do this, drag an applicable element into the visualization editor. Then configure the properties of the element with array variables and specify the index access placeholder $FIRSTDIM$ as component access. If you have declared a multidimensional array, then you can use the second index access placeholder $SECONDDDIM$ for the additional dimension. Configure the remaining properties as usual with the typical values. The purpose is to create a valid template element. Then execute the Multiply Visu Element command on the template element. Now the dialog with the same name opens. There you define in detail how many elements should be created and where they should be located.

After multiplying, the visualization contains as many of the same elements as are indexed using placeholders. In doing so, the settings in the Multiply Visu Element dialog are taken into consideration. All new elements in the properties that were preset with placeholders have these replaced with precise indexes. The remaining properties have been applied and copied without changes.

For example, you can have a layout of nine buttons as 3x3 tables, which are all the same size or the same color, but vary in the labeling. The labels are declared as a string array (nine components) and are passed as a value to the Texts->Text property.

Note

You can still use the placeholder % as usual for the text display of variable values in the properties in Texts.

Applicable visualization elements

Visualization elements that can be multiplied:

  • Rectangle
  • Rounded Rectangle
  • Ellipse
  • Line
  • Polygon
  • Polyline
  • Bézier Curve
  • Image
  • Frame
  • Button
  • Pie
  • Spin Box
  • Text Field
  • Check Box
  • Image Switcher
  • Lamp
  • Dip Switch
  • Power Switch
  • Push Switch
  • Push Switch LED
  • Rocker Switch
  • Rotary Switch

Configuring and multiplying lamps and buttons as templates

  1. Create a new standard project.

    ⇒ A CODESYS Control Win V3 is configured as the device. The MainTask calls PLC_PRG. The implementation language is ST.

  2. In PLC_PRG in the program code, declare array variables with basic data type STRING.

    PROGRAM PLC_PRG
    VAR
     axLampIsOn: ARRAY[1..2,1..3] OF BOOL;  // For lamp, property 'variable' and button, user input
     asButtonText: ARRAY[1..2,1..3] OF STRING := // Output text for button, property 'text variables''text variable'
     [
             '1A Lamp', '2A Lamp',
             '1B Lamp', '2B Lamp',
             '1C Lamp', '2C Lamp'
     ];
    END_VAR
    
  3. Select the application in the device tree and click Add Object ‣ Visualization .

  4. In the Add Visualization dialog, specify the name VisuMain and click Add to close the dialog.

  5. Drag a Lamp element from the Toolbox view to the visualization.

  6. Configure the fixed property values.

  7. Double-click the value field of the Variable property.

    ⇒ The line editor opens.

  8. Click .

    ⇒ The Input Assistant opens.

  9. Select the array variable PLC_PRG.axLampIsOn from the variable tree.

  10. Extend the string at the end, for example with “[f”.

    ⇒ If you have activated SmartCoding (Options dialog, SmartCoding category, List components immediately when typing option), then the current variable list appears with the placeholders:

  11. Select the placeholder $FIRSTDIM$ for the first dimension and confirm the selection.

  12. Extend the string at the end, for example with “,s”.

    ⇒ The variable list appears again.

  13. Select the placeholder $SECONDDIM$ for the second dimension and confirm the selection.

  14. Complete the string with a closing bracket.

    PLC_PRG.axLampIsOn[$FIRSTDIM$, $SECONDDIM$]

    The lamp is configured as a template.

  15. Click Visualization ‣ Multiply Visu Element .

    ⇒ The Multiply Visu Element dialog opens. The default values are derived from the array declarations.

    Total number of elements, Horizontal = 2

    Total number of elements, Vertical = 3

  16. Declare the distance between the new elements.

    Offset between elements, Horizontal = 3

    Offset between elements, Vertical = 3

  17. Check the advanced settings.

  18. Click OK to confirm the selection.

    ⇒ The new elements appear in the visualization editor. All properties are configured with a precise index and the array variables are indexed.

  19. In the Visualization Toolbox, in the Common Controls category, select and drag the Button element to the visualization editor.

    ⇒ The Properties view of the element opens.

  20. Configure the fixed property values.

  21. Configure the value for the Text variables->Text variable property.

    PLC_PRG.asButtonText[$FIRSTDIM$, $SECONDDIM$]

  22. Configure the value for the Input configuration->Toggle->Variable property.

    PLC_PRG.axLampIsOn[$FIRSTDIM$, $SECONDDIM$]

    The button is configured as a template.

  23. Click Visualization ‣ Multiply Visu Element .

    ⇒ The Multiply visu element dialog opens. The default values are derived from the array declarations.

    Total number of elements, Horizontal = 2

    Total number of elements, Vertical = 3

  24. Declare the distance between the new elements.

    Offset between elements, Horizontal = 3

    Offset between elements, Vertical = 3

  25. Check the advanced settings.

  26. Click OK to confirm the selection.

    ⇒ The new elements appear in the visualization editor. All properties are configured with a precise index and the array variables are indexed.

  27. Build, start, and download the application.

    ⇒ Visualization at runtime:

Array variable with more than two dimensions

You can also configure the template element with array variables that have more than two dimensions, but you can only assign placeholders to a maximum of two of the dimensions. In the additional dimensions, the indexes are fixed.

Example

Declaration

PROGRAM PLC_PRG
VAR
 asText: ARRAY[1..2, 1..3, 1..6, 1..2] OF STRING;
END_VAR

Configure the Text variables, Tooltip variable property for the template element:

PLC_PRG.asText[2, $FIRSTDIM$, $SECONDDIM$, 2]

Layout of a one-dimensional array in a table

You can configure the template element with a one-dimensional array by means of the index access placeholder $FIRSTDIM$. If the number of new elements to be created is greater than five, then a tabular layout is preset in the Multiply Visu Element dialog. The layout of the new elements is as quadratic as possible.

Example

PROGRAM PLC_PRG
VAR
 asText: ARRAY[1..100] OF STRING;
END_VAR

The default setting in the Multiply Visu Element dialog allows for a layout of 100 new elements in a 10x10 field.

See also