0

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.

user2281723
  • 519
  • 1
  • 5
  • 16

2 Answers2

1

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.

www.admiraalit.nl
  • 5,768
  • 1
  • 17
  • 32
  • Clear and - I think - correct answer. The middle case would have been a kind of timed "do action", but you are right, most likely it is not standard, so I just leave it. – user2281723 Nov 12 '15 at 14:59
0

Generally states are drawn with rounded rect.

1) The notation along the transition is <trigger>/<effect>. The semantics of After(10) leaves some room for interpretation. So when the <trigger> fires it will perform <effect> and return to the same state.

2) I don't know this notation. You can specify entry/do/exit operations like this enter image description here

3) Is like 1 but enters a new state.

qwerty_so
  • 35,448
  • 8
  • 62
  • 86
  • You are right, I was a lazy with the graphics, it should have been rounded rectngle. As far as I know "After" and "At" are standard UML2 timer triggers. "After" sets up a one shot timer that triggers after the given time (in ms I guess) and the "At" is also a one shot timer, but not at a relative time point from now, but an absoulte time value (for example 6:00AM). My question is when shall I setup the timer and when shall I cancel it in case of a transition. Shall I setup after the Enter action or before? The same applies to the Exit. – user2281723 Nov 08 '15 at 19:00
  • 1
    You are right. 13.3.4 of UML 2.5 denotes them. But I think it's scrap as it is semantically indifferent. The example time was not written as UTC, so what time zone, please? Relative notation: After 5 minutes - well, how exact? For eggs it's okay +- 30 seconds. For a tech device you might need microseconds. Now which of the above 3 notations you need depends on your use case (which you did not describe). – qwerty_so Nov 08 '15 at 19:44