6 UML Class Diagram.................................................................................................................................16
7 UML state diagram...................................................................................................................................49
This description is only intended for the use of trained specialists in control and automation engineering who
are familiar with applicable national standards.
It is essential that the documentation and the following notes and explanations are followed when installing
and commissioning the components.
It is the duty of the technical personnel to use the documentation published at the respective time of each
installation and commissioning.
The responsible staff must ensure that the application or use of the products described satisfy all the
requirements for safety, including all the relevant laws, regulations, guidelines and standards.
Disclaimer
The documentation has been prepared with care. The products described are, however, constantly under
development.
We reserve the right to revise and change the documentation at any time and without prior announcement.
No claims for the modification of products that have already been supplied may be made on the basis of the
data, diagrams and descriptions in this documentation.
Trademarks
Beckhoff®, TwinCAT®, EtherCAT®, EtherCAT G®, EtherCAT G10®, EtherCAT P®, Safety over EtherCAT®,
TwinSAFE®, XFC®, XTS® and XPlanar® are registered trademarks of and licensed by Beckhoff Automation
GmbH.
Other designations used in this publication may be trademarks whose use by third parties for their own
purposes could violate the rights of the owners.
Patent Pending
The EtherCAT Technology is covered, including but not limited to the following patent applications and
patents:
EP1590927, EP1789857, EP1456722, EP2137893, DE102015105702
with corresponding applications or registrations in various other countries.
EtherCAT® is a registered trademark and patented technology, licensed by Beckhoff Automation GmbH,
Germany
Please note the following safety instructions and explanations!
Product-specific safety instructions can be found on following pages or in the areas mounting, wiring,
commissioning etc.
Exclusion of liability
All the components are supplied in particular hardware and software configurations appropriate for the
application. Modifications to hardware or software configurations other than those described in the
documentation are not permitted, and nullify the liability of Beckhoff Automation GmbH & Co. KG.
Personnel qualification
This description is only intended for trained specialists in control, automation and drive engineering who are
familiar with the applicable national standards.
Description of symbols
In this documentation the following symbols are used with an accompanying safety instruction or note. The
safety instructions must be read carefully and followed without fail!
DANGER
Serious risk of injury!
Failure to follow the safety instructions associated with this symbol directly endangers the life and health of
persons.
WARNING
Risk of injury!
Failure to follow the safety instructions associated with this symbol endangers the life and health of persons.
CAUTION
Personal injuries!
Failure to follow the safety instructions associated with this symbol can lead to injuries to persons.
NOTE
Damage to the environment or devices
Failure to follow the instructions associated with this symbol can lead to damage to the environment or
equipment.
Tip or pointer
This symbol indicates information that contributes to better understanding.
TF19106Version: 2.3
Overview
2Overview
UML: general information
Unified Modeling Language (UML) is a graphical language that can be used for software analysis, design
and documentation. UML is particularly suitable for object-oriented implementations. The unified modelling of
the PLC application creates an easy-to-follow software documentation that can also be analyzed and
discussed by departments other than the Software Development Dept.
Diagram categories
Some of the UML diagrams can be categorized as structure diagrams, others as behavior diagrams.
Structure diagram are mainly used for static modelling and analysis, since they represent the software
architecture schematically. Behavior diagrams are used for dynamic modelling. They are executable models,
from which program code can be generated directly.
UML in TwinCAT 3.1 PLC
With the integration of UML (Unified Modelling Language) in TwinCAT 3.1, two additional editors for
modelling of PLC software are available. The existing TwinCAT PLC programming languages are extended
by the UML classes and the UML Statechart.
•: the functionality of the object UML class diagram
•: Programming a POU in the implementation language UML Statechart
UML class diagram
The UML class diagram belongs to the group of UML structure diagrams and can be used for schematic
representation of the software architecture. In this way it is possible to represent object classes and the
elements contained within them, as well as object relationships in a transparent manner.
UML Statechart
The UML Statechart is part of the UML behavior diagrams and is used for dynamic software modeling. It can
be used for a graphic specification of the dynamic response or the state-dependent system behavior.
Compilation of the statechart generates program code, so that the state machine can be executed directly.
The development process is supported by an online debugging option.
Advantages
There are many advantages to using UML diagrams for the analysis, design and/or documentation of
software. The essential aspects are covered in the following points:
• First of all, a graphic illustration that doesn't focus on technical details offers a good overview with
which to check software requirements before the implementation. This avoids an incomplete or
erroneous implementation of the application.
• The development of a well-conceived software architecture is greatly supported by the graphic
illustration of the control code. Such an architecture forms the basis for the simple and goal-oriented
implementation of even complex systems or requirements. Furthermore, a well-conceived software
architecture can contribute towards the development of autonomous modules that can be reused,
saving time and costs. In general, a well-planned software leads as a rule to fewer programming errors
and thus to a higher code quality.
• Graphic access to the software facilitates maintenance and debugging.
• An generally understandable documentation of the software is usually created with the help of UML
diagrams. On the one hand this can be used as a coordination tool in the development team, for
example to exchange ideas and concepts or to define requirements. On the other, UML diagrams can
be used to illustrate the control application to other technology specialists, for example mechanical
engineers or process technicians.
TF19107Version: 2.3
Installation
3Installation
3.1System requirements
UML class diagram:
Development environment
TwinCAT v3.1.4018.16
UML statechart:
Development environmentTarget platformLibrary placeholder to include
TwinCAT v3.1.4016.0PC or CX (x86, x64, ARM)UML statechart types
3.2Installation
Engineering:
The engineering components of the function "TF1910 | TC3 UML" are contained in the TC3.1 XAE setup
(both UML classes and UML Statechart).
You can use these directly after installing the XAE. No license is required for this.
Runtime:
If the UML Statechart is used, the required runtime components are installed with the TC3.1 XAE or XAR
setup.
You will require the TF1910 runtime license for the additional runtime component UML Statechart. For
further information please refer to the documentation on Licensing.
You can test the UML Statechart with a 7-day test license without the license for TF1910. You can
continuously regenerate the trial license during the test phase. Refer here also to the documentation for the
TwinCAT-3 test licenses.
TF19108Version: 2.3
Settings
4Settings
4.1Options
In the TwinCAT UML options (Tools > Options >TwinCAT > PLC Environment > UML) you can configure
the settings relating to the UML editors for the entire project. Modified options take effect when the dialog is
closed, even in UML editors that are already open.
General
• Gridspace: enter a whole number that will be used as the gridspace in pixels. Default: 10
• Snap To Grid: activate this option in order to align all the elements in the UML editors to the grid.
• Display grid points: activate this option in order to display the grid points in the UML editors.
State chart
• Position Condition and Action of a relation together: activate this option in order to synchronously
shift a watchdog condition and an action that belong to the same transition in the statechart.
Class diagram
• Show prompt when deleting objects from diagram: objects can be deleted either only from the
diagram or from the diagram and from the project. There are two possible procedures for this:
◦ If an object is marked in the class diagram, two command symbols appear above the object in
order to delete the object from the diagram only or from both the diagram and the project.
◦ Alternatively a marked object can be deleted by pressing the [Del] key. If the option to display a
selection window is deactivated, the object is deleted by default only from the diagram. If the
setting is activated, a selection window appears when deleting with which you can configure
whether the object should be deleted only from the diagram or also from the project.
TF19109Version: 2.3
Settings
4.2UML compiler version
The UML compiler version can be changed in the following dialogs:
• PLC project properties
• ProfileUpdate dialog
In addition, the following option is available with regard to the UML compiler version:
• Autoupdate UML Profile
The UML compiler version is only relevant if the UML Statechart language is used.
Scope of the setting “UML compiler version”
The setting of the UML compiler version is a “solution option” and therefore does not only affect the
PLC project, whose properties you are currently configuring, i.e. set UML compiler version applies
to all PLC projects in the development environment.
PLC project properties
You can change the UML compiler version in the properties of the PLC project.
Open the PLC project properties and click on the category UML.
TF191010Version: 2.3
Settings
• UML compiler version in project: Indicates the UML compiler version currently used in the project.
• Recommended, newest version: Indicates the latest available UML compiler version, whose
application is recommended.
• Action: In this dropdown menu you can select the required action. The action is executed directly
when you select it. Example actions:
◦ Do not update.
◦ Update to 4.0.2.1
ProfileUpdate dialog
If you open a PLC project, in which an outdated UML compiler version is used, a corresponding warning
appears in the message window (“New version found for UML”). Double-click this warning to open the
ProfileUpdate dialog, in which you can change the UML compiler version.
• UML compiler version in project: Indicates the UML compiler version currently used in the project.
• Recommended, newest version: Indicates the latest available UML compiler version, whose
application is recommended.
• Action: In this dropdown menu you can select the required action. The action is executed when the
dialog is confirmed via OK. Example actions:
◦ Do not update.
◦ Update to 4.0.2.1
• Set all to newest: Click the button to set the UML compiler version to the latest version.
TF191011Version: 2.3
Settings
Autoupdate UML Profile
The option Autoupdate UML Profile is available in the Advanced category of the PLC project properties. It
can be used to configure the automatic update behavior of the UML compiler version.
If you open a PLC project, in which an outdated UML compiler version is used, a corresponding warning
appears in the message window (“New version found for UML”).
: In such a case, the UML compiler version is automatically set to the latest version, if the option
Autoupdate UML profile is enabled. On such an automatic update of the UML compiler version, the
message window shows a corresponding warning (e.g. “UML set from '4.0.2.0' to '4.0.2.1'”).
: If the option Autoupdate UML Profile is disabled, the UML compiler version is not changed
automatically. Double-click on the warning “New version found for UML” to open the ProfileUpdate dialog[}11], in which you can change the UML compiler version manually.
TF191012Version: 2.3
Commands
5Commands
Common commands for all UML diagrams
If a UML diagram is selected in the project tree, the following command is available in the context menu:
• Generate bitmap from the selected UML diagram [}13]
The alignment of the elements relative to a grid can be enabled or disabled within the editor of a UML
diagram.
• Grid activated [}14]
• Grid deactivated [}15]
5.1Generate bitmap
The command Generate bitmap is available if
• the focus is on the project tree, and
• a class diagram or statechart is selected in the project tree and the context menu is open
Use the command in order to generate a diagram in BMP format from a class diagram or statechart and save
it in your file system.
Executing the command Generate bitmap opens the corresponding dialog. This dialog offers the following
configuration options.
Size of the longer side (in pixels):
• The value that is displayed refers to the edge length of the bitmap. Depending on the layout of UML
diagram, the bitmap is exported in landscape or portrait format. If the diagram is in landscape format,
the value represents the length of the bitmap. If the diagram is in portrait format, the value represents
the height of the bitmap.
Save bitmap to desktop:
•: If this option is enabled, the object name is used as the file name, e.g. "FB_UML_SC.bmp" for an
object with the name "FB_UML_SC"
◦ Confirm the setting with [ OK ] to save the diagram to the desktop.
NoteThis option overwrites any existing files on the desktop with this name without
warning.
◦ Use [ Cancel ] to terminate the dialog without saving.
•: The name and the directory of the bitmap are editable
◦ Confirming the setting with [ OK ] opens the standard dialog for saving a file. Enter a directory and
file name and confirm the dialog with [ Save ]. The diagram is saved in your file system.
TF191013Version: 2.3
Commands
Access by Automation Interface:
The command Generate bitmap is accessible on the POU node by Automation Interface using
ConsumeXML method.
If this command is available in the context menu of a focused class diagram or statechart, an element is
aligned along the grid when changing its position. The option Snap to grid with grid space in the TwinCAT
UML options (Extras > Options > PLC Environment > UML) is ticked.
If you perform the command, the diagram will switch to Grid disabled. The option won't be ticked.
See also:
• “Grid Disabled” [}15]
TF191014Version: 2.3
Commands
• “Options [}9]”
5.3Grid Disabled
Symbol:
If this command is available in the context menu of a focused class diagram or statechart, an element is
positioned without a grid when changing its position. Snap to grid with grid space in the TwinCAT UML
options (Extras > Options > PLC Environment > UML) is not ticked.
If you perform the command, the diagram will switch to Grid enabled. The option will be ticked.
See also:
• “Grid Enabled” [}14]
• “Options [}9]”
TF191015Version: 2.3
UML Class Diagram
6UML Class Diagram
In addition to the following information, please also note the samples [}87] that give a first introduction to
the tool.
6.1Basic principles
The UML class diagram can be used to document, analyze, design and expand the structure of a (complex)
system. In the process, classes can be designed and relationships between them can be mapped. The clear
illustration of PLC program elements includes a.o. inheritance and implementation relationships, so as to
clearly visualize interrelationships. A UML class diagram is therefore ideal for graphical system
documentation and offers a comprehensible basis for conveying technical content.
The class diagram editor provides elements that map the object orientation of the project. Since the editor is
embedded in the PLC area of the TwinCAT 3 development environment, automatic generation of code is
possible. An extensive range of features and tools is integrated.
The class diagram can be used in two directions. The existing project structure can be imported into the
class diagram, or selected elements of the existing project structure can be added to the class diagram. As a
result, the already existing software architecture can be documented and analyzed. Secondly, the class
diagram offers the possibility to change and expand existing PLC elements or the existing project structure.
This modification can be carried out with the aid of the class diagram editor [}23] and the associated
elements [}23] of the toolbox. These allow the software architecture to be changed and expanded and at
the same time to be documented and analyzed.
Terms from the object orientationSynonym in IEC 61131-3
Class (UML: class)POU types:
• Program (PRG): PROGRAM
• Function block (FB): FUNCTION_BLOCK
• Function (FUN): FUNCTION
Attribute (UML: attribute)
• Internal variable
• Parameter: {input}
• Property: {property}
• Output Parameters: {output}
Operation (UML: operation)• Method: METHOD
Interface (UML: interface)Interface: INTERFACE
Synchronicity
Objects in the class diagram and the project are kept in sync, so that user inputs affect both views. This
means the corresponding objects in the project tree are changed automatically when objects are changed
via the class diagram. On the other hand, modifications in the project tree automatically become visible in the
class diagram, if the corresponding objects are shown in the class diagram.
Variable types:
• Variables: VAR
• Input variables: VAR_INPUT
• Property: PROPERTY
• Output variables: VAR_OUTPUT
• Action
Global variable list (GVL): VAR_GLOBAL
User-defined data type (DUT): TYPE
Application options
In general, the following applies:
• Not all elements of a project have to be shown in the class diagram.
• Several class diagrams can be added to a project.
TF191016Version: 2.3
UML Class Diagram
In the interest of clarity it is generally preferable to show only a few objects in a class diagram. In this way it
is possible to create subject-related or project section-related class diagrams, as sample. The objects shown
can have particular dependencies, so that the objects and their dependencies are clearly displayed. On the
other hand, objects without explicit dependencies to one another can also be shown in a diagram, so that
they can be compared in parallel.
Based on this, the class diagram can be used for various purposes:
• As design and development tool
• As analysis tool for existing projects
• As project navigator
Information on which commands or actions can be used for the individual purposes is provided below.
As design and development tool
• Create a new, empty class diagram [}17].
• The class diagram can be edited [}20] by means of various action options.
→ All inputs also affect the objects in the project and are immediately visible in the project tree.
As analysis tool for existing projects
• Add existing elements to the class diagram [}18].
• Analyze the existing project structure with the aid of the class diagram you created and edit thediagram [}20] if required.
→ All inputs also affect the objects in the project and are immediately visible in the project tree.
As project navigator
• Open a class diagram and double-click on an element in the class diagram to open the corresponding
editor.
• The declaration and implementation can be edited as usual, if required.
→ Any changes of the declaration are automatically updated in the class diagram.
Commands
The following commands or action options are available for the class diagram:
• Creating a new class diagram [}17]
• Adding existing elements to a diagram [}18]
• Editing a class diagram [}20]
Also note the commands, which are available for all UML diagrams: Common commands for all UML
diagrams [}13]
6.2Commands
6.2.1Creating a new class diagram
If you create a class diagram, you can optionally import the existing project structure. If this option is used, all
relevant objects are imported into the class diagram. Relevant objects are programs, function blocks,
functions, interfaces, DUTs, GVLs and their respective components (methods, properties, variables etc.).
1. In the context menu of the project tree select the command Add object, then select the Class diagram
object.
2. In the Add UML class diagram dialog that opens enter a name for the class diagram.
3. Enable the option Import project structure into class diagram to import the existing project structure
into the new class diagram.
Disable the option to generate an empty class diagram.
TF191017Version: 2.3
UML Class Diagram
4. Import options (only relevant for importing the project structure):
Enable the option Collapse elements to display the element details (attribute or operation list) in
minimized form.
Disable the option to display the element details in expanded form.
5. Confirm the inputs and configurations with the Open button.
ð The new class diagram object is added in the project tree, and the editor for the new diagram opens.
6.2.2Adding existing elements to a diagram
Existing project elements can be added to a class diagram in a number of ways. On the one hand, several
elements can be added simultaneously by importing the whole project structure or a selected folder via a
command. On the other hand, an individual element can be added by dragging & dropping it onto the class
diagram editor.
Depending on the number of elements, the following action options are available.
• Adding several existing elements:
◦ Import whole project structure when a new diagram is created
◦ Import whole project structure into an empty diagram
◦ Import whole folder structure into an empty diagram
• Adding an individual existing element:
◦ Visualize existing element from the project tree on the diagram
◦ Visualize existing element from the cross-references on the diagram
TF191018Version: 2.3
UML Class Diagram
Import whole project structure when a new diagram is created
1. Create a new class diagram [}17] and activate the option Import project structure into class diagram.
ð The new class diagram object is added to the project tree. The class diagram editor opens and shows
the class diagram for the existing project.
Import whole project structure into an empty diagram
1. Open an empty class diagram, which sits directly at the top project level in the project tree, not in a
project folder.
2. Execute the command Import project structure to active class diagram, which is available in the
context menu of the class diagram editor.
ð The class diagram shows the existing structure of the whole project.
Import whole folder structure into an empty diagram
1. Open an empty class diagram from the folder whose structure you want to import into the class diagram.
2. Execute the command Import project structure to active class diagram, which is available in the
context menu of the class diagram editor.
ð The class diagram shows the existing structure of the folder containing the class diagram.
Visualize existing element from the project tree on the diagram
1. Select an element of type POU, INTERFACE, GVL or DUT in the project tree and drag & drop it onto the
opened class diagram. Drop it in a suitable location to visualize it there.
ð The corresponding element is shown in the diagram. If relationships with already shown elements exist,
these are displayed automatically.
TF191019Version: 2.3
UML Class Diagram
Visualize existing element from the cross-references on the diagram
The class element, which has a relationship with the selected element but is not included in the class
diagram, is shown in the Toolbox window under the heading Incoming cross-references or Outgoingcross-references. First, the relationship type that links the two elements is shown as a symbol. This is
followed by the name of the target or source element. You can drag & drop the element onto the diagram, so
that the element is shown in the class diagram.
Showing cross-references
1. Open the Toolbox window via the View menu.
2. Select a rectangle element in the opened class diagram, which has relationships that are not shown in
the class diagram.
ð Under Toolbox the relationships with the elements are listed, which are not yet shown in the class
diagram. Under Incoming cross-references missing incoming relationships with source elements are
listed. Under Outgoing cross-references missing outgoing relationships are listed, together with target
elements.
Visualize existing element from the cross-references on the diagram
1. Drag & drop the element, which is listed under Incoming cross-references or Outgoing crossreferences and which is to be shown in the diagram, onto the class diagram. Drop it in a suitable
location to visualize it there.
ð The corresponding element is shown in the diagram. The relationships with the already shown elements
are displayed automatically.
6.2.3Editing a class diagram
The actions available for editing a class diagram include the following. Further editing options can be found
under Editor [}23].
Adding a new element
1. Open the Tools window via the View menu.
2. Select an element [}23] in the Tools view and drag & drop it onto the opened class diagram. Drop it in
a suitable location to visualize it there.
ð The new element is created in the project tree and shown in the diagram.
Deselect “Toolbox” view
ü An element is selected in the Toolbox window. In the editor the cursor has the form of the selected ele-
ment.
1. Press the right mouse button.
ð The element is deselected, and the standard Pointer element is selected.
Editing identifiers
1. Open the line editor of an identifier with two single clicks.
TF191020Version: 2.3
UML Class Diagram
2. Enter a new name and confirm it via the [Enter] key or by clicking in an empty area of the diagram.
ð The identifier has the new name.
Visualize existing element from the project tree on the diagram
1. Select an element of type POU, INTERFACE, GVL or DUT in the project tree and drag & drop it onto the
opened class diagram. Drop it in a suitable location to visualize it there.
ð The corresponding element is shown in the diagram. If relationships with already shown elements exist,
these are displayed automatically.
Cross-references
The class element, which has a relationship with the selected element but is not included in the class
diagram, is shown in the Toolbox window under the heading Incoming cross-references or Outgoingcross-references. First, the relationship type that links the two elements is shown as a symbol. This is
followed by the name of the target or source element. You can drag & drop the element onto the diagram, so
that the element is shown in the class diagram.
Showing cross-references
1. Open the Toolbox window via the View menu.
2. Select a rectangle element in the opened class diagram, which has relationships that are not shown in
the class diagram.
ð Under Toolbox the relationships with the elements are listed, which are not yet shown in the class
diagram. Under Incoming cross-references missing incoming relationships with source elements are
listed. Under Outgoing cross-references missing outgoing relationships are listed, together with target
elements.
Visualize existing element from the cross-references on the diagram
1. Drag & drop the element, which is listed under Incoming cross-references or Outgoing crossreferences and which is to be shown in the diagram, onto the class diagram. Drop it in a suitable
location to visualize it there.
ð The corresponding element is shown in the diagram. The relationships with the already shown elements
are displayed automatically.
Generate relationship between diagram elements
Option 1 – via icon:
1. Select an element in the opened class diagram.
2. Click on a relationship icon, which appears above the element (the selected element acts as source
element).
3. Click on the target element of the selected relationship.
TF191021Version: 2.3
UML Class Diagram
ð You have created a relationship between the source and target element, which is active in the project
and shown in the diagram.
Option 2 – via Toolbox:
1. Click on a relationship element from Toolbox.
2. In the opened class diagram first click on the source element, then on the target element.
ð You have created a relationship between the source and target element, which is active in the project
and shown in the diagram.
Removing an element from the diagram
Option 1 – via icon:
1. Select the element in the class diagram, which you want to remove from the diagram.
2. Use the icon Remove from diagram, which appears above the element.
ð The selected element is removed from the diagram.
Option 2 – via the [Del] key
1. Select the element in the class diagram, which you want to remove from the diagram.
2. Press the [Del] key.
If the option [}9]Show prompt when deleting objects from diagram is disabled, the object is only
deleted from the diagram by default.
If the option is enabled, select the option “Remove from diagram” in the dialog that opens.
ð The selected element is removed from the diagram.
Removing an element from the diagram and the project
Option 1 – via icon:
1. Select the element in the class diagram, which you want to remove from the diagram and the project.
2. Use the icon Remove from project and diagram, which appears above the element.
ð The selected element is removed from the diagram and the project.
Option 2 – via the [Del] key
1. Enable the option [}9]Show prompt when deleting objects from diagram.
2. Select the element in the class diagram, which you want to remove from the diagram and the project.
3. Press the [Del] key and select the option Remove from project and diagram in the dialog that opens.
ð The selected element is removed from the diagram and the project.
As project navigator
1. Open a class diagram and double-click on an element in the class diagram.
ð The editor pertaining to the element opens.
2. If necessary, you can edit the declaration and implementation in the opened editor as usual.
ð Any changes of the declaration are automatically updated in the class diagram.
Multiple selections
• If Pointer is enabled in Toolbox (default), you can drag a rectangle over several elements in the class
diagram while pressing the left mouse button. All elements covered by the rectangle are then selected.
• Multiple selections are also possible by successively selecting the required elements while pressing the
[Ctrl] key.
• [Ctrl+A] or Select all selects all the elements within a rectangle, but no relationship elements.
TF191022Version: 2.3
UML Class Diagram
6.3Editor
A UML class diagram visualizes the static structure of a project and the elements declarations.
For a special or filtered view of the project, you can drag a selection of objects from the project tree
into the class diagram, or selected elements can be removed from the diagram.
The class diagram can be edited through various actions. Further information on the editing options can be
found under Editing a class diagram [}20].
In addition, there are further, element-specific user inputs:
• Edit class [}25]
• Edit interface [}31]
• Edit generalization [}47]
• Edit realization [}45]
• Edit association [}43]
• Edit composition [}40]
6.4Elements
The Tools window provides the elements of the class diagram. They can be added to the class diagram
window via drag & drop. The elements can be positioned freely.
Insert element
1. Open View > Tools to access the elements.
2. Drag an element into the class diagram window and drop it at a suitable location.
TF191023Version: 2.3
UML Class Diagram
Class [}24] (POU)
Interface [}30]
Global variable list [}33] (GVL)
Data type [}35] (DUT)
Variable Declaration [}38]
Property [}38]
Method [}39]
Composition [}39] (VAR)
Association [}42] (POINTER)
or
Association [}42] (REFERENCE)
Realization relationship [}44]
(IMPLEMENTS)
Generalization [}46] (EXTENDS)
6.4.1Class
A class is a logical unit in which data and operations are encapsulated. It also represents a variable type that
can be instantiated. A class can have an FB_Init method that is called when an instance is initialized.
A class can have the following relationship types:
• Composition: a class can contain other program elements.
• Association: a class can know other program elements.
• Realization: a class can implement an interface.
• Generalization: a class can inherit from another class.
A class is represented by a three-part rectangle.
• Orange with heading <<program>>: POU (PROGRAM)
• Blue without heading: POU (FUNCTION_BLOCK or FUNCTION)
• Blue with heading <<library>>: POU (FUNCTION_BLOCK or FUNCTION) from a library (library
function block)
TF191024Version: 2.3
UML Class Diagram
• Greyed with heading <<missing>>: POU (FUNCTION_BLOCK or FUNCTION) from a library, which is
currently not integrated in the project
The class name follows in bold.
All attributes are shown after the first dividing line. Each visible attribute has an identifier. If {input} in curly
brackets is appended, it is a variable of type VAR_INPUT; {output} indicates a variable of type
VAR_OUTPUT. A property has the ID {property}. An internal (non-visible) variable of type VAR has no ID:
The second dividing line is followed by all operations for the class, i.e. its methods or actions. The name of
the operation is followed by closing parentheses. This is followed by {action} to identify an action:
<action name>() {action}
If it is a method, the parentheses may indicate a variable transfer. If a return type is declared for a method,
this follows in the right-hand column. Unlike actions ({action}), methods have no concluding ID:
<Method name>(…) : <Return type>
Properties
“Property”Description
“Identifier”Class name
Sample: FB_EventLogger
User inputs for a class
The following user inputs are available if “Pointer” is enabled in the toolbox (default).
TF191025Version: 2.3
UML Class Diagram
User input in the class diagram
Select the tool “Class (POU)”:
Click in an empty area of the
diagram. The dialog “Add POU”
opens. Enter a name for the new
object, adjust the settings and
close the dialog with "Add".
Select a class.The class has expanded attribute
Click on .
Click on .
Click on and then in an
empty area of the diagram. The
dialog “Add POU” opens. Enter a
name for the new object, adjust
the settings and close the dialog
with "Add".
Click on , then on an
existing class.
Response in the class diagram Description
A class is created.The object exists in the diagram
and in the project. The view in
the project tree is updated
automatically.
and operation lists, which are
identified with .
Command icons for adding
relationship elements are now
visible to the left above the class.
Tip: If the class has relationships
that are currently not shown in
the class diagram (missing
rectangular elements), a list of
“Incoming cross-references” and/
or “Outgoing cross-references”
appears in the "Toolbox" view.
Below this the missing
rectangular elements are listed,
which you can drag & drop into
the class diagram for display.
The class is removed in the
diagram, so that it is no longer
displayed.
The class is removed from the
diagram and the project.
A composition arrow points from
the existing class to the new
class.
A composition arrow points from
the first class to the second
class.
Use "flat" removal of a class to
remove it from the class diagram
view only. The object still exists
and is visible in the project tree.
Tip: The class is shown in
“Toolbox” under “Incoming crossreferences” and/or “Outgoing
cross-references”, if a rectangle
element with a relationship to the
remote element is selected in the
class diagram.
The object no longer appears as
object in the class diagram or the
project tree. It no longer exists.
The existing class contains an
instance pointing to the new
class. Sample:
fbNew : FB_New;
The first class contains an
instance pointing to the second
class. Sample:
fbExistent : FB_Existent;
TF191026Version: 2.3
UML Class Diagram
User input in the class diagram
Click on and then in an
empty area of the diagram. The
dialog “Add POU” opens. Enter a
name for the new object, adjust
the settings and close the dialog
with "Add".
Click on , then on an
existing class.
Click on and then in an
empty area of the diagram. The
dialog “Add POU” opens. Enter a
name, adjust the settings and
close the dialog with "Add".
Click on , then on an
existing class.
Click on and then in an
empty area of the diagram. The
dialog “Add interface” opens.
Enter an interface name, adjust
the settings and close the dialog
with "Add".
Click on , then on an
interface.
Click on .
Response in the class diagram Description
A new class with an association
arrow pointing to the existing
class is created in the diagram.
An association arrow points from
the second class to the first
class.
A generalization points from the
existing class to the new class.
The existing class inherits from
the new class.
A generalization points from the
first class to second class.
A realization arrow points from
the class to the new interface.
A realization arrow points from
the class to the interface.
A new class FB_New is created.
The existing class now knows
the new class and contains an
association with the new class.
Sample:
pNew : POINTER TO FB_New .
The first class knows the second
class. It now contains a new
variable of type. Sample:
pExistent : POINTER TO
FB_Existent;
The existing class contains the
declaration. Sample:
FUNCTION_BLOCK FB_Sub
EXTENDS FB_New
The first class contains the
declaration. Sample:
FUNCTION_BLOCK FB_Sub
EXTENDS FB_Existent
The class implements the new
interface. The declaration section
of the class contains. Sample:
FUNCTION_BLOCK FB_Sample
IMPLEMENTS I_SampleNew
The class now implements the
interface. The declaration section
of the class contains. Sample:
Click on the class name. Once it
is selected, click on it once
again.
Click twice on an attribute or
operation name. Then change
the name in the line editor.
TF191027Version: 2.3
After the first click, the name has
a blue border. After the second
click the line editor opens.
After the first click, the name has
a blue border. After the second
click the line editor opens.
The attribute or operation list
expands.
The change is applied
synchronously and automatically
to the project. That is, the object
name in the project tree and in
the declaration section of the
POU is adjusted immediately.
The change is applied
synchronously and automatically
to the project.
UML Class Diagram
User input in the class diagram
Double-click on the class
element.
Keep in mind that the default settings in the dialog 'Add POU' or 'Add interface' originate from the
last application of this dialog.
Samples
• Composition
Response in the class diagram Description
The corresponding object editor
opens, and the declaration and
implementation are displayed.
You can change the declaration
or the implementation. After
closing of the object you are
returned to class diagram. The
changes are automatically
applied to the class diagram.
PROGRAM Test
VAR
fbSample : FB_Sample;
aSample : ARRAY[1..10] OF FB_Sample;
END_VAR
• Association
TF191028Version: 2.3
PROGRAM Test
VAR
pSample: POINTER TO FB_Sample;
aSample: ARRAY[1..10] OF POINTER TO FB_Sample;
END_VAR
• Generalization
UML Class Diagram
FUNCTION_BLOCKFB_SubEXTENDSFB_Base
• Implementation
TF191029Version: 2.3
Loading...
+ 66 hidden pages
You need points to download manuals.
1 point = 1 manual.
You can buy points or you can get point for every manual you upload.