commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rahul Akolkar <rahul.akol...@gmail.com>
Subject Re: [scxml] A local transition to a parallel sub-state affects all its parent's siblings
Date Tue, 26 Jul 2011 19:14:06 GMT
On Mon, Jul 25, 2011 at 6:31 AM, Hynek Cihlar <hynek.cihlar@gmail.com> wrote:
> I have come across the following case, where I believe the Commons SCXML
> behaves incorrectly.
>
> Assuming the following state machine configuration:
>
> <scxml xmlns="http://www.w3.org/2005/07/scxml"
>       xmlns:cs="http://commons.apache.org/scxml"
>       version="1.0"
>       initialstate="parallel">
>
>  <parallel id="parallel">
>
>    <state id="A">
>        <initial>
>            <transition target="A.1"/>
>        </initial>
>
>        <transition event="anEvent" target="A.2"/>
>        <transition event="anAEvent" target="A.3"/>
>
>        <state id="A.1"/>
>        <state id="A.2"/>
>        <state id="A.3"/>
>    </state>
>
>    <state id="B">
>
>        <initial>
>            <transition target="B.1"/>
>        </initial>
>
>        <transition event="anEvent" target="B.2"/>
>
>        <state id="B.1"/>
>        <state id="B.2"/>
>    </state>
>
>  </parallel>
> </scxml>
>
>
> First the event "anEvent" is triggered to bring the parallel states "A" and
> "B" from their initial states. Now, after triggering the event "anAEvent" I
> would expect only the state of "A" to be changed. Surprisingly the event has
> also effect on the "B" state, when it is brought to its initial state.
>
<snip/>

I understand why this could be slightly surprising, but this is
expected behavior.

There are two rules of execution that combine here:
(a) When a state machine follows a transition, it must leave the
source state (and enter the target)
(b) A state machine must be in all or none of the orthogonal siblings
(or regions of a parallel) at any given time

Now, with the above in mind, while processing "anAEvent" the state
machine must leave its source state "A" which happens to be a region
of the parallel, thereby the other region "B" must also be exited. On
reentry into these regions, the rest states are "A2" (explicit target
of transition) and "B1" (initial in absence of any explicit target).

Clearly, this behavior may not be what you desire. Couple of ways to
correct this and obtain the behavior you are after:
(1) Avoid having transitions that are placed in direct child states of
parallel, this may be done by having an intermediate "wrapper" state.
(2) Define the transition as "internal" so source state is not exited
in this case -- this is easier in theory but not supported by Commons
SCXML at the moment (patches to add support welcome).

-Rahul


> Tested on the svn revision 1143657, last changed date 2011-06-07 01:13:06
> +0200 (Tue, 07 Jun 2011).
>
> I am attaching the output log from the engine execution.
>
> 2011-07-25 12:26:56,419 INFO
> [org.apache.commons.scxml.env.SimpleSCXMLListener:44] : /parallel
> 2011-07-25 12:26:56,420 INFO
> [org.apache.commons.scxml.env.SimpleSCXMLListener:44] : /parallel/A
> 2011-07-25 12:26:56,421 INFO
> [org.apache.commons.scxml.env.SimpleSCXMLListener:44] : /parallel/B
> 2011-07-25 12:26:56,421 INFO
> [org.apache.commons.scxml.env.SimpleSCXMLListener:44] : /parallel/A/A.1
> 2011-07-25 12:26:56,421 INFO
> [org.apache.commons.scxml.env.SimpleSCXMLListener:44] : /parallel/B/B.1
> 2011-07-25 12:26:56,425 DEBUG
> [org.apache.commons.scxml.env.SimpleContext:165] : _eventdata = null
> 2011-07-25 12:26:56,426 DEBUG
> [org.apache.commons.scxml.env.SimpleContext:165] : _eventdatamap =
> {B.entry=null, parallel.entry=null, A.1.entry=null, B.1.entry=null,
> A.entry=null}
> 2011-07-25 12:26:56,451 DEBUG
> [org.apache.commons.scxml.env.SimpleContext:165] : _eventdata = null
> 2011-07-25 12:26:56,451 DEBUG
> [org.apache.commons.scxml.env.SimpleContext:165] : _eventdatamap =
> {B.entry=null, parallel.entry=null, A.1.entry=null, B.1.entry=null,
> A.entry=null}
> 2011-07-25 12:26:56,452 DEBUG [org.apache.commons.scxml.SCXMLExecutor:538] :
> Current States: [A.1, B.1]
> 2011-07-25 12:26:56,452 DEBUG
> [org.apache.commons.scxml.env.SimpleContext:165] : _eventdata = null
> 2011-07-25 12:26:56,452 DEBUG
> [org.apache.commons.scxml.env.SimpleContext:165] : _eventdatamap =
> {anEvent=null}
> 2011-07-25 12:26:56,459 INFO
> [org.apache.commons.scxml.env.SimpleSCXMLListener:53] : /parallel/B/B.1
> 2011-07-25 12:26:56,459 INFO
> [org.apache.commons.scxml.env.SimpleSCXMLListener:53] : /parallel/A/A.1
> 2011-07-25 12:26:56,459 INFO
> [org.apache.commons.scxml.env.SimpleSCXMLListener:53] : /parallel/B
> 2011-07-25 12:26:56,459 INFO
> [org.apache.commons.scxml.env.SimpleSCXMLListener:53] : /parallel/A
> 2011-07-25 12:26:56,459 INFO
> [org.apache.commons.scxml.env.SimpleSCXMLListener:63] : transition (event =
> anEvent, cond = null, from = /parallel/A, to = /parallel/A/A.2)
> 2011-07-25 12:26:56,459 INFO
> [org.apache.commons.scxml.env.SimpleSCXMLListener:63] : transition (event =
> anEvent, cond = null, from = /parallel/B, to = /parallel/B/B.2)
> 2011-07-25 12:26:56,460 INFO
> [org.apache.commons.scxml.env.SimpleSCXMLListener:44] : /parallel/A
> 2011-07-25 12:26:56,460 INFO
> [org.apache.commons.scxml.env.SimpleSCXMLListener:44] : /parallel/B
> 2011-07-25 12:26:56,460 INFO
> [org.apache.commons.scxml.env.SimpleSCXMLListener:44] : /parallel/A/A.2
> 2011-07-25 12:26:56,460 INFO
> [org.apache.commons.scxml.env.SimpleSCXMLListener:44] : /parallel/B/B.2
> 2011-07-25 12:26:56,460 DEBUG
> [org.apache.commons.scxml.env.SimpleContext:165] : _eventdata = null
> 2011-07-25 12:26:56,460 DEBUG
> [org.apache.commons.scxml.env.SimpleContext:165] : _eventdatamap =
> {B.entry=null, B.exit=null, B.2.entry=null, A.2.entry=null, B.1.exit=null,
> A.exit=null, A.1.exit=null, A.entry=null}
> 2011-07-25 12:26:56,465 DEBUG
> [org.apache.commons.scxml.env.SimpleContext:165] : _eventdata = null
> 2011-07-25 12:26:56,465 DEBUG
> [org.apache.commons.scxml.env.SimpleContext:165] : _eventdatamap =
> {B.entry=null, parallel.entry=null, A.1.entry=null, B.1.entry=null,
> A.entry=null}
> 2011-07-25 12:26:56,465 DEBUG [org.apache.commons.scxml.SCXMLExecutor:538] :
> Current States: [B.2, A.2]
> 2011-07-25 12:26:56,465 DEBUG
> [org.apache.commons.scxml.env.SimpleContext:165] : _eventdata = null
> 2011-07-25 12:26:56,465 DEBUG
> [org.apache.commons.scxml.env.SimpleContext:165] : _eventdatamap =
> {anAEvent=null}
> 2011-07-25 12:26:56,469 INFO
> [org.apache.commons.scxml.env.SimpleSCXMLListener:53] : /parallel/B/B.2
> 2011-07-25 12:26:56,469 INFO
> [org.apache.commons.scxml.env.SimpleSCXMLListener:53] : /parallel/A/A.2
> 2011-07-25 12:26:56,469 INFO
> [org.apache.commons.scxml.env.SimpleSCXMLListener:53] : /parallel/B
> 2011-07-25 12:26:56,470 INFO
> [org.apache.commons.scxml.env.SimpleSCXMLListener:53] : /parallel/A
> 2011-07-25 12:26:56,470 INFO
> [org.apache.commons.scxml.env.SimpleSCXMLListener:63] : transition (event =
> anAEvent, cond = null, from = /parallel/A, to = /parallel/A/A.3)
> 2011-07-25 12:26:56,470 INFO
> [org.apache.commons.scxml.env.SimpleSCXMLListener:44] : /parallel/A
> 2011-07-25 12:26:56,470 INFO
> [org.apache.commons.scxml.env.SimpleSCXMLListener:44] : /parallel/B
> 2011-07-25 12:26:56,470 INFO
> [org.apache.commons.scxml.env.SimpleSCXMLListener:44] : /parallel/A/A.3
> 2011-07-25 12:26:56,470 INFO
> [org.apache.commons.scxml.env.SimpleSCXMLListener:44] : /parallel/B/B.1
> 2011-07-25 12:26:56,470 DEBUG
> [org.apache.commons.scxml.env.SimpleContext:165] : _eventdata = null
> 2011-07-25 12:26:56,471 DEBUG
> [org.apache.commons.scxml.env.SimpleContext:165] : _eventdatamap =
> {B.entry=null, B.exit=null, B.2.exit=null, A.3.entry=null, A.exit=null,
> B.1.entry=null, A.entry=null, A.2.exit=null}
> 2011-07-25 12:26:56,473 DEBUG
> [org.apache.commons.scxml.env.SimpleContext:165] : _eventdata = null
> 2011-07-25 12:26:56,474 DEBUG
> [org.apache.commons.scxml.env.SimpleContext:165] : _eventdatamap =
> {B.entry=null, parallel.entry=null, A.1.entry=null, B.1.entry=null,
> A.entry=null}
> 2011-07-25 12:26:56,474 DEBUG [org.apache.commons.scxml.SCXMLExecutor:538] :
> Current States: [A.3, B.1]
>
>
>
> Hynek
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Mime
View raw message