Composition

A composition is a UML relationship that expresses a "contained" property: an element contains another element. In IEC code, this corresponds to the instantiation of an element: fbSample: FB_Sample. The cardinality indicates how often the relationship exists. In IEC code this corresponds to an ARRAY [...]. If a cardinality greater than 1 is specified, the declaration is as follow: aSample: ARRAY[1..10] OF FB_Sample.

Composition 1:

A composition is represented as an arrow with a solid black diamond, pointing from a class or a global variable list to a class of type FUNCTION_BLOCK or a DUT.

Property

“Property”

Description

“Relationship”

Composition (not editable)

“Optimize route”

If the option is enabled, the route of the relationship arrow is optimized automatically. The starting point at the start element and the end point at the target element are fixed. If, for sample, the target element is moved, the point to which the arrow points on the target element is retained. If the option is disabled, the route is retained. This option is deselected when a relationship element is positioned manually in the class diagram.
Activate the option if automatic optimization is required.

“Start element”

The name of the element at which the relationship element starts is displayed.

“Target element”

The name of the element to which the relationship element points is displayed.

“Identifier”

The name of the relationship element is displayed.

Edit composition

User input in the class diagram

Response in the class diagram

Description

Select the tool "Composition":

Composition 2:

Select a class or a GVL, then click on the element to include.

A composition between the elements is drawn.

The IEC code is automatically adapted by extending the declaration section of the existing element. Example:

fbExistent: FB_Existent;

Select the tool "Composition":

Composition 3:

Select a class or a GVL, then click in an empty area of the diagram. The dialog “Add POU” opens. Enter a name, adjust the settings and close the dialog with "Add".

A composition pointing from the class or GVL to the new class is created.

The IEC code is automatically adapted by extending the declaration section of the existing element. Example:

fbNew: FB_New;

Select the tool "Pointer“.
Click on a composition and move the line with the mouse.

 

The selected (and therefore blue) composition runs at the new position. The property "Optimize routing" is automatically disabled.

Select the tool "Pointer“.
Click on a composition and use the [Del] key or click on "Delete" in the context menu.

 

The association is removed from diagram and the IEC code. The instantiation of the class or the data type is removed from the declaration section of the element.

Samples

Composition 4:

PROGRAM Test
VAR
fbSample      : FB_Sample;
END_VAR
PROGRAM Test
VAR
aSample       : ARRAY[1..10] OF FB_Sample;
END_VAR

Composition 5:

FUNCTION_BLOCK FB_Message
VAR_INPUT
stMessageStation1 : ST_Message;
END_VAR

Composition 6:

VAR_GLOBAL
    fbMessage      : FB_Message;
END_VAR