This is an old revision of the document!
Table of Contents
New Version 3.0
Generate code from state machines with regions
In state diagrams usually only one state is active at a time. In UML state diagrams regions also allow to model concurrency - i.e. more than one state is active at a time (AND states).
A UML state may 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. The state machine below (Fig. 1) shows several regions each running in parallel in the state Active
. Dashed lines are used to divide a state into regions.
Using multiple regions
Consider a microwave oven. The power setting, light and microwave radiator are be considered as independent (concurrent) parts of the oven, each with its own states. The door and timer as the main external trigger are used in the regions to trigger state transitions. For example the radiator is switched on if the door gets closed and the timer is > zero.
As you can see multiple concurrent regions can be used to explicitly visualize different parts of a device. And all the states in the one diagram.
The model and the generated code thereof is provided in the examples folder of the current release.
Figure 1a: State machine model of a microwave oven using regions (created with UModel).
Leave your comments
Fixed with Version 3.1
Hello Max,
yes and no. You can generate C++ code with regions in it. But it does not copy the instance data yet. See section 6.2 in the manual.
Does the CX language support for regions include C++?