commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rahul Akolkar" <>
Subject Re: [SCXML] Same event to multiple parallel states
Date Mon, 03 Apr 2006 19:34:26 GMT
On 4/2/06, Fasih <> wrote:
> Hi
> I have a state m/c with multiple parallel states. A transition might
> result in one/all of the parallel state machines on a particular event.
> How do I accomplish this?
> This might sound wierd, but let me elucidate my problem:
> <state id="ua-ready">
>    <parallel id="lines">
>       <state id="line1">
>          <transition event="connection.alerting" target="accept"/>
>        </state>
>       <state id="line2">
>          <transition event="connection.alerting" target="reject"/>
>        </state>
>    </parallel>
> </state>
> Basically what I want to do is, for the different lines simulate a
> different behaviour depending on the line. There might be a better way
> to do this, I am new to this state machine concept. One alternative I
> thought of was to have events like line1.connection.alerting but that
> did not sound like a good idea, I also thought of having some indicator
> in the event as to which line it is meant for, but that does not sound
> too good either.

I wouldn't recommend the first option either. But the second option is
actually widely used, and the concept is refered to as event payload.

If you take a look at the TriggerEvent class [1] in Commons SCXML, you
will indeed find a property "payload" that should be used for such
purposes. Ofcourse, what the payload consists of depends on the
particular environment and event semantics, therefore, the only
acceptable type for payload is java.lang.Object (i.e. you can assign
an object of any type, even a user-defined one, as the event payload).

The latest SCXML WD also specifies that the special variable
"_eventdata" may be used to access data contained within the
triggering event (i.e. the payload). Thus, along the lines of the
above example, a transition may look like:

<transition event="connection.alerting"
                cond="_eventdata.line eq 1"
                target="..." />

where the event payload defines a "line" property. This bit (exposing
payload as "_eventdata") hasn't been done for Commons SCXML yet, but
I'll do it now. Will ping this thread when am done.

There has been no mention of <parallel> yet, since the way you refer
to event payload does not depend on parallelism. The parallelism
construct implies the following basic premise (<state> children of
<parallel> are refered to as "regions"):

 * The state machine is "active" in all regions of a parallel, or none at all

That implies corollaries such as:

 * If a region transitions outside the parallel, all regions are exited
 * A region may not transition into another
 * Usage of the "In()" predicate is common to check the status of
sibling regions

Parallelism is a powerful construct for state machines, which also
requires due diligence from an authoring perspective.

For your snippet above, if state "accept" lies outside the parallel,
then following that transition will not only exit region "line1", but
also its sibling region "line2". That might as well be the desired
outcome, I'm simply using the snippet as an example.



> Any help would be appreciated.
> +Fasih

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

View raw message