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] Calling go() twice
Date Tue, 03 May 2011 15:32:08 GMT
On Tue, May 3, 2011 at 10:13 AM, Dario D <darac1111@gmail.com> wrote:
> Thanks Jocke. How would you suggest to resume the the last state before the
> condition was not met? Let's say that the condition was made valid somehow.
> How to resume from the last state?
>
> To continue the previous example:
>
>        try {
>            exec.go();
>            // Execution stops at state2, condition is not met
>            // Condition is made valid through some means
>            // How to resume?
>        } catch (ModelException e) {
>            e.printStackTrace();
>        }
>
<snip/>

Triggering events is here:

  http://commons.apache.org/scxml/guide/core-events.html

The main page for the user guide, which has more, is here:

  http://commons.apache.org/scxml/guide.html

If you're using EL, you've have to use the EL syntax for expressions,
so rather than the following from your example ...

  <transition target="state3" cond="1 = 2" />

... the syntax will be like below:

  <transition target="state3" cond="${1 eq 2}" />

-Rahul


>
> 2011/5/3 jocke eriksson <joakim.eriksson@albatross.com>
>
>>  exec.go(); should only be called once. It will start the state
>> machine and it will go through all steps that meets the criteria
>> (event cond).
>>
>> Regards Jocke.
>>
>> 2011/5/3 Dario D <darac1111@gmail.com>:
>> > Hello all,
>> >
>> > I've just started using SCXML and it's great. However, I've hit a brick
>> wall
>> > and I can't seem to figure out something. I have the following XML file:
>> >
>> > <scxml xmlns="http://www.w3.org/2005/07/scxml"
>> >       version="1.0"
>> >       initialstate="state1">
>> >
>> >    <state id="state1">
>> >        <onentry>
>> >            <log expr="State 1"/>
>> >        </onentry>
>> >        <transition target="state2" />
>> >    </state>
>> >
>> >    <state id="state2">
>> >        <onentry>
>> >            <log expr="State 2"/>
>> >        </onentry>
>> >        <transition target="state3" cond="1 = 2" />
>> >    </state>
>> >
>> >    <state id="state3" final="true">
>> >        <onentry>
>> >            <log expr="State 3"/>
>> >        </onentry>
>> >    </state>
>> >
>> > </scxml>
>> >
>> > Now, I execute the state machine like this:
>> >
>> >        SCXMLExecutor exec = null;
>> >        exec = new SCXMLExecutor(new ELEvaluator(), new
>> SimpleDispatcher(),
>> > new SimpleErrorReporter());
>> >        Context ctx = new ELContext();
>> >        exec.setRootContext(ctx);
>> >        exec.setStateMachine(scxml);
>> >        exec.setSuperStep(true);
>> >        // Start execution
>> >        try {
>> >            exec.go();
>> >            exec.go();
>> >        } catch (ModelException e) {
>> >            e.printStackTrace();
>> >        }
>> >
>> > As you can see I call exec.go() two times. I would expect that in the
>> first
>> > time, the state machine will stop in the "state2" state and remain there,
>> > because condition is not satisfied for going into "state3". However, when
>> > exec.go() is called the second time, it goes from the start. Effectively,
>> it
>> > acts as exec.reset()? Following output is provided:
>> >
>> >        03.05.2011. 14:01:32 org.apache.commons.scxml.model.Log execute
>> >        INFO: null: State 1
>> >        03.05.2011. 14:01:32 org.apache.commons.scxml.model.Log execute
>> >        INFO: null: State 2
>> >        03.05.2011. 14:01:32 org.apache.commons.scxml.model.Log execute
>> >        INFO: null: State 1
>> >        03.05.2011. 14:01:32 org.apache.commons.scxml.model.Log execute
>> >        INFO: null: State 2
>> >
>> > Could you explain this behavior?
>> >

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


Mime
View raw message