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

Properties
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 | |
---|---|---|
| A composition is drawn between the elements. The IEC code is adapted automatically by extending the declaration part of the existing element. Example: | |
| 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: | |
| The lines are changed. The Optimise routing property is deselected automatically. | |
| 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
Fb_D
contains Fb_A
:

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
Fb_B
contains Dut_A
:

FUNCTION_BLOCK Fb_B VAR VarDut_A : Dut_A; END_VAR
GVL
contains Fb_B
and VarDut_A
:

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