uscxml icon indicating copy to clipboard operation
uscxml copied to clipboard

Done event is generated before all parallel states are final

Open josvos opened this issue 6 years ago • 2 comments

The basic parallel example of section 3.1.3 of the SCXML spec (S1, S2, S11, etc.) does not seem to work as expected, When stepping through this example (slightly modified, to get the syntax errors fixed ;-) and adding log entries), I see that the event "e4" correctly activates S12, but then "e1" causes the "done.state.p" event to be generated, while only S1 is in final state, not S2.

In general, when an event causes transitions in both parallel states and only one of these transitions targets a final state, the "done.state.p" event is generated while it should not. If an event is only doing a transition (to a final target) in one of the parallel states, it is not generating the done event.

josvos avatar Mar 30 '18 13:03 josvos

I could reproduce with the next steps:

issue_with_done_state_2

<scxml name="ScxmlJoinParallel" version="1.0" xmlns="http://www.w3.org/2005/07/scxml">
	<parallel id="p">
		<transition event="done.state.p" target="someOtherState"/>
		<state id="S1" initial="S11">
			<state id="S11">
				<transition event="e4" target="S12"/>
			</state>
			<state id="S12">
				<transition event="e1" target="S1Final"/>
			</state>
			<final id="S1Final"/>
		</state>
		<state id="S2" initial="S21">
			<state id="S21">
				<transition event="e1" target="S22"/>
			</state>
			<state id="S22">
				<transition event="e2" target="S2Final"/>
			</state>
			<final id="S2Final"/>
		</state>
	</parallel>
	<state id="someOtherState"/>
</scxml>
Microstep in config: {}
Entering: /scxml[1]
Entering: p
Entering: S1
Entering: S11
Entering: S2
Entering: S21
Stable Config: { /scxml[1], p, S1, S11, S2, S21 }
Received :{"name":"e4"}
Expect input:
Internal Event: e4
Microstep in config: {/scxml[1], p, S1, S11, S2, S21}
Exiting: S11
Transition: //state[@id="S11"]/transition[1]
Entering: S12
Stable Config: { /scxml[1], p, S1, S12, S2, S21 }
Received :{"name":"e1"}
Expect input:
Internal Event: e1
Microstep in config: {/scxml[1], p, S1, S12, S2, S21}
Exiting: S21
Exiting: S12
Transition: //state[@id="S12"]/transition[1]
Transition: //state[@id="S21"]/transition[1]
Entering: S1Final
Entering: S22
Internal Event: done.state.S1
Internal Event: done.state.p
Microstep in config: {/scxml[1], p, S1, S1Final, S2, S22}
Exiting: S22
Exiting: S2
Exiting: S1Final
Exiting: S1
Exiting: p
Transition: //parallel[@id="p"]/transition[1]
Entering: someOtherState
Stable Config: { /scxml[1], someOtherState }

P.S. But if we start from event 'e1' everything is working correctly state_chart

Microstep in config: {}
Entering: /scxml[1]
Entering: p
Entering: S1
Entering: S11
Entering: S2
Entering: S21
Stable Config: { /scxml[1], p, S1, S11, S2, S21 }
Received :{"name":"e1"}
Expect input:
Internal Event: e1
Microstep in config: {/scxml[1], p, S1, S11, S2, S21}
Exiting: S21
Transition: //state[@id="S21"]/transition[1]
Entering: S22
Stable Config: { /scxml[1], p, S1, S11, S2, S22 }
Received :{"name":"e4"}
Expect input:
Internal Event: e4
Microstep in config: {/scxml[1], p, S1, S11, S2, S22}
Exiting: S11
Transition: //state[@id="S11"]/transition[1]
Entering: S12
Stable Config: { /scxml[1], p, S1, S12, S2, S22 }
Received :{"name":"e2"}
Expect input:
Internal Event: e2
Microstep in config: {/scxml[1], p, S1, S12, S2, S22}
Exiting: S22
Transition: //state[@id="S22"]/transition[1]
Entering: S2Final
Internal Event: done.state.S2
Stable Config: { /scxml[1], p, S1, S12, S2, S2Final }
Received :{"name":"e1"}
Expect input:
Internal Event: e1
Microstep in config: {/scxml[1], p, S1, S12, S2, S2Final}
Exiting: S12
Transition: //state[@id="S12"]/transition[1]
Entering: S1Final
Internal Event: done.state.S1
Internal Event: done.state.p
Microstep in config: {/scxml[1], p, S1, S1Final, S2, S2Final}
Exiting: S2Final
Exiting: S2
Exiting: S1Final
Exiting: S1
Exiting: p
Transition: //parallel[@id="p"]/transition[1]
Entering: someOtherState
Stable Config: { /scxml[1], someOtherState }

alexzhornyak avatar Mar 12 '21 09:03 alexzhornyak