You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Linda Erlenhov <li...@gmail.com> on 2009/02/27 09:53:54 UTC

[SCXML] Transition/Var question

Hello
I have in my Transitions added "var" on the form:

    <transition       cond="${cancelOutcome eq 'success'}" target="editExit">
      <var            name="outcome"
                      expr="cancel"/>
    </transition>

(This example is taken directly from the SCXML specification)

In my statemachine (a version similar, but not derived from the
AbstractStateMachine that is included) I have added an "onTransition"
function in my listner that when I am on a transition should check if there
is an "var" and in that case send it to XXXX.

I´m having trouble fetching the "var". My thought is that that I should
derive a new class from the transition class that includes the method
"getVar" but I´ve looked through the API and I don´t understand how this
method should be written. Can anybody help me?

Best Regards
/Linda

Re: [SCXML] Transition/Var question

Posted by Rahul Akolkar <ra...@gmail.com>.
On Mon, Mar 2, 2009 at 5:07 AM, Linda Erlenhov <li...@gmail.com> wrote:
> Hello
>
> Yes this is what I want to do, but I don´t understand how (1) is done. With
> the getEngine you get the rootContext, The rootContext describes ALL var:s
> in the StateMachine as I understand,
<snip/>

No, just the bits defined in the root datamodel (child of <scxml>) and
any injected programmatically. This can be changed, but thats the
default behavior.


> so then it should be the context
> associated with the transition I want. How do I do that? The transition type
> doesn´t have a name and I can´t find a method that takes an "executable
> object"ish and returns something that I want.
>
<snap/>

In (1) below, we were identifying the value of the name attribute of
the <assign>. Given that you have a listener in use,
SCXMLListener#onTransition() provides a handle to the Transition
object -- iterate over the list of actions using
Transition#getActions() to find this assign action, then use
Assign#getName().

-Rahul


> best regards
> //Linda
>
> On Sat, Feb 28, 2009 at 6:20 AM, Rahul Akolkar <ra...@gmail.com>wrote:
>
>> On Fri, Feb 27, 2009 at 7:06 AM, Linda Erlenhov
>> <li...@gmail.com> wrote:
>> > Hello again!
>> >
>> >
>> >> <snip>
>> >>
>> >> followed by introspection like so:
>> >>
>> >>    getEngine().getRootContext().get("outcome");
>> >>
>> >> </snip>
>> >
>> > The problem with that approach is that i won´t know the names of my
>> "var":s.
>> >
>> > The idéa is:
>> > I´m building an graphical editor for Statecharts, where you can model a
>> > statemachine with some simple drag and drop actions. When your satisfied
>> > with your machine the editor generates an SCXML-file which then is meant
>> to
>> > be run. Everything I do has to be "generic" so what I wanted was a way
>> to,
>> > when the listner registers an "onTransition" ( the class Implements the
>> > SCXMLListener interface) move:
>> > 1. Check if there is an "var" associated with that transition
>> > 2. If so, fetch the exp.
>> >
>> <snip/>
>>
>> IIUC, for (1), introspect the Transition object (the list of actions
>> therein). (2) is above (replace the String constant "outcome" with the
>> value obtained in 1).
>>
>> -Rahul
>>
>>
>> > best regards
>> > //Linda
>> >
>>

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


Re: [SCXML] Transition/Var question

Posted by Linda Erlenhov <li...@gmail.com>.
Hello

Yes this is what I want to do, but I don´t understand how (1) is done. With
the getEngine you get the rootContext, The rootContext describes ALL var:s
in the StateMachine as I understand, so then it should be the context
associated with the transition I want. How do I do that? The transition type
doesn´t have a name and I can´t find a method that takes an "executable
object"ish and returns something that I want.

best regards
//Linda

On Sat, Feb 28, 2009 at 6:20 AM, Rahul Akolkar <ra...@gmail.com>wrote:

> On Fri, Feb 27, 2009 at 7:06 AM, Linda Erlenhov
> <li...@gmail.com> wrote:
> > Hello again!
> >
> >
> >> <snip>
> >>
> >> followed by introspection like so:
> >>
> >>    getEngine().getRootContext().get("outcome");
> >>
> >> </snip>
> >
> > The problem with that approach is that i won´t know the names of my
> "var":s.
> >
> > The idéa is:
> > I´m building an graphical editor for Statecharts, where you can model a
> > statemachine with some simple drag and drop actions. When your satisfied
> > with your machine the editor generates an SCXML-file which then is meant
> to
> > be run. Everything I do has to be "generic" so what I wanted was a way
> to,
> > when the listner registers an "onTransition" ( the class Implements the
> > SCXMLListener interface) move:
> > 1. Check if there is an "var" associated with that transition
> > 2. If so, fetch the exp.
> >
> <snip/>
>
> IIUC, for (1), introspect the Transition object (the list of actions
> therein). (2) is above (replace the String constant "outcome" with the
> value obtained in 1).
>
> -Rahul
>
>
> > best regards
> > //Linda
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>
>

Re: [SCXML] Transition/Var question

Posted by Rahul Akolkar <ra...@gmail.com>.
On Fri, Feb 27, 2009 at 7:06 AM, Linda Erlenhov
<li...@gmail.com> wrote:
> Hello again!
>
>
>> <snip>
>>
>> followed by introspection like so:
>>
>>    getEngine().getRootContext().get("outcome");
>>
>> </snip>
>
> The problem with that approach is that i won´t know the names of my "var":s.
>
> The idéa is:
> I´m building an graphical editor for Statecharts, where you can model a
> statemachine with some simple drag and drop actions. When your satisfied
> with your machine the editor generates an SCXML-file which then is meant to
> be run. Everything I do has to be "generic" so what I wanted was a way to,
> when the listner registers an "onTransition" ( the class Implements the
> SCXMLListener interface) move:
> 1. Check if there is an "var" associated with that transition
> 2. If so, fetch the exp.
>
<snip/>

IIUC, for (1), introspect the Transition object (the list of actions
therein). (2) is above (replace the String constant "outcome" with the
value obtained in 1).

-Rahul


> best regards
> //Linda
>

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


Re: [SCXML] Transition/Var question

Posted by Linda Erlenhov <li...@gmail.com>.
Hello again!


> <snip>
>
> followed by introspection like so:
>
>    getEngine().getRootContext().get("outcome");
>
> </snip>

The problem with that approach is that i won´t know the names of my "var":s.

The idéa is:
I´m building an graphical editor for Statecharts, where you can model a
statemachine with some simple drag and drop actions. When your satisfied
with your machine the editor generates an SCXML-file which then is meant to
be run. Everything I do has to be "generic" so what I wanted was a way to,
when the listner registers an "onTransition" ( the class Implements the
SCXMLListener interface) move:
1. Check if there is an "var" associated with that transition
2. If so, fetch the exp.

best regards
//Linda

Re: [SCXML] Transition/Var question

Posted by Rahul Akolkar <ra...@gmail.com>.
On Fri, Feb 27, 2009 at 3:53 AM, Linda Erlenhov
<li...@gmail.com> wrote:
> Hello
> I have in my Transitions added "var" on the form:
>
>    <transition       cond="${cancelOutcome eq 'success'}" target="editExit">
>      <var            name="outcome"
>                      expr="cancel"/>
>    </transition>
>
> (This example is taken directly from the SCXML specification)
>
> In my statemachine (a version similar, but not derived from the
> AbstractStateMachine that is included) I have added an "onTransition"
> function in my listner that when I am on a transition should check if there
> is an "var" and in that case send it to XXXX.
>
> I´m having trouble fetching the "var". My thought is that that I should
> derive a new class from the transition class that includes the method
> "getVar" but I´ve looked through the API and I don´t understand how this
> method should be written. Can anybody help me?
>
<snip/>

This will be short since I'm on the road. One approach is to declare
the variable in the root context (<datamodel> child of <scxml>) so it
will be easier to introspect.

Along the lines of (note use of <assign> instead of <var> in <transition>):

<scxml ...>

    <datamodel>
        <data name="outcome"/>
    </datamodel>

....

    <state ...>
        <transition cond="${cancelOutcome eq 'success'}" target="editExit">
            <assign name="outcome" expr="cancel"/>
        </transition>
    </state>

</scxml>

followed by introspection like so:

    getEngine().getRootContext().get("outcome");

-Rahul


> Best Regards
> /Linda
>

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