Skip to main content

Element: State

A state is the main element of a statechart. A state machine (or statechart) runs through various states during its runtime and executes their actions. A state can have ENTRY, DO, and EXIT actions which are executed at specified times during the runtime of the state.

_uml_img_state_default.png

A state is represented as a green box with rounded corners. An in-cycle state is displayed in red. You set an in-cycle state in the In-cycle property.

An ordinary state is clocked according to the task in which it is called. The transition to the next state is only switched with the next task cycle.

An in-cycle state switches independently of the task cycle. When the actions of an internal state have been completed, the switch is made to the transition immediately. The condition of the transition is checked and its transition action is executed, and then immediately switched to the end state.

Properties

Property

Description

Identifier

Name for the element. You can also change the name in the statechart.

Color

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

Implicit start state

  • No: The state is a normal state.

  • Diagram: The state is also a start state for the entire diagram.

  • Composite state/region: The state is also a start state for a region in a composite state.

In-cycle

  • _cds_icon_checked.png: The transition is switched immediately to the next state.

  • _cds_icon_option_deactivated.png: A transition is switched to the next state at a cycle change of the task (default).

Max DO cycle calls

Maximum number of calls of the DO action. Number between 1 and 32767. When this value is exceeded, the current state switches to the next state.

ENTRY action

Name of the corresponding action

DO action

EXIT action

User input

When you select the element, transition icons are visible above the element. You can use these to link states.

Action

Description

  1. Select a State element.

  2. Click the name.

    _uml_img_state_name.png
  3. Change the name.

The name of the element can also be changed in the properties.

  1. Select a State element.

  2. Click the _uml_icon_transition_outgoing.png symbol.

    An outgoing transition is generated.

    _uml_img_create_transition_for_state.png

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

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

  1. Hover the cursor over a state.

    The actions of the state are displayed.

    _uml_img_state_focused.png

  2. Click _uml_icon_sc_action_do.png.

    The state is extended by a DO action/method.

    _uml_img_state_do.png

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

  4. Click _uml_icon_sc_action_add.png.

    The New action object dialog opens.

  5. Select the Action object.

  6. Specify a name and an implementation language.

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

  7. Click _uml_icon_sc_action_open.png.

    The editor of the corresponding action or method opens.

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.

  1. Create multiple transitions on the same state:

    _uml_img_state_transition_prioritized.png

  2. Select one of the two transitions.

  3. Change the priority in the properties of the transition.

If a state has more than one outgoing/incoming transition, then its priorities define the order of execution. The priorities are displayed in a small circle.

You can change the priority in the properties of the transition.