Generate production quality code from state diagrams created with DrawIO Desktop

SinelaboreRT generates readable and maintainable code from hierarchical UML state machines created with DrawIO. With its unique features SinelaboreRT covers well the requirements of embedded real-time and low power application developers. With its other language backends it is also a perfect tool for developers of server or desktop applications.

Key Features:

Automated robustness checks before code generation

No run-time environment needed

Can be used with any CPU and with or without OS/RTOS

Code generation especially for embedded real-time and high availability systems.

Fits well in different system designs (foreground/background, RTOS-based …)

No gap between design and code

Support for automatic test-case generation

Simulation in interactive or batch mode.

Optionally generating trace code

Generated code creates no trouble when using static code checkers

How to get started ?

Download the code generator and use the DrawIO microwave example in the examples folder. It shows a fully functional example of a microwave oven in C. Make changes in the model, re-create the state machine code and then compile/run the example again. This is the fastest way to learn how to use the code generator. To recreate the code from the model file you need a Posix like development environment.

An example command like to generate C-code from a model called oven looks like this: java -cp “pathToCodegenJarFolder/*” codegen.Main -p drawio -l cx -o oven oven.drawio

Only special elements from the UML palette are supported from the parser. Below a list of supported elements is shown and an image where to find them.

Supported State Machine Elements

The supported elements are:

Normal state

Hierarchical state

Flat / deep history (appending (H) and (H*) in the state name)

Final state

Initial state

(Signal-)Events with event name, guard and action – Initial and final pseudo-states

Comment

Choice

How to

Connecting transitions to states

Start drawing a transition using the arrow elements on a state. Make sure the transition starts and ends on the light green circles that appear when you hover over the state borders. A nice tutorial is available here: https://www.drawio.com/doc/faq/connectors

Connecting nodes

Setting guards on the outgoing transitions of choices

Delete the default text of the choice element. Then double click on the transition and enter the guard text. Don't forget the square brackets.

Adding events/guards/actions to a transition

Double click on the transition and add the event, optionally a guard in square brackets and optionally the action code which is introduced by a slash. Example: ev1[i==4]/printf(“i=4”);

How can I selected the diagram in my model file?

Use the command line parameter -t. Here is an example how to select diagram oven from the model file: -t oven. If no diagram is specified (e.g there is only one) the first diagram found in the model file is taken.

How to add substates?

Delete the text of the composite state and add the substates within the empty field. Unfortunately there is no option the have enty/exit/do code in a composite state and child states. In this case use a comment to specific the text of the composite state as shown in the picture above.

How can I set include files for the generated state machine code file?

Use an unconnected comment as shown above starting with header: in the first line.