You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by "Arnon L." <ar...@nomagicasia.com> on 2011/12/28 11:17:00 UTC

[scxml] In Parallel, it is not work when State transitions to History.

Hi all SCXML guys,
I have been working with the model that using Parallel and History, the
picture of sample model in state diagram has also been attached(SM1.jpg).
I found the problem when I transition from "S1" to "History" by
triggering "Sig1" event (History was already memorized), this exception
was occurred.
2011-12-28 15:08:03,775 INFO : Illegal state machine configuration!
org.apache.commons.scxml.model.ModelException: Illegal state machine
configuration!
    at
org.apache.commons.scxml.semantics.SCXMLSemanticsImpl.followTransitions(SCXMLSemanticsImpl.java:703)
    at
org.apache.commons.scxml.SCXMLExecutor.triggerEvents(SCXMLExecutor.java:127)
    at
org.apache.commons.scxml.env.AbstractStateMachine.fireEvent(AbstractStateMachine.java:201)

The equivalent SCXML is following:

<?xml version="1.0" encoding="UTF-8"?>
<scxml xmlns="http://www.w3.org/2005/07/scxml" version="null"
initial="Main">
 <!-- http://commons.apache.org/scxml -->
 <parallel id="Main">
  <state id="region_Region1">
   <initial>
    <transition target="S1">
    </transition>
   </initial>
   <state id="S7">
    <initial>
     <transition target="s4">
     </transition>
    </initial>
    <history id="History" type="shallow">
     <transition>
      <target>       <state id="s4">
        <transition event="Sig3" target="S3">
        </transition>
       </state>
      </target>     </transition>
    </history>
    <transition event="Sig2" target="S1">
    </transition>
    <state id="S3">
    </state>
    <state id="s4">
     <transition event="Sig3" target="S3">
     </transition>
    </state>
   </state>
   <state id="S1">
    <transition event="Sig1" target="History">
    </transition>
    <transition event="Sig0" target="S7">
    </transition>
   </state>
  </state>
  <state id="region_Region2">
   <initial>
    <transition target="S10">
    </transition>
   </initial>
   <state id="S10">
   </state>
  </state>
 </parallel>
</scxml>

I don't sure this is a bug of SCXML or not. It seems like active states
is not valid in Parallel

        if (!SCXMLHelper.isLegalConfig(targetSet, errorReporter)) {
            throw new ModelException("Illegal state machine
configuration!");
        }

        in SCXMLHelper.isLegalConfig(targetSet, errorReporter):
            if (tt instanceof Parallel) {
                Parallel p = (Parallel) tt;
                if (count.size() < p.getChildren().size()) {
                    errRep.onError(ErrorConstants.ILLEGAL_CONFIG,
                        "Not all AND states active for parallel "
                        + p.getId(), entry);
                    legalConfig = false;
                }
            }

Thanks,
Arnon