QM  6.1.1
Model-Based Design Tool
Loading...
Searching...
No Matches
Working with Transitions to History

Working with Initial TransitionsWorking with Submachine Diagrams

Sometimes in hierarchical state machines you need to transition out of a composite state, but later you wish to come back to the most-recent active substate of this composite state. In UML, this coming back to the most-recent substate is accomplished by the transition to history feature. Actually, the UML specification distinguishes between two types of "transition to history":

  • shallow-history (shown as a circled letter H) is a shorthand notation that represents the most recent active direct substate of its containing state. A transition coming into the shallow-history vertex (called a transition to history) is equivalent to a transition coming into the most recently active direct substate of a state.
  • deep-history (shown as a circled H*) is similar to shallow-history except it represents the most recent leaf-substate of the composite state.

QM™ supports directly the "transition to history" feature for all QP framework types (qpc and qpcpp) as well as both QHsm-style state machines and QMsm-style state machines. Also, starting from version 4.0.0, QM supports both the deep history transition type denoted as a circled letter (H+) and the shallow history transition type denoted as a circled letter (H).

Transition to deep history

In most UML tools, the process of drawing a "transition to history" consists of first adding a history pseudostate (a circle with the letter H) and then attaching to it a transition to indicate the default substate, before the composite state has ever been visited.

In QM™, however, this process is simplified, because the State Machine Toolbox contains a ready-to-use History Segment tool, which combines a "history pseudostate" with a transition to the "default substate" permanently attached to it.

Note
A UML transition-to-history connector (of any type) can optionally have an outgoing transition pointing to the substate of the composite state. This is the way to designate a default substate, when the composite state has no history yet (has never been active before). In UML, the outgoing transition from the history connector is optional, but this leaves the "default substate" unspecified in case when the composite state has no history yet (has never been active before). The QM™ tool does not allow such incomplete history connectors and therefore the History Segment tool requires you to always attach it to an existing "default substate".

Adding History to a Composite State

You select the History Segment tool by clicking on the button the State Machine Toolbox. At this point, when you hover the mouse over the active state diagram, the mouse pointer changes to the history transition tool. To add a history transition, move the mouse to the edge of the desired composite state and press and hold down the left mouse button. At this point the mouse pointer changes to the history transition with the "forbidden" icon (). Next, you need to drag the mouse to an edge of the desired substate of the composite state. (If you release the mouse button without reaching any substate edge, the QM™ tool will delete the transition.) When you drag the mouse pointer over a state edge, the mouse pointer changes to the history transition with an anchor (), which indicates that you can anchor the end of the history transition connector at this edge. To anchor the history transition, release the mouse button.

Note
A given composite state can have at most one History Transition at its edge.
Adding History Transition to a Composite State
Attention
The QM™ tool permits you to attach the History Segment only to an edge of a composite state, as opposed to its interior (as in other UML tools). This is intentional to make transitions to history also available in Submachine Diagrams.
History inside a submachine (top) and at the boundary of a submachine state (bottom)

Adding History to a Submachine Diagram

History Segment can also be added to a Submachine Diagram in a similar way as it can be added to a composite state.

Note
Because the History Segment is attached to the boundary of the Submachine, it appears on the boundary of all associated Submachine States in the same consistent manner as all the Entry-Points and Exit-Points. In other words, the History Segment becomes part of the Submachine interface.
History Transition in a Submachine Diagram
Note
A given Submachine Diagram can have at most one History Transition at its boundary. The History connector is not allowed in any sub-states nested within the submachine, and the QM tool does not allow attaching the History connector to the sub-states of a submachine.

Invalid History Transitions

As you keep working on your state diagram, some history transition(s) might easily become invalid. For example, after resizing of a state the target substate of a history transition might fall outside of the state shape, such that it no longer is a substate of the composite state. Such invalid history transitions are shown with dashed line.

Adding Incoming Transition to State History

Once a composite state has a History Transition at its edge, it can become a target of regular state transitions. All such transitions will then lead to the history of the composite state. There is no limit on the number of such incoming transitions.

To attach a transition to a given history connector, select the desired transition and hover your mouse over its end (this can be either a regular transition , or an internal transition ). Once the mouse pointer changes to a hand, you can drag the transition end to the history connector. When you are over the history connector, the cursor changes into a circle with letter 'H' in it. At this point you release the left mouse button to "drop" the transition end on the history connector. As mentioned above, you can attach multiple transition ends to a given history connector.

Attaching a Transition to History of a Composite State

To disconnect a given transition from a history connector, you first select this transition by clicking on one of its segments. Then, you hover the mouse cursor over the history connector, until it changes into a circle with letter 'H' in it. You can then drag this transition end to a desired new location, which might be an edge to the new target state, or away from any state edge, at which point it becomes an internal transition (see also transition type).

Transition to History Property Sheet

The History Transition item has a simple Property Sheet that currently does not contain any configurable parameters.

Transition to History Property Sheet

The Transition to History property sheet contains the following properties:

Target

The target property is not editable directly, but rather it is determined geometrically by the end-point of the transition to history. The target property determines the value of the history before the composite state has been visited.

Is Shallow

The Is shallow property specifies the type of the transition to history. When the checkbox is unchecked, the history transition is to deep history, which is indicated by the circled (H+). When the checkbox is checked, the history transition is to shallow history, which is indicated by the circled (H).

Working with Initial TransitionsWorking with Submachine Diagrams