Association

An association is a UML relationship that expresses "knowing". The knowing element points as a pointer or reference to another element. In IEC code this corresponds to a POINTER TO instruction (pSample : POINTER TO FB_Sample) or a REFERENCE TO instruction (refSample : REFERENCE TO FB_Sample).

In the case of pointers, the cardinality specifies 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 POINTER TO FB_Sample.

Association 1:

An association is represented as an arrow pointing from a class or a global variable list to a class of type FUNCTION_BLOCK or DUT.

Property

“Property”

Description

“Relationship”

Association (cannot be edited)

“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 association

User input in the class diagram

Response in the class diagram

Description

Select the tool "Association":

Association 2:

Select a class or a GVL, then click on the object to be used for the association.

An association between the elements is drawn.

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

pExistent : POINTER TO FB_Existent;

Select the tool "Association":

Association 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".

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

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

pNew : POINTER TO FB_New;

Select the tool "Pointer".
Click on an association and move the line with the mouse.

 

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

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

 

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

Samples

Association 4:

PROGRAM Test
VAR
pSample     : POINTER TO FB_Sample;
aSample     : ARRAY[1..10] OF POINTER TO FB_Sample;
END_VAR

Association 5:

VAR_GLOBAL
pMessage     : POINTER TO ST_Message;
END_VAR