Generalization
A generalization is a UML relationship that expresses an inheritance or specialization. The inheriting element has the attributes and operations of the element from which it inherits. In IEC coding this relationship corresponds to the keyword EXTENDS.
A generalization indicated by an arrow with a solid tip, pointing from the inheriting class to the base class from which it inherits. The direction of the arrow indicates which component inherits from which.
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 or pass on.
Property
“Property” |
Description |
---|---|
“Relationship” |
Generalization (not editable) |
Edit generalization
User input in the class diagram |
Response in the class diagram |
Description |
---|---|---|
Select the tool “Generalization”: Select the object that is to inherit, then click on the parent object. |
A generalization is created, pointing from the inheriting element to the parent element. |
The IEC code is automatically adapted to indicate the parent element in the declaration section of the inheriting class. Example: FUNCTION_BLOCK FB_Sample EXTENDS FB_BaseExistent |
Select the tool “Generalization”: Select the object that is to inherit, and then click on an empty area in the diagram. |
A generalization is created, pointing from the inheriting element to the new parent element. |
The IEC code is automatically adapted by creating a new object and indicating the parent object in the declaration section of the inheriting object. Example: FUNCTION_BLOCK FB_Sample EXTENDS FB_BaseNew |
Select the tool "Pointer“. |
|
The selected (and therefore blue) generalization runs at the new position. |
Select the tool "Pointer“. |
|
The generalization is removed from the diagram and the IEC code. The EXTENDS statement is removed from the declaration section of the inheriting object |
Samples
- Function block
FUNCTION_BLOCK FB_Sub EXTENDS FB_Base
- Interface
INTERFACE I_Cylinder EXTENDS I_Base
- DUT
TYPE ST_Sub EXTENDS ST_Sample :
STRUCT
aMessages : ARRAY[1..10] OF STRING;
END_STRUCT
END_TYPE