2

Provided I am in StateB now. Sig2 comes. So no entry or exit will be executed, but only Act5. So far so good.

Now we are in StateC, but this time Sig1 comes. There is an internal transition defined, but in the parent composite state. Do I have to exit from StateC, do the Act2 and go to the initial connector and enter StateB?

I did not find answer to this question in the UML standard.

State machine

user2281723
  • 519
  • 1
  • 5
  • 16

2 Answers2

2

You don't need to exit StateC, internal transitions of an owning state can always occur as long as you are in some of it's substates.

14.5.12.3 Literals

  • internal
    • Implies that the Transition, if triggered, occurs without exiting or entering the source State (i.e., it does not cause a state change). This means that the entry or exit condition of the source State will not be invoked. An internal Transition can be taken even if the SateMachine is in one or more Regions nested within the associated State.

This makes sense --- you are always in some substate of a composite state. (Once you enter a composite state it immediately (after entry behavior) goes to the first state).

And of course internal transitions do not change state configuration, so it will remain the same (<StateA::StateC>).

This all is of course assuming that you teleported into StateC, because that state is unreachable.

Peter Uhnak
  • 9,617
  • 5
  • 38
  • 51
  • I tend to interpret the last sentence as you do. However the standard could be a bit more specific in this regard. Thanks Peter! – user2281723 Nov 20 '15 at 07:01
  • There often tends to be some level of ambiguity (especially in state machines) so the end-user can decide the exact semantics depending on his needs. – Peter Uhnak Nov 20 '15 at 07:11
0

The Wikipedia article on UML statecharts currently makes an unambiguous assertion that resolves this:

In contrast to a self-transition, no entry or exit actions are ever executed as a result of an internal transition, even if the internal transition is inherited from a higher level of the hierarchy than the currently active state. Internal transitions inherited from superstates at any level of nesting act as if they were defined directly in the currently active state.

Unfortunately it's not sourced. I agree with @user2281723 that the spec is ambiguous. From § 14.2.3.8.1 of UML 2.5:

internal is a special case of a local Transition that is a self-transition (i.e., with the same source and target States), such that the State is never exited (and, thus, not re-entered), ..

If this means the entire active state configuration (all active states in the nested hierarchy) is not exited then there's no state change. If it means just the specific state that owns the internal transition is not exited, doesn't that mean all substates will be exited and the state with the transition will become the active state? That is the target state of the transition in the model.

I suspect the first meaning was intended by the spec writers and is the one used in practice. Hopefully a clarification will be added to the spec eventually.