Skip to main content

Working in the Class Diagram Editor

The class diagram editor provides elements which map the object orientation of the project. Because the editor is embedded in the CODESYS Development System, you can generate code from it automatically. This provides you with extensive integrated features and tools, such as for error detection.

CODESYS automatically keeps the name and properties of objects in the class diagram and in the project the same. Therefore, user input affects both views. A class diagram does not have to represent all objects that are in the device tree. You can remove elements from the class diagram and leave the object in the device tree.

Tip

To get a filtered view of the project, you can intentionally drag only a selection of existing objects from the POUs view or Devices view or Devices view into the class diagram.

Adding new elements to the class diagram

  1. Drag a Class (POU) element from the toolbox of the class diagram to the class diagram editor.

    The Add POU dialog opens.

  2. Select the Function block type and specify a name for the new POU (example: POU_1. Click Add.

    The element is inserted into the editor as a new box element.

    The POU_1 object is added to the Devices view.

  3. Drag another Class (POU) element to the class diagram editor. Select the Function block type and specify a name for the new POU (example: POU_2.

    The element is inserted into the editor as a new box element.

    The POU_2 object is added to the Devices view.

  4. Select the POU_2 element.

    The possible commands are displayed as icons.

  5. Click Generalization (EXTENDS) and drag to the POU_1 element.

    A connecting line is drawn from POU_2 to POU_1.

    The IEC code of POU_2 is adapted accordingly to FUNCTION_BLOCK POU_2 EXTENDS POU_1. The POU_2 function block extends the POU_1 function block.

  6. Double-click the POU_2 element.

    The object opens in the editor.

Tip

You can drag objects that already exist in the Devices view or POUs view to the class diagram editor. All existing dependencies to other objects are displayed.

Tip

When you add an object, the Edit → Undo and Edit → Redo commands are no longer available.

Inserting relationships between elements

. Depending on the element, you can insert the following relationships:
  • _uml_icon_composition.png: Composition (VAR)

  • _uml_icon_association.png: Association (POINTER TO)

  • _uml_icon_association.png: Association (REFERENCE TO)

  • _uml_icon_realization_generalization.png: Realization (IMPLEMENTS)

  • _uml_icon_realization_generalization.png: Generalization (EXTENDS)

  1. Select the element that you want to link to another element.

  2. Drag the desired element from the ToolBox view to the other element, or click the icon above the element.

    A connecting line is displayed.

    Note

    Right-click to cancel the link.

  3. Click another element or a blank space in the editor.

    A dialog opens to add an object or a declaration, depending on the type of link and the "target element".

Removing elements from the class diagram

. The editor provides two options for removing elements:
  • _uml_icon_delete_element.png: The element is removed from the class diagram only.

  • _uml_icon_delete_element_object.png: The element is removed from the class diagram and the project

Tip

If you have removed selected elements from the class diagram and the project, then you cannot reverse this action with the Undo command.

When the elements are removed from the class diagram only, they can be inserted back into the diagram at any time.

Procedure. Removing an element from the class diagram only
  1. Select the element to be deleted.

  2. Press the Del key or click the _uml_icon_delete_element.png icon.

    A dialog prompt opens with the option to remove the selected elements only from the diagram or from both the diagram and the project.

  3. Select the Delete from diagram option and click OK to exit the dialog prompt.

    The class diagram no longer contains the previously selected elements. The respective objects are available both in the device tree and in the POU view.

Procedure. Removing an element from the class diagram and the project
  1. Select the element to be deleted.

  2. Press the Del key or click the _uml_icon_delete_element_object.png icon.

    When you press the Del key, a dialog prompt opens with the option to remove the selected elements only from the diagram or from both the diagram and the project. When you click _uml_icon_delete_element_object.png, the element is deleted immediately.

  3. Select the Delete from project and diagram (no undo possible!) option and click OK to exit the dialog prompt.

    The elements and the respective objects are deleted from both the device tree and the POU view.

Multiselection

It is possible to select multiple elements at one time. However, when you press Ctrl+A or click Select All pay attention that only the box elements are selected. The relationship elements are not selected.

Commands in the class diagram editor

. In the editor, the following commands are provided in the context menu of the elements:
  • Grid enabled / Grid disabled

  • Import project structure to active class diagram

  • Delete

  • Select All

  • Browse → Go To Definition

  • Browse → Browse Cross References

Cross references

Cross-references in the class diagram are dependencies and relationships between the elements of the diagram.

In the ToolBox view, in Incoming cross references and Outgoing cross references, elements are listed that have a relationship to the selected box element, but are not currently displayed in the diagram. For example, this is the case when the Delete from diagram command was used to remove an element from the class diagram but not the project. In Incoming cross references, missing incoming relationships with the source element are listed. In Outgoing cross references, missing outgoing relationships with the end element are listed.

You can drag a missing element from the ToolBox view to the class diagram.

If the selected element is a class with a relationship to a library function block, then this relationship is also detected and can be displayed as a missing element.

Procedure. Showing cross-references
  1. Click View → ToolBox.

  2. Select a box element in the class diagram that has relationships not represented in the class diagram.

    The relationships are listed in the ToolBox view.

    _uml_img_cd_crossrefs.png
Procedure. Inserting missing elements into the diagram
  • Drag an element listed in Incoming cross references or Outgoing cross references to the class diagram.

    The element is displayed in the class diagram.

Refactoring

The following changes that are made in the class diagram editor can be applied easily to the entire project by means of refactoring:

  • Renaming variables, POUS, or properties

  • Adding and removing variables of the type VAR_INPUT, VAR_OUTPUT, or VAR_INOUT

Tip

By default, the refactoring functionality and the associated preview () are enabled in the class diagram. However, you can restrict them using the options dialogs in Dialog: Options: Refactoring:Dialog: Options: Refactoring

In particular, note that the preview dialog can be skipped in the options for the UML class diagram. In this case, the change will be applied throughout the project without any prompt.

For more information, see: Dialog: Options: UML