Search code examples
umlstatechart

State machine timer self transition


enter image description here

Please explain to me if I get right the meaning of these 3 state machines.

1, StateA Enter action is called (which is nothing at the moment) and then the timer is set up. When the timer triggers Acion1 is executed, then the StateA Exit action (also nothing) is executed, then the whole loop repeats. So StateA Enter action, setting up the timer, etc. This makes a kind of polling with Action1

2, StateB Enter action is called, timer set up and triggers after 10ms and executes Action2. The timer will be not renewed, so it is a kind of delayed action on the state

3, StateC Enter action, Timer is set up, when triggers then Action3 is called, then StateC Exit action and finally StateD Enter action is executed.

Please confirm or correct if it is correct.


Solution

  • 1: Your description is correct, with one exception: the exit action is executed before Action1 is executed, at least, that is how I interpret the UML 2.5 spec. Section 14.2.3.4.6 says:

    If the composite State has an exit Behavior defined, it is executed (...) before any effect Behavior of the outgoing external Transition.

    I think you can safely assume that this is also true for non-composite states, but the UML 2.5 spec should be more explicit in this respect.

    2: I don't think this is a proper UML notation, so I cannot confirm or deny your description.

    3: This state machine diagram does not specify whether the initial state is StateC or StateD. If it is StateC, then your description is correct, with the exception that StateC's exit action is executed before Action3. To be unambiguous, the diagram should have an initial pseudostate (filled circle) with a transition from the initial pseudostate to StateC.