Completion events are standard UML events which are fired during the execution of a state machine diagram.
For composite or submachine states, a completion event is generated under the following circumstances:
When all internal activities (e.g., entry and doActivity Behaviors) have completed execution, and
If the State is a composite State, all its orthogonal Regions have reached a FinalState, or
if the State is a submachine State, the submachine StateMachine execution has reached a FinalState.
There is an option, named Completion Events and Transitions, in the simulation environment options for enabling/disabling completion events and transitions support.
Figure 1: Completion events and transitions environment value
Figure 2: Completion events and Transitions in a state machine diagram
For example, in the above state machine diagram, a transition from the "on" state to the "off" state does not happen until a completion event is generated. The completion event is generated after the DoActivity behavior completes and only then the state transits from "on" to "off".
Figure 3: Completion Events and Transitions in a state machine diagram
In the above state machine diagram, a completion event is generated after the entry and sendOff behaviors have completed.
Figure 4: Completion Events and Transitions in a state machine diagram
In the above state machine diagram, a completion event will be generated after the entry and working behaviors have completed.
Completion events have dispatch priority over all other events. They are put into the beginning of the event queue.