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] Need help returning from substate
Date Fri, 13 Feb 2009 23:58:37 GMT
On Fri, Feb 13, 2009 at 4:48 PM, Ouyang, Landon - ES/RDR -Gil
<Landon.Ouyang@itt.com> wrote:
> Background:  I have several states that need to call the same external substate machine.
 Once the substate machine has finished I need it to return to the calling state.
>
> Question:  How can I get the substate machine to return to the calling state without
explicitly naming the calling state in the transition?
>
<snip/>

Rather than returning to calling state, think about it as waiting for
the .done event related to the src'ed in state machine. Then the
troublesome transition moves from the src'ed in state machine to the
<state> with the src attribute. In terms of your example ...


> I have found bits and pieces in the archives and online but no good examples or full
explanations.
> Any pointers to online documentation for this would also be helpful.  Thanks.
>
> Code:
> I would like to return from the password.xml substate to the calling state (SaveButton,
ReloadButton, etc).  The tag <transition event="e_Done"        target="* Back to Calling
State* " /> specifies a specific state However, that state depends on the calling state.
 How do I get it to return to the calling state automatically?
>
> <state id="SaveButton" src="Password.xml" >
>        <transition event="e_Done"        target="SteadyState" />
>    </state>
> <state id="ReloadButton" src="Password.xml" >
>        <transition event="e_Done"        target="SteadyState" />
>    </state>
>
<snap/>

When the submachine in Password.xml runs to completion (which means it
needs to have one or more <final> states), the $parentstate.done event
will be generated (so in the above cases, SaveButton.done and
ReloadButton.done respectively).

<state id="SaveButton" src="Password.xml" >
    <transition event="e_Done"         target="SteadyState" />
    <!-- Take a transition on SaveButton.done when Password.xml runs
to completion -->
</state>
<state id="ReloadButton" src="Password.xml" >
    <transition event="e_Done"        target="SteadyState" />
    <!-- Take a transition on ReloadButton.done when Password.xml runs
to completion -->
</state>

This assumes that the state "ControlGranted" in the submachine below
is changed to a final state (and is reached so the .done internal
events are generated).

There are a couple of test cases in the JUnit test suite that use this
pattern, in case you want to look at a complete example.

-Rahul


>
> Password.xml
> <scxml xmlns="http://www.w3.org/2005/07/scxml"
>       xmlns:my="http://www.ttt.com" version="1.0" initialstate="PasswordCheck">
>    <state id="PasswordCheck" >
>        <onentry>
>            <my:StateLog/>
>            <my:PasswordCheck/>
>        </onentry>
>        <transition event="e_Done"        target="SteadyState" />
>        <transition event="e_validate"        target="PasswordValid" />
>        <transition event="e_allow"        target="ControlGranted" />
>    </state>
>    <state id="PasswordValid" >
>        <onentry>
>            <my:StateLog/>
>            <my:PasswordValid/>
>        </onentry>
>        <transition event="e_allow"        target="ControlGranted" />
>        <transition event="e_Done"        target=" SteadyState " />
>    </state>
>    <state id="ControlGranted" >
>        <onentry>
>            <my:StateLog/>
>            <my:ControlGranted/>
>        </onentry>
>        <transition event="e_Done"        target="* Back to Calling State* " />
>    </state>
> </scxml>
>
>
> --
> Landon Ouyang
> Senior Design Engineer
> ITT Electronics Systems, Radar Systems - Gilfillan
> 7821 Orion Ave,
> Van Nuys, CA 91406
> (818) 901-2982
>
>

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


Mime
View raw message