For modeling systems and software, we use the Enterprise Architect tool. This tool is a powerful tool for modeling systems and software and is widely used in development departments. In previously published articles, we have, for example, addressed the topic Requirements Engineering with Enterprise Architect In this article, we'll explore the graphical simulation of state machines. I'd like to share a few tips and tricks with you on how we approach simulating state machines with Enterprise Architect.
Creating a state machine
When you create a state machine in Enterprise Architect, a package is created with an empty diagram in the State Machine category.

Standard diagram for the state machine

Empty State Machine
This diagram is not This is a diagram that can be executed in the simulation. Therefore, it is recommended to use a state machine as State Element (in our example: Main State Machine). This state machine is a simulatable file and contains a visual diagram that should be used as the "main diagram." The original state machine can be hidden in a folder for invisible components.

executable state machine

Executable state machine in original state machine
Structure of the State Machine
To perform a simulation, the model needs a starting point (Initial) and states or state machines. A simulation path can be terminated with an endpoint (Final). These elements must be Transitions Nesting of elements is possible, and in State Machines, subordinate diagrams can be created in a separate view.

Creating a transition between states
Controlling the State Machine
Simple transitions (Transitions) are signaled independently by the program and thus automatically lead to the next element.
In order to have manual control over the processes, the transition is assigned a Trigger In our example, we have the triggers "Mainpower connect" and "Power loss" to manually switch the states.
Organizing States and State Machines
To improve clarity, there are various ways to arrange diagram elements on different levels.
Boxed
In boxed state machines, elements are positioned within the boundaries and can be directly connected to other elements via transitions. This means that all elements in these state machines are visible at the current level. In small diagrams, this allows for a quick understanding of the elements. In complex diagrams, this variant quickly leads to an overload of information and is not helpful for a clear presentation. The boxed method can be used for states and state machines.

Boxed elements in the state “Powered” and the state machine “State Machine boxed”
Detailed
With detailed state machines, the elements contained within them are displayed in a separate diagram, at a deeper level. This method significantly improves clarity, especially in large systems, by reducing them to the essentials.

Detailed view of the state machine
As you can see in our example, both methods can be combined to create clear and understandable diagrams.
Transitions between state machines
When transitioning to a state machine, it may be desirable to have multiple entry paths that result in different simulation sequences. This is not possible with the "Initial" element. EntryPoints are used for this purpose, enabling the transition from a higher-level state machine to a dedicated sub-state machine. To do this, the corresponding EntryPoint must be inserted as a link at each level (the initial state machine and the sub-state machine). This procedure can also be used for the transition back to the initial state machine. Enterprise Architect provides ExitPoints for this path. In our experience, ExitPoints did not work as expected, and the simulation did not continue with subsequent events. There is a simple workaround for this, which is only visible in the symbolism. Instead of ExitPoints, EntryPoints can be used to transition to another state machine or the higher-level state machine. If necessary, these EntryPoints can be renamed, for example, to ExitPoint.
Simulating the State Machine
To perform the simulation, the simulator is used, which can be selected in the menu under Analyzer → Simulate → Simulator.

Opening the simulator
The simulator allows you to select, start, pause, and stop the state machine for the simulation. The simulator also displays the simulation processes as text.

Simulation window when opening

Simulation with executed events
We also recommend displaying the Simulation Events Window.

Opening the Simulation Events Window
Waiting, available triggers are displayed in the Simulation Event Window and can be activated. Activated triggers are listed. Additionally, the trigger sequence can be saved and used for automated processing.

Simulation Events Window with used triggers (left) and available triggers (right).
In the simulation, the currently active element and the waiting paths are displayed normally and the inactive elements are overlaid with a blue veil.

Standby is the active state, Start Boxed Machine and Start Detailed Machine are the waiting triggers. The remaining elements are "blued out."
The triggers can also be executed by another action by right-clicking the waiting trigger in the diagram and selecting the “Signal Trigger in Simulation” action.

Signaling the trigger directly in the diagram
In this way, triggers can be queued in the Simulation Events Window and then executed manually or automatically.

Simulation Events Window with executed (Mainpower connect), queued (Start boxed Machine and Standby) and waiting triggers (right column).
With these tips, you can create a simulable state machine that you can use to engage your stakeholders when discussing system behavior and simulate the system's behavior.
Do you have questions about modeling state machines? We would be happy to support you with the system engineering for your project. Contact us.
