I am designing a state machine using UML2 statecharts.
There is an embedded "controller" state machine, which in the state WAITING_FOR_CONNECTION is waiting for an online connection to be established. The entire connection handling is performed in a second "communication" state machine.
When the controller enters the WAITING_FOR_CONNECTION state, and the connection is not yet established, it just waits for the trigger "connectionEstablished" to initiate the corresponding state transition. But what if the online connection is already available? There will be no trigger fired, and a guard on the connection status won't help, because the guard is evaluated once on a trigger only.
One solution I can think of is to have two transitions to the same target state: One default transition without explicit trigger but with a guard "isOnline", and one transition with trigger "connectionEstablished". A rather clumsy solution, I think.
What I am looking for is a "level trigger" instead of the usual "edge trigger" semantics. Does the UML2 state chart specification provide for such a trigger type? Comparable with then "when" condition in Modelica, for example. The controller would enter the WAITING_FOR_CONNECTION state and transition when the online connection became available.
You can use a null triggered transition. This is a transition with no tigger and only a guard, the guard in this case being "[isConnected]". The semantics are:
Note that the trigger is evaluated only on entry, a second completeion transition or explicit connect/ transition is necessary for change-of-state. See slide 72 in the Bruce Powell-Douglass link above for an example.
Alternatively you could have a choice pseudo-state before the wait state that bypasses it if already connected. This differs from the null trigger in that no entry actions are performed, but if you have none in any case it will behave in the same manner.