Re: [SCXML] Polling in datamodel

2009-05-11 Thread Linda Erlenhov
Hello!

The thing here is that the value is never a DOM node. Hence my question. I
previousley asked why the assign location didn´t call for the set
function in the Context and got the answere that the assign location
doesn´t work as assign name, assign name calls the set function and sets
a variable, assign location manipulates the XML tree as it is. The advice
was to make an custom action instead or do the ugly hack I did: do an
assign name with the name after the assign location has executed.
What I wanted to know is if there is any way of fetching the tree or
whatever it is to get the data associatet to a name, according to the model
below.
If you look at my example below, I will always know the name of the
datamodel in this case: DynamicData, and I will recieve the name of the
specific tag in this data, in this case Data_1, Data_2 or Data_3. In
my model below I have done an ugly way of finding out what the value is but
i realized that that was not enough, i need to know the type aswell. And
that I don´t know how to find.

Does anybody have a solution to this, or some kind of idea on how to solve
this?

best regards
//Linda

On Tue, May 5, 2009 at 3:50 PM, Ingmar Kliche
ingmar.kli...@googlemail.comwrote:

 Linda,
 you should be able to use the DOM API to read the values. In
 context.set(name, value) you should check whether the value is a DOM node:

 import import org.w3c.dom.Node;

 ...
 ... set(String name, Object value) {

if (value instanceof Node) {
Node nodeValue = (Node) value;
}

 scope.put(name, scope, value);


 2009/5/5 Linda Erlenhov linda.erlen...@gmail.com

  Hello.
  I´m back with another thousand questions!
 
  Still with my datamodel like this:
  
  scxml version=1.0 initialstate=176 xmlns:cs=
  http://commons.apache.org/scxml; xmlns=http://www.w3.org/2005/07/scxml
 
 
  datamodel
  data name=DynamicData
  Data_1 xmlns= id=1 type=Integer0/Data_1
  Data_2 xmlns= id=2 type=Integer0/Data_2
  Data_3 xmlns= id=3 type=Stringnone/Data_2
  /data
  data name=DDChange/
  data name=DDValue/
  data name=DDType/
  data name=Indication_1 expr=false/
  /datamodel
  ...snip...
  Later on i set the data:
  ...snip.
  state id=StateB
  onentry
  log label=Renegade expr='Entering state: StateB'/
  log label=Renegade expr=Data(DynamicData,'Data_1')/
  assign location=Data(DynamicData,'Data_1')
  expr=Data(DynamicData,'Data_1')+1/
  assign name=DDValue expr=Data(DynamicData,'Data_1')/
  assign name=DDChange expr='Data_1'/
  log label=Renegade expr=Data(DynamicData,'Data_1')/
 
  /onentry
  ..snip
 
  So now here´s the problem.
 
  As you see I haven´t used the custom action, but an rather ugly hack
 where
  I
  do an assign name after I do the assign location to trigger a call to the
  set function in the context.
 
  In this version I also do another assign where I assign another name with
  the value. All my data are named Data_XX so i screen the calls to set byt
  looking for the ones that are named Data_XX. When I recieve a call for
  Data_XX I would like to know what the value is, which I in this case have
  solved by assigning another variable with it earlier, when i get a set
  call named Data_xx i know that the variable DDValue contains the value of
  this data. Not pretty, but OK and working so far.
  Now I would like to be able to see what type the data is aswell. How do
 I
  do that? And: Is there a less spaghetti way to poll the value of the data
  from where I am (In the context) when I have the name of it. (The name
 in
  this case is Data_1, Data_2 or Data_3, I also know that the data=name is
  DynamicData) .
 
  Due to lack of time I would prefer if i wouldn´t have to redo to much
 of
  the scxml, but is this possible to do it my way otherwise? Or do I have
 to
  do it over.
 
  Best Regards
  //Linda
 



[SCXML] Polling in datamodel

2009-05-05 Thread Linda Erlenhov
Hello.
I´m back with another thousand questions!

Still with my datamodel like this:

scxml version=1.0 initialstate=176 xmlns:cs=
http://commons.apache.org/scxml; xmlns=http://www.w3.org/2005/07/scxml;

datamodel
data name=DynamicData
Data_1 xmlns= id=1 type=Integer0/Data_1
Data_2 xmlns= id=2 type=Integer0/Data_2
Data_3 xmlns= id=3 type=Stringnone/Data_2
/data
data name=DDChange/
data name=DDValue/
data name=DDType/
data name=Indication_1 expr=false/
/datamodel
...snip...
Later on i set the data:
...snip.
state id=StateB
onentry
log label=Renegade expr='Entering state: StateB'/
log label=Renegade expr=Data(DynamicData,'Data_1')/
assign location=Data(DynamicData,'Data_1')
expr=Data(DynamicData,'Data_1')+1/
assign name=DDValue expr=Data(DynamicData,'Data_1')/
assign name=DDChange expr='Data_1'/
log label=Renegade expr=Data(DynamicData,'Data_1')/

/onentry
..snip

So now here´s the problem.

As you see I haven´t used the custom action, but an rather ugly hack where I
do an assign name after I do the assign location to trigger a call to the
set function in the context.

In this version I also do another assign where I assign another name with
the value. All my data are named Data_XX so i screen the calls to set byt
looking for the ones that are named Data_XX. When I recieve a call for
Data_XX I would like to know what the value is, which I in this case have
solved by assigning another variable with it earlier, when i get a set
call named Data_xx i know that the variable DDValue contains the value of
this data. Not pretty, but OK and working so far.
Now I would like to be able to see what type the data is aswell. How do I
do that? And: Is there a less spaghetti way to poll the value of the data
from where I am (In the context) when I have the name of it. (The name in
this case is Data_1, Data_2 or Data_3, I also know that the data=name is
DynamicData) .

Due to lack of time I would prefer if i wouldn´t have to redo to much of
the scxml, but is this possible to do it my way otherwise? Or do I have to
do it over.

Best Regards
//Linda


Re: [SCXML] getting set datats in the datamodel

2009-04-23 Thread Linda Erlenhov
Hello again!
This seems to work, since we now can see that data has changed.
Unfortunately, we seem to have missed out an important part of the
question. In addition to being notified when a data value is set, we
also would like to be able to get/recieve the new data value aswell as the
name (in this case numdat) so that we can display it to the screen in our
interface.
And, in this example we only have one data value, NumDat. However, it
is possible to define several data values insade the DynamicData-tag.
Can we still just write assign name=DynamicData
expr=DynamicData/ after the first assign tag, or do we also have to
define what data value has been changed?
Sincerely,

Linda


 snip/

 Yup, I see what you are running into. Unfortunately for the specific
 usage pattern here, the two assign variations have different
 semantics as follows:

 1)  assign name=... expr=.../
 is a set operation, which produces a Context#set(...) call

 2) assign location=... expr=.../
 is really a mutation operation, it retrieves the XML data tree
 (stored as a DOM node in memory) and manipulates it -- there is no
 call to Context#set(...)


  How do I notify when my DynamicData has changed?
 
 snap/

 ISTR that you prefer to not use custom actions. With those
 constraints, one option (since you are generating all the SCXML) is to
 accomodate for the above variation via the SCXML markup itself -- so
 you could generate a redundant identity assignment to trigger the
 Context#set(...) call like so:

 !-- assignment below taken from example above --
 assign location=Data(DynamicData,'NumDat')
 expr=Data(DynamicData,'NumDat')+1/
 !-- followed by assignment that triggers the set call with the new value
 --
 assign name=DynamicData expr=DynamicData/

 -Rahul



Re: [SCXML] getting set datats in the datamodel

2009-04-20 Thread Linda Erlenhov
Hello
I think I´ve done some mixing between two things that doesn´t work together
as I hoped it would.

I have this Datamodel, the scxml document starts like this:

scxml version=1.0 initialstate=INIT xmlns:cs=
http://commons.apache.org/scxml; xmlns=http://www.w3.org/2005/07/scxml;

datamodel
data name=DynamicData
NumDat xmlns= id=1 type=Integer0/NumDat
/data
data name=Indication1 expr=false/
/datamodel

snip/-

I assign the Indication1 later on:

---
state id=StateC
onentry
log label=Renegade expr='Entering state: StateC'/
assign name=Indication1 expr=true/
/onentry

snip/---

And the DynamicData also later:
---
state id=StateB
onentry
log label=Renegade expr='Entering state: StateB'/
log label=Renegade expr=Data(DynamicData,'NumDat')/
assign location=Data(DynamicData,'NumDat')
expr=Data(DynamicData,'NumDat')+1/
log label=Renegade expr=Data(DynamicData,'NumDat')/
/onentry

snip/---

I implemented a custom context with a notification functionality in the
set function (observer observed pattern) but the problem now is that the
only time the set function in the context is used is when indications are
set. Not when the DynamicData is set. I know that the SCXML works and that
the expressions evaluate properly because of the log:labels, my guess is
that it´s something with the Data() function that makes these expressions do
something different. What? Where is the set for the DynamicData located?
How do I notify when my DynamicData has changed?


Best regards
Linda


Re: [SCXML] Timers in SCXML

2009-04-15 Thread Linda Erlenhov
Hello again.
I run the standalone test and it looks like the timers work fine there (An
infinit loop between the two states, the logs, except for those that was
nested as you pointed out, are printed one or two seconds apart as specified
in the scxml ), so now I´m a bit clueless with how to proceed, any idéas? Is
there anything I might have forgotten in my java files since it doesn´t work
there?

best regards
//Linda

On Tue, Apr 14, 2009 at 9:11 PM, Rahul Akolkar rahul.akol...@gmail.comwrote:

 On Tue, Apr 14, 2009 at 8:19 AM, Linda Erlenhov
 linda.erlen...@gmail.com wrote:
  Hello!
 
  This may be a stupid question but:
  I have read through the code for the simple scheduler and I´m  not sure i
  understand what happens.
  We have written a simple scxml for a small statechart containing two
 states
  with timers and used the simple scheduler as described in your previous
  e-mail. As I understand the timers would make the machine just jump
 between
  the two states. This doesn´t happen. Why?
 snip/

 The Commons SCXML version and the relevant driver (Java) code will
 help towards answering -- we know this works, so we'll need to know
 whats being done differently. Bear in mind that the timers execute as
 daemons.

 I suggest trying your example standalone [1] first, and we'll go from
 there.

 As an aside, in the markup below, log is nested in send which
 isn't legal, so the nested log will be ignored.

 -Rahul

 [1] http://commons.apache.org/scxml/guide/testing-standalone.html



  ---
  scxml version=1.0 initialstate=167 xmlns:cs=
  http://commons.apache.org/scxml; xmlns=http://www.w3.org/2005/07/scxml
 
  state id = 167
  transition target=StateA/
  /state
  state id =StateA
  onentry
  log label=Renegade expr='Entering state: A'/
  send sendid=1 event='ToB' delay='1000ms'
  log label=Renegade expr='Timer starting...'/
  /send
  /onentry
  transition event=ToB target=StateB/
  /state
  state id=StateB
  onentry
  log label=Renegade expr='Entering state: B'/
  send sendid=2 event='ToA' delay='2000ms'
  log label=Renegade expr='Timer starting...'/
  /send
  /onentry
  transition event=ToA target=StateA/
  /state
  /scxml
  -
 
  The output when this is run is simply:
  2009-apr-14 13:08:57 org.apache.commons.scxml.model.Log execute
  INFO: Renegade: Entering state: A
  2009-apr-14 13:08:57 org.apache.commons.scxml.env.SimpleScheduler send
  INFO: send ( sendId: 1, target: null, targetType: scxml, event: ToB,
 params:
  null, hints: null, delay: 1000)
 
  best regards
  //Linda
 

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




Re: [SCXML] Timers in SCXML

2009-04-14 Thread Linda Erlenhov
Hello!

This may be a stupid question but:
I have read through the code for the simple scheduler and I´m  not sure i
understand what happens.
We have written a simple scxml for a small statechart containing two states
with timers and used the simple scheduler as described in your previous
e-mail. As I understand the timers would make the machine just jump between
the two states. This doesn´t happen. Why?
---
scxml version=1.0 initialstate=167 xmlns:cs=
http://commons.apache.org/scxml; xmlns=http://www.w3.org/2005/07/scxml;
state id = 167
transition target=StateA/
/state
state id =StateA
onentry
log label=Renegade expr='Entering state: A'/
send sendid=1 event='ToB' delay='1000ms'
log label=Renegade expr='Timer starting...'/
/send
/onentry
transition event=ToB target=StateB/
/state
state id=StateB
onentry
log label=Renegade expr='Entering state: B'/
send sendid=2 event='ToA' delay='2000ms'
log label=Renegade expr='Timer starting...'/
/send
/onentry
transition event=ToA target=StateA/
/state
/scxml
-

The output when this is run is simply:
2009-apr-14 13:08:57 org.apache.commons.scxml.model.Log execute
INFO: Renegade: Entering state: A
2009-apr-14 13:08:57 org.apache.commons.scxml.env.SimpleScheduler send
INFO: send ( sendId: 1, target: null, targetType: scxml, event: ToB, params:
null, hints: null, delay: 1000)

best regards
//Linda


Re: [SCXML] getting set datats in the datamodel

2009-04-06 Thread Linda Erlenhov
Hello Armel
Me and another girl named Anna has build the editor using GMF, Graphical
modeling framework for Eclipse (http://www.eclipse.org/modeling/gmf/) as a
part of our Master Thesis project.

best regards
//Linda


On Fri, Apr 3, 2009 at 11:59 AM, Armel SORO armel.soro.sc...@gmail.comwrote:

 Hi Linda,

 This is not really an answer to the problem but a simple question: which
 kind of graphical editor do you use to build state machines?
 Was it built from scratch or did you use any specific software to do this?

 I am indeed interesting in using one like that to model my system and
 generate the corresponding SCXML document.

 B.R.

 --
 Armel


 2009/3/31 Linda Erlenhov linda.erlen...@gmail.com

  Hello again!
 
  I have a problem with my datamodel. Or rather the fetching of datas that
  are
  used in the datamodel.
  I have my editor for building statemachines graphical, this is then
  translated into a corresponding SCXML document that then is run
  normally
  with Apache commons. The person that uses the editor shoul amongst other
  things be able select if she/he has want´s some data to be set (integers
 or
  strings) when entering states.
  The GUI that communicates with the machine does this via an interface
 wich
  is the thing I´m writing now. The GUI can send subscriptions requests for
  data wich basically means that it wants to subscribe certain data and
 wants
  the interface to send it when the data is changed.
  How I solved the part of saving checking the data is somewhat irrelevant,
  the problem is when I want to fetch the data that is saved. Since the
 model
  doesn´t tell when data has changed I check whenever entering a state
  (onEntry Listner) but where do I check this.
  Where is this, the data, saved?
 
  best regards
  //Linda
 



Re: [SCXML] getting set datats in the datamodel

2009-04-06 Thread Linda Erlenhov
Hello again!

I´m not sure how to explain what I want to do. 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):
data name=Data
Title id=1 type=Stringtext/Title
Track id=4 type=Integer0/Track
/data

and then somewhere in the scema the person who build the simulation wants
title to change, this is then translated to:

assign location=Data.title expr=oh yeah! /
as an example.

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.



 This still is all quite vague to me -- for example, not clear where
 you put the data in the first place.

 If you want to listen to data changes, listening to state changes may
 not be the way to proceed (so I wouldn't use SCXMLListener for this
 purpose). I can think of multiple potential options:

  * Avoid the need for any data synchronization / subscriptions
 altogether - Back the state machine's root context with the actual
 data store


Unfortunently this is not an option because the parts that use the
subscriptions are not written by me and already exists, I just want to
communicate with these parts.



  * Declaratively add transitions guarded on specific *.change events
 - Has the benefit of capturing the associated actions in the SCXML
 document itself (use the appropriate executable content on transition)


Not sure how this would work for the user of my editor.



  * 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

best regards
//Linda


[SCXML] getting a state id.

2009-03-11 Thread Linda Erlenhov
Hello
I´m back with sort of the same (but then again not) problem as I´ve asked
previousley. It´s about fetching ID:s again. I have an SCXML file that looks
on the form like this:

?xml version=1.0 encoding=ISO-8859-1?
scxml id=runsim
state id=176
initial
transition event=1 cond=!1 target=0
var name=1/
/transition
/initial
state id=0
transition event=2 cond=2 target=END/
transition event=3 cond=!1 target=2
var name=1/
/transition
/state
final id=END/
/state
/scxml

I would like to fetch the first states id, the one that wrapps everything
(in this version the id is 176).
How do I do that?

Best Regards
Linda


[SCXML] more Evaluator/Context questions

2009-03-05 Thread Linda Erlenhov
Hello!

This is my plan:
My guards are boolean expressions and the boolean variables that the
expression consists of are updated in onEntry/onExit. I use a listner
for _when_ the update should be done.

The trouble is that I´m not shure _where/how_ the updating is done. Since
this should be done during runtime a guess is that it is some kind of update
in the context, but I have clearly not understood properly how this
(context)  works.

So if I create a simple example then maybe someone could use it to explain
this to me:

The statemachine has three states. A, B and C. There are transitions between
A  B both ways, and also transitions between B  C both ways. You can
trigger events that are go to A, go to B go to C. You start in A. On
the transition from B to A there is a guard for been in C that is set when
you visit C. So you have to visit C atleast once before you enter state A
the second time.

A=B=C

How/where do I set the been in C state to true when i enter the state?


Best Regards

//Linda


[SCXML] Transition/Var question

2009-02-27 Thread Linda Erlenhov
Hello
I have in my Transitions added var on the form:

transition   cond=${cancelOutcome eq 'success'} target=editExit
  varname=outcome
  expr=cancel/
/transition

(This example is taken directly from the SCXML specification)

In my statemachine (a version similar, but not derived from the
AbstractStateMachine that is included) I have added an onTransition
function in my listner that when I am on a transition should check if there
is an var and in that case send it to .

I´m having trouble fetching the var. My thought is that that I should
derive a new class from the transition class that includes the method
getVar but I´ve looked through the API and I don´t understand how this
method should be written. Can anybody help me?

Best Regards
/Linda


Re: [SCXML] Transition/Var question

2009-02-27 Thread Linda Erlenhov
Hello again!


 snip

 followed by introspection like so:

getEngine().getRootContext().get(outcome);

 /snip

The problem with that approach is that i won´t know the names of my var:s.

The idéa is:
I´m building an graphical editor for Statecharts, where you can model a
statemachine with some simple drag and drop actions. When your satisfied
with your machine the editor generates an SCXML-file which then is meant to
be run. Everything I do has to be generic so what I wanted was a way to,
when the listner registers an onTransition ( the class Implements the
SCXMLListener interface) move:
1. Check if there is an var associated with that transition
2. If so, fetch the exp.

best regards
//Linda


Re: [SCXML] Executor Questions

2009-02-19 Thread Linda Erlenhov
Hello again.
Doesn´t anybody have a solution to my problem?
I don´t know if maybe theres something I need to clarify.

The engine sends messages that are java objects that I in the (?) part
translates to somethin on the form that the ApacheEngine wants.
What I don´t understand is what I should do with the context and
evauator in my model, can I work around it somehow?

best regards
//Linda



On Tue, Feb 17, 2009 at 1:52 PM, Linda Erlenhov linda.erlen...@gmail.comwrote:

 Hello
 I have just begun using the Apache SCXML  and I have encountered a problem.

 This is what already is:
 I have an editor for HMI. You build the interfaces using modules and then
 connects to actions and events in a databas and this is then run by another
 engine that sends events/actions (for some strange reasond they are named
 the wrong way in this program, i didn´t build it so...) to a CD player or
 whatever through a protocol via an interface.

 My job:
  is to build a simulator for the cd-player part. The tricky is that it
 should be generic, so that the client can build whatever kind of machine he
 or she wants to.

 I have created a graphical interface with GMF in eclipse where you can
 build statemachines with the help of modules representing states,
 transitions etc. This generates a XML representation of  the statemachine
 once it´s finished and then that is translated into SCXML. So far so good.

 so what we have here now is HMIeditor - DB - Engine - protocol -
 (??) - Apache engine-SCXML-XML - my editor for statecharts.

 All the functions (actions, events etc.) of the cd-player is described in
 a XML file wich both the HMI editor and my editor uses so I can put them on
 any form I want to and I have knowledge in what the HMIeditorengine does
 to the data.

 This is what I think is the problem (above shown as (??)):
 Between the apache engine and the protocol ther should be an interface
 (duh). My interface there should start up both engines and then (i think)
 listen to two buffers (i´m thinking two threads), my interface takes care of
 the translation from the protocol data look to the ApacheEngines data look.

 I just don´t undstand now how I should start up the Apache engine. I don't
 understand what i need the context and evaluator and so on for, the things
 that the apache engine recieves should be on the form it wants?

 Or have I just misunderstood?

 I hope someone understands something of what my problem is.

 best regards
 //Linda