3

In the given example: enter image description here

What are the conditions to move from S0 to S2? Does e1 and [x==6] need to be true, or is it enough that only one of them will be true to move to the s2 state?

user3636583
  • 177
  • 1
  • 3
  • 11

2 Answers2

4

Those are two separate transitions, so only one event needs to fire.

You didn't ask, but be aware that when in state s1, event e1 is non-deterministic. The reason is that there are two competing transitions available.

I'll point out, as suggested by @thomas, that you could make the guard also apply to the event e1 by adding that guard to that event. It would look like e1[x==6].

Jim L.
  • 6,177
  • 3
  • 21
  • 47
  • The `[x==6]` transition has no event. `[x==6]` is a guard. – sergej Feb 14 '16 at 13:16
  • The transition is triggered by a completion event and only applies if that guard condition evaluates to true. – Jim L. Feb 14 '16 at 15:21
  • 4
    To have the AND condition the `e1` would need the guard at the same transition arrow. Maybe that could be noted in the answer too. – qwerty_so Feb 14 '16 at 15:33
1

In UML, internal transitions have priority over external ones (see "transition selection algorithm" in section 15.3.12 of the UML 2.4.1 spec), so while in s0, getting e1, will always fire the internal transition. So the only way to move to s2 is sending e1 three times which will turn the condition of the guard to true and thus the run to completion step will take the transition to s2. BTW, even though the guard will be enabled and the transition to S2 will occur, the value of x will actually be 7 when reaching s2 because of the exit action of s1.

  • There are no internal transitions in the OP diagram. The transition s1::e1 is a self-transition, not an internal transition. But it is true that while the state machine is in s0::s1, event e1 will trigger s1::e1, because the sub-state has always precedence over superstate (that's the semantics associated with state nesting, not with internal transition). BTW, when s1::e1 is triggered, the event is consumed and the supperstate s0 will never execute s0::e1, or the completion tranisition s0::[x==6]. Therefore there seems to be no path from s0 to s2. The state machine is just wrong. – Miro Samek Mar 14 '16 at 00:34