SinelaboreRT Header Logo


It's better when it's simple!

User Tools

Site Tools


Version 3.1

Region support for the C++ backend

A UML state might be divided into regions. Each region contains sub-states. Regions are executed in parallel. You can think of regions as independent state machines displayed in one diagram.

For each region an own method is generated in the state machine class. Its name is automatically derived from the region name. If a state contains several regions they are called one after the other (in alphabetical order). If the event sent to the state machine was processed in one of the regions no further event handling happens in the parent state. Otherwise the event is processed in the parent state. This is similar to the event handling of normal hierarchical state machines.

To maintain consistency during execution of machine code a copy of the instance data is created at the beginning of the state machine code. All state machine internal tests are performed on the original instance data. All changes are done on the copy. This ensures that all regions see the same situation when running. At the end of the machine code the modified instance data is copied back to the original data.

Here is an example how the generated C++ code looks like:

// State machine event handler
int testcase::processEvent(TESTCASE_EVENT_T msg){
	int evConsumed = 0;
	if(m_initialized==false) return 0;
	//Create copy of statevar
	stateVarsCopy = stateVars;
	switch (stateVars.stateVar) {
		case S1:
			/* calling region code */
			evConsumed |= testcaseS1Region1(msg);
			evConsumed |= testcaseS1Region2(msg);
			/* Check if event was already processed  */
	} /* end switch stateVar_root */
	// Copy state variables back
	stateVars = stateVarsCopy;
	return evConsumed;
} // end processEvent
// Region handler code for state S1 Region1
int testcase::testcaseS1Region1(TESTCASE_EVENT_T msg){
// Region handler code for state S1 Region2
int testcase::testcaseS1Region2(TESTCASE_EVENT_T msg){

New Parameter PrefixStateNamesWithMachineName

This parameter allows to prefix state names with the C machine name. Use this option if multiple state-machine header files are included into one other file (e.g. main.c) to avoid definition conflicts due to double used state names. See also parameter PrefixMsg- WithMachineName.

New Parameter PrefixStateNamesWithParentName

This parameter allows to prefix state names with the parent state name. Use this option if you have a hierarchical state machine and want to use the same state names in different child states. Example: There are two parent states called EngineOn and EngineOff. And in both states you have children FuelPumpOn and FuelPumpOff. To make the children names unique they can be prefixed with the parent name.

This new version is free for users who bought their license within the last two years.

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/03jan2013.txt · Last modified: 2013/01/03 20:48 by pmueller

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki