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; /* action code */ printf("Outer test action\n"); switch (stateVars.stateVar) { case S1: /* calling region code */ evConsumed |= testcaseS1Region1(msg); evConsumed |= testcaseS1Region2(msg); /* Check if event was already processed */ if(evConsumed==0){ ... break; } /* end switch stateVar_root */ // Copy state variables back stateVars = stateVarsCopy; return evConsumed; } // end processEvent }