Reputation: 143
I am designing a state-machine and have one specific state that I can enter from two different states... I am not sure how to go back to the previous state... or am I modeling it wrong ?
to illustrate :
| state | trigger | nextstate --------------------------------- 1. | initial | evtX | A 2. | initial | evtY | B 3. | B | evtX | A 4. | A | evtZ | ????
The last row is where I am having trouble. I need to transition to initial state, if A was arrived at from the transiton in row number 1 and I need to transition to state B, if A was arrived at from transition in row number 3.
How can i model this better ?
Upvotes: 0
Views: 201
Reputation: 9325
In fact, you have two different A states:
| state | trigger | nextstate
---------------------------------
1. | initial | evtX | A1
2. | initial | evtY | B
3. | B | evtX | A2
4. | A1 | evtZ | initial
4. | A2 | evtZ | B
If you want something more powerful, try with Harel/UML statecharts (which have 'superstates, orthogonal regions, and activities as part of a state" [1]). You might have a look at SCXML as weel [2]. I don't know any of them though.
[1] http://en.wikipedia.org/wiki/Harel_statechart#Harel_statechart
[2] http://en.wikipedia.org/wiki/SCXML
Upvotes: 1