Illegal state transitions

23 views
Skip to first unread message

Mathew Benson

unread,
Nov 24, 2022, 11:47:03 AM11/24/22
to YAKINDU User
I'm using the C++ code generator.  How can I check for legal state transitions or be notified that an event did not result in a state transition?

Axel Terfloth

unread,
Nov 25, 2022, 4:35:19 AM11/25/22
to YAKINDU User
Hello,

by default the statechart execution semantics does not distinguish between legal and illegal events. Events can trigger transitions and are ignored if they are not relevant for the current state. This is compliant with the approach which you know from UML, SCXML etc.. Nevertheless there are different approaches to handle events that do not match any outgoing transition. 

One is to use callbacks triggered by local reactions. A states local reactions are executed if no outgoing transition can be taken. If you declare an operation callback in the declaration section:

    operation no_transition():void

and you declare the following local reaction within a state:

    always / no_transition

Then the callback is called whenever the state is active, an event was raised and no outgoing transition can be taken. This only works with event driven state machine execution.

Another  approach is to enable trace callbacks. If you add

        feature Tracing {

           enterState = true

           exitState = false

       }

to your .sgen file then you can set a trace callback. it will be called whenever a state is entered. So if you raise an event and the trace observer is not called, then no transition was taken. So this provides the inverse logic to the approach above.

There are definitely more approaches to handle this in the state machine itself but the proper choice depends on your concrete scenario.

Best regards,
Axel 

Mathew Benson

unread,
Nov 27, 2022, 7:02:06 PM11/27/22
to YAKINDU User
Thanks.
Reply all
Reply to author
Forward
0 new messages