SinelaboreRT Header Logo


It's better when it's simple!

User Tools

Site Tools


Using Activities -- Updated Microwave Oven

In the manual a simplified microwave oven is used to explain the generation of source code from state machine diagrams. This example was updated here to show how to generate code also from activity diagrams.

The extended state machine of the oven is shown below. For demonstration on how to use activities the oven performs a hardware selftest at startup. The hardware test happens on the incoming transition of the choice. Depending on the result of the selftest the machine enters an error state (marked in red) or the normal operation state (super). The hardware selftest routine was modelled as activity diagram.

The following code snipped shows the call of the hardware selftest. The selftest function itself was fully generated from the code generator

uint8_t hwStatus; // selftest status
void  oven(OVEN_INSTANCEDATA_T *instanceVar){
	/*execute entry code of default state once to init machine */
		hwStatus = hardwareTest();
			instanceVar->stateVar = Error;
			instanceVar->stateVar = Super;
	switch (instanceVar->stateVar) {

The hardware selftest function was modelled in an own activity diagram. A class can have one or more activity diagrams. The code generator generates an own c-file/header per activity. The activity of the hardware test function is shown below. The single steps do not really do anything useful and only the most basic features of an activity diagram are used. But it shows the principles and how well both generators complement each other.

To generate code from the diagram call the code generator as follows. The -A enables the generation of code from activity diagrams. Without this flag state machine code is generated. To generate both call the generator twice.

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

The latest download contains the full model and code in the examples folder. The example is called microwave_handbook_enterpr_arch

In case of questions just send a mail.

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

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki