Engee documentation

Finite automata debugger

Page in progress.

Creating models based on finite automata is an efficient way to describe complex discrete logic. To simplify the analysis of such automata and to provide control over their behaviour, Engee has a built-in debugger that allows you to trace the execution step by step and detect errors of the finite automaton.

The debugger is available inside the Chart block and is enabled by setting a Breakpoint for state stateflow state and/or transition stateflow default transition:

state machines breakpoint 1

Breakpoints appear as red markers state machines breakpoint 1 (or grey state machines breakpoint 2, if disabled).

Breakpoints is a key tool of the finite automaton debugger, which can be used to set conditions for stopping the execution of the model. This allows you to investigate the behaviour of the model at a particular step of the finite automaton execution. Thus, breakpoints can be used to:

  • Control the simulation of the finite automaton step by step;

  • View the values of variables at a particular step;

  • Analyse when and which states become active or terminate;

  • Check if Groups of state machine operators (for entry, during and exit groups) are executed;

  • Analyse the validity of transitions, including transitions with temporal logic, edge tracking and change indicators operators;

  • And diagnose hidden logic errors and unstable states that do not appear in the model output.

Working with breakpoints

Breakpoints can be set to:

  • States stateflow state - on entry, during execution, and on exit;

  • Transitions stateflow default transition - when checking a condition or before executing a transition.

To add a breakpoint to the state stateflow state or transition stateflow default transition, left-click on the required element and then on the breakpoint icon that appears. The active breakpoint will be marked with a red marker:

sm breakpoints 1

state machines breakpoint 4

You can set different types of breakpoints for states and transitions. To do this, click on the breakpoint with the left mouse button:

In states

At transitions

state machines breakpoint 3

  • When entering a state (entry) - simulation stops before executing entry;

  • When in a state (during) - simulation stops before executing during on each clock cycle;

  • When leaving a state (exit) - the simulation is paused immediately after exit execution before moving to another state.

state machines breakpoint 11

  • When a transition is valid - the simulation is paused at the moment when the transition becomes valid and can be executed;

  • When transition is tested - the simulation is paused at the moment when the transition condition is checked. This parameter is not available if the transition does not contain a logical condition (for example, an unconditional transition).

The selected types will be displayed when you move the cursor over the breakpoint:

state machines breakpoint 4
state machines breakpoint 12

Any combination of checkboxes can be enabled - depending on which state/transition operation point is to be monitored. If all check boxes are unchecked, the breakpoint will be deleted.

To temporarily disable a breakpoint (leaving it on the state/transition but without triggering), click the breakpoint icon again:

state machines breakpoint 3

Breakpoint List

To switch to the breakpoint list, left-click on an already created breakpoint and select Breakpoint List:

state machines breakpoint 5

This opens a list of all breakpoints of the finite automaton model:

state machines breakpoint 6

Through the list of breakpoints you can:

  • Track which breakpoints were triggered during the simulation of the model and the number of times they were triggered. The number of actuations is shown in the column "Actuations". The triggered breakpoint will be highlighted in green:

    state machines breakpoint 14 x

  • Delete a breakpoint by left-clicking on it in the list and clicking on the Delete breakpoint icon state machines breakpoint 7.

  • Add a breakpoint by clicking on it in the list with the left mouse button and clicking on the Add breakpoint icon state machines breakpoint 8. In the window that opens, select the required parameters - trigger type and, if necessary, condition:

    state machines breakpoint 9

  • Enable/disable breakpoint - to do this, control the checkboxes state machines breakpoint 10 at the corresponding points.

  • Specify a condition for the breakpoint by entering an expression in the "Condition" column against the desired row. For example, y > 5 or (y == 0) & (n > 5). Conditions can specify logical expressions supported by finite automata logic. The values of inputs, outputs, and all variables available in the Chart block are used for them.

Control of model execution

Step-by-step execution is only available within the Chart block and does not affect the global execution of the model in the workspace. When you exit the Chart block, the panel is hidden and Engee returns to normal simulation mode.
The active breakpoints of the Chart block do not conflict with the breakpoints models and scripts.

After setting the first breakpoint inside the Chart block, a step-by-step simulation control panel will appear in the upper left corner of the canvas:

state machines breakpoint 14

Three run control commands are available:

  1. Step In state machines breakpoint 14 1 - moves to the next execution step within the current state or transition. The command executes the details of a finite automaton element in steps. It can be:

    • Entering the finite automaton diagram;

    • Checking the transition conditions;

    • Execution of transition actions;

    • Activating a state;

    • Executing groups of entry, during or exit operators;

    • Transition to child states or nested Transition graphs.

  2. Step Over state machines breakpoint 14 2 - Executes the current step in its entirety, without going to internal parts. The command is used to sequentially pass through the key execution steps of a finite automaton:

    • Activation of the finite automaton;

    • State transition;

    • Checking for available transitions;

    • Execution of transition actions;

    • Execution of state actions.

  3. Step Out state machines breakpoint 14 3 - terminates the execution of the current state, transition, child state or nested transition graph and returns to the higher level of execution. The command allows you to exit the current level of nesting and continue execution of the automaton at the level from which the input was performed.


To visually track the current stage of execution of the automaton model, highlighting is used - the active element is highlighted in green colour during execution both in the model itself and in the list of breakpoints:

state machines breakpoint 14 4

In addition to highlighting with colour, the system also provides hints in the form of icons, when you move the cursor over them, an auxiliary message pops up as to how exactly the model was executed at the current step:

  • sm before entering Before entering a state

  • sm during Inside the state

  • sm before exit Before leaving a state

  • sm before testing transition Before checking transition conditions

  • sm before transition Before transition

For example:

state machines breakpoint 14 5 state machines breakpoint 14 6

Viewing and editing variables

During a step-by-step simulation of a finite automaton, you can not only observe which states and transitions are activated, but also monitor the values of the variables used inside the Chart block.

To do this, open settings window debug article icon 1 of the Chart block - it displays all available variables.

state machines breakpoint 14 7

In this window you can:

  • View the current values of the variables at each step;

  • See the changes in values - they are highlighted in green, similar to the list of breakpoints;

  • Manually change the values of some variables directly while the model is stopped.

    Editing variable values is only available during a simulation pause and when there is an active breakpoint.

*To change the value of a variable:

  1. Move the cursor over the desired row in the "Value" column;

  2. Click on the current value;

  3. Enter the new value and press Enter.

The local variables and output signals can be changed. The values of the input signals are set from the external modelling environment (outside the Chart block).