Reputation: 143
I have a state machine, where
S1--->inp X, guard condition = Y---->S1 (self transition to S1 after executing, action1()
S1--->inp X, guard condition = !Y---->S1 (self transition S1 after executing, action2()
So the only difference between the two inputs is that it is executing a different action,
I feel something is wrong here, should I be doing something different ?
Upvotes: 1
Views: 1256
Reputation: 9960
You can't have two alternate entry actions in the same state. Whole point is the state is independent of the route you got there. You have two options:
action1()
& action2()
. State S1 would have two exiting transitions, one to each of the new states. Transition 1 would be labelled X[Y]
and lead to state containing action1()
. Similar for action2()
. Each new state would have a transition back to S1 which was executed as soon as the action was complete.Which you choose is largely stylistic if the diagram is conceptual. If you're translating directly to code then you'll need to consider semantics. Option (1) is more concise visually, however it means the transition will not be 'instantaneous'. For some environments - especially real-time / embedded - that may be significant.
hth.
Upvotes: 2