commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jocke eriksson <joakim.eriks...@albatross.com>
Subject Re: [scxml] Calling go() twice
Date Tue, 03 May 2011 12:36:10 GMT
 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?
>



-- 

Joakim Eriksson

Albatross
Holländargatan 20, 111 60 Stockholm Sweden
+46 8 51160773 | Mobile +46 708 507 480
joakim.eriksson@albatross.com | www.albatross.com

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


Mime
View raw message