On Sat, Dec 11, 2010 at 6:26 AM, Micka <[email protected]> wrote:
> Hi,
>
>
> I'm trying to get the currentStates in case we have multiple states.
>
> by example :
>
>
> <?xml version="1.0" encoding="UTF-8"?>
>
> <scxml xmlns="http://www.w3.org/2005/07/scxml" version="1.0"
> initialstate="start">
>
> <parallel id="start">
>
> <state id="simulatedUser">
> <datamodel>
> <data name="one" expr="1" />
> <data name="two" expr="2" />
> </datamodel>
>
> <onentry>
> <send event="'event.bar'" namelist="one two"
> delay="'100ms'"/>
> </onentry>
> <transition event="event.bar">
> <log label="'simulatedUser'"
> expr="_eventdatamap['event.bar'].one + ', ' +
> _eventdatamap['event.bar'].two"/>
> </transition>
> </state>
>
> <state id="counter">
> <initial>
> <transition target="twenty"/>
> </initial>
>
> <state id="twenty">
> <transition event="event.bar"
> cond="_eventdatamap['event.bar'].one +
> _eventdatamap['event.bar'].two eq 3"
> target="thirty"/>
> <transition event="event.bar">
> <log label="'event.bar in twenty state'"
> expr="_eventdatamap['event.bar'].one + ', ' +
> _eventdatamap['event.bar'].two"/>
> </transition>
> </state>
>
> <state id="thirty" final="true"/>
> </state>
>
> </parallel>
>
> </scxml>
>
> theoretically , the current states is : *simulatedUser *and *twenty*
>
<snip/>
Correct.
> I tried to code something but i'm getting : twenty+thirty#simulatedUser
> I should have twenty#simulatedUser !! instead i get all the state inside
> counter ......... :(
>
> do you have an answer and a solution for that ?
>
<snap/>
Nothing stood out in the code so I actually pasted it into a test and
ran it -- I get "simulatedUser#twenty" which is effectively the same
thing.
If you aren't seeing the expected result there is some other relevant
piece of information that you haven't yet posted here.
-Rahul
> public String getCurrentStates() {
> Set states = exec.getCurrentStatus().getStates();
> Iterator<State> it = states.iterator();
> State state;
> String sid="";
> while(it.hasNext()){
> state = it.next();
> sid+=stateToString(state,"+-*(){}/");
> if(it.hasNext())sid+="#";
> }
> return ((State)
> exec.getCurrentStatus().getStates().iterator().next())
> .getId();
> }
> public String stateToString(State state,String separators){
> String sid="";
> boolean test= state.isComposite();
> if( test && separators.length()>0){
> char separator=separators.charAt(0);
> separators=separators.substring(1);
> Map states = state.getChildren();
> Iterator<State> it = states.values().iterator();
> while(it.hasNext()){
> state = it.next();
> sid+=stateToString(state,separators);
> if(it.hasNext())sid+=separator;
> }
> return sid;
> }else{
> return state.getId();
> }
> }
>
> It will be helpfull to have a solution for that, because it is the same
> problem for the checkIfAbleToChangeState() function.
>
>
> Thank you !!
>
>
>
> ( And thanks for this amazing work )
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]