4

I read a lot about it, but still not sure in what order states executes (in Composite States) and how exactly deep and shallow history works? Could anybody help me? I have an example, which I'm not sure how to solve, here it is: enter image description here

I would appreciate any help!

gariaable
  • 179
  • 1
  • 3
  • 15
  • Is this a homework assignment? It would be better if you specify further what exactly you do and do not understand and *what have you tried to figure out the solution*. If your question is too broad (which it currently is), it will likely be closed. – Peter Uhnak Jan 12 '16 at 04:16
  • 2
    It's one of last year exams' questions. So first of all I'm not sure if I always should start from initial point, which is outside of all composites? I think so, but if first event is e1, then maybe I should start with this one which is inside? 2)IF I would start with this initial point on the left then before going inside of B state I should already execute "entry/x=x*2" operation? 3) As I believe when I leave state Y, my x should have a value of 7, but where should I go when I meet H..? – gariaable Jan 12 '16 at 05:51

2 Answers2

5

Question 1:

... not sure .. how exactly deep and shallow history works?

Answer 1:

Note this:

A shallow history is indicated by a small circle containing an "H". It applies to the state region that directly encloses it.

Shallow history pseudostate represents the most recent active substate of its containing state (but not the substates of that substate). ...

Source: http://www.uml-diagrams.org/state-machine-diagrams.html#shallow-history-pseudostate

Question 2:

... I'm not sure if I always should start from initial point, which is outside of all composites?

Answer 2:

Yes. You start from the Initial Pseudostate of the root state (A in this case).

Example:

For the given state-chart and event chain, you would get the following result (simulated with Rhapsody):

after default transition to A

  • value of x (transition to A): x = 3
  • value of x (entry A): x = x * 2 = 6
  • new state: A

after default transition to A::B

  • new state: A::B
  • value of x: x = 6

enter image description here

after e1

  • value of x (entry A::C): x = x + 1 = 7
  • new state: A::C

after default transition to A::C::G

  • value of x (entry A::C::G): x = x + 1 = 8
  • new state: A::C::G

enter image description here

after e3

  • value of x (exit A::C::G): x = x - 2 = 6
  • value of x (entry A::C::H): x = x / 2 = 3
  • new state: A::C::H

enter image description here

after e4

  • value of x (entry A::C::G): x = x + 1 = 4
  • new state: A::C::G

enter image description here

after e6

  • value of x (exit A::C::G): x = x - 2 = 2
  • value of x (exit A::C): x = x - 1 = 1
  • value of x (exit A): x = x - 1 = 0
  • value of x (transition to Y): x = (x * 4) + 2 = 2
  • new state: Y

enter image description here

after e7

  • value of x (entry A::C see the note above): x = x + 1 = 3
  • value of x (entry A::C::G): x = x + 1 = 4
  • new state: A::C::G

enter image description here

e4 is discarded

enter image description here

sergej
  • 17,147
  • 6
  • 52
  • 89
0

after e7

value of x (exit Y): x = x / 2 = 1

value of x (entry A): x = x * 2 = 2

value of x (entry A::C see the note above): x = x + 1 = 3

value of x (entry A::C::G): x = x + 1 = 4

new state: A::C::G

eylay
  • 1,712
  • 4
  • 30
  • 54
vadim
  • 1