On Mon, Apr 6, 2009 at 10:35 AM, Linda Erlenhov <linda.erlen...@gmail.com> wrote: > Hello again! > > I´m not sure how to explain what I want to do. <snip/>
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): > <data name=Data> > <Title id=1 type=String>text</Title> > <Track id=4 type=Integer>0</Track> > </data> > <snap/> 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: > > <assign location="Data.title" expr="oh yeah!" /> > as an example. > <snip/> For an XML data model, its best to use the XPath Evaluator (though its yet unreleased), where the above would look like: <assign location="$Data/title" expr="oh yeah!" /> 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: <assign location="$Data/title" expr="oh yeah!" /> you could generate: <my:assign location="$Data/title" expr="oh yeah!" /> where custom action <my:assign> inherits from standard action <assign> 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. > <snap/> 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" > <snip/> 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