itemisCREATE / statecharts

YAKINDU Statechart Tools (http://www.statecharts.org)
Eclipse Public License 1.0
174 stars 84 forks source link

Event does not drive event-driven statechart #2125

Closed RainerKlute closed 6 years ago

RainerKlute commented 6 years ago

The following statechart should continuously execute the dicing loop. However, it gets stuck in the Rolling_the_dice state. It seems that the ev event raised in the state has either not been raised at all or is not processed correctly. In cycle-drive mode, the behavior is the same.

dice_rolling_050_event_driven

BeckmaR commented 6 years ago

I can confirm this issue - weird, I thought this works.

BeckmaR commented 6 years ago

This works when this is not the first state. The reason is that Entering the state machine does not trigger a full run cycle. The expressions in the initial state are evaluated though, but the internal event queue is not checked after that. Raising any event on the statemachine would make it run.

However, this particular statechart would of course run into an infinite loop, which is probably not desired. A stop condition should be considered.

All in all, this is more an issue of the actual handling of initial states than of internal events.

BeckmaR commented 6 years ago

After inspecting the generated code it becomes clear that this is indeed the expected behavior. The event gets raised as expected, but "entering" the statechart is not doing a runCycle, which is fully consistent with all code generators. A workaround would be to either just raise some event on the statechart or instead of entry declare a time event, which will trigger a runcycle when it elapses.