Thursday, August 2, 2007

Modeling Composite States

Composite states contains one or more Statechart diagrams.
they are 2 types
  1. Mutually exclusive states - embedding a Statechart diagram inside of a state.
  2. Concurrent states - divides a state into two or more regions. Each region contains a Statechart diagram. Each region executes independently and at the same time as the other regions.
A composoite state is also called a superstate. It contains a set of specialized states called substates.
A superstate may be modeled as a state icon with one additional feature, a composite icon that consists of two small horizontally aligned rounded-rectangles connected by a line. The icon indicates that the state can be expanded to reveal more details.


Figure 10-33: An elided superstate icon (left) and the expanded superstate icon (right).

Modeling mutually exclusive substates.
A composite state (superstate) may be decomposed into two or more substates. The substates resides within a graphic compartment below the name and internal transition compartments.



Figure 10-34: Mutually exclusive substates displayed in a graphic compartment within a superstate.

Modeling concurrent substates
The regions are divided using a dashed line within the graphic compartment.


Figure 10-35: Composite state with concurrent regions.

Submachine States
Submachine state is a subclass of the Composite State.
Within a composite state, the submachine state maybe referenced in the same manner that a class would call a subroutine or a function on another class.
The containing state icon models the reference to the submachine state by adding the keyword "include" followed by a slash and the name of the submachine state.

Transitions to and from composite substates


Figure 10-38: Initial state refers to a specific substate.

Exiting the superstate can be accomplished in multiple ways. An object may leave the superstate regardless of the current substate, leave from a specific substate, or exit at the completion of all activities within the superstate.


Figure 10-39: Leaving a superstate.



Figure 10-40: Exiting a superstate from a specific substate.

Stubbed transitions
Stub states represent only the entry and exit points for a submachine state.
Each stub is drawn as a line with the substate name as the label.
A stub used as an entry point is a stub with one or more transition arrows pointing to it. A stub used as an exit point is a stub state with one or more arrows coming out of it.


Figure 10-42: Modeling an exit stub state.


Transitions to and from concurrent states.

Concurrent states introduce the need to coordinate simultaneous behaviors, including synchronization, split of control, and merge of control.

1.Split of control and merge of control.

Split of control means that based on a single transition, you want to proceed with many tasks concurrently. Split of control is shown by a single transition dividing into multiple arrows, each pointing to different substates.
The regions execute independently of one another.



Figure 10-44: Split of control and merge of control using the synchronization bar.


Merge of control- based on the completion of a number of transitions, you want to proceed with a single task. A merge is the opposite of a split.

2. Synch states

Figure 10-45: Using sync states to coordinate behaviors across regions.


When state B1 is completed, it trasitions to a split point. At split point a transition is send to a sync state, modeled as a circle containig an asterisk(*). The transition to C2 has to wait for the completion of both B1 and C1, even though B1 is not in the same region.


3. Multiple transitions out of a superstate

There are three ways that the object can exit the composite state.



Figure 10-46: Multiple ways to exit a composite state with concurrent substates.

1. Some type of interrupt event, such as T1.
2. All three substate regions could run to completion.
3. A specific event, such as T2.

No comments: