StateGraph example event handling clarification
We have identified an issue in some StateGraph example models that can affect the simulation result depending on the order in which the events get handled. We are looking for clarification on the event firing order.
Specifically, looking at the FirstExample_Variant2 model, we have the following equations (post trivial simplification):
Events:
Event trigger#1: transition2.localCondition := greaterEqual.u >=1 Event trigger#2: RVAR := transition1.t_start + 1 <= T
Continuous equation:
greaterEqual.u := IF(step.localActive=true, T-timer.entryTime, 0.0)
Subset of discrete equations:
step.localActive := pre(step.newActive) timer.entryTime := WHEN(step.localActive, timer.entryTime=T) transition1.t_start := WHEN(transition1.enableFire, transition1.t_start=T)
Prior to any events firing at T=2.0, these are valued at:
transition2.localCondition := false RVAR := true
step.localActive := true timer.entryTime := 1.0 transition1.t_start := 0.0
At T=2.0 the continuous part evaluates to:
greaterEqual.u := 1.0
With the above values, event trigger #1 fires, which results in the following values at the end of the discrete event iteration:
transition2.localCondition := true RVAR := true
step.localActive := false timer.entryTime := 1.0 transition1.t_start := 2.0
Now if we handle event trigger #2 before evaluating the continuous equation then the simulation result is 'as expected'. The problem is that if we evaluate the continuous part before handling trigger #2 then:
greaterEqual.u := 0.0
and then both event trigger #1 and #2 switch from true to false. This causes step.localActive to switch back to true and thus the pulse of step.localActive remains in the ON position past T=2.0.
What is the expected event handling behaviour when two events fire at the same time point? Is it acceptable to perform continuous evaluation after the first event has been handled or does the second event need to be serviced prior to continuous evaluation?