You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Rahul Akolkar <ra...@gmail.com> on 2006/09/13 22:37:18 UTC

Re: [SCXML] Send an event in 10s by attribute delay

This is a shared mailing list, so please prefix the email subjects
with the Commons component name, as I've done above.

On 9/13/06, Raimundo Santos Moura <ra...@gmail.com> wrote:
> Hi,
>   I tried to run the code below, but the attribute <delay> doesn't work well
> (seemingly).
>
>   What do i want to do?
<snip/>

There are two things going on here:

Firstly, in the general case, to implement delay, you have to:

(1) Author a concrete implementation of the Commons SCXML
EventDispatcher interface
(2) Use an appropriate scheme to create "timers" if you receive an
onsend() callback with a non-negative delay
(3) Use an instance of this implementation when instantiating the SCXMLExecutor

The reason why it is setup this way (to be more work) is that there is
no delay scheme that will be suitable for all usecases (J2SE Timers
and TimerTasks are unacceptable in many environments -- so the usecase
gets to pick what it needs).

Secondly, in this specific case, there is a bug:

When the targettype attribute is absent (as is below) the engine
defaults it to "scxml" as required by the Working Draft and takes over
processing (the default type doesn't result in an EventDispatcher
callback). So, the above recipe doesn't work here (short term, you can
hack it by defining your own targettype). Please create a JIRA ticket
for this:

 http://jakarta.apache.org/commons/scxml/issue-tracking.html

Thanks,
-Rahul


>      In state "Off", by trigger of the event <ev1>, i need to wait 10s in
> state "On"; after this time, i should return to state "Off".
>
>   Is there any error?
>
>   Thanks,
> Raimundo Moura
>
> <?xml version="1.0"?>
> <scxml xmlns="http://www.w3.org/2005/07/SCXML" version="1.0"
> initialstate="Off">
>
>        <state id="Off">
>             <transition event="ev1" target="On"/>
>        </state>
>        <state id="On">
>              <onentry>
>                  <log expr="'Inside On...'"/>
>                  <send event="Timer" delay="10s"/>
>              </onentry>
>              <transition event="Timer" target="Off"/>
>              <onexit>
>                  <log expr="'Leaving On...'"/>
>              </onexit>
>       </state>
> </scxml>
>
>

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