Skip to main content

Element: Composition

A composition is a UML relationship in which one element contains another element. In IEC code, this corresponds to the instantiation of an element: instFb_A : Fb_A. The cardinality indicates how often the relationship occurs. In IEC code, this corresponds to an ARRAY[ .. ]. When you specify a cardinality greater than 1, the system declares the following: instMultiFb_A : ARRAY[0..9] OF Fb_A;.

A composition points from a class or a global variable list to a class (type: FUNCTION_BLOCK) or a DUT.

Display of an arrow with a solid black head

_uml_img_composition.png

Properties

Table 4.

Relationship

Relationship type

Optimise route

When this option is selected, the route of the relationship arrow is optimized automatically. The fixed points are the initial point at the start element and the final point at the end element. For example, if the end element is moved, then the point where the arrow points to the end element remains the same. When this option is deselected, the route remains unchanged. As soon as a relationship element is positioned manually in the class diagram, this option is deselected.

Select this option if automatic optimization is required.

Start element

Name of the element where the relationship element starts

End element

Name of the element that the relationship element points to

Identifier

For the Association and Composition relationships only

Name of the relationship element



User input

Action

Description

  1. Select the Composition (VAR) _uml_icon_tool_composition.png tool.

  2. Click a class or a GVL.

  3. Click the element that should be a component.

    The Variable Declaration dialog opens.

  4. Specify a name and click OK to exit the dialog.

A composition is drawn between the elements.

The IEC code is adapted automatically by extending the declaration part of the existing element.

Example: VarFbA : FB_A;

  1. Select the Composition (VAR) _uml_icon_tool_composition.png tool.

  2. Select a class or a GVL.

  3. Click a blank area in the diagram.

    The Add POU dialog opens.

  4. Specify a name, configure the settings, and click Add to exit the dialog.

A composition is created that points from the class to the new class.

The IEC code is adapted automatically by extending the declaration part of the existing element.

Example: VarFb_A : Fb_A;

  1. Select the Choice _uml_tool_selection.png tool.

  2. Click a composition.

  3. Move the line.

The lines are changed. The Optimise routing property is deselected automatically.

  1. Select the Choice _uml_tool_selection.png tool.

  2. Click a composition.

  3. Press the Del key or click Delete in the context menu.

The composition is removed from the diagram and IEC code. The instantiation of the class or DUT is removed from the declaration part of the element.

Example

Example 12. Composition of a class

Fb_D contains Fb_A:

_uml_img_example_composition.png

Single composition

FUNCTION_BLOCK Fb_D
VAR
    VarFb_A : Fb_A;
END_VAR

Multiple composition

FUNCTION_BLOCK Fb_D
VAR
...
    VarMultiFb_A : ARRAY[1..10] OF Fb_A;
END_VAR


Example 13. Composition of a data object

Fb_B contains Dut_A:

_uml_img_example_composition_dut.png
FUNCTION_BLOCK Fb_B
VAR
    VarDut_A : Dut_A;
END_VAR


Example 14. Composition in GVL

GVL contains Fb_B and VarDut_A:

_uml_img_example_composition_gvl.png
VAR_GLOBAL
    g_iCounter : INT;
    g_a : BOOL;
    pPOU_2: POINTER TO POU_2;
    VarFb_B: Fb_B;
    VarDut_A: Dut_A;
END_VAR