Skip to main content

Element: Composite state

You can use this element to group multiple states together.

. A composite state can be orthogonal or non-orthogonal.
  • Orthogonal state: Composite state with two or more regions. In an orthogonal state, the inner states are grouped into regions and the regions are prioritized. They control the processing order at runtime. The states of the regions are run pseudo-parallel according to their internal sequencing.

  • Non-orthogonal state: Composite state with exactly one region. In a non-orthogonal state, the internal states are run sequentially at runtime. An internal state can also be a composite state. The nesting of non-orthogonal states can have any depth, whereby none of the states may have multiple regions, except for the innermost state.

Orthogonal and non-orthogonal states can also call an ENTRY action, a DO action, and an EXIT action. When an exception transition is active, the EXIT action of each active state of each region of the orthogonal state is executed.

_uml_img_orthogonal_state.png

The name of the composite state is displayed in the upper left corner of the rectangle. Regions are divided by a dashed line. The priority of the region is displayed in the upper right corner of the region.

Rules

. Rules
  • A transition is not permitted between states in different regions.

  • A composite state can have one or more outgoing exception transitions. You can implement error handling efficiently, for example, with an exception transition.

  • A composite state has at most one completion transition. Therefore each region includes one start state and one end state. The composite state reaches its end state when all of the regions have reached their end states. If a composite state does not have an outgoing completion transition, then the regions may not have a start state or end state.

  • A transition to a state within an orthogonal state is permitted only from a fork and is always unconditional.

  • A non-orthogonal state can contain another composite state. In this case, the states are nested.

  • A non-orthogonal composite state can have an assigned ENTRY action and/or DO action and/or EXIT action.

Properties

Property

Description

Identifier

Name of the composite state

Example: DoorAutomaton

Color

Color of the element. You can change the color using a color selection dialog. Default: Yellow

Allow ENTRY / DO / EXIT actions

Requirement: The selected composite state has exactly one region.

ENTRY, DO, and EXIT actions can also be assigned for the following use cases:

  • Nested composite states

  • States without internal start or end states

  • States without internal outgoing completion or exception transitions

_cds_icon_checked.png: You can assign one of each ENTRY, DO, and EXIT actions to the state.

Execute DO actions even if the internal composite states are active

The option is available for the outermost composite state only and inherited by the internal ones.

_cds_icon_checked.png: The DO action is executed continually at runtime, even if one of the inner composite states is active at the same time. The {executed also for inner composites} note is displayed in the editor next to the DO action in order to point out this action behavior.

_cds_icon_option_deactivated.png: As soon as one of the internal composite states is active, the DO action of the outer state pauses.

User input

Action

Description

  1. Select an empty composite state.

  2. Click the _uml_icon_transition_completion.png symbol.

    An outgoing completion transition is generated.

  3. 3. Click an existing element (type: State, Composite state, Fork/Join, or Choice).

    A completion transition is inserted between the two elements.

Note: If you do not click an existing element, but in a blank area, then a new state is created.

You add an _uml_icon_transition_exception.png exception transition in the same way.

  1. Move the mouse pointer to an empty composite state.

  2. Click the _uml_icon_sc_area_add.png symbol.

    The state is subdivided and another region is added.

    _uml_state_orthogonal.png

The priority is displayed on the right in the region. Regions with a lower priority are processed first. You can change the priority. CODESYS adapts the priorities of the other regions automatically.

  1. Select a composite state with multiple regions.

  2. Move the separator line.

  3. Select the separator line by double-clicking it.

    The line is displayed in blue.

  4. Press the Del key.

    The line is deleted.

After the separator line is deleted, the two regions (separated by the border) merge into one region.

  1. Select a composite state with multiple regions.

  2. Click the priority in a region two times.

Now the priority can be changed.

When the priority is changed, the other priorities are adapted automatically.

  1. Move the mouse pointer to an empty composite state.

    The actions of the state are displayed.

    _uml_img_composite_state_with_acitvated_actions.png

  2. 2. 2. Click one of the three _uml_icon_actions_vertical.png symbols.

  3. Click the _uml_icon_sc_action_do.png symbol.

    The state is extended by a DO action/method.

  4. Hover the cursor over a state with an assigned DO action.

  5. Click the _uml_icon_sc_action_add.png symbol.

    The New action object dialog opens.

  6. Select the Action object.

  7. Specify a name and an implementation language.

    A new action is inserted below the POU of the statechart.

  8. Click the _uml_icon_sc_action_open.png symbol.

    The editor of the corresponding action or method opens.

Requirement: The Allow ENTRY / DO / EXIT actions property is selected.

The action object can be an action or a method. If the action is a method, then you also have to define the return type and the access type in the New Action Object dialog. The assignment to the action object can be changed in the properties of the element.

A state can have an ENTRY action, a DO action, and an EXIT action:

  • An ENTRY action/method can initialize the state. It is executed one time when all incoming transitions are set to TRUE.

  • The DO action/method is executed as long as the state is active. The action can be programmed in any implementation language. When you use Statechart, a hierarchical structure is created.

  • The EXIT action/method should make sure that the state is exited in a valid state. The EXIT action is executed one time when all outgoing transitions of the state are TRUE.

Tip

You can also add or change the actions or methods in the properties of the element.

Examples

Example 22. Composite state with exception transition and completion transition
_uml_img_composite_state_example.png


Example 23. Composite state without completion transition
_uml_img_composite_state_without_completion.png


Example 24. Nested composite states
_uml_img_nested_composite_states.png


Example 25. Orthogonal state with fork
_uml_img_fork_join_example.png


Example: Elevator Lift

Example 26. Orthogonal state with completion transition and exception transition
_uml_img_orthogonal_state_lift.png