Generate production quality code from state diagrams created with Enterprise Architect

SinelaboreRT generates readable and maintainable code from hierarchical UML state machines. With its unique features and the C code generator the tool covers well the requirements of embedded real-time and low power application developers. With its C++, Python and Java backend it is also a perfect tool for developers of server or desktop applications.

Key Features:

Watch the code generator in action

The following example shows how the code generator works by means of a simple microwave oven.

microwave oven with requirements

Requirements:

The sate machine below shows a possible solution.

State machine of a simple microwave oven

To generate for example C code just export your model to XMI and call the code generator as follows:

java -jar codegen.jar -p EA -t "Model:Class Model:first_example_step3" -o oven first_example_step3.xml

After checking the model against a set of well-formedness rules (e.g. no double state names) the complete state machine code is generated.

Done!

Look into the generated files: oven.c oven.h oven_ext.h

In the examples folder you will find the complete code ready to be tested and expanded by you.

Supported State Machine Elements

The code-generator supports a subset of the design elements provided by Enterprise Architect. The supported elements are:

Find out more about the code generator

Classes have attributes and operations

Download the demo version and try it right now. It includes many other examples.

Enterprise Architect HowTo

Enterprise Architect HowTo

Below some tips and tricks are listed that simplify the state-chart creation using Enterprise Architect. If you have further hints let us know and we add them here. For a short intro on on how to use EA with the codegen go on reading here.

:?: Where to put the events to:

:!: States should be put “below” the class containing the state diagram. See next figure.


:?: How to define the path to the state machine:

:!: Since version 9.0 of Enterprise architect it looks like that always a view package is required. This package must appear in the path you specify on the codegen command line. In the figure above the path to the state machine is -t “Model:test:testclass”


:?: I always get the error message ‘Can't find path element ….’. But I’m sure the path is correct:

:!: Most probably you have not selected to root element (e.g. Model in the figure above) before exporting the XMI file. Select the root model element and then export to XMI.


:?: How to specify multiple lines entry/exit/do action code:

:!: There are some different ways.

The codegen can take the activity name as code. But only one line can be specified then.

It is also possible to specify multiple lines of action code in the behaviour field. The name of the action is not used anymore as code line if code is found in the behavior field.

The third way is to use the code field. It has syntax highlighting activated which is nice.

:?: Where do I find the “export to XMI” dialog?

:!: In recent versions of EA the export to XMI is available under Publish → Export XMI