Add dynamic graphical objectsΒΆ

Purpose of this module

In this module, we will set some typical HMI application graphical objects. We will also see how to set the value of a property based on the value of another property. In UNIQO this feature is called dynamic link.

In particular:

  • We will connect an LED to a switch to set its on/off status.

  • We will connect the same LED to a spin-box, through a converter, to set its color.

This is the final result:

../_images/e4c3dbaa4dfdeb55575d8bdaa3f3b14284be341f.gif
  1. Add graphical objects

    We will add the objects in the first navigable panel, i.e. Page1 (type):

    1. Double-click Page1 (type): the panel opens in the editor.

    2. To add the LED, in Project right-click Page1 (type), then select New> Basic controls > LED LED: LED1 appears in Page1 (type) and in the objects editor.

    3. To add the switch, in Project right-click Page1 (type), then select New > Basic controls > Switch Switch: Switch1 appears in Page1 (type) and in the objects editor.

    4. To add the spin box, in Project right-click Page1 (type), then select New > Basic controls > Spin box Spin box: SpinBox1 appears in Page1 (type) and in the objects editor.

    5. In the editor, drag the three objects to the desired position. Below is an example:

      ../_images/f986a346ab5f06ac9643a7738d8d9b80bd1f2ddd.png
  2. Associate the LED status with the switch status

    To turn the LED on/off with a switch, we will insert a dynamic link between the activation states of the two objects:

    1. In the LED1 properties, click image1 next to the Active property: the dynamic links window opens which displays all the project elements and their properties.

    2. In the window, inside Switch1 select the Active variable and press Select: the value of the Active property of LED1 is the path to the switch property.

      ../_images/0d28a2ce69d624f567a0ad866d91bca8e346d17d.png

    In this way, the LED status depends on the switch status. In this case, the two linked properties contain a value of the same type (Boolean). For this, a simple dynamic link is sufficient.

    Find out more about dynamic links: Dynamic Links.

  3. Associate the LED color with the spin-box value

    In this phase, the link is between two properties that contain values of different types: number and color. For this, a converter has to be used, which transforms the input data into another type of data. Here we will use a Key-Value converter to transform the spin-box numerical data into data of color type for the LED.

    1. Select the LED and click image2 next to its Color property, then click Advanced: the editor of the dynamic link for the Color property opens.

      ../_images/8caf5dee79249542c2923d7d7c2b7fc022b311b6.png
    2. To add the converter, click image3 > Key-Value converter: the block of the Key-value converter appears. DynamicLink Source indicates the input variable to the converter, which transforms it to supply its value to the Color property.

      ../_images/4b03609801aee85c55ceaa3ad845d678302abaf6.png
    3. To set the converter input, in our case the spin-box value, in DynamicLink Source click image4, then in Spinbox1 select Value, then click Select.

      ../_images/27fd3aacab7ac1c2de3677ce19606bb80c7accd3.png
    4. To set the conversions to perform, in KeyValueConverter1 click image5: the conversion table appears in the object editor.
      ../_images/b291fb73e679a4deedef4d494e0d019403e0af27.png

      Each row defines a key/value pair: in this case Key is the spin-box value, Value is the LED color.

    5. For the conversion, the correct data types must be set for Key and Value visible in the header; in particular Value must be of color type. To do it, in the Value column click String: a list with the most common data types appears.

      ../_images/e37c8020bd671af3a7c71de6d82f9076d0891d1e.png
    6. To display all the available data types, select Show All, then choose Color and click Select.

      ../_images/5d85f73ca458e1f9e6d94ac552f17237c95332f1.png
    7. To change the color associated with the existing 0 key, click Pick in the related cell, select the color and click Select.

    8. To set other key/value pairs, click image6 and change the values. Below is an example:

      ../_images/d294802db4f6f97f1945ee9c45959500a243d4b5.png

    Find out more about the Key-Value converter: Key-Value converter.

To remember

  • When two variables of the same type are linked, a dynamic link is created.

  • When two variables of a different type are linked, it is necessary to set up one or more converters: then an advanced dynamic link is created.

image7 Add navigation pages

Import and display PLC variables image8