commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dario D <darac1...@gmail.com>
Subject Re: [scxml] Calling go() twice
Date Tue, 10 May 2011 13:21:33 GMT
Thank you Rahul for your fast response. So, the syntax is:

    <state id="action1">
        <onentry>
            <log expr="'entering action1'"/>
            <send event="'testEvent'"/>
        </onentry>
        <transition event="testEvent" target="action2"/>
        <onexit>
            <log expr="'exiting action1'"/>
        </onexit>
    </state>

and this works.

2011/5/10 Rahul Akolkar <rahul.akolkar@gmail.com>

> On Tue, May 10, 2011 at 8:51 AM, Dario D <darac1111@gmail.com> wrote:
> > Rahul, in regards to triggering events, I am trying to trigger them from
> > within the workflow like this:
> >
> >    <datamodel>
> >        <data name="testEvent" expr="'some test event'"/>
> >    </datamodel>
> >
> >    <state id="action1">
> >        <onentry>
> >            <log expr="'entering action1'"/>
> >            <send event="testEvent"/>
> >        </onentry>
> >        <transition event="testEvent" target="action2"/>
> >        <onexit>
> >            <log expr="'exiting action1'"/>
> >        </onexit>
> >    </state>
> >    <state id="action2">
> >        <onentry>
> >            <log expr="'action2'"/>
> >        </onentry>
> >    </state>
> >
> > As you can see, I am trying to trigger an event from within "action1"
> state
> > and then move to "action2". However, this does not happen and the log
> output
> > shows only "entering action1". If the event is being triggered, why the
> > transition does not take place?
> >
> <snip/>
>
> I'll assume you're using JEXL given your previous post. If so, you'll
> need single quotes around the event name like so (its treated as an
> expression - spaces added below for readability):
>
>  event=" 'testEvent' "
>
> If you pass in an application log, you'll see a warn level message to
> the effect of expression not resolving to a (non-empty) event name
> string.
>
> -Rahul
>
>
> > Thank you.
> >
> > 2011/5/3 Rahul Akolkar <rahul.akolkar@gmail.com>
> >
> >> 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
> >>
> >>
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message