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