Prev | Next |
StateMachines
StateMachines illustrate how an element (often a Class) can move between States, classifying its behavior according to transition triggers and constraining guards.
You generate StateMachine elements and connectors from the 'State' pages of the Diagram Toolbox.
Naming
- StateMachines were formerly known as State diagrams
- StateMachine representations in UML are based on the Harel State Chart Notation and therefore are sometimes referred to as State Charts
State Tables
You can display a StateMachine as a diagram, or as a table in one of three relationship formats.
Select the display format
Step |
Action |
See also |
---|---|---|
1 |
Right-click on the diagram background and select the 'Statechart Editor' option. |
|
2 |
Select the appropriate display option:
|
StateMachine Table |
Example Diagram
This diagram illustrates some features of StateMachines.
Composite Diagram States
The chain-link symbol in the bottom right corner of the Saved State indicates that it is a State with a Composite diagram.
You have two options for displaying the contents of a State's Composite diagram. Firstly, you can double-click on the parent element to display its child diagram separately, as shown here:
By default, the child diagram displays within a labeled frame that represents the parent object in the context of the child diagram. You can right-click on the background and select the 'Hide Diagram Frame' option to hide the frame, and on the 'Show Diagram Frame' option to show the frame again.
Alternatively, you can right-click on the composite element on the main diagram and select the 'Advanced | Show Composite Diagram' option, which again displays the child diagram in a labeled frame, but this time within the context of the parent diagram.
ProtocolStateMachines
The OMG UML specification (UML Superstructure Specification, v2.5, sect. 14.4) states:
"ProtocolStateMachines are used to express usage protocols. ProtocolStateMachines express the legal sequences of Event occurrences to which the Behaviors of an associated BehavioredClassifier must conform. The StateMachine notation is a convenient way to define the order of invocations of the behavioral features of a Classifier. ProtocolStateMachines can be associated with Classifiers, Interfaces, and Ports."
To create a ProtocolStateMachine, create a StateMachine element and open the Properties window for that element. Select the 'Behavior' tab and, on that, select the 'Protocol State Machine' checkbox. The element on the diagram now has the word <<protocol>> above the element name.
StateMachine Diagram Element Toolbox Icons
Icon |
Description |
See also |
---|---|---|
A State represents a situation where some invariant condition holds; this condition can be static (waiting for an event) or dynamic (performing a set of activities). |
State | |
A StateMachine element is a container for groups of related State elements. |
StateMachine | |
The Initial element represents a pseudo-state used to denote the default state of a Composite State; there can be one Initial vertex in each Region of the Composite State. |
Initial | |
The Activity Final element indicates the completion of an Activity; upon reaching the Final, all execution in the Activity diagram is aborted. |
Final | |
There are two types of History pseudo-states defined in UML: shallow and deep history. |
History | |
A Synch state is useful for indicating that concurrent paths of a StateMachine are synchronized. They are used to split and rejoin periods of parallel processing. |
Synch | |
An Object is a particular instance of a Class at run time. |
Object | |
The Choice pseudo-state is used to compose complex transitional paths, where the outgoing transition path is decided by dynamic, run-time conditions. |
Choice | |
Junction pseudostates are used to design complex transitional paths in StateMachine diagrams. A Junction can be used to combine or merge multiple paths into a shared transition path. |
Junction | |
Entry Point pseudostates are used to define the beginning of a StateMachine. An Entry Point exists for each region, directing the initial concurrent state configuration. |
Entry Point | |
Exit Points are used in StateMachine elements and StateMachine diagrams to denote the point where the machine is exited and the transition sourcing this exit point. |
Exit Point | |
The Terminate pseudostate indicates that upon entry of its pseudostate, the StateMachine's execution ends. |
Terminate | |
A Fork/Join element can be used to: 1) split a single flow into a number of concurrent flows, 2) join a number of concurrent flows or 3) both join and fork a number of incoming flows to a number of outgoing flows. |
Fork/Join Fork Join | |
A Fork/Join element can be used to: 1) Split a single flow into a number of concurrent flows 2) Join a number of concurrent flows or 3) Both join and fork a number of incoming flows to a number of outgoing flows |
StateMachine Diagram Connector Toolbox Icons
Icon |
Description |
See also |
---|---|---|
A Transition connector represents the logical movement from one State to another in a StateMachine diagram. |
Transition | |
An Object Flow connects two elements, with specific data passing through it, modeling an active transition. |
Object Flow |
Notes
- State elements can display either with or without a line across them; the line - as shown - displays when the element has features such as operations (which could be hidden) or when the 'Show State Compartment' checkbox is selected in the 'Objects' page of the 'Preferences' dialog
- It is possible to add Entry Point and Exit Point elements to the border of a State or StateMachine element - right-click on the element in the diagram and select the 'New Child Element| Entry Point' or 'Exit Point' option; if the element is a composite element and represented by a frame, you can also right-click on the selected frame and add the Entry Point or Exit Point elements
- If you have Entry Points and/or Exit Points on a StateMachine that is a classifier for another State, you can create Connection Point References to the classifier from the other State
- It is also possible to add Regions to a State element or StateMachine element frame; right-click on the selected frame and select the 'Define Concurrent Substates' option
- You can perform model simulations on StateMachine models, and the model that you simulate can contain elements from more than one Package; to include the external elements in the simulation, you must create a Package diagram containing the 'parent' Package and the 'external' Packages containing the external elements, and then create a Package Import connector from the parent Package to each external Package