SinelaboreRT Header Logo


It's better when it's simple!

User Tools

Site Tools


New version 3.6 has support for activity diagrams

There are two diagrams that can be used to express dynamic behaviour in the UML. State machine diagrams express the states of an object and the events and transitions to change the state. In contrast activity diagrams (aka flow diagrams) describe the control flow of an algorithm. The great thing of both types of diagrams is that they allow to generate 100% code out of the model description.

The latest version of the sinelabore code generator can now also generate code from activity diagrams. Activity diagrams consist of the following elements:

  • Black circle to indicate the begin of the activity
  • Circled black circle to indicate the end of the activity (return)
  • Rounded rectangles representing actions
  • Diamonds representing decisions and merge
  • Arrows connect the other elements and represent the flow throughout the diagram. Arrows might have a guard expression. If the guard expression is true the control flow follows this arrow to the next action.
  • Activity diagrams might contain sub-activities

In addition to this basic elements UML activity diagrams also allow to model loops and decisions.

To generate code from an activity diagram just call the code generator with the new command line parameter -A. The other command line parameters are still the same. Use the -t parameter to define the path in the model file to the class containing the activity. And -l for the target language.

Presently the code generator only supports XMI files exported from Enterprise Architect models and can only generate C code.

The following figure shows a fictitious activity diagram with all the elements presently supported from the code generator.

The code generator supports several configuration parameters that can be specified in the codegen.cfg file. The parameters are:

  • ActivityFileNamePostfix: By default the c/h file with the activity are based on the name specified by -o and the activity name in the model file. But for specific reasons it might be necessary to provide an additional postfix to the file names.
  • ActivityFunctionParameterDefinition: Allows to define the parameters for the activity function in the c file
  • ActivityFunctionPrefixHeader: Same as above but for the header file
  • ActivityFunctionPrefixCFile: Allows to define the type of the return value if the activity returns something
  • ActivityFunctionReturnCode: Defines the code snipped that is used at the end of the activity to actually return something.

To generate code from the above example diagram call the code generator the following way:

java -jar codegen.jar -A -p EA -o testcase -t “Model:test:class_with_activities” testcase.xml

The generated c-file can be found here. Due the way the algorithm is generated (based on a while loop with switch / case statements) all kinds of loops including back links can be generated without problem. For the shown diagram the generated code contains just 180 lines of code including empty lines and some documentation.

⇒The activity generator backend is still under development. Error handling and parser robustness must be increased. Additionally sections about the activity generator must be added to the manual.

Nevertheless the generator can already be used for real word applications. Please give it a try! Your feedback is very welcome.

Beside the activity generator backend the new version also contains several improvements in the state machine generator. In addition support for transitions from initial states to choice states in Java was added.

Have fun!

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/news/12may2014.txt · Last modified: 2014/05/13 18:45 by pmueller

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki