Triggers and Transitions
The majority of connectors that you see on a StateMachine Diagram will be Transitions; these are the lines that connect one State to another, indicating the allowable ways the owning Block (instance) can change. The order in which they change and the behaviors that are executed will depend on the conditions and real world context of the Block. For example, a traffic light might flash amber until the maintenance engineer has rectified a fault, or an aircraft might maintain a holding pattern until the Control Tower at the destination airport gives landing clearance. This diagram shows two transitions that are directed in different directions, effectively creating the possibility of a cycle between the two States.
The transitions always originate from one State and target another, including the special case of a self-transition where the origin and the target are one and the same. The lines in the diagram have a label that can display a number of different options: Trigger, Guard and Effect. We will discuss these options in detail because they express important semantics about the transitions, including whether the transition will be executed at all. A transition can be in three conditions:
- Reached - the originating State (or Vertex) is active and ready to complete its behaviors
- Traversed - the transition is being executed (including any defined effect behaviors)
- Completed - the target state has been reached and is ready to execute entry behaviors
These terms will be useful to system engineers and others when working collaboratively, discussing the execution of a StateMachine and its description of the behavior of the owning Block.
Triggers are the initiators of a transition and are mapped to events that are said to trigger event occurrences. It is these triggers and their related events that result in a transition executing (firing) and the owning Block moving from one state to another. When a state is active it is effectively waiting to be triggered by an event, and as long as its entry action is completed - regardless of any other factors - it is ready to receive and respond to events.
This screen capture demonstrates how the Trigger, Guard and Effect can be entered and viewed in Enterprise Architect.
This diagram illustrates the way the Trigger, Guard and Effect are displayed on a diagram. The Effect in this case has been defined as a behavior and has been linked to an Operation defined on the Block.
Guards are the 'gate keepers' of a transition and it is only when the guard's expression evaluates to True that the transition will fire. If the expression evaluates to false the event will be consumed and there will be no observable change in the Block's state resulting from the trigger.
Apart from moving the owning Block from one state to another, the significance of the Transition relationship is that it can execute a behavior that could be an Activity or an Operation on the Owning Block or on any other Block. This behavior is in addition to the Exit behavior that might have been defined on the source State, and the Entry behavior on the target state. This ensures that there is a mechanism to change the behavior during the execution of the Transition.
Enterprise Architect has a wide range of tools and facilities for working with diagrams, including StateMachine diagrams, and these can be used to help create and visualize the information codified in the StateMachines. Particularly useful when working with Transitions is the ability to route connectors that help make the diagram more appealing. The line style for the connector in this diagram has been set to a Bezier Curve, giving the Transition a less rigid appearance.
The shape of the curve can be altered by dragging the construction point to a new location. Any one of a number of line styles can be used, providing the modeler with a toolkit of options for diagram presentation. This context menu can be selected and the line style set for each connector individually. The color and thickness of the line can also be set from the Layout ribbon.