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:
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.
The supported elements are:
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
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.