commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rahul Akolkar <rahul.akol...@gmail.com>
Subject Re: [SCXML] Modifying a statechart during runtime
Date Tue, 26 Jan 2010 23:13:24 GMT
On Tue, Jan 26, 2010 at 8:01 AM, Hallvard Trætteberg <hal@idi.ntnu.no> wrote:
> Hi,
>
> I been using SCXML for a long time (among others, I've implemented support
> for Javascript), and I am in general pretty satisfied. In my latest project,
> I will be generating a statechart from states that will be composed into a
> hierarchy. The states are actually tied to objects in an object tree, which
> is traversed to collect and compose the statechart. Since objects come and
> go, I need to extend the machine during runtime. In principle, I can stop,
> regenerate and restart the statechart, but I would rather extend it on the
> fly.
>
<snip/>

This is certainly possible, with great caution. SCXML is not designed
for the statechart to be dynamic in the sense above, and therefore any
affordances to such extensions have to be provided by application
logic itself. For example, one must be careful not to update the
statechart (or the "model") while any executor that is tied to that
model is actually processing an event. Also, if any of the currently
active states themselves change, then the behavior might be harder to
understand than if the model were static.

So, in a nutshell, yes but -- here be dragons.


> - Is it possible to extend the state machine with new states, without
> restarting the machine? In my case, I only need to add regions in a
> parallel, so semantically it isn't problematic.
<snap/>

Depending on what needs adding, it may be possible to update the model
(instance of the SCXML class) accordingly while taking precautions
such as those mentioned above. In certain cases, the model may need
"updating" to wire in any new transitions or rewire any existing ones
etc. (see class o.a.c.scxml.io.ModelUpdater).


> - Is there a clean way of storing and restoring the state of the machine, in
> a format that can be inspected and modified (e.g. to change the current
> state).
>
<snip/>

There have been some previous discussions on this topic, please search
the list archives. Again, this is possible in certain cases and this
thread has a working example:

  http://markmail.org/thread/sn5zuyzc4m5en6hy

-Rahul


> Best regards,
>
> Hallvard Trætteberg
>

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


Mime
View raw message