Skip to main content

Element: Association

An association is a UML relationship that expresses recognition. The recognizing element points to another element as a pointer.

In IEC code, this corresponds to a POINTER TO or REFERENCE TO statement (for example, ptrFb_A: POINTER TO Fb_A; or ptrFb_B: REFERENCE TO Fb_B;). That is why both Association (POINTER) and Association (REFERENCE) elements are available in the UML editor. 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:

ptrMulti_B : ARRAY[1..8] OF POINTER TO Fb_B;

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

_uml_img_assoziation.png

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

  1. Select an Association _uml_icon_tool_association.png tool.

  2. Click a class or a GVL.

  3. Click the element that should be associated.

    The Variable Declaration dialog opens.

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

An association is drawn between the elements.

The IEC code is adapted automatically by extending the declaration part of the existing element. Example: var_A : POINTER TO Fb_A

  1. Select the Association _uml_icon_tool_association.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.

An association is created that points from the class or GVL to the new class.

The IEC code is adapted automatically by extending the declaration part of the existing element. Example: varClass_1 : POINTER TO Class_1

  1. Select the Choice _uml_tool_selection.png tool.

  2. Click an association.

  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 an association.

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

The association is removed from the diagram and IEC code. The POINTER TO statement is removed from the declaration part of the element.

Examples

Example 15. Association of a class

Fb_C recognizes Fb_B and Fb_A (single and multiple).

_uml_img_example_assoziation_class.png
FUNCTION_BLOCK Fb_C
VAR
    VarFb_A : POINTER TO Fb_A;
    VarMultiFb_A: ARRAY [1..10] OF POINTER TO Fb_A; (* Kardinalität 10 *)
END_VAR


Example 16. Association of a data structure

Fb_C recognizes Dut_A.

_uml_img_example_assoziation_dut.png
FUNCTION_BLOCK Fb_C
VAR
    pDut_A: POINTER TO Dut_A;
END_VAR


Example 17. Association of a GVL

GVL recognizes POU_2.

_uml_img_example_assoziation_gvl.png
VAR_GLOBAL
    g_iCounter : INT;
    g_a : BOOL;
    pPOU_2: POINTER TO POU_2;
END_VAR