You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Rahul Akolkar <ra...@gmail.com> on 2008/04/11 03:21:50 UTC

Re: [SCXML] W3C specs compatibility and state transition issues

On Thu, Apr 10, 2008 at 8:30 PM, Ouyang, Landon - ES/RDR -Gil
<La...@itt.com> wrote:
> Apologize for the duplicate e-mail, I had to be schooled on the proper format by Mr. Cooper. :)
>
>
> I am a new user of Commons SCXML. I have two very basic questions:
>
> 1)      How much of the W3C specs for SCXML is supported with Common SCXML? Are all of the tags recognized?
>
<snip/>

Not supported:
  <anchor> (supporting this one is optional for engines)
  <validate>

Experimental (due to missing pieces in draft spec, see TBD markers for example):
  <invoke>


> 2)      Basing my code off of the simple stopwatch example, I created a simple Java app that navigated across 10 states. I noticed that if I put any code in the state handler methods that fires off events to transition to other states, the application still thinks I am in the *previous* state! For example, if I am in the state 5 subroutine and fire off an EVENT_NEXT event to go to state 6, the app actually keeps me in state 5 because it still thinks I am in state 4! Is it true that the state machine transitions *after* the handler for the new state is called? If so, how do I put custom code so that the state can make transition decisions based on certain conditions?
>
<snap/>

You'd have to do that asynchronously (the executor is still processing
the earlier event). However ...

I'd store the result of "certain conditions" in the datamodel, and
query the datamodel later, like so:

public void foo() { // handler for state "foo"

    // check certain conditions, create someresultbean

    getEngine().getRootContext().put("fooresult", someresultbean);
}

And further, in a totally fictitious example:

<state id="foo">
    <transition cond="fooresult.success" target="bar"/>
    <transition cond="fooresult.numfailures gt 2" target="exit"/>
    <transition cond="not fooresult.success" target="foo"/> <!-- try again -->
    <!-- foo's other content -->
</state>

-Rahul


>
>
> --
> Landon Ouyang
> Member Technical Staff
> ITT Electronics Systems, Radar Systems - Gilfillan
> 7821 Orion Ave,
> Van Nuys, CA 91406
> (818) 901-2982
>

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


Re: [SCXML] _eventdata not included in collection events ?

Posted by Rahul Akolkar <ra...@gmail.com>.
On 4/30/08, Tony Seebregts <to...@iveri.com> wrote:
> Ah, of course ... thanks Rahul !
>
>  This exposes a problem with the Javascript evaluator though. The
>  Javascript engine (both JDK and JSR223) isn't able to apply the []
>  operator to a HashMap because its a Java object rather than a Javascript
>  object (using _eventdatamap.get('event.name') works fine).
>
>  Will file a bug...
>
<snip/>

Makes sense, will comment on SCXML-71.

-Rahul


>  regards
>
>
>  Tony
>
>
>
>  >> Hi,
>  >>
>  >>  I'm trying to pass information from a class that extends Action via a
>  >>  TriggerEvent payload but in the SCXML script the _eventdata value for
>  >>  the associated event transition seems to be null.
>  >>
>  >>  Any ideas ?
>  >>
>  >>  The payload works fine if I call triggerEvent but not if I just add the
>  >>  event to the events Collection and I can't figure out why (for various
>  >>  reasons triggerEvent doesn't work in the scenario).
>  >>
>  > <snip/>
>  >
>  > Yup, you shouldn't use triggerEvent here.
>  >
>  > The way derived events are handled is to process all of them in a
>  > microstep. Since there may be more than one event, _eventdata is
>  > ambigous, and _eventdatamap['event.name'] should be used instead for
>  > derived events.
>  >
>  > For example, see the eventdata_* test case documents in the JUnit test
>  > suite ... few of them are here:
>  >
>  > http://svn.apache.org/repos/asf/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/env/jexl/
>  >
>  > -Rahul
>
>

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


Re: [SCXML] _eventdata not included in collection events ?

Posted by Tony Seebregts <to...@iveri.com>.
Ah, of course ... thanks Rahul !

This exposes a problem with the Javascript evaluator though. The
Javascript engine (both JDK and JSR223) isn't able to apply the []
operator to a HashMap because its a Java object rather than a Javascript
object (using _eventdatamap.get('event.name') works fine).

Will file a bug...

regards

Tony


>> Hi,
>>
>>  I'm trying to pass information from a class that extends Action via a
>>  TriggerEvent payload but in the SCXML script the _eventdata value for
>>  the associated event transition seems to be null.
>>
>>  Any ideas ?
>>
>>  The payload works fine if I call triggerEvent but not if I just add the
>>  event to the events Collection and I can't figure out why (for various
>>  reasons triggerEvent doesn't work in the scenario).
>>
> <snip/>
> 
> Yup, you shouldn't use triggerEvent here.
> 
> The way derived events are handled is to process all of them in a
> microstep. Since there may be more than one event, _eventdata is
> ambigous, and _eventdatamap['event.name'] should be used instead for
> derived events.
> 
> For example, see the eventdata_* test case documents in the JUnit test
> suite ... few of them are here:
> 
> http://svn.apache.org/repos/asf/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/env/jexl/
> 
> -Rahul


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


Re: [SCXML] _eventdata not included in collection events ?

Posted by Rahul Akolkar <ra...@gmail.com>.
On 4/29/08, Tony Seebregts <to...@iveri.com> wrote:
> Hi,
>
>  I'm trying to pass information from a class that extends Action via a
>  TriggerEvent payload but in the SCXML script the _eventdata value for
>  the associated event transition seems to be null.
>
>  Any ideas ?
>
>  The payload works fine if I call triggerEvent but not if I just add the
>  event to the events Collection and I can't figure out why (for various
>  reasons triggerEvent doesn't work in the scenario).
>
<snip/>

Yup, you shouldn't use triggerEvent here.

The way derived events are handled is to process all of them in a
microstep. Since there may be more than one event, _eventdata is
ambigous, and _eventdatamap['event.name'] should be used instead for
derived events.

For example, see the eventdata_* test case documents in the JUnit test
suite ... few of them are here:

http://svn.apache.org/repos/asf/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/env/jexl/

-Rahul


>  The relevant code is:
>
>  public void execute(EventDispatcher dispatcher,
>                     ErrorReporter   reporter,
>                     SCInstance      instance,
>                     Log             log,
>                     Collection      events) throws
>  ModelException,SCXMLExpressionException
>        { Evaluator evaluator = instance.getEvaluator();
>          Context   context   = instance.getContext  (getParentState());
>          String    uidx      = null;
>          String    pinx      = null;
>          int       serviceID;
>          User      user;
>
>          try
>             { if (uid != null)
>                  uidx = (String) evaluator.eval(context,uid);
>
>               if (pin != null)
>                  pinx = (String) evaluator.eval(context,pin);
>
>               if ((user = login(uidx,pinx)) == null)
>                  { events.add(INVALID);
>                    return;
>                  }
>
>               events.add(new  TriggerEvent("ok",
>  TriggerEvent.SIGNAL_EVENT, user));
>                        return;
>             }
>          catch(Throwable x)
>             { log.error("Error logging in: " + x.toString());
>             }
>
>          instance.getExecutor().triggerEvent(ERROR);
>        }
>
>  regards
>
>  Tony Seebregts
>

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


[SCXML] _eventdata not included in collection events ?

Posted by Tony Seebregts <to...@iveri.com>.
Hi,

I'm trying to pass information from a class that extends Action via a
TriggerEvent payload but in the SCXML script the _eventdata value for
the associated event transition seems to be null.

Any ideas ?

The payload works fine if I call triggerEvent but not if I just add the
event to the events Collection and I can't figure out why (for various
reasons triggerEvent doesn't work in the scenario).

The relevant code is:

public void execute(EventDispatcher dispatcher,
                    ErrorReporter   reporter,
                    SCInstance      instance,
                    Log             log,
                    Collection      events) throws
ModelException,SCXMLExpressionException
       { Evaluator evaluator = instance.getEvaluator();
         Context   context   = instance.getContext  (getParentState());
         String    uidx      = null;
         String    pinx      = null;
         int       serviceID;
         User      user;

         try
            { if (uid != null)
                 uidx = (String) evaluator.eval(context,uid);

              if (pin != null)
                 pinx = (String) evaluator.eval(context,pin);

              if ((user = login(uidx,pinx)) == null)
                 { events.add(INVALID);
                   return;
                 }

              events.add(new  TriggerEvent("ok",
TriggerEvent.SIGNAL_EVENT, user));
                       return;
            }
         catch(Throwable x)
            { log.error("Error logging in: " + x.toString());
            }

         instance.getExecutor().triggerEvent(ERROR);
       }

regards

Tony Seebregts

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


Re: [SCXML] Rational Software Architect

Posted by Rahul Akolkar <ra...@gmail.com>.
On 4/23/08, Ouyang, Landon - ES/RDR -Gil <La...@itt.com> wrote:
> Hello,
>
>  According to the website, the Rational Software Architect could be used
>  to generate the XML files that run with the Commons SCXML engine.
>  However, there appears to be syntactical differences between what is
>  generated from the software and what actually works on the engine.
>
>  The following XML was generated for composite states by the software:
>
>  <state id="Region1">
>         <initial id="zero">
>                 <transition event="display.next">
>                         <target next="one" />
>                 </transition>
>         </initial>
>
>  This does not work (both the transition and the initial state).
<snip/>

Sure, I can see why.


> It must
>  be changed to this to work:
>
>  <state id="Region1">
>     <initial>
>         <transition target="zero"/>
>     </initial>
>  <state id="zero">
>     <transition event="display.next" target="one" />
>  </state>
>
>  Can you explain this discrepancy because I assumed that the Software
>  Architect adhered to the proper SCXML standards? Were there any settings
>  changes that you made to the software to generate the syntax-correct
>  files?
>
<snap/>

The plugin (note that its a prototype, hence on alphaWorks) was
originally authored for a previous release of Commons SCXML (IIRC,
v0.5). At that point, the Working Draft did have a slightly different
vocabulary for specifying transition targets (as evidenced above). I
don't think the plugin has been updated to work with v0.7. That
explains one part of the above discrepancy. I'm not sure about the
other error in generation (the transition for 'display.next'). Perhaps
you can try asking on the forum provided on alphaWorks, since you may
get a better answer there.

-Rahul


>  Thanks,
>  Landon
>
>

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


[SCXML] Rational Software Architect

Posted by "Ouyang, Landon - ES/RDR -Gil" <La...@itt.com>.
Hello,

According to the website, the Rational Software Architect could be used
to generate the XML files that run with the Commons SCXML engine.
However, there appears to be syntactical differences between what is
generated from the software and what actually works on the engine.

The following XML was generated for composite states by the software:

<state id="Region1">
        <initial id="zero">
                <transition event="display.next">
                        <target next="one" />
                </transition>
        </initial>

This does not work (both the transition and the initial state). It must
be changed to this to work:

<state id="Region1">
    <initial>
        <transition target="zero"/>
    </initial>
<state id="zero">
    <transition event="display.next" target="one" />
</state>

Can you explain this discrepancy because I assumed that the Software
Architect adhered to the proper SCXML standards? Were there any settings
changes that you made to the software to generate the syntax-correct
files?

Thanks,
Landon





--
Landon Ouyang
Member Technical Staff
ITT Electronics Systems, Radar Systems - Gilfillan
7821 Orion Ave,
Van Nuys, CA 91406
(818) 901-2982

This e-mail and any files transmitted with it may be proprietary and are intended solely for the use of the individual or entity to whom they are addressed. If you have received this e-mail in error please notify the sender. Please note that any views or opinions presented in this e-mail are solely those of the author and do not necessarily represent those of ITT Corporation. The recipient should check this e-mail and any attachments for the presence of viruses. ITT accepts no liability for any damage caused by any virus transmitted by this e-mail.

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


Re: [SCXML] State transitions from within handler

Posted by Rahul Akolkar <ra...@gmail.com>.
On 4/17/08, Ouyang, Landon - ES/RDR -Gil <La...@itt.com> wrote:
> Hi Rahul,
>
>  Thanks for your informative response.
>
>  Using your suggestions I created my own state machine class that did not
>  utilize a listener. I overwrote the Initialize() and fireEvent()
>  routines to invoke the state methods and utilize an event stack to
>  process external events.
>
>  The only issue with my implementation is that an event must be fired for
>  a state method to be invoked. For example, if we make state 4
>  automatically (unconditionally) transition to state 5 in the SCXML file,
>  state5() will not be called. It will only be called if we fire an event
>  in state 4 to transition to state 5.
>
>  Is there a place where I can call invoke() in the state machine
>  implementation (without a listener) so that the state handler is called
>  on a transition regardless of whether an event was fired or not?
>
<snip/>

You could register a listener simply to track the progress, especially
when eventless transitions are involved as you describe (and refer to
this list to invoke state "handlers" in order). Alternatively, you
could guard the previously eventless transitions with a special event
(some event name TBD) that you fire at the end of the preceeding state
handler.

-Rahul



>
>  --
>  Landon Ouyang
>  Member Technical Staff
>  ITT Electronics Systems, Radar Systems - Gilfillan
>  7821 Orion Ave,
>  Van Nuys, CA 91406
>  (818) 901-2982
>
>  -----Original Message-----
>  From: Rahul Akolkar [mailto:rahul.akolkar@gmail.com]
>
> Sent: Monday, April 14, 2008 12:19 PM
>  To: Jakarta Commons Users List
>
> Subject: Re: [SCXML] State transitions from within handler
>
>  On 4/14/08, Ouyang, Landon - ES/RDR -Gil <La...@itt.com> wrote:
>  > Rahul,
>  >
>  >  Thanks for your help, I was able to implement the state transition
>  >  method you had described earlier.
>  >
>  >  The reason for this investigation is that we intend to use the
>  Commons
>  >  SCXML engine to implement highly complex systems by separating all
>  the
>  >  "pieces" into atomic modules (states).
>  <snip/>
>
>  Makes sense, for very simple systems [scxml] may even be overkill.
>
>
>  >  However, we would like the
>  >  decision making for the transitions to be done within the application
>  >  code (state handlers) and not the state machine implementation (XML).
>  We
>  >  foresee problems if the XML document must specifically reference the
>  >  attributes needed to decide which transitions occur (ie
>  'result.value'
>  >  in our earlier example).
>  >
>  <snap/>
>
>  OK, though I don't necessarily agree. Couple of points:
>
>   * IMO, in highly complex systems the declarative vocabulary (be it
>  XML or otherwise) can be thought of as merely a serialization of some
>  model (such as the domain UML2 state charts) which the developer(s)
>  maintain.
>
>   * The [scxml] library can be the basis of building components that
>  serve to wrapper certain conventions in place over the state machine
>  implementation -- conventions that mitigate problems in having to
>  "specifically reference the attributes needed". The
>  AbstractStateMachine is one such simple example (uses a convention to
>  call "state handlers"). However, it has drawbacks (such as invoking
>  handlers synchronously while processing events) and is not fit for
>  complex systems.
>
>
>  >  The only way I can think around this problem is to create a custom
>  >  transition/event stack in which the next event gets pushed during the
>  >  state handler and popped once we are officially in the current state
>  >  (since the previous state is still being processed while we are in
>  the
>  >  handler).
>  >
>  <snip/>
>
>  May not be necessary. The following suggested replacements is how I
>  have understood the sentences in the above paragraph:
>
>  s/officially in a state/at rest in a state/
>  s/previous state is being processed/previous event is being processed/
>
>
>  >  Is there a better way around this issue? If not, where in
>  >  AbstractStateMachine will I know for a fact that the previous state's
>  >  processing has been completed?
>  >
>  <snap/>
>
>  See this page:
>
>   http://commons.apache.org/scxml/guide/using-commons-scxml.html
>
>  The AbstractStateMachine uses the second pattern. One of the ways to
>  achieve what you want is using the first pattern, "Mapping states to
>  activities" (current state --> state handler).
>
>  Create a variant that bootstraps similar to the AbstractStateMachine
>  class, waits for state machine to come to rest (initially, and when
>  any subsequent event is triggered on it), looks up current state
>  (rather than registering a listener that gets called synchronously),
>  and calls the corresponding state handler. Maintain a queue for
>  external events, have state handlers add to that queue, trigger events
>  in order while queue not empty. Adjustments necessary per taste etc.
>  :-)
>
>  -Rahul
>

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


RE: [SCXML] State transitions from within handler

Posted by "Ouyang, Landon - ES/RDR -Gil" <La...@itt.com>.
Hi Rahul,

Thanks for your informative response.

Using your suggestions I created my own state machine class that did not
utilize a listener. I overwrote the Initialize() and fireEvent()
routines to invoke the state methods and utilize an event stack to
process external events.

The only issue with my implementation is that an event must be fired for
a state method to be invoked. For example, if we make state 4
automatically (unconditionally) transition to state 5 in the SCXML file,
state5() will not be called. It will only be called if we fire an event
in state 4 to transition to state 5.

Is there a place where I can call invoke() in the state machine
implementation (without a listener) so that the state handler is called
on a transition regardless of whether an event was fired or not?

--
Landon Ouyang
Member Technical Staff
ITT Electronics Systems, Radar Systems - Gilfillan
7821 Orion Ave,
Van Nuys, CA 91406
(818) 901-2982

-----Original Message-----
From: Rahul Akolkar [mailto:rahul.akolkar@gmail.com]
Sent: Monday, April 14, 2008 12:19 PM
To: Jakarta Commons Users List
Subject: Re: [SCXML] State transitions from within handler

On 4/14/08, Ouyang, Landon - ES/RDR -Gil <La...@itt.com> wrote:
> Rahul,
>
>  Thanks for your help, I was able to implement the state transition
>  method you had described earlier.
>
>  The reason for this investigation is that we intend to use the
Commons
>  SCXML engine to implement highly complex systems by separating all
the
>  "pieces" into atomic modules (states).
<snip/>

Makes sense, for very simple systems [scxml] may even be overkill.


>  However, we would like the
>  decision making for the transitions to be done within the application
>  code (state handlers) and not the state machine implementation (XML).
We
>  foresee problems if the XML document must specifically reference the
>  attributes needed to decide which transitions occur (ie
'result.value'
>  in our earlier example).
>
<snap/>

OK, though I don't necessarily agree. Couple of points:

 * IMO, in highly complex systems the declarative vocabulary (be it
XML or otherwise) can be thought of as merely a serialization of some
model (such as the domain UML2 state charts) which the developer(s)
maintain.

 * The [scxml] library can be the basis of building components that
serve to wrapper certain conventions in place over the state machine
implementation -- conventions that mitigate problems in having to
"specifically reference the attributes needed". The
AbstractStateMachine is one such simple example (uses a convention to
call "state handlers"). However, it has drawbacks (such as invoking
handlers synchronously while processing events) and is not fit for
complex systems.


>  The only way I can think around this problem is to create a custom
>  transition/event stack in which the next event gets pushed during the
>  state handler and popped once we are officially in the current state
>  (since the previous state is still being processed while we are in
the
>  handler).
>
<snip/>

May not be necessary. The following suggested replacements is how I
have understood the sentences in the above paragraph:

s/officially in a state/at rest in a state/
s/previous state is being processed/previous event is being processed/


>  Is there a better way around this issue? If not, where in
>  AbstractStateMachine will I know for a fact that the previous state's
>  processing has been completed?
>
<snap/>

See this page:

  http://commons.apache.org/scxml/guide/using-commons-scxml.html

The AbstractStateMachine uses the second pattern. One of the ways to
achieve what you want is using the first pattern, "Mapping states to
activities" (current state --> state handler).

Create a variant that bootstraps similar to the AbstractStateMachine
class, waits for state machine to come to rest (initially, and when
any subsequent event is triggered on it), looks up current state
(rather than registering a listener that gets called synchronously),
and calls the corresponding state handler. Maintain a queue for
external events, have state handlers add to that queue, trigger events
in order while queue not empty. Adjustments necessary per taste etc.
:-)

-Rahul

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


This e-mail and any files transmitted with it may be proprietary and are intended solely for the use of the individual or entity to whom they are addressed. If you have received this e-mail in error please notify the sender. Please note that any views or opinions presented in this e-mail are solely those of the author and do not necessarily represent those of ITT Corporation. The recipient should check this e-mail and any attachments for the presence of viruses. ITT accepts no liability for any damage caused by any virus transmitted by this e-mail.

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


Re: [SCXML] State transitions from within handler

Posted by Rahul Akolkar <ra...@gmail.com>.
On 4/14/08, Ouyang, Landon - ES/RDR -Gil <La...@itt.com> wrote:
> Rahul,
>
>  Thanks for your help, I was able to implement the state transition
>  method you had described earlier.
>
>  The reason for this investigation is that we intend to use the Commons
>  SCXML engine to implement highly complex systems by separating all the
>  "pieces" into atomic modules (states).
<snip/>

Makes sense, for very simple systems [scxml] may even be overkill.


>  However, we would like the
>  decision making for the transitions to be done within the application
>  code (state handlers) and not the state machine implementation (XML). We
>  foresee problems if the XML document must specifically reference the
>  attributes needed to decide which transitions occur (ie 'result.value'
>  in our earlier example).
>
<snap/>

OK, though I don't necessarily agree. Couple of points:

 * IMO, in highly complex systems the declarative vocabulary (be it
XML or otherwise) can be thought of as merely a serialization of some
model (such as the domain UML2 state charts) which the developer(s)
maintain.

 * The [scxml] library can be the basis of building components that
serve to wrapper certain conventions in place over the state machine
implementation -- conventions that mitigate problems in having to
"specifically reference the attributes needed". The
AbstractStateMachine is one such simple example (uses a convention to
call "state handlers"). However, it has drawbacks (such as invoking
handlers synchronously while processing events) and is not fit for
complex systems.


>  The only way I can think around this problem is to create a custom
>  transition/event stack in which the next event gets pushed during the
>  state handler and popped once we are officially in the current state
>  (since the previous state is still being processed while we are in the
>  handler).
>
<snip/>

May not be necessary. The following suggested replacements is how I
have understood the sentences in the above paragraph:

s/officially in a state/at rest in a state/
s/previous state is being processed/previous event is being processed/


>  Is there a better way around this issue? If not, where in
>  AbstractStateMachine will I know for a fact that the previous state's
>  processing has been completed?
>
<snap/>

See this page:

  http://commons.apache.org/scxml/guide/using-commons-scxml.html

The AbstractStateMachine uses the second pattern. One of the ways to
achieve what you want is using the first pattern, "Mapping states to
activities" (current state --> state handler).

Create a variant that bootstraps similar to the AbstractStateMachine
class, waits for state machine to come to rest (initially, and when
any subsequent event is triggered on it), looks up current state
(rather than registering a listener that gets called synchronously),
and calls the corresponding state handler. Maintain a queue for
external events, have state handlers add to that queue, trigger events
in order while queue not empty. Adjustments necessary per taste etc.
:-)

-Rahul

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


[SCXML] State transitions from within handler

Posted by "Ouyang, Landon - ES/RDR -Gil" <La...@itt.com>.
Rahul,

Thanks for your help, I was able to implement the state transition
method you had described earlier.

The reason for this investigation is that we intend to use the Commons
SCXML engine to implement highly complex systems by separating all the
"pieces" into atomic modules (states). However, we would like the
decision making for the transitions to be done within the application
code (state handlers) and not the state machine implementation (XML). We
foresee problems if the XML document must specifically reference the
attributes needed to decide which transitions occur (ie 'result.value'
in our earlier example).

The only way I can think around this problem is to create a custom
transition/event stack in which the next event gets pushed during the
state handler and popped once we are officially in the current state
(since the previous state is still being processed while we are in the
handler).

Is there a better way around this issue? If not, where in
AbstractStateMachine will I know for a fact that the previous state's
processing has been completed?

Thanks once again,
Landon Ouyang
Member Technical Staff
ITT Electronics Systems, Radar Systems - Gilfillan
7821 Orion Ave,
Van Nuys, CA 91406
(818) 901-2982


-----Original Message-----
From: Ouyang, Landon - ES/RDR -Gil [mailto:Landon.Ouyang@itt.com]
Sent: Monday, April 14, 2008 9:31 AM
To: Jakarta Commons Users List
Subject: RE: [SCXML] W3C specs compatibility and state transition issues

Hi Rahul,

My (limited) understand of JavaBeans is that a JavaBean object must
implement java.io.Serializable, has a public no argument constructor,
and contains set/get methods for properties. So I setup my result class
as follows:

    class result implements Serializable
        {
        public result() {}
        private int value;
        public int getValue()
            { return value; }
        public void setValue(int nNum)
            { value = nNum; }
        }

However, the state transition still does not work!

FYI, I was able to prove that the object is sent to the engine correctly
using:

result newResult = (result)getEngine().getRootContext().get("result");

But for some reason, I cannot retrieve/use "result.value" in my XML
file!

Any ideas what I'm missing here? Thanks for the help.

--
Landon Ouyang
Member Technical Staff
ITT Electronics Systems, Radar Systems - Gilfillan
7821 Orion Ave,
Van Nuys, CA 91406
(818) 901-2982

-----Original Message-----
From: Rahul Akolkar [mailto:rahul.akolkar@gmail.com]
Sent: Friday, April 11, 2008 6:56 PM
To: Jakarta Commons Users List
Subject: Re: [SCXML] W3C specs compatibility and state transition issues

On Fri, Apr 11, 2008 at 7:15 PM, Ouyang, Landon - ES/RDR -Gil
<La...@itt.com> wrote:
> Hmmm....
>
> Given your snippet, I assumed this would work:
>
> result aResult = new result();
>
> if(bIsTest)
>   aResult.value = 1;
> else
>   aResult.value = 0;
>
> getEngine().getRootContext().set("result", aResult);
>
> where the XML transition is conditional on "result.value eq 1". Why
> doesn't it work?
>
<snip/>

Try adding getter and setter methods, as I suggest below (for property
"value" in this example). Detailed discussion is in the JavaBeans
spec, which forms the basis of bean property access in most ELs we
use.

-Rahul


> --
> Landon Ouyang
> Member Technical Staff
> ITT Electronics Systems, Radar Systems - Gilfillan
> 7821 Orion Ave,
> Van Nuys, CA 91406
> (818) 901-2982
>
>
> -----Original Message-----
> From: Rahul Akolkar [mailto:rahul.akolkar@gmail.com]
>
> Sent: Friday, April 11, 2008 2:18 PM
> To: Jakarta Commons Users List
> Subject: Re: [SCXML] W3C specs compatibility and state transition
issues
>
> On Fri, Apr 11, 2008 at 5:01 PM, Ouyang, Landon - ES/RDR -Gil
> <La...@itt.com> wrote:
> > I figured out the solution:
> >
> > I needed to remove the event properties from the conditional
> > transitions. So if I change the state to:
> >
> > <state id="six">
> >        <datamodel>
> >                <data name="result">
> >                        <value>0</value>
> >                </data>
> >        </datamodel>
> >  <transition cond="result.value eq '1'" target="zero"/>
> >  <transition cond="result.value eq '0'" target="five"/>
> >  <transition target="three" event="display.prev"/>
> > </state>
> >
> > the code will work! Am I missing any other crucial details?
> >
> <snip/>
>
> Not really, but couple of comments:
>
>  * At a quick glance, I suspect you don't need the <datamodel>
> specified declaratively, so you can just remove the entire <datamodel>
> element (we are setting "result.value" via Java handlers). A brief
> discussion about datamodels is here:
>
>  http://commons.apache.org/scxml/guide/datamodel.html
>
>  * When I gave the example (below), I intended "fooresult.success" and
> "fooresult.numfailures" to be expressions of the flavor bean.property
> i.e. fooresult was an instance of:
>
> class FooResult {
>  get/setSuccess()
>  get/setNumfailures()
> }
>
> Generally better if you want to return a data structure, rather than
> multiple "flat variables" (your example is fine, for one value its
> much overhead).
>
> -Rahul
>

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


This e-mail and any files transmitted with it may be proprietary and are
intended solely for the use of the individual or entity to whom they are
addressed. If you have received this e-mail in error please notify the
sender. Please note that any views or opinions presented in this e-mail
are solely those of the author and do not necessarily represent those of
ITT Corporation. The recipient should check this e-mail and any
attachments for the presence of viruses. ITT accepts no liability for
any damage caused by any virus transmitted by this e-mail.

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


This e-mail and any files transmitted with it may be proprietary and are intended solely for the use of the individual or entity to whom they are addressed. If you have received this e-mail in error please notify the sender. Please note that any views or opinions presented in this e-mail are solely those of the author and do not necessarily represent those of ITT Corporation. The recipient should check this e-mail and any attachments for the presence of viruses. ITT accepts no liability for any damage caused by any virus transmitted by this e-mail.

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


Re: [SCXML] XML engine decoupled from code

Posted by Rahul Akolkar <ra...@gmail.com>.
On 5/1/08, Ouyang, Landon - ES/RDR -Gil <La...@itt.com> wrote:
> Rahul,
>
>  Thanks for the response. I am now up and running with <invoke>
>  (somewhat) but the lack of synchronicity is causing me a few issues that
>  I hope you can help with.
>
<snip/>

As I mentioned in a previous email in this thread, I think custom
actions are more appropriate given what you've said so far.

See Invoker Javadoc, the implied lifecycle, and particularly note at the bottom:

  http://commons.apache.org/scxml/apidocs/org/apache/commons/scxml/invoke/Invoker.html


>  First, is there a way for a state to invoke a method and then
>  unconditionally transition to another state?
<snap/>

Part of its <onentry> say:

<onentry>
  <my:java ... /> <!-- Reuse your invoke impl for the guts of this action -->
</onentry>


> For example:
>
>     <state id="GetOnlineRemote">
>         <invoke targettype="java" src="GetOnlineRemote"/>
>         <transition target="SteadyState" />
>     </state>
>
>  *should* execute the GetOnlineRemote() method and then transition to
>  SteadyState. However, because invoke is asynchronous, only the
>  transition happens. Is there a solution to this besides firing a return
>  event in GetOnlineRemote and conditioning the transition to that event?
>
<snip/>

No, but conventionally, the event should be named
"{stateID}.invoke.done". Here is a simple example:

  http://svn.apache.org/repos/asf/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/invoke/invoker-01.xml

Also conventionally, non-standard targettypes should begin with 'x-'
so the more appropriate name for the above would be 'x-java' or some
such.

Though feels a bit like strong-arming invoke in this case.


>  Second, I chained several states together before going back to our
>  steady state (the starting point for state transitions):
>
>     <state id="GetAll">
>         <invoke targettype="java" src="GetOnlineRemote"/>
>         <transition event="s3d.ReturnToSteady"
>  target="GetTransmitterStateAll"/>
>     </state>
>     <state id="GetTransmitterStateAll">
>         <invoke targettype="java" src="GetTransmitterState"/>
>         <transition event="s3d.ReturnToSteady"
>  target="GetAntRotateAll"/>
>     </state>
>     <state id="GetAntRotateAll">
>         <invoke targettype="java" src="GetAntennaRotating"/>
>         <transition event="s3d.ReturnToSteady" target="GetWIPModeAll"/>
>     </state>
>     <state id="GetWIPModeAll">
>         <invoke targettype="java" src="GetWIPMode"/>
>         <transition event="s3d.ReturnToSteady" target="SteadyState" />
>     </state>
>
>  All states fired the s3d.ReturnToSteady event at the end of execution.
>  When executed, each method invocation happens as desired and I verified
>  that the state machine returns to the steady state. However, after
>  execution none of the transitions from the steady state work anymore!
>  This only happens when I chained the states together instead of entering
>  one state and then immediately returning to the steady state. Any idea
>  what is going on?
>
<snap/>

Not yet.

-Rahul



>
>  --
>  Landon Ouyang
>  Member Technical Staff
>  ITT Electronics Systems, Radar Systems - Gilfillan
>  7821 Orion Ave,
>  Van Nuys, CA 91406
>  (818) 901-2982
>
>
>  -----Original Message-----
>  From: Rahul Akolkar [mailto:rahul.akolkar@gmail.com]
>
> Sent: Thursday, May 01, 2008 12:40 PM
>  To: Commons Users List
>  Subject: Re: [SCXML] XML engine decoupled from code
>
>  On 4/30/08, Ouyang, Landon - ES/RDR -Gil <La...@itt.com> wrote:
>  > Rahul,
>  >
>  >  Thanks once again for the quick response.
>  >
>  >  Before reading your e-mail I had already decided to go with the
>  <invoke>
>  >  route for developing our implementation. I made our state machine
>  class
>  >  an invoker class and registered it with the SCXML executor. The
>  invoke()
>  >  method would trim the string passed in as the source parameter and
>  >  invoke the method similar to the AbstractStateMachine class. I am now
>  >  able to add statements in the XML that utilize the <invoke> tag to
>  >  invoke Java methods defined inside the state machine class.
>  >
>  >  I ran into a problem which leads me to believe I may have chosen the
>  >  wrong route: I cannot access the initiated values of the class!
>  <snip/>
>
>  As in static fields? Should be possible.
>
>
>  > For
>  >  example, the state machine needed access to the GUI to change various
>  >  widgets. I had a member assigned to the JFrame to accomplish this but
>  >  this member is now null in the invoked method even though I correctly
>  >  initialized it earlier! This never happened before until I
>  transformed
>  >  the state machine class to an invoker class. Is the Invoker object a
>  >  separate instance of the original state machine object?
>  >
>  <snap/>
>
>  Each <invoke> gets a new instance of the Invoker class. If you need to
>  "initialize" the instance with handles to other bits (such as a
>  JFrame, in this example), those need to be in the state machine's
>  Context and passed in as <param>s.
>
>  IOW, an example in code:
>
>  0) Say myJFrame is the frame
>  executor.getRootContext().set("frame", myJFrame);
>
>  1) Markup fragment
>  <invoke ...>
>   <param name="frame" expr="frame"/>
>   ...
>  </invoke>
>
>  2) In invoker#invoke(String src, Map params) .... params.get("frame")
>  gets you the frame.
>
>  Finally, as mentioned on the Commons SCXML homepage (and the spec in
>  progress), <invoke> is evolving.
>
>  -Rahul
>
>
>  >
>  >  --
>  >
>  > Landon Ouyang
>  >  Member Technical Staff
>  >  ITT Electronics Systems, Radar Systems - Gilfillan
>  >  7821 Orion Ave,
>  >  Van Nuys, CA 91406
>  >  (818) 901-2982
>  >
>  >  -----Original Message-----
>  >
>  > From: Rahul Akolkar [mailto:rahul.akolkar@gmail.com]
>  >  Sent: Wednesday, April 30, 2008 11:15 AM
>  >  To: Commons Users List
>  >  Subject: Re: [SCXML] XML engine decoupled from code
>  >
>  >  On 4/29/08, Ouyang, Landon - ES/RDR -Gil <La...@itt.com>
>  wrote:
>  >  > Ingmar,
>  >  >
>  >  >  Thanks for the response. Our state machine maps states to specific
>  >  >  activities. It does not use a listener or a timer but rather a
>  custom
>  >  >  class that utilizes an event stack for the firing of events within
>  >  the
>  >  >  state routines.
>  >  >
>  >  >  Your solution based on conditional transitions sounds like a
>  >  reasonable
>  >  >  one. Given this information there are a couple more questions I
>  have:
>  >  >
>  >  >  1) Is there a way to specify Java routines in the XML file to be
>  >  >  executed with the <onentry> tag? Possibly with <invoke>? We can
>  then
>  >  do
>  >  >  away with invoking state routine/handlers that are implemented in
>  our
>  >  >  class (similar to AbstractStateMachine).
>  >  >
>  >  <snip/>
>  >
>  >  Possible with either (<invoke> for long running semantics, custom
>  >  actions in <onentry> etc. for shorter routines).
>  >
>  >  Specifically to your <onentry> question, see:
>  >
>  >   http://commons.apache.org/scxml/guide/custom-actions.html
>  >
>  >  For custom actions, map Java exceptions to logical outcomes (events)
>  >  rather than throwing them.
>  >
>  >
>  >  >  2) If the answer to question 1 is true, can we fire events within
>  >  these
>  >  >  Java routines to determine the transitions within these states? If
>  >  true,
>  >  >  we can forego your "cond" solution and instead use the Java
>  routines
>  >  to
>  >  >  determine the paths our state machine takes.
>  >  >
>  >  <snap/>
>  >
>  >  There are two categories of events, external and internal / derived.
>  >  For custom actions, you can trigger derived events (add any events to
>  >  the derviedEvents collection in Action#execute(...) ).
>  >
>  >  If you must fire external events, then the semantics of <invoke> are
>  >  more suitable. Based on what I've read in this thread so far, I think
>  >  a custom action will do (and has a considerably simpler execution
>  >  model).
>  >
>  >  -Rahul
>  >
>  >
>  >  >  Thanks!
>  >  >
>  >  >
>  >  >  Landon Ouyang
>  >  >  Member Technical Staff
>  >  >  ITT Electronics Systems, Radar Systems - Gilfillan
>  >  >  7821 Orion Ave,
>  >  >  Van Nuys, CA 91406
>  >  >  (818) 901-2982
>  >  >
>  >  >
>  >  >
>  >  > -----Original Message-----
>  >  >  From: Ingmar Kliche [mailto:ingmar.kliche@googlemail.com]
>  >  >  Sent: Tuesday, April 29, 2008 1:16 PM
>  >  >  To: Commons Users List
>  >  >  Subject: Re: [SCXML] XML engine decoupled from code
>  >  >
>  >  >  Landon,
>  >  >
>  >  >  I'm not sure if your CheckRotation is really a state. To me it
>  sounds
>  >  >  more
>  >  >  like a guard condition (i.e. a condition) to decide which state to
>  >  enter
>  >  >  (e.g. the state machine is in state A and some event arrives -
>  which
>  >  one
>  >  >  ? -
>  >  >  then check the guard condition and decide to go to B or C). Could
>  you
>  >  >  elaborate a little on your state machine. What is the event which
>  >  >  is triggered? What drives your state machine? Is it a timer which
>  >  >  triggers
>  >  >  the engine on a regular basis? Or is it an external process that
>  >  sends
>  >  >  events, or is it some user input, ...?
>  >  >
>  >  >  The information which you need to check (i.e. bRotating) seems to
>  be
>  >  >  available in the container application (the one that embedds the
>  >  SCXML
>  >  >  engine). Isn't it possible to pass this information (bRotating)
>  along
>  >  >  with
>  >  >  the event (i.e. as payload of the event) into the engine
>  (something
>  >  like
>  >  >  triggerEvent("???", bRotation))? In this case you could access
>  >  bRotation
>  >  >  within the SCXML code:
>  >  >
>  >  >  <state id="A">
>  >  >    <transition event="???" cond="_eventdata.bRotation == true"
>  >  >  target="B"/>
>  >  >    <transition event="???" cond="_eventdata.bRotation == false"
>  >  >  target="C"/>
>  >  >  </state>
>  >  >
>  >  >  Or could you use a CustomAction to access bRotation?
>  >  >
>  >  >  There is certainly a solution for your problem, but it would help
>  (at
>  >  >  least
>  >  >  me) if you could describe a little more (if possible).
>  >  >
>  >  >  Best,
>  >  >  Ingmar.
>  >  >  2008/4/29 Ouyang, Landon - ES/RDR -Gil <La...@itt.com>:
>  >  >
>  >  >  > Hi,
>  >  >  >
>  >  >  > A conceptual issue has arisen after creating a working
>  application
>  >  >  that
>  >  >  > uses the Commons SCXML engine.
>  >  >  >
>  >  >  > Based on what we want out of the engine, it is essentially
>  >  important
>  >  >  > that the code implementation (Java) is decoupled/independent of
>  the
>  >  >  > underlying engine (XML file).
>  >  >  >
>  >  >  > To illustrate the problems I encountered, here is an example:
>  there
>  >  is
>  >  >  a
>  >  >  > state called CheckRotation that can detect whether there is or
>  >  isn't a
>  >  >  > rotation. We need the ability for a developer to be able to
>  place
>  >  this
>  >  >  > state anywhere in the state machine (possibly multiple times)
>  and
>  >  >  direct
>  >  >  > the state machine based on one of the two outcomes without
>  having
>  >  to
>  >  >  > write any Java code; he should only have to edit the XML file.
>  For
>  >  >  > example, one path could be A -> CheckRotation -> C or D and
>  another
>  >  >  > could be E -> CheckRotation -> F or G.
>  >  >  >
>  >  >  > We can modify the Java code so the CheckRotation method could
>  fire
>  >  >  > different events to direct the path.
>  >  >  >
>  >  >  > if(PrevState == A)
>  >  >  > {
>  >  >  >        if(bRotating)
>  >  >  >                fireEvent(EVENT_C);
>  >  >  >        else
>  >  >  >                fireEvent(EVENT_D);
>  >  >  > }
>  >  >  > else if(PrevState == E)
>  >  >  > {
>  >  >  >        if(bRotating)
>  >  >  >                fireEvent(EVENT_F);
>  >  >  >        else
>  >  >  >                fireEvent(EVENT_G);
>  >  >  > }
>  >  >  >
>  >  >  > But this solution adds complexity and defeats the whole purpose
>  of
>  >  >  using
>  >  >  > the engine in the first place! The CheckRotation state would
>  need
>  >  >  > multiple conditional transitions defined (instead of two) in the
>  >  XML
>  >  >  > file and the Java code would be interlinked with the XML engine!
>  Is
>  >  >  > there a more proper solution to this issue?
>  >  >  >
>  >  >  > --
>  >  >  > Landon Ouyang
>  >  >  > Member Technical Staff
>  >  >  > ITT Electronics Systems, Radar Systems - Gilfillan
>  >  >  > 7821 Orion Ave,
>  >  >  > Van Nuys, CA 91406
>  >  >  > (818) 901-2982
>  >  >  >
>  >

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


RE: [SCXML] XML engine decoupled from code

Posted by "Ouyang, Landon - ES/RDR -Gil" <La...@itt.com>.
Rahul,

Thanks for the response. I am now up and running with <invoke>
(somewhat) but the lack of synchronicity is causing me a few issues that
I hope you can help with.

First, is there a way for a state to invoke a method and then
unconditionally transition to another state? For example:

    <state id="GetOnlineRemote">
        <invoke targettype="java" src="GetOnlineRemote"/>
        <transition target="SteadyState" />
    </state>

*should* execute the GetOnlineRemote() method and then transition to
SteadyState. However, because invoke is asynchronous, only the
transition happens. Is there a solution to this besides firing a return
event in GetOnlineRemote and conditioning the transition to that event?

Second, I chained several states together before going back to our
steady state (the starting point for state transitions):

    <state id="GetAll">
        <invoke targettype="java" src="GetOnlineRemote"/>
        <transition event="s3d.ReturnToSteady"
target="GetTransmitterStateAll"/>
    </state>
    <state id="GetTransmitterStateAll">
        <invoke targettype="java" src="GetTransmitterState"/>
        <transition event="s3d.ReturnToSteady"
target="GetAntRotateAll"/>
    </state>
    <state id="GetAntRotateAll">
        <invoke targettype="java" src="GetAntennaRotating"/>
        <transition event="s3d.ReturnToSteady" target="GetWIPModeAll"/>
    </state>
    <state id="GetWIPModeAll">
        <invoke targettype="java" src="GetWIPMode"/>
        <transition event="s3d.ReturnToSteady" target="SteadyState" />
    </state>

All states fired the s3d.ReturnToSteady event at the end of execution.
When executed, each method invocation happens as desired and I verified
that the state machine returns to the steady state. However, after
execution none of the transitions from the steady state work anymore!
This only happens when I chained the states together instead of entering
one state and then immediately returning to the steady state. Any idea
what is going on?

--
Landon Ouyang
Member Technical Staff
ITT Electronics Systems, Radar Systems - Gilfillan
7821 Orion Ave,
Van Nuys, CA 91406
(818) 901-2982


-----Original Message-----
From: Rahul Akolkar [mailto:rahul.akolkar@gmail.com]
Sent: Thursday, May 01, 2008 12:40 PM
To: Commons Users List
Subject: Re: [SCXML] XML engine decoupled from code

On 4/30/08, Ouyang, Landon - ES/RDR -Gil <La...@itt.com> wrote:
> Rahul,
>
>  Thanks once again for the quick response.
>
>  Before reading your e-mail I had already decided to go with the
<invoke>
>  route for developing our implementation. I made our state machine
class
>  an invoker class and registered it with the SCXML executor. The
invoke()
>  method would trim the string passed in as the source parameter and
>  invoke the method similar to the AbstractStateMachine class. I am now
>  able to add statements in the XML that utilize the <invoke> tag to
>  invoke Java methods defined inside the state machine class.
>
>  I ran into a problem which leads me to believe I may have chosen the
>  wrong route: I cannot access the initiated values of the class!
<snip/>

As in static fields? Should be possible.


> For
>  example, the state machine needed access to the GUI to change various
>  widgets. I had a member assigned to the JFrame to accomplish this but
>  this member is now null in the invoked method even though I correctly
>  initialized it earlier! This never happened before until I
transformed
>  the state machine class to an invoker class. Is the Invoker object a
>  separate instance of the original state machine object?
>
<snap/>

Each <invoke> gets a new instance of the Invoker class. If you need to
"initialize" the instance with handles to other bits (such as a
JFrame, in this example), those need to be in the state machine's
Context and passed in as <param>s.

IOW, an example in code:

0) Say myJFrame is the frame
executor.getRootContext().set("frame", myJFrame);

1) Markup fragment
<invoke ...>
  <param name="frame" expr="frame"/>
  ...
</invoke>

2) In invoker#invoke(String src, Map params) .... params.get("frame")
gets you the frame.

Finally, as mentioned on the Commons SCXML homepage (and the spec in
progress), <invoke> is evolving.

-Rahul


>
>  --
>
> Landon Ouyang
>  Member Technical Staff
>  ITT Electronics Systems, Radar Systems - Gilfillan
>  7821 Orion Ave,
>  Van Nuys, CA 91406
>  (818) 901-2982
>
>  -----Original Message-----
>
> From: Rahul Akolkar [mailto:rahul.akolkar@gmail.com]
>  Sent: Wednesday, April 30, 2008 11:15 AM
>  To: Commons Users List
>  Subject: Re: [SCXML] XML engine decoupled from code
>
>  On 4/29/08, Ouyang, Landon - ES/RDR -Gil <La...@itt.com>
wrote:
>  > Ingmar,
>  >
>  >  Thanks for the response. Our state machine maps states to specific
>  >  activities. It does not use a listener or a timer but rather a
custom
>  >  class that utilizes an event stack for the firing of events within
>  the
>  >  state routines.
>  >
>  >  Your solution based on conditional transitions sounds like a
>  reasonable
>  >  one. Given this information there are a couple more questions I
have:
>  >
>  >  1) Is there a way to specify Java routines in the XML file to be
>  >  executed with the <onentry> tag? Possibly with <invoke>? We can
then
>  do
>  >  away with invoking state routine/handlers that are implemented in
our
>  >  class (similar to AbstractStateMachine).
>  >
>  <snip/>
>
>  Possible with either (<invoke> for long running semantics, custom
>  actions in <onentry> etc. for shorter routines).
>
>  Specifically to your <onentry> question, see:
>
>   http://commons.apache.org/scxml/guide/custom-actions.html
>
>  For custom actions, map Java exceptions to logical outcomes (events)
>  rather than throwing them.
>
>
>  >  2) If the answer to question 1 is true, can we fire events within
>  these
>  >  Java routines to determine the transitions within these states? If
>  true,
>  >  we can forego your "cond" solution and instead use the Java
routines
>  to
>  >  determine the paths our state machine takes.
>  >
>  <snap/>
>
>  There are two categories of events, external and internal / derived.
>  For custom actions, you can trigger derived events (add any events to
>  the derviedEvents collection in Action#execute(...) ).
>
>  If you must fire external events, then the semantics of <invoke> are
>  more suitable. Based on what I've read in this thread so far, I think
>  a custom action will do (and has a considerably simpler execution
>  model).
>
>  -Rahul
>
>
>  >  Thanks!
>  >
>  >
>  >  Landon Ouyang
>  >  Member Technical Staff
>  >  ITT Electronics Systems, Radar Systems - Gilfillan
>  >  7821 Orion Ave,
>  >  Van Nuys, CA 91406
>  >  (818) 901-2982
>  >
>  >
>  >
>  > -----Original Message-----
>  >  From: Ingmar Kliche [mailto:ingmar.kliche@googlemail.com]
>  >  Sent: Tuesday, April 29, 2008 1:16 PM
>  >  To: Commons Users List
>  >  Subject: Re: [SCXML] XML engine decoupled from code
>  >
>  >  Landon,
>  >
>  >  I'm not sure if your CheckRotation is really a state. To me it
sounds
>  >  more
>  >  like a guard condition (i.e. a condition) to decide which state to
>  enter
>  >  (e.g. the state machine is in state A and some event arrives -
which
>  one
>  >  ? -
>  >  then check the guard condition and decide to go to B or C). Could
you
>  >  elaborate a little on your state machine. What is the event which
>  >  is triggered? What drives your state machine? Is it a timer which
>  >  triggers
>  >  the engine on a regular basis? Or is it an external process that
>  sends
>  >  events, or is it some user input, ...?
>  >
>  >  The information which you need to check (i.e. bRotating) seems to
be
>  >  available in the container application (the one that embedds the
>  SCXML
>  >  engine). Isn't it possible to pass this information (bRotating)
along
>  >  with
>  >  the event (i.e. as payload of the event) into the engine
(something
>  like
>  >  triggerEvent("???", bRotation))? In this case you could access
>  bRotation
>  >  within the SCXML code:
>  >
>  >  <state id="A">
>  >    <transition event="???" cond="_eventdata.bRotation == true"
>  >  target="B"/>
>  >    <transition event="???" cond="_eventdata.bRotation == false"
>  >  target="C"/>
>  >  </state>
>  >
>  >  Or could you use a CustomAction to access bRotation?
>  >
>  >  There is certainly a solution for your problem, but it would help
(at
>  >  least
>  >  me) if you could describe a little more (if possible).
>  >
>  >  Best,
>  >  Ingmar.
>  >  2008/4/29 Ouyang, Landon - ES/RDR -Gil <La...@itt.com>:
>  >
>  >  > Hi,
>  >  >
>  >  > A conceptual issue has arisen after creating a working
application
>  >  that
>  >  > uses the Commons SCXML engine.
>  >  >
>  >  > Based on what we want out of the engine, it is essentially
>  important
>  >  > that the code implementation (Java) is decoupled/independent of
the
>  >  > underlying engine (XML file).
>  >  >
>  >  > To illustrate the problems I encountered, here is an example:
there
>  is
>  >  a
>  >  > state called CheckRotation that can detect whether there is or
>  isn't a
>  >  > rotation. We need the ability for a developer to be able to
place
>  this
>  >  > state anywhere in the state machine (possibly multiple times)
and
>  >  direct
>  >  > the state machine based on one of the two outcomes without
having
>  to
>  >  > write any Java code; he should only have to edit the XML file.
For
>  >  > example, one path could be A -> CheckRotation -> C or D and
another
>  >  > could be E -> CheckRotation -> F or G.
>  >  >
>  >  > We can modify the Java code so the CheckRotation method could
fire
>  >  > different events to direct the path.
>  >  >
>  >  > if(PrevState == A)
>  >  > {
>  >  >        if(bRotating)
>  >  >                fireEvent(EVENT_C);
>  >  >        else
>  >  >                fireEvent(EVENT_D);
>  >  > }
>  >  > else if(PrevState == E)
>  >  > {
>  >  >        if(bRotating)
>  >  >                fireEvent(EVENT_F);
>  >  >        else
>  >  >                fireEvent(EVENT_G);
>  >  > }
>  >  >
>  >  > But this solution adds complexity and defeats the whole purpose
of
>  >  using
>  >  > the engine in the first place! The CheckRotation state would
need
>  >  > multiple conditional transitions defined (instead of two) in the
>  XML
>  >  > file and the Java code would be interlinked with the XML engine!
Is
>  >  > there a more proper solution to this issue?
>  >  >
>  >  > --
>  >  > Landon Ouyang
>  >  > Member Technical Staff
>  >  > ITT Electronics Systems, Radar Systems - Gilfillan
>  >  > 7821 Orion Ave,
>  >  > Van Nuys, CA 91406
>  >  > (818) 901-2982
>  >  >
>

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


This e-mail and any files transmitted with it may be proprietary and are intended solely for the use of the individual or entity to whom they are addressed. If you have received this e-mail in error please notify the sender. Please note that any views or opinions presented in this e-mail are solely those of the author and do not necessarily represent those of ITT Corporation. The recipient should check this e-mail and any attachments for the presence of viruses. ITT accepts no liability for any damage caused by any virus transmitted by this e-mail.

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


Re: [SCXML] XML engine decoupled from code

Posted by Rahul Akolkar <ra...@gmail.com>.
On 4/30/08, Ouyang, Landon - ES/RDR -Gil <La...@itt.com> wrote:
> Rahul,
>
>  Thanks once again for the quick response.
>
>  Before reading your e-mail I had already decided to go with the <invoke>
>  route for developing our implementation. I made our state machine class
>  an invoker class and registered it with the SCXML executor. The invoke()
>  method would trim the string passed in as the source parameter and
>  invoke the method similar to the AbstractStateMachine class. I am now
>  able to add statements in the XML that utilize the <invoke> tag to
>  invoke Java methods defined inside the state machine class.
>
>  I ran into a problem which leads me to believe I may have chosen the
>  wrong route: I cannot access the initiated values of the class!
<snip/>

As in static fields? Should be possible.


> For
>  example, the state machine needed access to the GUI to change various
>  widgets. I had a member assigned to the JFrame to accomplish this but
>  this member is now null in the invoked method even though I correctly
>  initialized it earlier! This never happened before until I transformed
>  the state machine class to an invoker class. Is the Invoker object a
>  separate instance of the original state machine object?
>
<snap/>

Each <invoke> gets a new instance of the Invoker class. If you need to
"initialize" the instance with handles to other bits (such as a
JFrame, in this example), those need to be in the state machine's
Context and passed in as <param>s.

IOW, an example in code:

0) Say myJFrame is the frame
executor.getRootContext().set("frame", myJFrame);

1) Markup fragment
<invoke ...>
  <param name="frame" expr="frame"/>
  ...
</invoke>

2) In invoker#invoke(String src, Map params) .... params.get("frame")
gets you the frame.

Finally, as mentioned on the Commons SCXML homepage (and the spec in
progress), <invoke> is evolving.

-Rahul


>
>  --
>
> Landon Ouyang
>  Member Technical Staff
>  ITT Electronics Systems, Radar Systems - Gilfillan
>  7821 Orion Ave,
>  Van Nuys, CA 91406
>  (818) 901-2982
>
>  -----Original Message-----
>
> From: Rahul Akolkar [mailto:rahul.akolkar@gmail.com]
>  Sent: Wednesday, April 30, 2008 11:15 AM
>  To: Commons Users List
>  Subject: Re: [SCXML] XML engine decoupled from code
>
>  On 4/29/08, Ouyang, Landon - ES/RDR -Gil <La...@itt.com> wrote:
>  > Ingmar,
>  >
>  >  Thanks for the response. Our state machine maps states to specific
>  >  activities. It does not use a listener or a timer but rather a custom
>  >  class that utilizes an event stack for the firing of events within
>  the
>  >  state routines.
>  >
>  >  Your solution based on conditional transitions sounds like a
>  reasonable
>  >  one. Given this information there are a couple more questions I have:
>  >
>  >  1) Is there a way to specify Java routines in the XML file to be
>  >  executed with the <onentry> tag? Possibly with <invoke>? We can then
>  do
>  >  away with invoking state routine/handlers that are implemented in our
>  >  class (similar to AbstractStateMachine).
>  >
>  <snip/>
>
>  Possible with either (<invoke> for long running semantics, custom
>  actions in <onentry> etc. for shorter routines).
>
>  Specifically to your <onentry> question, see:
>
>   http://commons.apache.org/scxml/guide/custom-actions.html
>
>  For custom actions, map Java exceptions to logical outcomes (events)
>  rather than throwing them.
>
>
>  >  2) If the answer to question 1 is true, can we fire events within
>  these
>  >  Java routines to determine the transitions within these states? If
>  true,
>  >  we can forego your "cond" solution and instead use the Java routines
>  to
>  >  determine the paths our state machine takes.
>  >
>  <snap/>
>
>  There are two categories of events, external and internal / derived.
>  For custom actions, you can trigger derived events (add any events to
>  the derviedEvents collection in Action#execute(...) ).
>
>  If you must fire external events, then the semantics of <invoke> are
>  more suitable. Based on what I've read in this thread so far, I think
>  a custom action will do (and has a considerably simpler execution
>  model).
>
>  -Rahul
>
>
>  >  Thanks!
>  >
>  >
>  >  Landon Ouyang
>  >  Member Technical Staff
>  >  ITT Electronics Systems, Radar Systems - Gilfillan
>  >  7821 Orion Ave,
>  >  Van Nuys, CA 91406
>  >  (818) 901-2982
>  >
>  >
>  >
>  > -----Original Message-----
>  >  From: Ingmar Kliche [mailto:ingmar.kliche@googlemail.com]
>  >  Sent: Tuesday, April 29, 2008 1:16 PM
>  >  To: Commons Users List
>  >  Subject: Re: [SCXML] XML engine decoupled from code
>  >
>  >  Landon,
>  >
>  >  I'm not sure if your CheckRotation is really a state. To me it sounds
>  >  more
>  >  like a guard condition (i.e. a condition) to decide which state to
>  enter
>  >  (e.g. the state machine is in state A and some event arrives - which
>  one
>  >  ? -
>  >  then check the guard condition and decide to go to B or C). Could you
>  >  elaborate a little on your state machine. What is the event which
>  >  is triggered? What drives your state machine? Is it a timer which
>  >  triggers
>  >  the engine on a regular basis? Or is it an external process that
>  sends
>  >  events, or is it some user input, ...?
>  >
>  >  The information which you need to check (i.e. bRotating) seems to be
>  >  available in the container application (the one that embedds the
>  SCXML
>  >  engine). Isn't it possible to pass this information (bRotating) along
>  >  with
>  >  the event (i.e. as payload of the event) into the engine (something
>  like
>  >  triggerEvent("???", bRotation))? In this case you could access
>  bRotation
>  >  within the SCXML code:
>  >
>  >  <state id="A">
>  >    <transition event="???" cond="_eventdata.bRotation == true"
>  >  target="B"/>
>  >    <transition event="???" cond="_eventdata.bRotation == false"
>  >  target="C"/>
>  >  </state>
>  >
>  >  Or could you use a CustomAction to access bRotation?
>  >
>  >  There is certainly a solution for your problem, but it would help (at
>  >  least
>  >  me) if you could describe a little more (if possible).
>  >
>  >  Best,
>  >  Ingmar.
>  >  2008/4/29 Ouyang, Landon - ES/RDR -Gil <La...@itt.com>:
>  >
>  >  > Hi,
>  >  >
>  >  > A conceptual issue has arisen after creating a working application
>  >  that
>  >  > uses the Commons SCXML engine.
>  >  >
>  >  > Based on what we want out of the engine, it is essentially
>  important
>  >  > that the code implementation (Java) is decoupled/independent of the
>  >  > underlying engine (XML file).
>  >  >
>  >  > To illustrate the problems I encountered, here is an example: there
>  is
>  >  a
>  >  > state called CheckRotation that can detect whether there is or
>  isn't a
>  >  > rotation. We need the ability for a developer to be able to place
>  this
>  >  > state anywhere in the state machine (possibly multiple times) and
>  >  direct
>  >  > the state machine based on one of the two outcomes without having
>  to
>  >  > write any Java code; he should only have to edit the XML file. For
>  >  > example, one path could be A -> CheckRotation -> C or D and another
>  >  > could be E -> CheckRotation -> F or G.
>  >  >
>  >  > We can modify the Java code so the CheckRotation method could fire
>  >  > different events to direct the path.
>  >  >
>  >  > if(PrevState == A)
>  >  > {
>  >  >        if(bRotating)
>  >  >                fireEvent(EVENT_C);
>  >  >        else
>  >  >                fireEvent(EVENT_D);
>  >  > }
>  >  > else if(PrevState == E)
>  >  > {
>  >  >        if(bRotating)
>  >  >                fireEvent(EVENT_F);
>  >  >        else
>  >  >                fireEvent(EVENT_G);
>  >  > }
>  >  >
>  >  > But this solution adds complexity and defeats the whole purpose of
>  >  using
>  >  > the engine in the first place! The CheckRotation state would need
>  >  > multiple conditional transitions defined (instead of two) in the
>  XML
>  >  > file and the Java code would be interlinked with the XML engine! Is
>  >  > there a more proper solution to this issue?
>  >  >
>  >  > --
>  >  > Landon Ouyang
>  >  > Member Technical Staff
>  >  > ITT Electronics Systems, Radar Systems - Gilfillan
>  >  > 7821 Orion Ave,
>  >  > Van Nuys, CA 91406
>  >  > (818) 901-2982
>  >  >
>

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


RE: [SCXML] XML engine decoupled from code

Posted by "Ouyang, Landon - ES/RDR -Gil" <La...@itt.com>.
Rahul,

Thanks once again for the quick response.

Before reading your e-mail I had already decided to go with the <invoke>
route for developing our implementation. I made our state machine class
an invoker class and registered it with the SCXML executor. The invoke()
method would trim the string passed in as the source parameter and
invoke the method similar to the AbstractStateMachine class. I am now
able to add statements in the XML that utilize the <invoke> tag to
invoke Java methods defined inside the state machine class.

I ran into a problem which leads me to believe I may have chosen the
wrong route: I cannot access the initiated values of the class! For
example, the state machine needed access to the GUI to change various
widgets. I had a member assigned to the JFrame to accomplish this but
this member is now null in the invoked method even though I correctly
initialized it earlier! This never happened before until I transformed
the state machine class to an invoker class. Is the Invoker object a
separate instance of the original state machine object?

--
Landon Ouyang
Member Technical Staff
ITT Electronics Systems, Radar Systems - Gilfillan
7821 Orion Ave,
Van Nuys, CA 91406
(818) 901-2982

-----Original Message-----
From: Rahul Akolkar [mailto:rahul.akolkar@gmail.com]
Sent: Wednesday, April 30, 2008 11:15 AM
To: Commons Users List
Subject: Re: [SCXML] XML engine decoupled from code

On 4/29/08, Ouyang, Landon - ES/RDR -Gil <La...@itt.com> wrote:
> Ingmar,
>
>  Thanks for the response. Our state machine maps states to specific
>  activities. It does not use a listener or a timer but rather a custom
>  class that utilizes an event stack for the firing of events within
the
>  state routines.
>
>  Your solution based on conditional transitions sounds like a
reasonable
>  one. Given this information there are a couple more questions I have:
>
>  1) Is there a way to specify Java routines in the XML file to be
>  executed with the <onentry> tag? Possibly with <invoke>? We can then
do
>  away with invoking state routine/handlers that are implemented in our
>  class (similar to AbstractStateMachine).
>
<snip/>

Possible with either (<invoke> for long running semantics, custom
actions in <onentry> etc. for shorter routines).

Specifically to your <onentry> question, see:

  http://commons.apache.org/scxml/guide/custom-actions.html

For custom actions, map Java exceptions to logical outcomes (events)
rather than throwing them.


>  2) If the answer to question 1 is true, can we fire events within
these
>  Java routines to determine the transitions within these states? If
true,
>  we can forego your "cond" solution and instead use the Java routines
to
>  determine the paths our state machine takes.
>
<snap/>

There are two categories of events, external and internal / derived.
For custom actions, you can trigger derived events (add any events to
the derviedEvents collection in Action#execute(...) ).

If you must fire external events, then the semantics of <invoke> are
more suitable. Based on what I've read in this thread so far, I think
a custom action will do (and has a considerably simpler execution
model).

-Rahul


>  Thanks!
>
>
>  Landon Ouyang
>  Member Technical Staff
>  ITT Electronics Systems, Radar Systems - Gilfillan
>  7821 Orion Ave,
>  Van Nuys, CA 91406
>  (818) 901-2982
>
>
>
> -----Original Message-----
>  From: Ingmar Kliche [mailto:ingmar.kliche@googlemail.com]
>  Sent: Tuesday, April 29, 2008 1:16 PM
>  To: Commons Users List
>  Subject: Re: [SCXML] XML engine decoupled from code
>
>  Landon,
>
>  I'm not sure if your CheckRotation is really a state. To me it sounds
>  more
>  like a guard condition (i.e. a condition) to decide which state to
enter
>  (e.g. the state machine is in state A and some event arrives - which
one
>  ? -
>  then check the guard condition and decide to go to B or C). Could you
>  elaborate a little on your state machine. What is the event which
>  is triggered? What drives your state machine? Is it a timer which
>  triggers
>  the engine on a regular basis? Or is it an external process that
sends
>  events, or is it some user input, ...?
>
>  The information which you need to check (i.e. bRotating) seems to be
>  available in the container application (the one that embedds the
SCXML
>  engine). Isn't it possible to pass this information (bRotating) along
>  with
>  the event (i.e. as payload of the event) into the engine (something
like
>  triggerEvent("???", bRotation))? In this case you could access
bRotation
>  within the SCXML code:
>
>  <state id="A">
>    <transition event="???" cond="_eventdata.bRotation == true"
>  target="B"/>
>    <transition event="???" cond="_eventdata.bRotation == false"
>  target="C"/>
>  </state>
>
>  Or could you use a CustomAction to access bRotation?
>
>  There is certainly a solution for your problem, but it would help (at
>  least
>  me) if you could describe a little more (if possible).
>
>  Best,
>  Ingmar.
>  2008/4/29 Ouyang, Landon - ES/RDR -Gil <La...@itt.com>:
>
>  > Hi,
>  >
>  > A conceptual issue has arisen after creating a working application
>  that
>  > uses the Commons SCXML engine.
>  >
>  > Based on what we want out of the engine, it is essentially
important
>  > that the code implementation (Java) is decoupled/independent of the
>  > underlying engine (XML file).
>  >
>  > To illustrate the problems I encountered, here is an example: there
is
>  a
>  > state called CheckRotation that can detect whether there is or
isn't a
>  > rotation. We need the ability for a developer to be able to place
this
>  > state anywhere in the state machine (possibly multiple times) and
>  direct
>  > the state machine based on one of the two outcomes without having
to
>  > write any Java code; he should only have to edit the XML file. For
>  > example, one path could be A -> CheckRotation -> C or D and another
>  > could be E -> CheckRotation -> F or G.
>  >
>  > We can modify the Java code so the CheckRotation method could fire
>  > different events to direct the path.
>  >
>  > if(PrevState == A)
>  > {
>  >        if(bRotating)
>  >                fireEvent(EVENT_C);
>  >        else
>  >                fireEvent(EVENT_D);
>  > }
>  > else if(PrevState == E)
>  > {
>  >        if(bRotating)
>  >                fireEvent(EVENT_F);
>  >        else
>  >                fireEvent(EVENT_G);
>  > }
>  >
>  > But this solution adds complexity and defeats the whole purpose of
>  using
>  > the engine in the first place! The CheckRotation state would need
>  > multiple conditional transitions defined (instead of two) in the
XML
>  > file and the Java code would be interlinked with the XML engine! Is
>  > there a more proper solution to this issue?
>  >
>  > --
>  > Landon Ouyang
>  > Member Technical Staff
>  > ITT Electronics Systems, Radar Systems - Gilfillan
>  > 7821 Orion Ave,
>  > Van Nuys, CA 91406
>  > (818) 901-2982
>  >

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


This e-mail and any files transmitted with it may be proprietary and are intended solely for the use of the individual or entity to whom they are addressed. If you have received this e-mail in error please notify the sender. Please note that any views or opinions presented in this e-mail are solely those of the author and do not necessarily represent those of ITT Corporation. The recipient should check this e-mail and any attachments for the presence of viruses. ITT accepts no liability for any damage caused by any virus transmitted by this e-mail.

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


Re: [SCXML] XML engine decoupled from code

Posted by Rahul Akolkar <ra...@gmail.com>.
On 4/29/08, Ouyang, Landon - ES/RDR -Gil <La...@itt.com> wrote:
> Ingmar,
>
>  Thanks for the response. Our state machine maps states to specific
>  activities. It does not use a listener or a timer but rather a custom
>  class that utilizes an event stack for the firing of events within the
>  state routines.
>
>  Your solution based on conditional transitions sounds like a reasonable
>  one. Given this information there are a couple more questions I have:
>
>  1) Is there a way to specify Java routines in the XML file to be
>  executed with the <onentry> tag? Possibly with <invoke>? We can then do
>  away with invoking state routine/handlers that are implemented in our
>  class (similar to AbstractStateMachine).
>
<snip/>

Possible with either (<invoke> for long running semantics, custom
actions in <onentry> etc. for shorter routines).

Specifically to your <onentry> question, see:

  http://commons.apache.org/scxml/guide/custom-actions.html

For custom actions, map Java exceptions to logical outcomes (events)
rather than throwing them.


>  2) If the answer to question 1 is true, can we fire events within these
>  Java routines to determine the transitions within these states? If true,
>  we can forego your "cond" solution and instead use the Java routines to
>  determine the paths our state machine takes.
>
<snap/>

There are two categories of events, external and internal / derived.
For custom actions, you can trigger derived events (add any events to
the derviedEvents collection in Action#execute(...) ).

If you must fire external events, then the semantics of <invoke> are
more suitable. Based on what I've read in this thread so far, I think
a custom action will do (and has a considerably simpler execution
model).

-Rahul


>  Thanks!
>
>
>  Landon Ouyang
>  Member Technical Staff
>  ITT Electronics Systems, Radar Systems - Gilfillan
>  7821 Orion Ave,
>  Van Nuys, CA 91406
>  (818) 901-2982
>
>
>
> -----Original Message-----
>  From: Ingmar Kliche [mailto:ingmar.kliche@googlemail.com]
>  Sent: Tuesday, April 29, 2008 1:16 PM
>  To: Commons Users List
>  Subject: Re: [SCXML] XML engine decoupled from code
>
>  Landon,
>
>  I'm not sure if your CheckRotation is really a state. To me it sounds
>  more
>  like a guard condition (i.e. a condition) to decide which state to enter
>  (e.g. the state machine is in state A and some event arrives - which one
>  ? -
>  then check the guard condition and decide to go to B or C). Could you
>  elaborate a little on your state machine. What is the event which
>  is triggered? What drives your state machine? Is it a timer which
>  triggers
>  the engine on a regular basis? Or is it an external process that sends
>  events, or is it some user input, ...?
>
>  The information which you need to check (i.e. bRotating) seems to be
>  available in the container application (the one that embedds the SCXML
>  engine). Isn't it possible to pass this information (bRotating) along
>  with
>  the event (i.e. as payload of the event) into the engine (something like
>  triggerEvent("???", bRotation))? In this case you could access bRotation
>  within the SCXML code:
>
>  <state id="A">
>    <transition event="???" cond="_eventdata.bRotation == true"
>  target="B"/>
>    <transition event="???" cond="_eventdata.bRotation == false"
>  target="C"/>
>  </state>
>
>  Or could you use a CustomAction to access bRotation?
>
>  There is certainly a solution for your problem, but it would help (at
>  least
>  me) if you could describe a little more (if possible).
>
>  Best,
>  Ingmar.
>  2008/4/29 Ouyang, Landon - ES/RDR -Gil <La...@itt.com>:
>
>  > Hi,
>  >
>  > A conceptual issue has arisen after creating a working application
>  that
>  > uses the Commons SCXML engine.
>  >
>  > Based on what we want out of the engine, it is essentially important
>  > that the code implementation (Java) is decoupled/independent of the
>  > underlying engine (XML file).
>  >
>  > To illustrate the problems I encountered, here is an example: there is
>  a
>  > state called CheckRotation that can detect whether there is or isn't a
>  > rotation. We need the ability for a developer to be able to place this
>  > state anywhere in the state machine (possibly multiple times) and
>  direct
>  > the state machine based on one of the two outcomes without having to
>  > write any Java code; he should only have to edit the XML file. For
>  > example, one path could be A -> CheckRotation -> C or D and another
>  > could be E -> CheckRotation -> F or G.
>  >
>  > We can modify the Java code so the CheckRotation method could fire
>  > different events to direct the path.
>  >
>  > if(PrevState == A)
>  > {
>  >        if(bRotating)
>  >                fireEvent(EVENT_C);
>  >        else
>  >                fireEvent(EVENT_D);
>  > }
>  > else if(PrevState == E)
>  > {
>  >        if(bRotating)
>  >                fireEvent(EVENT_F);
>  >        else
>  >                fireEvent(EVENT_G);
>  > }
>  >
>  > But this solution adds complexity and defeats the whole purpose of
>  using
>  > the engine in the first place! The CheckRotation state would need
>  > multiple conditional transitions defined (instead of two) in the XML
>  > file and the Java code would be interlinked with the XML engine! Is
>  > there a more proper solution to this issue?
>  >
>  > --
>  > Landon Ouyang
>  > Member Technical Staff
>  > ITT Electronics Systems, Radar Systems - Gilfillan
>  > 7821 Orion Ave,
>  > Van Nuys, CA 91406
>  > (818) 901-2982
>  >

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


RE: [SCXML] XML engine decoupled from code

Posted by "Ouyang, Landon - ES/RDR -Gil" <La...@itt.com>.
Ingmar,

Thanks for the response. Our state machine maps states to specific
activities. It does not use a listener or a timer but rather a custom
class that utilizes an event stack for the firing of events within the
state routines.

Your solution based on conditional transitions sounds like a reasonable
one. Given this information there are a couple more questions I have:

1) Is there a way to specify Java routines in the XML file to be
executed with the <onentry> tag? Possibly with <invoke>? We can then do
away with invoking state routine/handlers that are implemented in our
class (similar to AbstractStateMachine).

2) If the answer to question 1 is true, can we fire events within these
Java routines to determine the transitions within these states? If true,
we can forego your "cond" solution and instead use the Java routines to
determine the paths our state machine takes.

Thanks!

Landon Ouyang
Member Technical Staff
ITT Electronics Systems, Radar Systems - Gilfillan
7821 Orion Ave,
Van Nuys, CA 91406
(818) 901-2982


-----Original Message-----
From: Ingmar Kliche [mailto:ingmar.kliche@googlemail.com]
Sent: Tuesday, April 29, 2008 1:16 PM
To: Commons Users List
Subject: Re: [SCXML] XML engine decoupled from code

Landon,

I'm not sure if your CheckRotation is really a state. To me it sounds
more
like a guard condition (i.e. a condition) to decide which state to enter
(e.g. the state machine is in state A and some event arrives - which one
? -
then check the guard condition and decide to go to B or C). Could you
elaborate a little on your state machine. What is the event which
is triggered? What drives your state machine? Is it a timer which
triggers
the engine on a regular basis? Or is it an external process that sends
events, or is it some user input, ...?

The information which you need to check (i.e. bRotating) seems to be
available in the container application (the one that embedds the SCXML
engine). Isn't it possible to pass this information (bRotating) along
with
the event (i.e. as payload of the event) into the engine (something like
triggerEvent("???", bRotation))? In this case you could access bRotation
within the SCXML code:

<state id="A">
   <transition event="???" cond="_eventdata.bRotation == true"
target="B"/>
   <transition event="???" cond="_eventdata.bRotation == false"
target="C"/>
</state>

Or could you use a CustomAction to access bRotation?

There is certainly a solution for your problem, but it would help (at
least
me) if you could describe a little more (if possible).

Best,
Ingmar.
2008/4/29 Ouyang, Landon - ES/RDR -Gil <La...@itt.com>:

> Hi,
>
> A conceptual issue has arisen after creating a working application
that
> uses the Commons SCXML engine.
>
> Based on what we want out of the engine, it is essentially important
> that the code implementation (Java) is decoupled/independent of the
> underlying engine (XML file).
>
> To illustrate the problems I encountered, here is an example: there is
a
> state called CheckRotation that can detect whether there is or isn't a
> rotation. We need the ability for a developer to be able to place this
> state anywhere in the state machine (possibly multiple times) and
direct
> the state machine based on one of the two outcomes without having to
> write any Java code; he should only have to edit the XML file. For
> example, one path could be A -> CheckRotation -> C or D and another
> could be E -> CheckRotation -> F or G.
>
> We can modify the Java code so the CheckRotation method could fire
> different events to direct the path.
>
> if(PrevState == A)
> {
>        if(bRotating)
>                fireEvent(EVENT_C);
>        else
>                fireEvent(EVENT_D);
> }
> else if(PrevState == E)
> {
>        if(bRotating)
>                fireEvent(EVENT_F);
>        else
>                fireEvent(EVENT_G);
> }
>
> But this solution adds complexity and defeats the whole purpose of
using
> the engine in the first place! The CheckRotation state would need
> multiple conditional transitions defined (instead of two) in the XML
> file and the Java code would be interlinked with the XML engine! Is
> there a more proper solution to this issue?
>
> --
> Landon Ouyang
> Member Technical Staff
> ITT Electronics Systems, Radar Systems - Gilfillan
> 7821 Orion Ave,
> Van Nuys, CA 91406
> (818) 901-2982
>
> This e-mail and any files transmitted with it may be proprietary and
are
> intended solely for the use of the individual or entity to whom they
are
> addressed. If you have received this e-mail in error please notify the
> sender. Please note that any views or opinions presented in this
e-mail are
> solely those of the author and do not necessarily represent those of
ITT
> Corporation. The recipient should check this e-mail and any
attachments for
> the presence of viruses. ITT accepts no liability for any damage
caused by
> any virus transmitted by this e-mail.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>
>

This e-mail and any files transmitted with it may be proprietary and are intended solely for the use of the individual or entity to whom they are addressed. If you have received this e-mail in error please notify the sender. Please note that any views or opinions presented in this e-mail are solely those of the author and do not necessarily represent those of ITT Corporation. The recipient should check this e-mail and any attachments for the presence of viruses. ITT accepts no liability for any damage caused by any virus transmitted by this e-mail.

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


Re: [SCXML] XML engine decoupled from code

Posted by Ingmar Kliche <in...@googlemail.com>.
Landon,

I'm not sure if your CheckRotation is really a state. To me it sounds more
like a guard condition (i.e. a condition) to decide which state to enter
(e.g. the state machine is in state A and some event arrives - which one ? -
then check the guard condition and decide to go to B or C). Could you
elaborate a little on your state machine. What is the event which
is triggered? What drives your state machine? Is it a timer which triggers
the engine on a regular basis? Or is it an external process that sends
events, or is it some user input, ...?

The information which you need to check (i.e. bRotating) seems to be
available in the container application (the one that embedds the SCXML
engine). Isn't it possible to pass this information (bRotating) along with
the event (i.e. as payload of the event) into the engine (something like
triggerEvent("???", bRotation))? In this case you could access bRotation
within the SCXML code:

<state id="A">
   <transition event="???" cond="_eventdata.bRotation == true" target="B"/>
   <transition event="???" cond="_eventdata.bRotation == false" target="C"/>
</state>

Or could you use a CustomAction to access bRotation?

There is certainly a solution for your problem, but it would help (at least
me) if you could describe a little more (if possible).

Best,
Ingmar.
2008/4/29 Ouyang, Landon - ES/RDR -Gil <La...@itt.com>:

> Hi,
>
> A conceptual issue has arisen after creating a working application that
> uses the Commons SCXML engine.
>
> Based on what we want out of the engine, it is essentially important
> that the code implementation (Java) is decoupled/independent of the
> underlying engine (XML file).
>
> To illustrate the problems I encountered, here is an example: there is a
> state called CheckRotation that can detect whether there is or isn't a
> rotation. We need the ability for a developer to be able to place this
> state anywhere in the state machine (possibly multiple times) and direct
> the state machine based on one of the two outcomes without having to
> write any Java code; he should only have to edit the XML file. For
> example, one path could be A -> CheckRotation -> C or D and another
> could be E -> CheckRotation -> F or G.
>
> We can modify the Java code so the CheckRotation method could fire
> different events to direct the path.
>
> if(PrevState == A)
> {
>        if(bRotating)
>                fireEvent(EVENT_C);
>        else
>                fireEvent(EVENT_D);
> }
> else if(PrevState == E)
> {
>        if(bRotating)
>                fireEvent(EVENT_F);
>        else
>                fireEvent(EVENT_G);
> }
>
> But this solution adds complexity and defeats the whole purpose of using
> the engine in the first place! The CheckRotation state would need
> multiple conditional transitions defined (instead of two) in the XML
> file and the Java code would be interlinked with the XML engine! Is
> there a more proper solution to this issue?
>
> --
> Landon Ouyang
> Member Technical Staff
> ITT Electronics Systems, Radar Systems - Gilfillan
> 7821 Orion Ave,
> Van Nuys, CA 91406
> (818) 901-2982
>
> This e-mail and any files transmitted with it may be proprietary and are
> intended solely for the use of the individual or entity to whom they are
> addressed. If you have received this e-mail in error please notify the
> sender. Please note that any views or opinions presented in this e-mail are
> solely those of the author and do not necessarily represent those of ITT
> Corporation. The recipient should check this e-mail and any attachments for
> the presence of viruses. ITT accepts no liability for any damage caused by
> any virus transmitted by this e-mail.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>
>

[SCXML] XML engine decoupled from code

Posted by "Ouyang, Landon - ES/RDR -Gil" <La...@itt.com>.
Hi,

A conceptual issue has arisen after creating a working application that
uses the Commons SCXML engine.

Based on what we want out of the engine, it is essentially important
that the code implementation (Java) is decoupled/independent of the
underlying engine (XML file).

To illustrate the problems I encountered, here is an example: there is a
state called CheckRotation that can detect whether there is or isn't a
rotation. We need the ability for a developer to be able to place this
state anywhere in the state machine (possibly multiple times) and direct
the state machine based on one of the two outcomes without having to
write any Java code; he should only have to edit the XML file. For
example, one path could be A -> CheckRotation -> C or D and another
could be E -> CheckRotation -> F or G.

We can modify the Java code so the CheckRotation method could fire
different events to direct the path.

if(PrevState == A)
{
        if(bRotating)
                fireEvent(EVENT_C);
        else
                fireEvent(EVENT_D);
}
else if(PrevState == E)
{
        if(bRotating)
                fireEvent(EVENT_F);
        else
                fireEvent(EVENT_G);
}

But this solution adds complexity and defeats the whole purpose of using
the engine in the first place! The CheckRotation state would need
multiple conditional transitions defined (instead of two) in the XML
file and the Java code would be interlinked with the XML engine! Is
there a more proper solution to this issue?

--
Landon Ouyang
Member Technical Staff
ITT Electronics Systems, Radar Systems - Gilfillan
7821 Orion Ave,
Van Nuys, CA 91406
(818) 901-2982

This e-mail and any files transmitted with it may be proprietary and are intended solely for the use of the individual or entity to whom they are addressed. If you have received this e-mail in error please notify the sender. Please note that any views or opinions presented in this e-mail are solely those of the author and do not necessarily represent those of ITT Corporation. The recipient should check this e-mail and any attachments for the presence of viruses. ITT accepts no liability for any damage caused by any virus transmitted by this e-mail.

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


Re: [SCXML] W3C specs compatibility and state transition issues

Posted by Rahul Akolkar <ra...@gmail.com>.
On 4/14/08, Ouyang, Landon - ES/RDR -Gil <La...@itt.com> wrote:
> Hi Rahul,
>
>  My (limited) understand of JavaBeans is that a JavaBean object must
>  implement java.io.Serializable, has a public no argument constructor,
>  and contains set/get methods for properties. So I setup my result class
>  as follows:
>
>     class result implements Serializable
<snip/>

I think making the class public will fix the problem.

This is no longer a [scxml] discussion. My preference would be to have
a new email thread, if the discussion continues.

-Rahul


>         {
>         public result() {}
>         private int value;
>         public int getValue()
>             { return value; }
>         public void setValue(int nNum)
>             { value = nNum; }
>         }
>
>  However, the state transition still does not work!
>
>  FYI, I was able to prove that the object is sent to the engine correctly
>  using:
>
>  result newResult = (result)getEngine().getRootContext().get("result");
>
>  But for some reason, I cannot retrieve/use "result.value" in my XML
>  file!
>
>  Any ideas what I'm missing here? Thanks for the help.
>
>
>  --
>  Landon Ouyang
>  Member Technical Staff
>  ITT Electronics Systems, Radar Systems - Gilfillan
>  7821 Orion Ave,
>  Van Nuys, CA 91406
>  (818) 901-2982
>
>  -----Original Message-----
>  From: Rahul Akolkar [mailto:rahul.akolkar@gmail.com]
>
> Sent: Friday, April 11, 2008 6:56 PM
>  To: Jakarta Commons Users List
>  Subject: Re: [SCXML] W3C specs compatibility and state transition issues
>
>  On Fri, Apr 11, 2008 at 7:15 PM, Ouyang, Landon - ES/RDR -Gil
>  <La...@itt.com> wrote:
>  > Hmmm....
>  >
>  > Given your snippet, I assumed this would work:
>  >
>  > result aResult = new result();
>  >
>  > if(bIsTest)
>  >   aResult.value = 1;
>  > else
>  >   aResult.value = 0;
>  >
>  > getEngine().getRootContext().set("result", aResult);
>  >
>  > where the XML transition is conditional on "result.value eq 1". Why
>  > doesn't it work?
>  >
>  <snip/>
>
>  Try adding getter and setter methods, as I suggest below (for property
>  "value" in this example). Detailed discussion is in the JavaBeans
>  spec, which forms the basis of bean property access in most ELs we
>  use.
>
>  -Rahul
>
>
>  > --
>  > Landon Ouyang
>  > Member Technical Staff
>  > ITT Electronics Systems, Radar Systems - Gilfillan
>  > 7821 Orion Ave,
>  > Van Nuys, CA 91406
>  > (818) 901-2982
>  >
>  >
>  > -----Original Message-----
>  > From: Rahul Akolkar [mailto:rahul.akolkar@gmail.com]
>  >
>  > Sent: Friday, April 11, 2008 2:18 PM
>  > To: Jakarta Commons Users List
>  > Subject: Re: [SCXML] W3C specs compatibility and state transition
>  issues
>  >
>  > On Fri, Apr 11, 2008 at 5:01 PM, Ouyang, Landon - ES/RDR -Gil
>  > <La...@itt.com> wrote:
>  > > I figured out the solution:
>  > >
>  > > I needed to remove the event properties from the conditional
>  > > transitions. So if I change the state to:
>  > >
>  > > <state id="six">
>  > >        <datamodel>
>  > >                <data name="result">
>  > >                        <value>0</value>
>  > >                </data>
>  > >        </datamodel>
>  > >  <transition cond="result.value eq '1'" target="zero"/>
>  > >  <transition cond="result.value eq '0'" target="five"/>
>  > >  <transition target="three" event="display.prev"/>
>  > > </state>
>  > >
>  > > the code will work! Am I missing any other crucial details?
>  > >
>  > <snip/>
>  >
>  > Not really, but couple of comments:
>  >
>  >  * At a quick glance, I suspect you don't need the <datamodel>
>  > specified declaratively, so you can just remove the entire <datamodel>
>  > element (we are setting "result.value" via Java handlers). A brief
>  > discussion about datamodels is here:
>  >
>  >  http://commons.apache.org/scxml/guide/datamodel.html
>  >
>  >  * When I gave the example (below), I intended "fooresult.success" and
>  > "fooresult.numfailures" to be expressions of the flavor bean.property
>  > i.e. fooresult was an instance of:
>  >
>  > class FooResult {
>  >  get/setSuccess()
>  >  get/setNumfailures()
>  > }
>  >
>  > Generally better if you want to return a data structure, rather than
>  > multiple "flat variables" (your example is fine, for one value its
>  > much overhead).
>  >
>  > -Rahul
>  >

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


RE: [SCXML] W3C specs compatibility and state transition issues

Posted by "Ouyang, Landon - ES/RDR -Gil" <La...@itt.com>.
Hi Rahul,

My (limited) understand of JavaBeans is that a JavaBean object must
implement java.io.Serializable, has a public no argument constructor,
and contains set/get methods for properties. So I setup my result class
as follows:

    class result implements Serializable
        {
        public result() {}
        private int value;
        public int getValue()
            { return value; }
        public void setValue(int nNum)
            { value = nNum; }
        }

However, the state transition still does not work!

FYI, I was able to prove that the object is sent to the engine correctly
using:

result newResult = (result)getEngine().getRootContext().get("result");

But for some reason, I cannot retrieve/use "result.value" in my XML
file!

Any ideas what I'm missing here? Thanks for the help.

--
Landon Ouyang
Member Technical Staff
ITT Electronics Systems, Radar Systems - Gilfillan
7821 Orion Ave,
Van Nuys, CA 91406
(818) 901-2982

-----Original Message-----
From: Rahul Akolkar [mailto:rahul.akolkar@gmail.com]
Sent: Friday, April 11, 2008 6:56 PM
To: Jakarta Commons Users List
Subject: Re: [SCXML] W3C specs compatibility and state transition issues

On Fri, Apr 11, 2008 at 7:15 PM, Ouyang, Landon - ES/RDR -Gil
<La...@itt.com> wrote:
> Hmmm....
>
> Given your snippet, I assumed this would work:
>
> result aResult = new result();
>
> if(bIsTest)
>   aResult.value = 1;
> else
>   aResult.value = 0;
>
> getEngine().getRootContext().set("result", aResult);
>
> where the XML transition is conditional on "result.value eq 1". Why
> doesn't it work?
>
<snip/>

Try adding getter and setter methods, as I suggest below (for property
"value" in this example). Detailed discussion is in the JavaBeans
spec, which forms the basis of bean property access in most ELs we
use.

-Rahul


> --
> Landon Ouyang
> Member Technical Staff
> ITT Electronics Systems, Radar Systems - Gilfillan
> 7821 Orion Ave,
> Van Nuys, CA 91406
> (818) 901-2982
>
>
> -----Original Message-----
> From: Rahul Akolkar [mailto:rahul.akolkar@gmail.com]
>
> Sent: Friday, April 11, 2008 2:18 PM
> To: Jakarta Commons Users List
> Subject: Re: [SCXML] W3C specs compatibility and state transition
issues
>
> On Fri, Apr 11, 2008 at 5:01 PM, Ouyang, Landon - ES/RDR -Gil
> <La...@itt.com> wrote:
> > I figured out the solution:
> >
> > I needed to remove the event properties from the conditional
> > transitions. So if I change the state to:
> >
> > <state id="six">
> >        <datamodel>
> >                <data name="result">
> >                        <value>0</value>
> >                </data>
> >        </datamodel>
> >  <transition cond="result.value eq '1'" target="zero"/>
> >  <transition cond="result.value eq '0'" target="five"/>
> >  <transition target="three" event="display.prev"/>
> > </state>
> >
> > the code will work! Am I missing any other crucial details?
> >
> <snip/>
>
> Not really, but couple of comments:
>
>  * At a quick glance, I suspect you don't need the <datamodel>
> specified declaratively, so you can just remove the entire <datamodel>
> element (we are setting "result.value" via Java handlers). A brief
> discussion about datamodels is here:
>
>  http://commons.apache.org/scxml/guide/datamodel.html
>
>  * When I gave the example (below), I intended "fooresult.success" and
> "fooresult.numfailures" to be expressions of the flavor bean.property
> i.e. fooresult was an instance of:
>
> class FooResult {
>  get/setSuccess()
>  get/setNumfailures()
> }
>
> Generally better if you want to return a data structure, rather than
> multiple "flat variables" (your example is fine, for one value its
> much overhead).
>
> -Rahul
>

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


This e-mail and any files transmitted with it may be proprietary and are intended solely for the use of the individual or entity to whom they are addressed. If you have received this e-mail in error please notify the sender. Please note that any views or opinions presented in this e-mail are solely those of the author and do not necessarily represent those of ITT Corporation. The recipient should check this e-mail and any attachments for the presence of viruses. ITT accepts no liability for any damage caused by any virus transmitted by this e-mail.

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


Re: [SCXML] W3C specs compatibility and state transition issues

Posted by Rahul Akolkar <ra...@gmail.com>.
On Fri, Apr 11, 2008 at 7:15 PM, Ouyang, Landon - ES/RDR -Gil
<La...@itt.com> wrote:
> Hmmm....
>
> Given your snippet, I assumed this would work:
>
> result aResult = new result();
>
> if(bIsTest)
>   aResult.value = 1;
> else
>   aResult.value = 0;
>
> getEngine().getRootContext().set("result", aResult);
>
> where the XML transition is conditional on "result.value eq 1". Why
> doesn't it work?
>
<snip/>

Try adding getter and setter methods, as I suggest below (for property
"value" in this example). Detailed discussion is in the JavaBeans
spec, which forms the basis of bean property access in most ELs we
use.

-Rahul


> --
> Landon Ouyang
> Member Technical Staff
> ITT Electronics Systems, Radar Systems - Gilfillan
> 7821 Orion Ave,
> Van Nuys, CA 91406
> (818) 901-2982
>
>
> -----Original Message-----
> From: Rahul Akolkar [mailto:rahul.akolkar@gmail.com]
>
> Sent: Friday, April 11, 2008 2:18 PM
> To: Jakarta Commons Users List
> Subject: Re: [SCXML] W3C specs compatibility and state transition issues
>
> On Fri, Apr 11, 2008 at 5:01 PM, Ouyang, Landon - ES/RDR -Gil
> <La...@itt.com> wrote:
> > I figured out the solution:
> >
> > I needed to remove the event properties from the conditional
> > transitions. So if I change the state to:
> >
> > <state id="six">
> >        <datamodel>
> >                <data name="result">
> >                        <value>0</value>
> >                </data>
> >        </datamodel>
> >  <transition cond="result.value eq '1'" target="zero"/>
> >  <transition cond="result.value eq '0'" target="five"/>
> >  <transition target="three" event="display.prev"/>
> > </state>
> >
> > the code will work! Am I missing any other crucial details?
> >
> <snip/>
>
> Not really, but couple of comments:
>
>  * At a quick glance, I suspect you don't need the <datamodel>
> specified declaratively, so you can just remove the entire <datamodel>
> element (we are setting "result.value" via Java handlers). A brief
> discussion about datamodels is here:
>
>  http://commons.apache.org/scxml/guide/datamodel.html
>
>  * When I gave the example (below), I intended "fooresult.success" and
> "fooresult.numfailures" to be expressions of the flavor bean.property
> i.e. fooresult was an instance of:
>
> class FooResult {
>  get/setSuccess()
>  get/setNumfailures()
> }
>
> Generally better if you want to return a data structure, rather than
> multiple "flat variables" (your example is fine, for one value its
> much overhead).
>
> -Rahul
>

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


RE: [SCXML] W3C specs compatibility and state transition issues

Posted by "Ouyang, Landon - ES/RDR -Gil" <La...@itt.com>.
Hmmm....

Given your snippet, I assumed this would work:

result aResult = new result();

if(bIsTest)
   aResult.value = 1;
else
   aResult.value = 0;

getEngine().getRootContext().set("result", aResult);

where the XML transition is conditional on "result.value eq 1". Why
doesn't it work?

--
Landon Ouyang
Member Technical Staff
ITT Electronics Systems, Radar Systems - Gilfillan
7821 Orion Ave,
Van Nuys, CA 91406
(818) 901-2982


-----Original Message-----
From: Rahul Akolkar [mailto:rahul.akolkar@gmail.com]
Sent: Friday, April 11, 2008 2:18 PM
To: Jakarta Commons Users List
Subject: Re: [SCXML] W3C specs compatibility and state transition issues

On Fri, Apr 11, 2008 at 5:01 PM, Ouyang, Landon - ES/RDR -Gil
<La...@itt.com> wrote:
> I figured out the solution:
>
> I needed to remove the event properties from the conditional
> transitions. So if I change the state to:
>
> <state id="six">
>        <datamodel>
>                <data name="result">
>                        <value>0</value>
>                </data>
>        </datamodel>
>  <transition cond="result.value eq '1'" target="zero"/>
>  <transition cond="result.value eq '0'" target="five"/>
>  <transition target="three" event="display.prev"/>
> </state>
>
> the code will work! Am I missing any other crucial details?
>
<snip/>

Not really, but couple of comments:

 * At a quick glance, I suspect you don't need the <datamodel>
specified declaratively, so you can just remove the entire <datamodel>
element (we are setting "result.value" via Java handlers). A brief
discussion about datamodels is here:

  http://commons.apache.org/scxml/guide/datamodel.html

 * When I gave the example (below), I intended "fooresult.success" and
"fooresult.numfailures" to be expressions of the flavor bean.property
i.e. fooresult was an instance of:

class FooResult {
  get/setSuccess()
  get/setNumfailures()
}

Generally better if you want to return a data structure, rather than
multiple "flat variables" (your example is fine, for one value its
much overhead).

-Rahul


> --
> Landon Ouyang
> Member Technical Staff
> ITT Electronics Systems, Radar Systems - Gilfillan
> 7821 Orion Ave,
> Van Nuys, CA 91406
> (818) 901-2982
>
>
> -----Original Message-----
> From: Ouyang, Landon - ES/RDR -Gil [mailto:Landon.Ouyang@itt.com]
> Sent: Friday, April 11, 2008 1:34 PM
> To: Jakarta Commons Users List
>
> Subject: RE: [SCXML] W3C specs compatibility and state transition
issues
>
> Hi Rahul,
>
> Thanks for the quick and helpful response. I am still having trouble
> creating a conditional state transition. Using your example, I added a
> conditional transition in my XML file as follows:
>
> <state id="six">
> <datamodel>
>        <data name="result">
>                <value>0</value>
>        </data>
> </datamodel>
>  <transition cond="$(result.value eq '1')" target="zero"
> event="display.next"/>
>  <transition cond="$(result.value eq '0')" target="seven"
> event="display.next"/>
>  <transition target="five" event="display.prev"/>
> </state>
>
> My handler for state 6 is the following:
> public void six(){
>      getEngine().getRootContext().set("result.value", "1");
>        }
>
> I have a NEXT button in my GUI that fires off the 'display.next'
event.
> In state 5, I hit this NEXT button and this code gets executed. I
would
> assume that when I hit the NEXT button again I should be in state 0,
but
> instead I stay in state 6 indefinitely!
>
> Can you tell me what I am doing wrong?
>
> --
> Landon Ouyang
> Member Technical Staff
> ITT Electronics Systems, Radar Systems - Gilfillan
> 7821 Orion Ave,
> Van Nuys, CA 91406
> (818) 901-2982
>
> -----Original Message-----
> From: Rahul Akolkar [mailto:rahul.akolkar@gmail.com]
> Sent: Thursday, April 10, 2008 6:22 PM
> To: Jakarta Commons Users List
> Subject: Re: [SCXML] W3C specs compatibility and state transition
issues
>
> On Thu, Apr 10, 2008 at 8:30 PM, Ouyang, Landon - ES/RDR -Gil
> <La...@itt.com> wrote:
> > Apologize for the duplicate e-mail, I had to be schooled on the
proper
> format by Mr. Cooper. :)
> >
> >
> > I am a new user of Commons SCXML. I have two very basic questions:
> >
> > 1)      How much of the W3C specs for SCXML is supported with Common
> SCXML? Are all of the tags recognized?
> >
> <snip/>
>
> Not supported:
>  <anchor> (supporting this one is optional for engines)
>  <validate>
>
> Experimental (due to missing pieces in draft spec, see TBD markers for
> example):
>  <invoke>
>
>
> > 2)      Basing my code off of the simple stopwatch example, I
created
> a simple Java app that navigated across 10 states. I noticed that if I
> put any code in the state handler methods that fires off events to
> transition to other states, the application still thinks I am in the
> *previous* state! For example, if I am in the state 5 subroutine and
> fire off an EVENT_NEXT event to go to state 6, the app actually keeps
me
> in state 5 because it still thinks I am in state 4! Is it true that
the
> state machine transitions *after* the handler for the new state is
> called? If so, how do I put custom code so that the state can make
> transition decisions based on certain conditions?
> >
> <snap/>
>
> You'd have to do that asynchronously (the executor is still processing
> the earlier event). However ...
>
> I'd store the result of "certain conditions" in the datamodel, and
> query the datamodel later, like so:
>
> public void foo() { // handler for state "foo"
>
>    // check certain conditions, create someresultbean
>
>    getEngine().getRootContext().put("fooresult", someresultbean);
> }
>
> And further, in a totally fictitious example:
>
> <state id="foo">
>    <transition cond="fooresult.success" target="bar"/>
>    <transition cond="fooresult.numfailures gt 2" target="exit"/>
>    <transition cond="not fooresult.success" target="foo"/> <!-- try
> again -->
>    <!-- foo's other content -->
> </state>
>
> -Rahul
>
>
> >
> >

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


This e-mail and any files transmitted with it may be proprietary and are intended solely for the use of the individual or entity to whom they are addressed. If you have received this e-mail in error please notify the sender. Please note that any views or opinions presented in this e-mail are solely those of the author and do not necessarily represent those of ITT Corporation. The recipient should check this e-mail and any attachments for the presence of viruses. ITT accepts no liability for any damage caused by any virus transmitted by this e-mail.

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


Re: [SCXML] W3C specs compatibility and state transition issues

Posted by Rahul Akolkar <ra...@gmail.com>.
On Fri, Apr 11, 2008 at 5:01 PM, Ouyang, Landon - ES/RDR -Gil
<La...@itt.com> wrote:
> I figured out the solution:
>
> I needed to remove the event properties from the conditional
> transitions. So if I change the state to:
>
> <state id="six">
>        <datamodel>
>                <data name="result">
>                        <value>0</value>
>                </data>
>        </datamodel>
>  <transition cond="result.value eq '1'" target="zero"/>
>  <transition cond="result.value eq '0'" target="five"/>
>  <transition target="three" event="display.prev"/>
> </state>
>
> the code will work! Am I missing any other crucial details?
>
<snip/>

Not really, but couple of comments:

 * At a quick glance, I suspect you don't need the <datamodel>
specified declaratively, so you can just remove the entire <datamodel>
element (we are setting "result.value" via Java handlers). A brief
discussion about datamodels is here:

  http://commons.apache.org/scxml/guide/datamodel.html

 * When I gave the example (below), I intended "fooresult.success" and
"fooresult.numfailures" to be expressions of the flavor bean.property
i.e. fooresult was an instance of:

class FooResult {
  get/setSuccess()
  get/setNumfailures()
}

Generally better if you want to return a data structure, rather than
multiple "flat variables" (your example is fine, for one value its
much overhead).

-Rahul


> --
> Landon Ouyang
> Member Technical Staff
> ITT Electronics Systems, Radar Systems - Gilfillan
> 7821 Orion Ave,
> Van Nuys, CA 91406
> (818) 901-2982
>
>
> -----Original Message-----
> From: Ouyang, Landon - ES/RDR -Gil [mailto:Landon.Ouyang@itt.com]
> Sent: Friday, April 11, 2008 1:34 PM
> To: Jakarta Commons Users List
>
> Subject: RE: [SCXML] W3C specs compatibility and state transition issues
>
> Hi Rahul,
>
> Thanks for the quick and helpful response. I am still having trouble
> creating a conditional state transition. Using your example, I added a
> conditional transition in my XML file as follows:
>
> <state id="six">
> <datamodel>
>        <data name="result">
>                <value>0</value>
>        </data>
> </datamodel>
>  <transition cond="$(result.value eq '1')" target="zero"
> event="display.next"/>
>  <transition cond="$(result.value eq '0')" target="seven"
> event="display.next"/>
>  <transition target="five" event="display.prev"/>
> </state>
>
> My handler for state 6 is the following:
> public void six(){
>      getEngine().getRootContext().set("result.value", "1");
>        }
>
> I have a NEXT button in my GUI that fires off the 'display.next' event.
> In state 5, I hit this NEXT button and this code gets executed. I would
> assume that when I hit the NEXT button again I should be in state 0, but
> instead I stay in state 6 indefinitely!
>
> Can you tell me what I am doing wrong?
>
> --
> Landon Ouyang
> Member Technical Staff
> ITT Electronics Systems, Radar Systems - Gilfillan
> 7821 Orion Ave,
> Van Nuys, CA 91406
> (818) 901-2982
>
> -----Original Message-----
> From: Rahul Akolkar [mailto:rahul.akolkar@gmail.com]
> Sent: Thursday, April 10, 2008 6:22 PM
> To: Jakarta Commons Users List
> Subject: Re: [SCXML] W3C specs compatibility and state transition issues
>
> On Thu, Apr 10, 2008 at 8:30 PM, Ouyang, Landon - ES/RDR -Gil
> <La...@itt.com> wrote:
> > Apologize for the duplicate e-mail, I had to be schooled on the proper
> format by Mr. Cooper. :)
> >
> >
> > I am a new user of Commons SCXML. I have two very basic questions:
> >
> > 1)      How much of the W3C specs for SCXML is supported with Common
> SCXML? Are all of the tags recognized?
> >
> <snip/>
>
> Not supported:
>  <anchor> (supporting this one is optional for engines)
>  <validate>
>
> Experimental (due to missing pieces in draft spec, see TBD markers for
> example):
>  <invoke>
>
>
> > 2)      Basing my code off of the simple stopwatch example, I created
> a simple Java app that navigated across 10 states. I noticed that if I
> put any code in the state handler methods that fires off events to
> transition to other states, the application still thinks I am in the
> *previous* state! For example, if I am in the state 5 subroutine and
> fire off an EVENT_NEXT event to go to state 6, the app actually keeps me
> in state 5 because it still thinks I am in state 4! Is it true that the
> state machine transitions *after* the handler for the new state is
> called? If so, how do I put custom code so that the state can make
> transition decisions based on certain conditions?
> >
> <snap/>
>
> You'd have to do that asynchronously (the executor is still processing
> the earlier event). However ...
>
> I'd store the result of "certain conditions" in the datamodel, and
> query the datamodel later, like so:
>
> public void foo() { // handler for state "foo"
>
>    // check certain conditions, create someresultbean
>
>    getEngine().getRootContext().put("fooresult", someresultbean);
> }
>
> And further, in a totally fictitious example:
>
> <state id="foo">
>    <transition cond="fooresult.success" target="bar"/>
>    <transition cond="fooresult.numfailures gt 2" target="exit"/>
>    <transition cond="not fooresult.success" target="foo"/> <!-- try
> again -->
>    <!-- foo's other content -->
> </state>
>
> -Rahul
>
>
> >
> >

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


RE: [SCXML] W3C specs compatibility and state transition issues

Posted by "Ouyang, Landon - ES/RDR -Gil" <La...@itt.com>.
I figured out the solution:

I needed to remove the event properties from the conditional
transitions. So if I change the state to:

<state id="six">
        <datamodel>
                <data name="result">
                        <value>0</value>
                </data>
        </datamodel>
 <transition cond="result.value eq '1'" target="zero"/>
 <transition cond="result.value eq '0'" target="five"/>
 <transition target="three" event="display.prev"/>
</state>

the code will work! Am I missing any other crucial details?

--
Landon Ouyang
Member Technical Staff
ITT Electronics Systems, Radar Systems - Gilfillan
7821 Orion Ave,
Van Nuys, CA 91406
(818) 901-2982


-----Original Message-----
From: Ouyang, Landon - ES/RDR -Gil [mailto:Landon.Ouyang@itt.com]
Sent: Friday, April 11, 2008 1:34 PM
To: Jakarta Commons Users List
Subject: RE: [SCXML] W3C specs compatibility and state transition issues

Hi Rahul,

Thanks for the quick and helpful response. I am still having trouble
creating a conditional state transition. Using your example, I added a
conditional transition in my XML file as follows:

<state id="six">
<datamodel>
        <data name="result">
                <value>0</value>
        </data>
</datamodel>
 <transition cond="$(result.value eq '1')" target="zero"
event="display.next"/>
 <transition cond="$(result.value eq '0')" target="seven"
event="display.next"/>
 <transition target="five" event="display.prev"/>
</state>

My handler for state 6 is the following:
public void six(){
      getEngine().getRootContext().set("result.value", "1");
        }

I have a NEXT button in my GUI that fires off the 'display.next' event.
In state 5, I hit this NEXT button and this code gets executed. I would
assume that when I hit the NEXT button again I should be in state 0, but
instead I stay in state 6 indefinitely!

Can you tell me what I am doing wrong?

--
Landon Ouyang
Member Technical Staff
ITT Electronics Systems, Radar Systems - Gilfillan
7821 Orion Ave,
Van Nuys, CA 91406
(818) 901-2982

-----Original Message-----
From: Rahul Akolkar [mailto:rahul.akolkar@gmail.com]
Sent: Thursday, April 10, 2008 6:22 PM
To: Jakarta Commons Users List
Subject: Re: [SCXML] W3C specs compatibility and state transition issues

On Thu, Apr 10, 2008 at 8:30 PM, Ouyang, Landon - ES/RDR -Gil
<La...@itt.com> wrote:
> Apologize for the duplicate e-mail, I had to be schooled on the proper
format by Mr. Cooper. :)
>
>
> I am a new user of Commons SCXML. I have two very basic questions:
>
> 1)      How much of the W3C specs for SCXML is supported with Common
SCXML? Are all of the tags recognized?
>
<snip/>

Not supported:
  <anchor> (supporting this one is optional for engines)
  <validate>

Experimental (due to missing pieces in draft spec, see TBD markers for
example):
  <invoke>


> 2)      Basing my code off of the simple stopwatch example, I created
a simple Java app that navigated across 10 states. I noticed that if I
put any code in the state handler methods that fires off events to
transition to other states, the application still thinks I am in the
*previous* state! For example, if I am in the state 5 subroutine and
fire off an EVENT_NEXT event to go to state 6, the app actually keeps me
in state 5 because it still thinks I am in state 4! Is it true that the
state machine transitions *after* the handler for the new state is
called? If so, how do I put custom code so that the state can make
transition decisions based on certain conditions?
>
<snap/>

You'd have to do that asynchronously (the executor is still processing
the earlier event). However ...

I'd store the result of "certain conditions" in the datamodel, and
query the datamodel later, like so:

public void foo() { // handler for state "foo"

    // check certain conditions, create someresultbean

    getEngine().getRootContext().put("fooresult", someresultbean);
}

And further, in a totally fictitious example:

<state id="foo">
    <transition cond="fooresult.success" target="bar"/>
    <transition cond="fooresult.numfailures gt 2" target="exit"/>
    <transition cond="not fooresult.success" target="foo"/> <!-- try
again -->
    <!-- foo's other content -->
</state>

-Rahul


>
>
> --
> Landon Ouyang
> Member Technical Staff
> ITT Electronics Systems, Radar Systems - Gilfillan
> 7821 Orion Ave,
> Van Nuys, CA 91406
> (818) 901-2982
>

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


This e-mail and any files transmitted with it may be proprietary and are
intended solely for the use of the individual or entity to whom they are
addressed. If you have received this e-mail in error please notify the
sender. Please note that any views or opinions presented in this e-mail
are solely those of the author and do not necessarily represent those of
ITT Corporation. The recipient should check this e-mail and any
attachments for the presence of viruses. ITT accepts no liability for
any damage caused by any virus transmitted by this e-mail.

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


This e-mail and any files transmitted with it may be proprietary and are intended solely for the use of the individual or entity to whom they are addressed. If you have received this e-mail in error please notify the sender. Please note that any views or opinions presented in this e-mail are solely those of the author and do not necessarily represent those of ITT Corporation. The recipient should check this e-mail and any attachments for the presence of viruses. ITT accepts no liability for any damage caused by any virus transmitted by this e-mail.

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


RE: [SCXML] W3C specs compatibility and state transition issues

Posted by "Ouyang, Landon - ES/RDR -Gil" <La...@itt.com>.
Hi Rahul,

Thanks for the quick and helpful response. I am still having trouble
creating a conditional state transition. Using your example, I added a
conditional transition in my XML file as follows:

<state id="six">
<datamodel>
        <data name="result">
                <value>0</value>
        </data>
</datamodel>
 <transition cond="$(result.value eq '1')" target="zero"
event="display.next"/>
 <transition cond="$(result.value eq '0')" target="seven"
event="display.next"/>
 <transition target="five" event="display.prev"/>
</state>

My handler for state 6 is the following:
public void six(){
      getEngine().getRootContext().set("result.value", "1");
        }

I have a NEXT button in my GUI that fires off the 'display.next' event.
In state 5, I hit this NEXT button and this code gets executed. I would
assume that when I hit the NEXT button again I should be in state 0, but
instead I stay in state 6 indefinitely!

Can you tell me what I am doing wrong?

--
Landon Ouyang
Member Technical Staff
ITT Electronics Systems, Radar Systems - Gilfillan
7821 Orion Ave,
Van Nuys, CA 91406
(818) 901-2982

-----Original Message-----
From: Rahul Akolkar [mailto:rahul.akolkar@gmail.com]
Sent: Thursday, April 10, 2008 6:22 PM
To: Jakarta Commons Users List
Subject: Re: [SCXML] W3C specs compatibility and state transition issues

On Thu, Apr 10, 2008 at 8:30 PM, Ouyang, Landon - ES/RDR -Gil
<La...@itt.com> wrote:
> Apologize for the duplicate e-mail, I had to be schooled on the proper
format by Mr. Cooper. :)
>
>
> I am a new user of Commons SCXML. I have two very basic questions:
>
> 1)      How much of the W3C specs for SCXML is supported with Common
SCXML? Are all of the tags recognized?
>
<snip/>

Not supported:
  <anchor> (supporting this one is optional for engines)
  <validate>

Experimental (due to missing pieces in draft spec, see TBD markers for
example):
  <invoke>


> 2)      Basing my code off of the simple stopwatch example, I created
a simple Java app that navigated across 10 states. I noticed that if I
put any code in the state handler methods that fires off events to
transition to other states, the application still thinks I am in the
*previous* state! For example, if I am in the state 5 subroutine and
fire off an EVENT_NEXT event to go to state 6, the app actually keeps me
in state 5 because it still thinks I am in state 4! Is it true that the
state machine transitions *after* the handler for the new state is
called? If so, how do I put custom code so that the state can make
transition decisions based on certain conditions?
>
<snap/>

You'd have to do that asynchronously (the executor is still processing
the earlier event). However ...

I'd store the result of "certain conditions" in the datamodel, and
query the datamodel later, like so:

public void foo() { // handler for state "foo"

    // check certain conditions, create someresultbean

    getEngine().getRootContext().put("fooresult", someresultbean);
}

And further, in a totally fictitious example:

<state id="foo">
    <transition cond="fooresult.success" target="bar"/>
    <transition cond="fooresult.numfailures gt 2" target="exit"/>
    <transition cond="not fooresult.success" target="foo"/> <!-- try
again -->
    <!-- foo's other content -->
</state>

-Rahul


>
>
> --
> Landon Ouyang
> Member Technical Staff
> ITT Electronics Systems, Radar Systems - Gilfillan
> 7821 Orion Ave,
> Van Nuys, CA 91406
> (818) 901-2982
>

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


This e-mail and any files transmitted with it may be proprietary and are intended solely for the use of the individual or entity to whom they are addressed. If you have received this e-mail in error please notify the sender. Please note that any views or opinions presented in this e-mail are solely those of the author and do not necessarily represent those of ITT Corporation. The recipient should check this e-mail and any attachments for the presence of viruses. ITT accepts no liability for any damage caused by any virus transmitted by this e-mail.

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