Re: [SCXML] History state

2009-04-07 Thread Rahul Akolkar
On Mon, Apr 6, 2009 at 4:24 PM, Ouyang, Landon - ES/RDR -Gil
 wrote:
>>> In TopState  (This is what I don't want!!)
>>
>>
>>This seems off, TopState isn't part of the least common ancestor so shouldn't 
>>be entered. If you can attach a JUnit test case to JIRA, I'll have a look.
>
> This is why I asked the question.  It was my understanding that the super 
> states of State1 (TopState in this case) should not be entered and their 
> entry actions should not be executed.  I did not mean to include State1 in 
> the list of unwanted functionality.
>


Yup, so State1 is expected but TopState isn't (if thats what you are seeing).


> I am new to Java and have not used JUnit yet.  Can you explain what you would 
> like to see in the JUnit test; events fired, transitions taken, state 
> history, or something else?
>


There are JUnit tests buried in here:

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

which you can use as examples. Generally, anything that will help us
creating a test case is welcome -- so just a complete SCXML document
with the sequence of events and expected vs. observed behavior is
enough in the report if you want to skip writing a complete JUnit
test.

-Rahul



> --
> Landon Ouyang
> Senior Design Engineer
> ITT Electronics Systems, Radar Systems - Gilfillan
> 7821 Orion Ave,
> Van Nuys, CA 91406
> (818) 901-2982
>
> -Original Message-
> From: Rahul Akolkar [mailto:rahul.akol...@gmail.com]
> Sent: Thursday, April 02, 2009 6:25 PM
> To: Commons Users List
> Subject: Re: [SCXML] History state
>
> On Thu, Apr 2, 2009 at 5:43 PM, Ouyang, Landon - ES/RDR -Gil
>  wrote:
>> My apologies for not modifying the Subject header in my last e-mail 
>> (reproduced below).
>>
> 
>
> Thanks for correcting. Response below.
>
>
>> --
>> Landon Ouyang
>> Senior Design Engineer
>> 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.ouy...@itt.com]
>> Sent: Thursday, April 02, 2009 2:08 PM
>> To: Commons Users List
>> Subject: RE: [SCXML] getting set datats in the datamodel
>>
>> I am trying to implement a history state.  It does work, returns to the 
>> calling state, however it enters all the super states before getting to the 
>> calling state.  Which also calls entry actions (when there are entry 
>> actions).  This is not the behavior I was expecting.  Can you explain to me 
>> how to prevent this?
>>
> 
>
> In effect, transitions to histories are not much different from
> regular transitions, barring the dynamic nature of the transition
> target.
>
> The corresponding executable content (exit, transition, entry) will be
> called. If you want other behavior, you can control blocks of
> executable content using the  container and appropriate
> conditions. So, for example -- the first entry into the composite
> state containing the history updates some part of the datamodel, and
> latter entries guard the executable content using  that checks for
> the said datamodel update.
>
>
>> Below is the command line output from a small program that accepts trigger 
>> events and has a listener attached to the states that outputs the current 
>> state.
>> [spalmis...@linuxserver src]$ run.sh
>> Default scxml file is: HistoryTest.scxml
>> Enter path to over-ride (or enter to continue):
>> trigger>TO_STATE12
>> In State12
>> trigger>TO_STATE32
>> In State3
>> In State32
>> trigger>STATE32_TO_HISTORY
>> In TopState  (This is what I don't want!!)
> 
>
> This seems off, TopState isn't part of the least common ancestor so
> shouldn't be entered. If you can attach a JUnit test case to JIRA,
> I'll have a look.
>
>
>> In State1    (This is what I don't want!!)
> 
>
> This is as expected. As mentioned before, you may have to guard
> executable content via application logic.
>
> -Rahul
>
>
>> In State12   (This is what I do want)
>> trigger>
>>
>>
>> SCXML file used:
>>
>> 
>> http://www.w3.org/2005/07/scxml"; 
>> xmlns:my="http://www.company.com"; 
>> xmlns:uml="http://schema.omg.org/spec/UML/2.1.1"; 
>> xmlns:xmi="http://schema.omg.org/spec/XMI/2.1"; version="1.0" 
>> initial="StateMachineInitial">
>>  
>>    
>>      
>>        
>>      
>>      
>>        
>>      
>>      
>>        
>>      
>>    
>>    
>>      
>>    
>>    
>>      
>>        
>>        
>>      
>>      
>>        
>>        
>>      
>>      
>>        
>>      
>>      
>>        
>>      
>>    
>>    
>>  
>>  
>>    
>>  
>>  
>> 
>>
>> --
>> Landon Ouyang
>> Senior Design Engineer
>> 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 opin

Re: [SCXML] getting set datats in the datamodel

2009-04-07 Thread Rahul Akolkar
On Mon, Apr 6, 2009 at 10:35 AM, Linda Erlenhov
 wrote:
> Hello again!
>
> I´m not sure how to explain what I want to do.


Code snippets like the ones below help.


> The task I have is to build
> an editor that you then can use to build simulations of applications. An
> application can be a cd-player for instance. What already exists is an
> editor for building GUI:s without coding (not build by me) and an engine
> that runs this and via a protocol "talks" to an application. What I´m trying
> to do is "attatch" my editor to the protocol instead of a "real life"
> application. The problem is that I´m developing this very generic. I can not
> know what kind of application the user want to simulate, the only thing I
> have to run this from is the protocol specification and in that
> specification it, for one thing,  says that I should be able to handle
> dynamic data subscriptions.
>
> In the cd-player case this could be that a track on the cd has ended and a
> new has begun, if I have an subscription for the title of the song playing I
> would then like to send it to the engine i was talking about.
>
> So if I write a datamodel like (well, I don´t, it would be generated like
> this):
> 
> text
> 0
> 
>


OK. What location in the SCXML document do you generate this
datamodel? I previously suggested its easiest if this appears as child
of root (you can use the stock Contexts and Evaluators):

  http://markmail.org/message/bt3oli33cey7ecju


> and then somewhere in the scema the person who build the simulation wants
> "title" to change, this is then translated to:
>
> 
> as an example.
>


For an XML data model, its best to use the XPath Evaluator (though its
yet unreleased), where the above would look like:

  

Or use the Data() function with other Evaluators, see this page for details:

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

Moreover, since you are in control of the generated markup, you could
generate a custom action to do the notifications for you. More on
custom actions here:

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

So, for example, instead of generating:

  

you could generate:

  

where custom action  inherits from standard action 
to do the extra notifications bit.


> If i want to "read" what data.title:s expression is, how do I do that?
>
> I used the:
> http://www.ling.gu.se/~lager/Labs/SCXML-Lab/
> for more examples, I´m not sure if you´re using the same standard, but it´s
> an easy way to understand how the SCXML works.
>


Same, but the expression language in use isn't the same, the XML data
model seems to be shredded into an ECMA friendly variant. Hence the
difference in the expression above.


>>
>>
>>  * Use a custom Context implementation - This will allow you to
>> intercept data changes, à la pointcut at
>> oacs.Context#set(String,Object), and get notifications that way
>
>
> This could possibly be of intrest, but I´m still not 100% sure on how the
> context works. Where would these notifications "arrive"
>


This is another approach, some background:

  http://commons.apache.org/scxml/guide/contexts-evaluators.html

I'll sketch an outline here -- say we have MyContext extending
SimpleContext where MyContext#set(String,Object) looks like:

   public void set(String name, Object value) {
  // inherit behavior
  super.set(name, value);
  // notifications you need
  notify(name, value);
   }

and a MyEvaluator extending the Evaluator you are currently using
whose newContext() method does this:

   public Context newContext(Context parent) {
  return new MyContext(parent);
   }

then using this evaluator with the SCXMLExecutor instances like so:

   SCXMLExecutor exec = new SCXMLExecutor();
   ...
   exec.setEvaluator(new MyEvaluator());

ties in the above "pointcut" behavior causing notifications for any
data changes within the state machine. Adjust outline per
requirements.

-Rahul


> best regards
> //Linda
>

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