10

As already asked in http://www.eclipse.org/forums/index.php/t/452409/ I am not sure I correctly got the meaning of local transition and I'd like to know whether I am using them with the right semantics or not

Are these two state machines equal?

State Machine with local transition

State Machine with no local transition

Andrea Sindico
  • 7,358
  • 6
  • 47
  • 84

1 Answers1

5

Under UML 2.4.1, the first diagram shows a local transition from State1 on receipt of trigger where the second shows transitions between sub-states on receipt of trigger. An external transition from State1 would be shown by the arrow pointing out of State1 then curving back into it (Figure 15.48 of the superstructure specification).

Section 15.3.15 TransitionKind of the UML Superstructure 2.4.1 gives the semantics of internal, local and external transitions:

kind=local implies that the transition, if triggered, will not exit the composite (source) state, but it will apply to any state within the composite state, and these will be exited and entered.

As neither local nor transitions between sub-states will cause State1 to be exited, the diagrams show similar state machines - the difference being that from State1.3 the first machine will re-enter State1.3 (causing its exit and entry behaviours to be invoked) whereas the second will do nothing from State1.3 on trigger.

Pete Kirkham
  • 48,893
  • 5
  • 92
  • 171
  • An external transition is a transition that exits its source Vertex. Thus state1.1->state1.3; state1.2->state1.3 and state1.1->state1.2 are external transitions – Andrea Sindico Feb 09 '13 at 12:24
  • I think the local transition in the first diagram would cause the execution of the exit behavior of the current State1 substate (not the exit behavior of the State1 state) followed by the entry behavior of the State1.3. – Andrea Sindico Feb 09 '13 at 12:29
  • As far as I understand, the only difference with the second diagram is the lack the transition state1.3->state1.3 with the same trigger which is in fact also represented by local transition in the first SM – Andrea Sindico Feb 09 '13 at 12:30
  • an internal transition is defined by the UML specification as a special case of a local Transition that is a self-transition (i.e. with the same source and target States). a further reason to claim state1.1->state1.2; state1.1->state1.3 and state1.2->state1.3 are not internal – Andrea Sindico Feb 09 '13 at 12:46
  • @Sindico The transitions state 1.1 -> state 1.2 etc. are internal to state 1 - they do not cause the exit behaviour of state 1. They are external to the sub-states involved - they do cause the exit behaviour of state 1.1 and the entry behaviour of state 1.2. You have to be a bit careful about the context and sometimes have to say what the transition is internal/external to to be clear. – Pete Kirkham Feb 09 '13 at 15:06
  • according to the UML specification an internal transition is a local transition having as target state the source state. I think this condition does not hold for the transitions you mentioned – Andrea Sindico Feb 09 '13 at 15:12
  • @Sindico 15.3.14 'semantics' "An internal transition executes without exiting or re-entering the state in which it is defined." the transition 1.1 -> 1.2 is defined in state1, and does not exit or re-enter state 1. Therefore it is internal. The part you're looking at in 15.3.15 is IMO badly phrased - it implies that only reflexive transitions are internal, and that internal transitions don't cause any actions to be performed. So by that definition, internal transitions leave the system in the same state with no side effects - empirically, they don't even exist! So I would go with 15.3.14 – Pete Kirkham Feb 09 '13 at 15:24
  • and you go wrong. In fact in the same section you mention the third OCL constraint says [3]: A transition with kind internal must have a state as its source, and its source and target must be equal. context Transition inv: (kind = TransitionKind::internal) implies (source.oclIsKindOf (State) and source = target) – Andrea Sindico Feb 09 '13 at 15:32
  • As far as I understand internal transitions are, as you correctly noticed, all reflexive. In UML 2.5 I have seen their representation is as sentences formatted like trigger/actions in the state to which they apply. Internal transition are just a means to say if some event occurs while the system is in a certain state execute a behavior without changing ait. – Andrea Sindico Feb 09 '13 at 15:44
  • @Sindico I've checked the 2.5 draft and it's a lot clearer and you are correct. Although most other notations call a transition between sub-states an internal transition, UML takes internal/external with respect to the source state instead. If State1 was modelled without a nested state machine, the transitions which consume `trigger` would be internal transitions, but once those transitions are modelled using a nested state machine the transitions are external to those sub-states and so are 'external' transitions. – Pete Kirkham Feb 09 '13 at 20:07
  • hi Pete, please also check what I said about local transitions. I guess in both the SMs the State1.1 and State1.2 exit behaviors would be executed. The only (but important) difference is that in the first SM the State1.3 would exit and enter itself if the trigger occurred. Thus to be the same the second SM should have a State1.3->State1.3 transition with the same trigger. If you agree with this change your answer. Regards. – Andrea Sindico Feb 10 '13 at 08:37