Ordering and Timing of State Machine transitions

78 Views Asked by At

This is not a problem but more of a fundamental question, that I know will have been implemented differently by each of the tool suppliers, so I want what people believe to be the intended behaviour by the OMG UML/SysML working groups.

In the following image of a complex state, and I know there are a lot of untriggered and only guarded transitions. Is the do behaviour of the state Motion::Active::Debounce trigger if the guard on the exiting transition is true before the entry behaviour is completed?

enter image description here

Or, would you model this in a different manner?

2

There are 2 best solutions below

10
qwerty_so On BEST ANSWER

The UML 2.5.1 spec states on p. 309:

14.2.3.4.3 State entry, exit, and doActivity Behaviors

[...]

A State may also have an associated doActivity Behavior. This Behavior commences execution when the State is entered (but only after the State entry Behavior has completed) and executes concurrently with any other Behaviors that may be associated with the State, until:

  • it completes (in which case a completion event is generated) or
  • the State is exited, in which case execution of the doActivity Behavior is aborted.

The execution of a doActivity Behavior of a State is not affected by the firing of an internal Transition of that State.

So: the doActivity will be triggered but aborted immediately since the exit condition is true. In other words: it will not run.

0
Axel Scheithauer On

Yes. The do-behavior will be executed completely.

Here is the explanation: What you call an "untriggered" transition is in fact a transition without explicit trigger.

UML 2.5.: A special kind of Transition is a completion Transition, which has an implicit trigger. The event that enables this trigger is called a completion event and it signifies that all Behaviors associated with the source State of the completion Transition have completed execution.

All behaviors means:

UML 2.5: a completion event is generated when the associated entry and doActivity Behaviors have completed executing.

The time when the guard becomes true has no significance for the transition. It is a guard and as such will be evaluated only once at the moment the event triggering the transition is dispatched. Since this event is the completion of the do-behavior, the do-behavior will complete before the guard is evaluated.