getting list of active states inside a composite parallel state

105 views
Skip to first unread message

Gururaj R

unread,
May 25, 2015, 3:31:02 PM5/25/15
to squirrel-st...@googlegroups.com
Hi,
     I have defined the state transitions as below (an example).
Let's say event "etop" is fired - this takes the state to "S21" which is inside a parallel state "p".
During this state, "S11" and "S21" are the atomic states that are active.
At present there is getCurrentState which returns only the last active state.
Also let's say if the "etop" transitions to "p" instead of "S21" - I would like to get "all active atomic states which are "S11" and "S21".
Is there a easy way to get "all active atomic states" from the state machine.
      The reason is we need to store the state machine state in case the server crash/shutdown and restore the statemachine to it's early terminal statues.
Also let's say if there is a way to fetch the above info, now how do I create a stateMachine with initial state of - let's say "S12" and "S22" (builder.newStateMachine(Object initialState) -- > takes only one state)
Thanks,
   Gururaj




<scxml xmlns="http://www.w3.org/2005/07/scxml" version="1.0"
initial="off" xmlns:sqrl="http://squirrelframework.org/squirrel">
<sqrl:fsm id="Spuhpls9kR" fsm-type="org.gradle.MySecondStateMachine"
state-type="java.lang.String" event-type="java.lang.String"
context-type="java.lang.Void" context-insensitive="true" />
<state id="S" initial="s1">
<state id="s1" initial="s11">
<onexit>
<sqrl:action content="method#onExit" />
</onexit>

<state id="s11">
<onexit>
<sqrl:action content="method#onExit" />
</onexit>
</state>

<transition event="e" target="s21" sqrl:type="EXTERNAL"
cond="instance#org.squirrelframework.foundation.fsm.Conditions$Always">
<sqrl:action content="method#onTransition" />
</transition>

</state>

<state id="s2" initial="s21">
<onexit>
<sqrl:action content="method#onExit" />
</onexit>
<state id="s21">
<onentry>
<sqrl:action content="method#onEntry" />
</onentry>
<onexit>
<sqrl:action content="method#onExit" />
</onexit>
</state>
<onentry>
<sqrl:action content="method#onEntry" />
</onentry>
<transition event="etop" target="S21" sqrl:type="EXTERNAL"
cond="instance#org.squirrelframework.foundation.fsm.Conditions$Always">
<sqrl:action content="method#onTransition" />
</transition>
</state>

<parallel id="p">
<onentry>
<sqrl:action content="method#onEntry" />
</onentry>
<transition sqrl:type="EXTERNAL" event="done.state.p" target="someOtherState" cond="instance#org.squirrelframework.foundation.fsm.Conditions$Always"/>

<state id="S1" initial="S11">
<onentry>
<sqrl:action content="method#onEntry" />
</onentry>
<state id="S11">
<onentry>
<sqrl:action content="method#onEntry" />
</onentry>
<transition sqrl:type="EXTERNAL" event="e4" target="S12" cond="instance#org.squirrelframework.foundation.fsm.Conditions$Always"/>
</state>
<state id="S12">
<onentry>
<sqrl:action content="method#onEntry" />
</onentry>
<transition sqrl:type="EXTERNAL" event="e1" target="S1Final" cond="instance#org.squirrelframework.foundation.fsm.Conditions$Always"/>
</state>
<final id="S1Final" />
</state>

<state id="S2" initial="S21">
<onentry>
<sqrl:action content="method#onEntry" />
</onentry>
<state id="S21">
<onentry>
<sqrl:action content="method#onEntry" />
</onentry>
<transition sqrl:type="EXTERNAL" event="e1" target="S12" cond="instance#org.squirrelframework.foundation.fsm.Conditions$Always"/>
</state>
<state id="S22">
<transition sqrl:type="EXTERNAL" event="e2" target="S2Final" cond="instance#org.squirrelframework.foundation.fsm.Conditions$Always"/>
</state>
<final id="S2Final" />
</state>

</parallel>
<onentry>
<sqrl:action content="method#onEntry" />
</onentry>
<onexit>
<sqrl:action content="method#onExit" />
</onexit>
</state>
</scxml>


He Henry

unread,
Jun 3, 2015, 3:49:59 AM6/3/15
to squirrel-st...@googlegroups.com, rgur...@gmail.com

To get current sub states of the parallel state

stateMachine.getSubStatesOn(MyState.Root); // return list of current sub states of parallel state

在 2015年5月26日星期二 UTC+8上午3:31:02,Gururaj R写道:

Alexey Pakseykin

unread,
Jul 16, 2017, 1:39:11 PM7/16/17
to squirrel state machine, rgur...@gmail.com

It seems like stateMachine.getSubStatesOn(parent) returns possible states of parent (instead of actual current state).
In other words, it's static configuration rather than active dynamic state.


Technically and ideally, stateMachine.getCurrentState() should return list of states (leaf states within hierarchical state machine).
It is list because state machine is active in all parallel states.
If there is no parallel states, the list contains single leaf state.

Is there a way to query all active states within parallel "branches" of state machine?
Reply all
Reply to author
Forward
0 new messages