commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rahul Akolkar" <rahul.akol...@gmail.com>
Subject Re: [SCXML] Relation between data model names and event names ?
Date Sat, 09 Jun 2007 02:55:01 GMT
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 <ingmar.kliche@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


Mime
View raw message