SinelaboreRT Header Logo

SinelaboreRT

As simple as possible, but not any simpler!

User Tools

Site Tools


wiki:getting_started:staruml

Generate production quality code from state diagrams created with StarUML

The StarUML parser is work in progress. If you are interested in this feature send us a mail expressing your interest and specific needs.

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:

  • 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

Drawing the State Machine Diagram

StarUML allows efficient drawing of state diagrams as part of a class. The following example state diagram shows the features that are supported from the code generator right now.

Creating Code

It is assumed you have a recent Java version installed e.g. on a Mac.

java --version
openjdk 17-ea 2021-09-14
OpenJDK Runtime Environment (build 17-ea+29-2576)
OpenJDK 64-Bit Server VM (build 17-ea+29-2576, mixed mode, sharing)

To generate code first export your model to XMI using “File → Export → XMI”. Then specify StarUML as modelling tool (-p struml) as well as the path to the state diagram inside the model file (-t “Model:class1” ). The command line to generate C-code looks like as follows:

java -cp "/path to codegen jar file/*" codegen.Main -l cx -p StarUML -o testcase -t "Model:class1"  testcase.xmi

This generates C-code from the specified state machine diagram.

Supported State Machine Elements

The code-generator supports a relevant subset of the design elements provided by Magic Draw. The supported elements are:

  • Hierarchical states
  • (Signal-)Events with event name, guard and action
  • Initial and final pseudo-states
  • History states (deep, flat)
  • Choices

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

StarUML Draw HowTo

:?:I'm not able to define header code as specified in the header comment

:!: StarUML unfortunately does not export linked comments to the XMI file. Therefore specify the comment in the configuration file. Example

AdditionalMachineImplementationInclude=#include <stdint.h>\n#include "testcase_ext.h"\n#include "testcase.h"\n#include <stdio.h>\nextern TESTCASE_EVENT_T msg;\n\n
This website uses cookies. By using the website, you agree with storing cookies on your computer. Also you acknowledge that you have read and understand our Privacy Policy. If you do not agree leave the website.More information about cookies
wiki/getting_started/staruml.txt · Last modified: 2023/08/19 14:53 by webmin

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki