Skip to main content

Element: Generalization

A Generalization is a UML relationship that expresses inheritance or specialization. The inheriting element has the attributes and operations of the root element. In IEC code, this relationship corresponds to the keyword EXTENDS.

A generalization points from the inheriting class to the root class. Therefore, the direction of the arrow indicates who inherits from whom.

. Inheritance is possible between classes, interfaces, and user-defined data types:
  • A function block can inherit from another function block.

  • An interface can inherit from another interface.

  • A DUT can inherit from another DUT.

  • Programs and functions cannot inherit and be inherited.

_uml_img_element_generalization.png

Display as arrow

Properties

Table 6.

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 Generalization _uml_icon_tool_generalization.png tool.

  2. Click the element that should inherit.

  3. Click the parent object.

A generalization is drawn between the heir and the parent element.

The IEC code is adapted synchronously by specifying the parent element in the declaration part of the inheriting class.

Example: Class_A EXTENDS Class_Base

  1. Select the Generalization _uml_icon_tool_generalization.png tool.

  2. Click the element that should inherit.

  3. Click a blank area in the diagram.

    A dialog for generating the new object opens.

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

A generalization is drawn between the heir and the parent element.

The IEC code is adapted automatically by creating the new object and specifying the parent object in the declaration part of the inheriting object. Example: Class_A EXTENDS Class_Base.

Note

This input does not work for the DUT element.

  1. Select the Choice _uml_tool_selection.png tool.

  2. Click a generalization.

  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 generalization.

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

The generalization is removed from the diagram and IEC code. The statement EXTENDS is removed from the declaration part of the inheriting class.

Example

Example 19. Function block

Fb_A inherits from Fb_Base:

_uml_img_example_generalization_function_block.png
FUNCTION_BLOCK Fb_A EXTENDS Fb_Base


Example 20. Interface

Itf_A inherits from Ift_Base:

_uml_img_example_generalization_interface.png
INTERFACE Itf_A EXTENDS Itf_Base


Example 21. DUT

Dut_A inherits from Dut_Base:

_uml_img_example_generalization_dut.png
TYPE Dut_Base :
STRUCT
    counter : INT;
END_STRUCT
END_TYPE

TYPE Dut_A EXTENDS Dut_Base :
STRUCT
    data : ARRAY[0..9] OF WORD;
END_STRUCT
END_TYPE