Prev | Next |
Pseudostates - The Traffic Police
The Transition relationships that connect States in a StateMachine diagram need to be orchestrated to ensure that the StateMachine is representative of the freedoms that a Block has to change its state in the physical world. Pseudostates are nodes that are used to direct the flow along transitions. The nodes can appear at the beginning, along the path of a transition or at the end. Types of pseudostate include:
- Initial - used to initiate a StateMachine
- Fork and Join - used to split and reunite a Transition
- Terminate - used to end a StateMachine
- Join - used to reunite a number of Transitions
- Junction - used to split a Transition
- Entry and Exit Point - used on the boundary of a SubMachine State
- Deep and Shallow History - used as mementoes when a composite State is exited
We will look at each in a little more detail and show how Enterprise Architect can be used to create and manage these important nodes. it is important to understand that the Final State - which has an analogous icon to the Initial pseudostate - is in fact a State in its own right.
Initial
The Initial pseudostate is the most widely used of all the nodes and represents the stating point for a region. There can only be one Initial in a region and a single transition is permitted to emerge from the Initial pseudostate. Because it is the starting point it would not make sense to have a trigger or a guard - the pseudostate simply becomes active when the region is entered, a modeler can however define an effect. Some system engineers will leave this all-important pseudostate off diagrams, reasoning that its position is implied, but it is considered good practice to include them as formally the starting point is undefined without them. It is, however, common practice to leave the Initial pseudostate unnamed.
Enterprise Architect will also rely on the StateMachines being well formed, and that each region has an initial pseudostate defined, when a modeler is working with Executable StateMachines or running simulations to visualize the States a Block instance will transition through in its lifetime.
Fork and Join
When Regions are used in StateMachine diagrams, it often necessary to split a transition that targets the State into multiple transitions such that each outgoing transition targets a given State in each orthogonal Region. The outgoing transitions from a Fork pseudostate are restricted and cannot have a guard or a trigger defined but an Effect can be defined. This ensures that multiple regions can simultaneously have active states.
Joins work in an analogous but opposite way to unite incoming transitions from multiple regions. The reverse restriction applies such that the incoming transitions cannot have a guard or a trigger defined but an Effect can be defined. The Effects for all incoming transitions must be completed before the outgoing transition can fire.
Terminate
The Terminate pseudostate is a useful node to ensure that an entire StateMachine is shut down. Regardless of what level in a State hierarchy the node is located, all regions and all levels of the hierarchy will terminate. It is a final node in the sense that the owning StateMachine will immediately stop executing. The termination is not 'graceful' and any behaviors that are currently being executed will simply stop; no exit behaviors will be executed. This diagram shows a Composite State with a single region; if there is a Pressure Leak the operation of the Autoclave must be immediately terminated, so there is a transition from the operating state to the Cycle Aborted Terminate pseudostate.
Enterprise Architect allows this node to be placed at any level and in any region and will honor its semantics in Executable StateMachine simulations.
Junction
The junction pseudostate is used to model transitions with compound paths There are both inbound and outbound transitions that are connected to a junction, but during the execution of the StateMachine only one of the inbound and one of the outbound transitions will fire. The outbound transitions are protected by guards and only the transition with a guard whose expression first evaluates to Boolean true will fire and carry the outgoing token.
Entry and Exit Point
The Entry point and Exit point pseudostates are used to allow a StateMachine to be reused as a sub-machine State in multiple contexts; they can also be used on a composite State. These pseudostates appear as small circles that straddle the boundary of a composite State or a sub-machine State; the entry point is empty whereas the exit point has a small x inside the circle.
Their position on the boundary is significant because, from a visual syntax point of view, they allow messages between the inside and outside of the element to be conveyed.
Deep and Shallow History
The History pseudostate is like a bookmark or memento for a Composite State, and simply stores the name of the sub-state that was active when the region was exited. When the region is subsequently re-entered, the StateMachine resumes its transitions from the sub-state specified by the History. It is possible that for some reason a region could be re-entered and the History is unable to provide the last State; this situation can be handled by a modeler pre-emptively creating a Transition from the History pseudostate to a target default sub-State; the Transition would only be used in the event that the History was unable to provide the memento.
In this example of a Tubular Centrifuge, a System Engineer has placed a Shallow History State in the operating Composite State, indicating that if that start is exited while a given State is active, and then the State is subsequently re-entered, the execution will resume at the active sub-state. The transition exiting the History indicates, in the event that the owning State is re-entered and the machine did not know which State to make active, Rinsing would be selected.
Both Shallow and Deep History States work the same way except that a Shallow History pseudostate only remembers the active sub-states in the owning Region, a Deep History can remember down to any level in a sub-state hierarchy. The Deep History is indicated visually by an asterisk placed after the H*.