SinelaboreRT Header Logo

SinelaboreRT

It's better when it's simple!

User Tools

Site Tools


Sidebar

Tool Landing Pages

Examples

Designers Toolbox

How-To

Integrated state-chart editor with auto-layout

Focus on modeling and not on moving states around to create a nice looking diagram! Syntax aware text fields offer a comfortable way to specify actions, guards etc. When the diagram passed the model checker it can be directly simulated. Connect the diagram to the real hardware to monitor the state machine in action.

There are better ways to model state machines than using spread sheets!

In the past different μC manufacturers have published application notes about the benefit of using state machines for the design of embedded software. An example is the application note SLAA402 from Texas Instruments (TI). It suggests to generate source code based on a spread sheet table. Nowadays several affordable UML modeling tools are available supporting the efficient design of state machines in a graphical way. SinelaboreRT generates production quality source code from state diagrams created with many different UML tools. Give it a try!

Latest Changes

PageDateUserTags
Generate efficient source code from UML state diagrams and activity diagrams! 2017/04/23 11:02 Peter Mueller  
Navigation 2017/04/23 10:55 Peter Mueller  
wiki:news:18may2014

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){
 
	OVEN_EV_CONSUMED_FLAG_T evConsumed = 0U;
 
 
	/*execute entry code of default state once to init machine */
	if(instanceVar->superEntry==1U){
		hwStatus = hardwareTest();
		if(hwStatus>0){
			instanceVar->stateVar = Error;
		}else{
			instanceVar->stateVar = Super;
		}
 
		instanceVar->superEntry=0U;
	}
 
 
	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!

wiki/news/18may2014.txt · Last modified: 2014/05/18 18:41 by pmueller