MetaCase Homepage
Forum Home Forum Home > > MetaEdit+
  New Posts New Posts RSS Feed - Extending transition in "watch application" sample
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Extending transition in "watch application" sample

 Post Reply Post Reply Page  <12
Author
Message
janne View Drop Down
MetaCase
MetaCase
Avatar

Joined: 25.Mar.2008
Points: 58
Post Options Post Options   Thanks (0) Thanks(0)   Quote janne Quote  Post ReplyReply Direct Link To This Post Posted: 21.Mar.2012 at 15:59
Hi,

i) Java generators start from the 'WatchFamily' (Graph type). Just select the 'WatchFamily' for the Graph type and then open and follow the structure under the '!Build' generator



Back to Top
stevek View Drop Down
MetaCase
MetaCase
Avatar

Joined: 11.Mar.2008
Points: 643
Post Options Post Options   Thanks (0) Thanks(0)   Quote stevek Quote  Post ReplyReply Direct Link To This Post Posted: 21.Mar.2012 at 16:39
ii) No, that's not what I meant. Or indeed what I said Smile. Maybe you want to slow down a bit, and if things don't seem to show what you expected, make sure you've read the earlier answers correctly. I don't mind answering again, I just don't want you to have to waste your time waiting for us to answer.
 
The binding you have added is a new kind of transition from a State to a State, but that's not what you want. Instead, you want to be able to draw a line from an Action to a Beep, in a similar way to the current Icon binding. At least I suggest you do it this way first, as the watch language supports easy addition of new kinds of actions - once you can do that successfully, you can think about the alternatives, like parameterizing transitions with a property.
Back to Top
miomy View Drop Down
Contributor
Contributor
Avatar

Joined: 22.Feb.2012
Points: 11
Post Options Post Options   Thanks (0) Thanks(0)   Quote miomy Quote  Post ReplyReply Direct Link To This Post Posted: 22.Mar.2012 at 18:04
Sorry, my second question is a bit confusing. I mean the beep() function needs the file "windows.h" to be included to function correctly. Where should I add that "#include" line?
Back to Top
miomy View Drop Down
Contributor
Contributor
Avatar

Joined: 22.Feb.2012
Points: 11
Post Options Post Options   Thanks (0) Thanks(0)   Quote miomy Quote  Post ReplyReply Direct Link To This Post Posted: 22.Mar.2012 at 18:08
Thank you! Finally, I find it.
Back to Top
miomy View Drop Down
Contributor
Contributor
Avatar

Joined: 22.Feb.2012
Points: 11
Post Options Post Options   Thanks (0) Thanks(0)   Quote miomy Quote  Post ReplyReply Direct Link To This Post Posted: 22.Mar.2012 at 18:17
Hi, Steve

Really sorry for wasting your time due to my awful question description. What I want to do at the beginning is to add a new transition between two states. Like

It just connects two states, with an event involved (like button pressing). I just want the system beep during the specific kind of transition. That is all. What I want to avoid is having to linking a Beep Action object every time I use this transition in the graph. That is why I said before I try to encapsulate the beep action into the transition. Do I make my question clear this time? Please feel free to point out any confusing description.
Back to Top
stevek View Drop Down
MetaCase
MetaCase
Avatar

Joined: 11.Mar.2008
Points: 643
Post Options Post Options   Thanks (0) Thanks(0)   Quote stevek Quote  Post ReplyReply Direct Link To This Post Posted: 22.Mar.2012 at 18:29
That's fine if you want to do it that way - I've said above why I would do it a different way, but let's do it like you say.
You just need to create BeepingTransition as a subtype of Transition, and add it to the Relationships list on the Contents tabe of the Graph Tool for WatchApplication. That says it is a possible kind of relationship in graphs of this type, and adds it to the toolbar.
You don't need to create a new binding for it, because WatchApplication already includes a binding for Transition, and BeepingTransition is legal in that binding by inheritance.
 
In the generators you'll need to check any places that refer to Transition, and make them allow BeepingTransition too. E.g. if the generator has
 
foreach >Transition
 
You can replace that with
 
foreach >(Transition | BeepingTransition)
 
or indeed with a wildcard match
 
foreach >(*Transition)
 
That will make your BeepingTransitions work as Transitions, but you also need to extend the generators and framework so that they remember to beep for each BeepingTransition. You'd need to change the _TransitionData generator to add a new bool beep parameter, and update the framework to use it: add the beep bool to AbstractWatchApplication's addTransition(), add the beep bool to the Result class, and change AbstractWatchApplication's handleEvent() to beep as well as perform the Actions:
if (result.action != 0) perform(result.action);
if (result.beep) beep();
 
Of course that's all for Java, but you mention windows.h, which sounds like Windows C/C++ programming. That of course is possible too, but you'd have to build the framework and generators from scratch.
Back to Top
miomy View Drop Down
Contributor
Contributor
Avatar

Joined: 22.Feb.2012
Points: 11
Post Options Post Options   Thanks (0) Thanks(0)   Quote miomy Quote  Post ReplyReply Direct Link To This Post Posted: 26.Mar.2012 at 13:41
Hi, Steve

I am working on the C# generators. Sorry, I get lost again. I understand _Cs_LogicalWatches generator is for generating the subclasses of AbstractWatchApplication (like stopwatch). But I can't find the generator for generating the super class. I've added the bool parameter to the _TransitionData generator.

But that only update the invocation of addTransition method, not the declaration.

Another question is: where is the generator for Result class? I didn't find it down through _*Model generator tree.
Back to Top
stevek View Drop Down
MetaCase
MetaCase
Avatar

Joined: 11.Mar.2008
Points: 643
Post Options Post Options   Thanks (0) Thanks(0)   Quote stevek Quote  Post ReplyReply Direct Link To This Post Posted: 26.Mar.2012 at 19:16
AbstractWatchApplication and Result are both part of the domain framework: they are written once, and don't depend on what's in the model. Normally such unchanging files wouldn't be in the modeling tool, but separately as in-house components, and would be linked in with the generated files. In the case of the Digital Watch example, MetaCase needed to supply the files to you, and the best (?) way was to 'hide' them in the model.
 
You can find the domain framework classes from the "Language Frameworks" properties of the 2012Models: WatchFamily model. There are two frameworks, C# and Java, and within each are all its domain framework classes -"Framework Components". Some of the classes are there multiple times, e.g. for different versions for WPF vs. WP7. Adding beeping transitions probably affects all the different versions.
 
In a Framework Component's Source Code text property, you can choose Editor from the pop-up menu to open the source in a larger window.
Back to Top
miomy View Drop Down
Contributor
Contributor
Avatar

Joined: 22.Feb.2012
Points: 11
Post Options Post Options   Thanks (0) Thanks(0)   Quote miomy Quote  Post ReplyReply Direct Link To This Post Posted: 27.Mar.2012 at 16:11
Hi Steve

How can I access the "Language Frameworks" properties? I am using the latest 50beta33 version. And I did not find any directory named "Language Frameworks" or "Framework Components" from the root level. There are only 2 folders from the root "demo50d21" (there is a folder "areas/Digital Watch" here, but I don't think it has any code template within it) and "reports" (like cg output folder).

Is there any menu or operation in the MetaEdit+ can lead me to open these "Framework Components"?
Back to Top
stevek View Drop Down
MetaCase
MetaCase
Avatar

Joined: 11.Mar.2008
Points: 643
Post Options Post Options   Thanks (0) Thanks(0)   Quote stevek Quote  Post ReplyReply Direct Link To This Post Posted: 27.Mar.2012 at 17:42
When you log in, the top graph is 2012Models; open its Properties from its pop-up menu.
Back to Top
 Post Reply Post Reply Page  <12

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.05
Copyright ©2001-2022 Web Wiz Ltd.

This page was generated in 0.044 seconds.