Skip to main content

Online Mode

At runtime, you can monitor and control the behavior of the diagram in the monitoring in the editor.

Tip

The sample project UML_SC_CoffeeMachine.project is provided to illustrate the following examples.

Time behavior of a transition

Statecharts react to events. When an event occurs and as a result a condition is true, a state transition occurs with the next bus cycle clock. You can also configure transitions so that the state transition switches edge-triggered with the corresponding condition. In the implementation, the transition is then flagged with the _uml_icon_rising_edge.png symbol.

In the Properties → Property view, select the Rising edge option.

Time behavior of a state

At runtime of a statechart, its states are usually executed with the task cycle. However, you can configure a state in such a way that it is executed in-cycle and the state quickly executes all actions within one bus cycle. This kind of state is displayed in red in the implementation.

_uml_img_sc_red_state_grind.png

In the case of functions and methods, the local variables are usually temporary. At runtime, the local variables are not stored, but released, when the POU is exited. As a result, the information about the state of the statechart is not stored. Therefore, a switching behavior controlled by the bus cycle is not possible. For this reason, statecharts in functions or methods are executed in-cycle. So if you implement a method as a statechart, then this diagram is switched quickly. Also in the ToolBox view, only a _uml_icon_fast_state.png red state is available.

You can prevent this behavior by declaring instance variables VAR_INST instead of local variables in the function or method. When you exit the method, instance variables are stored in the calling POU (a program or a function block instance). The state transitions are then switched slowly edge-controlled with the bus cycle.

Tip

The requirement for this is that the Stateful implementation option is selected in the Properties dialog on the UML tab.

Monitoring and forcing

When an application has been downloaded and started, you can monitor its POUs in the monitoring. In the case of POUs in the UML Statechart implementation language, you can graphically monitor which state is active, because the currently active state is marked in blue. The statechart is updated continuously.

You can force variables in the declaration in the Prepared Value column. In the case of Boolean variables, you can also click the monitoring value to do this in the implementation. When a value is prepared, the monitoring value is marked in the upper right corner of the implementation.

You can also monitor the condition variables of transitions in watch lists in online mode.

Example 5. Example
Procedure. Monitoring and forcing a statechart
  1. Download and start the application of the sample project UML_SC_CoffeeMachine.project.

    The application is executed.

  2. Open the editor of the Kaffeemaschine POU, which was implemented as a UML statechart.

    The state that is displayed in blue is the current active state of the POU.

    _uml_img_coffeemaker_online_power_off.png
  3. In the statechart, click the value of the variable bPowerUp.

    In the declaration, the value FALSE is prepared for this variable in the Prepared value column. In the implementation, the monitoring value is flagged with a blue corner.

    _uml_img_coffeemaker_online_prepared_value.png
  4. Click Debug → Write Values (Ctrl+F7).

    The transition bPowerUp is TRUE. The statechart switches to the state Idle.

    _uml_img_coffeemaker_online.png
  5. Click the variable bPowerUp.

    A context menu opens.

  6. Click Add Watch.

    In the Watch List 1 view, the variable Coffeemaker.bPowerUp is listed with its context



Breakpoints

In the statechart in online mode, you can define breakpoints to halt the execution of the application at these points and to check the variables or watch lists there. In the statechart in online mode, all possible breakpoint positions are displayed as a _uml_icon_breakpoint.png gray circle. You can click the circle to select and deselect a position. Click Debug → Toggle Breakpoint or press the F9 key to define a selected position as a breakpoint or release it.

In addition, you can resume an application halted at a breakpoint in single steps.

. Representation in the statechart:
  • _uml_icon_breakpoint.png: Possible position

  • _uml_icon_breakpoint_selected.png: Selected position

  • _uml_icon_breakpoint_activated.png: Enabled breakpoint

  • _uml_icon_breakpoint_deactivated.png: Disabled breakpoint

  • _uml_icon_breakpoint_stopped.png: Execution stop at breakpoint In addition, the associated state or transition is marked in yellow.

Procedure. Inserting breakpoints and halting execution there
  1. Download and start the application of the sample project UML_SC_CoffeeMachine.project.

    The application is executed.

  2. Open the editor of the Kaffeemaschine POU, which was implemented as a UML statechart.

    Possible breakpoint positions are marked with a _uml_icon_breakpoint.png light gray circle.

    _uml_img_coffeemaker_online_power_off.png
  3. Click a _uml_icon_breakpoint.png circle.

    The position is selected: _uml_icon_breakpoint_selected.png.

  4. Click Debug → Toggle Breakpoint.

    Alternative: F9

    The position is activated as a breakpoint: _uml_icon_breakpoint_activated.png. When the position is reached during execution, the application halts and the position changes to yellow.

    _uml_img_coffeemaker_online_halt_on_breakpoint.png

Tip

For general information about breakpoints, see: Using Breakpoints

Online change

If you do offline editing on an existing statechart, such as changing transitions, conditions, priorities, actions, or names, then you can download the diagram to the controller with an online change when you log in. The diagram does not require reinitialization.

However, when you add, remove, or replace a state or region, the diagram does require reinitialization. This also applies to changes to implicit states, such as the Selection element or if you select the Abortable implementation condition in the properties dialog of a statechart. Then log in to the controller with a download.