commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rahul Akolkar <>
Subject Re: [SCXML] Timers in SCXML
Date Wed, 08 Apr 2009 20:19:17 GMT
On Wed, Apr 8, 2009 at 7:53 AM, Anna Södling <> wrote:
> Hello,
> I'm having a little problem regarding timers in SCXML. I have built a
> simple statemachine with two states and a transition going from each
> state to the other. The transitions should not be taken when a user
> "orders" an event, but when a timer has timed out. The code I have
> written for this (which obviously is incorrect since it doesn't solve my
> problem, but it might give an idea of how I'm thinking) looks like this
> (I've tried to implement the timers like in the examples on this page,
> if that might be any hint to what may be wrong:
> ):
> <scxml version="1.0" initialstate="167" xmlns:cs="
>" xmlns="
> <state id = "167">
> <transition target="StateA"/>
> </state>
> <state id ="StateA">
> <onentry>
> <send sendid="1" target="'StateA'" event="'ToB'" delay="'1000ms'" />
> </onentry>
> <transition event="ToB" target="StateB"/>
> </state>
> <state id="StateB">
> <onentry>
> <send sendid="2" target="'StateB'" event="'ToA'" delay="'2000ms'" />
> </onentry>
> <transition event="ToA" target="StateA"/>
> </state>
> </scxml>
> I get complaints about my target and event parts. What I want is that
> when you enter a state, a timer with the value of the delay attribute
> should start ticking inside the current state and when the timer times
> out, it should take the transition with the same event as the event in
> the send tag. But when I do this, I get this warning:
> VARNING: <send>: target expression "StateA" evaluated to null or empty
> String
> (I tried to write target="'Self'" instead, too, but that didn't help
> either)

Targets cannot be states, only entire state machines. "Self" has no
associated semantics at all in SCXML.

> I also tried to remove the target attribute, but then I get this line:

Thats the right way to proceed. No target means current state machine.

> INFO: send ( sendId: 1, target: null, targetType: scxml, event: ToB,
> params: null, hints: null, delay: 1000)
> and nothing else happens.
> If anyone has any ideas of what I might have done wrong and how I can
> solve this problem (preferably without implementing any custom actions),
> I would be really happy!

Use an EventDispatcher that supports timers. Here is one that uses
Java SE timers:

So, along these lines:

    SCXMLExecutor exec = new SCXMLExecutor();
    exec.setEventDispatcher(new SimpleScheduler(exec));


> Sincerely,
> Anna

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message