You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Ingmar Kliche <in...@googlemail.com> on 2007/06/08 23:16:26 UTC
[SCXML] Relation between data model names and event names ?
Rahul,
I have a strange behavior with one of my samples I'm currently playing with.
I try generate a number of timer events (like a count down) using a variable
in the data model and delayed events:
<datamodel>
<data name="timer" expr = "'5'"/>
</datamodel>
<state id="welcome">
<onentry>
<!-- start timer -->
<assign name="timer" expr="timer - 1"/>
<send event="timer" delay="1s"/>
</onentry>
<transition event="timer" cond="timer > 0">
<assign name="timer" expr="timer - 1"/>
<send event="timer" delay="1s"/>
<!-- do something -->
</transition>
<transition event="timer" cond="timer == 0" target="somewhere"/>
</state>
This sample does not work as expected. All events are fired immediately and
are not delayed. As soon as I rename either the event name or the name of
the data tag to "timer1" it works fine. As soon as I use a dotted name for
the data tag name attribute (e.g. "timer.id" while event="timer") it doesn't
work again.
I have no clue why the data model names and the event names should
be related. Is this intended?
I'm using snapshot 0.7
-Ingmar.
Re: [SCXML] Relation between data model names and event names ?
Posted by Rahul Akolkar <ra...@gmail.com>.
On 6/23/07, Ingmar Kliche <in...@googlemail.com> wrote:
<snip/>
> > I understand there are some subtleties here, and the above definitely
> > needs to be better documented. If you want to help, feel free to add
> > some of your recent experiences and some of the pitfalls to the
> > Commons SCXML wiki [1] by creating a new page (you'll need to create
> > an account to log in, if you don't already have one).
> >
> >
> > -Rahul
> >
> > [1] http://wiki.apache.org/jakarta-commons/SCXML
>
>
> I'll try to write some comments within the near future.
>
> BTW: Are there any other pitfalls or "features" in commons-scxml which
> extending the (current) standard?
>
<snap/>
:-)
I'd say understanding the consequence of event names and the internal
events generated tops the list (both of which we discussed in this
thread). Other than that, there are expression language related good
housekeeping bits that you will never find mentioned in the spec (such
as variable names shouldn't contain dots -- which is more a
side-effect of using JEXL or EL rather than anything else).
The wiki page doesn't have to be comprehensive, just a starting point.
-Rahul
> - Ingmar.
>
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
Re: [SCXML] Relation between data model names and event names ?
Posted by Ingmar Kliche <in...@googlemail.com>.
Rahul,
thanks for clarification. In this case I consider it to be a feature (which
could indeed be very useful) rather than a bug.
>
> * The Commons SCXML implementation generates a .change event when a
> piece of any data model changes (similarly it generates a .entry when
> any state is entered and a .exit when a state is exited). Which means
> one can watch some part of the datamodel for an update for triggering
> a transition. This is quite useful for communicating across regions
> etc.
>
> ...
> I understand there are some subtleties here, and the above definitely
> needs to be better documented. If you want to help, feel free to add
> some of your recent experiences and some of the pitfalls to the
> Commons SCXML wiki [1] by creating a new page (you'll need to create
> an account to log in, if you don't already have one).
>
>
> -Rahul
>
> [1] http://wiki.apache.org/jakarta-commons/SCXML
I'll try to write some comments within the near future.
BTW: Are there any other pitfalls or "features" in commons-scxml which
extending the (current) standard?
- Ingmar.
Re: [SCXML] Relation between data model names and event names ?
Posted by Rahul Akolkar <ra...@gmail.com>.
Before we get into the specifics below, some background:
* Event names imply an ontology. So an "error.foo" event is an
"error" event, and so is the "error.foo.bar" event (which, in
addition, is also a type of "error.foo" event). Therefore, the
following transition ...
<transition event="error" target="errorstate" />
... will be followed if any of the following events are triggered on
the state machine (because all of these are "error" events):
- error
- error.foo
- error.bar
- error.foo.bar.baz
IMO, event names should be chosen scrupulously during the design of
reactive systems keeping the above in mind.
* The Commons SCXML implementation generates a .change event when a
piece of any data model changes (similarly it generates a .entry when
any state is entered and a .exit when a state is exited). Which means
one can watch some part of the datamodel for an update for triggering
a transition. This is quite useful for communicating across regions
etc.
Now, to answer your questions:
On 6/8/07, Ingmar Kliche <in...@googlemail.com> wrote:
> Rahul,
>
> I have a strange behavior with one of my samples I'm currently playing with.
> I try generate a number of timer events (like a count down) using a variable
> in the data model and delayed events:
>
> <datamodel>
> <data name="timer" expr = "'5'"/>
> </datamodel>
>
> <state id="welcome">
> <onentry>
> <!-- start timer -->
> <assign name="timer" expr="timer - 1"/>
> <send event="timer" delay="1s"/>
> </onentry>
>
> <transition event="timer" cond="timer > 0">
> <assign name="timer" expr="timer - 1"/>
> <send event="timer" delay="1s"/>
> <!-- do something -->
> </transition>
>
> <transition event="timer" cond="timer == 0" target="somewhere"/>
> </state>
>
> This sample does not work as expected. All events are fired immediately and
> are not delayed.
<snip/>
<assign>'ing a new value to the <data> named 'timer' generates a
'timer.change' event. The assumption of an ontology as stated above
causes the <transition event="timer" ... > to be immediately followed
(all 5 of them, because there are 5 cascading <assign>s).
I understand there are some subtleties here, and the above definitely
needs to be better documented. If you want to help, feel free to add
some of your recent experiences and some of the pitfalls to the
Commons SCXML wiki [1] by creating a new page (you'll need to create
an account to log in, if you don't already have one).
> As soon as I rename either the event name or the name of
> the data tag to "timer1" it works fine.
<snap/>
I take it this is as expected, so doesn't need any further clarification :-)
> As soon as I use a dotted name for
> the data tag name attribute (e.g. "timer.id" while event="timer") it doesn't
> work again.
>
<snip/>
'Dotted names' are never recommended for use in documents with JEXL or
EL expressions (so no dots in <data> or <var> names please). Both
languages have a dot operator, and the evaluators get thrown off.
-Rahul
[1] http://wiki.apache.org/jakarta-commons/SCXML
> I have no clue why the data model names and the event names should
> be related. Is this intended?
>
> I'm using snapshot 0.7
>
> -Ingmar.
>
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org