architecture - state machine with self transition but different entry actions -


i have state machine,

s1--->inp x, guard condition = y---->s1 (self transition s1 after executing, action1()

s1--->inp x, guard condition = !y---->s1 (self transition s1 after executing, action2()

so difference between 2 inputs is executing different action,

i feel wrong here, should doing different ?

you can't have 2 alternate entry actions in same state. whole point state independent of route got there. have 2 options:

  1. put actions on transitions. uml allows transition have 3 parts:
    • a triggering event
    • a guard condition
    • an action executed if event occurs , guard true. action completed before transition target state occurs.
  2. create 2 further states, 1 each of action1() & action2(). state s1 have 2 exiting transitions, 1 each of new states. transition 1 labelled x[y] , lead state containing action1(). similar action2(). each new state have transition s1 executed action complete.

which choose largely stylistic if diagram conceptual. if you're translating directly code you'll need consider semantics. option (1) more concise visually, means transition not 'instantaneous'. environments - real-time / embedded - may significant.

hth.


Comments