Jump to content

Video - Objects and Classes


Recommended Posts

QUOTE (Tomi Maila @ Jul 7 2008, 03:50 AM)

:worship:

Great!

I need to watch the next nine episodes before noon today so I can stay productive.

Do plan on realizing UML in LV?

Which episode will cover instaciating active objects?

Ben

Link to comment

QUOTE (Tomi Maila @ Jul 7 2008, 09:50 AM)

Verry good video :worship: - Now I have just to wait till I can use classes on LabVIEW RT :oops: ...

Link to comment

QUOTE (Tomi Maila @ Jul 7 2008, 07:08 AM)

I'm afraid you will need to stay unproductive for a while ;)

Ok then I'll fight my way through the fog myself. I you hear a scream, you'll know which direction the abys lies.

Your discision of classes reminded me of a passage I recently read in Craig Larman's "Applying UML and Patterns, An introduction to Object-Oriented Analysis and Design and Iteractive Developement, Third Edition" where on page 236 and 237 he writes;

"

You can show class or static method calls by using a lifeline box label that indicates the receiving object is a class, or more precisely, an instance of a metaclass (see Figure 15.20).

What di I mean? For example, in Java and Smalltalk, all classes are conceptually or literally instances of class Class; in .NET classes are instances of class Type. The classes Class and Type are metaclasses, which means their instances are themselves classes. A specific class, as class Calendar, is itself an instance of class Class. Thus, calss Calendar is an instance of a metaclass! It may help to drink some beer before trying to understand this.

"

All typos are of-course mine. (BTW: I recomend Craig's book for getting into UML)

So ...

The class Rectangle you showed in your project is a metaclass and when you drop one on your picture, you are instaciating a class?

Ben

"

Link to comment

QUOTE (neB @ Jul 7 2008, 04:03 PM)

The class Rectangle you showed in your project is a metaclass and when you drop one on your picture, you are instaciating a class?

If I understand the concept correctly, LabVIEW only has one meta class - LabVIEW object. All other classes are instances of that class (and I'm not even sure if that's correct, since they could also just be described as child classes).

The rectangle is simply a child class of shape (or whatever the hierarchy is in this case) - when you drop one, you are creating an object, not a class.

Link to comment

QUOTE (Yair @ Jul 7 2008, 07:14 PM)

The rectangle is simply a child class of shape (or whatever the hierarchy is in this case) - when you drop one, you are creating an object, not a class.

Yes that's right, it's the reason LabVIEW names the front panel palette element 'LabVIEW object'

We are using the Endevo by-reference Goop implementation.

It has two kinds of data attributes:

Class attributes which are the same for all the objects of that class

Object attributes which are specific to a single object

The fun thing is you can set and get class attributes from a class constant without creating an object.

On the video:

Respect!

I've done two swf movies for the Code Capture Tool and it is hard.

What program have you used to capture your screen activities, I've used Jing but found it is not real-time.

Ton

Link to comment

QUOTE (Ton @ Jul 7 2008, 08:41 PM)

What program have you used to capture your screen activities, I've used Jing but found it is not real-time.

I've used CamStudio beta together with Lagarith lossless codec. The audio sync sucks and therefore I don't use CamStudio to capture audio. I edit the videos with Sony Vegas Pro 8.

Link to comment

QUOTE (Yair @ Jul 7 2008, 12:14 PM)

LabVIEW does not have any metaclasses. LabVIEW Object is a class. It is the ancestor class that all other classes inherit from.

When Tomi dropped the rectangle, he instantiated an object. An object is an instance of a class. There's no such thing as a "metaclass" in LabVIEW*.

* unless you're talking about the C++ code in the LabVIEW.exe which contains a class "LVClass" which is the C++ class that defines what it is to be a LabVIEW class and inherits from class Library which inherits from ... well, something else. I've put this as a footnote because I felt it was important to specify what a metaclass would be -- if G code had one -- but I didn't want to confuse anyone who just wanted a straight answer and would just glaze over footnotes.

QUOTE (Ton @ Jul 7 2008, 12:41 PM)

Yes that's right, it's the reason LabVIEW names the front panel palette element 'LabVIEW object'

No. We name the front panel element "LabVIEW Object" because that is an FP control for the class LabVIEW Object specifically. The data value of that control is an object. What kind of object? LabVIEW Object.

If we add other class FP controls to the palettes in the future, they'll be named for their class.

QUOTE (neB @ Jul 7 2008, 05:47 AM)

Do plan on realizing UML in
LV
?

Already done, and done incredibly well, by the folks over at Endevo. If you need UML, check out their UML tools. Very powerful, very clean user interface.

Link to comment

QUOTE (Aristos Queue @ Jul 7 2008, 06:41 PM)

Already done, and done incredibly well, by the folks over at Endevo. If you need UML, check out their UML tools. Very powerful, very clean user interface.

Right - all native LabVIEW and allows you to engineer and reverse engineer your classes.

Link to comment

QUOTE (Aristos Queue @ Jul 7 2008, 06:41 PM)

LabVIEW does not have any metaclasses. LabVIEW Object is a class. It is the ancestor class that all other classes inherit from.

When Tomi dropped the rectangle, he instantiated an object. An object is an instance of a class. There's no such thing as a "metaclass" in LabVIEW*.

* unless you're talking about the C++ code in the LabVIEW.exe which contains a class "LVClass" which is the C++ class that defines what it is to be a LabVIEW class and inherits from class Library which inherits from ... well, something else. I've put this as a footnote because I felt it was important to specify what a metaclass would be -- if G code had one -- but I didn't want to confuse anyone who just wanted a straight answer and would just glaze over footnotes.

No. We name the front panel element "LabVIEW Object" because that is an FP control for the class LabVIEW Object specifically. The data value of that control is an object. What kind of object? LabVIEW Object.

If we add other class FP controls to the palettes in the future, they'll be named for their class.

Already done, and done incredibly well, by the folks over at Endevo. If you need UML, check out their UML tools. Very powerful, very clean user interface.

Thank you Aristos!

Its nice being wrong in this neighborhood. Plenty of people willing to straighten you out. So the term metaclass really does not come into play in LabVIEW applications.

I got all excited about Tomi's video and typical for myslef did not explain myself well. When I was asking about UML what I was actually thinking about was what Craig Larman calls "Sequence Diagrams". I got to the point were he introduced the idea of an "active object" and I am curious about how an active object would be implemented in LabVIEW. From its description I have gone off and created code that spawns off (VI server run no-wait) a VI that is coded to watch an input queue for one of its methods being invoked. The non-active objects appear to quickly and easily manifest themselves from one of the templates. But they return their resluts imediately and there is "nothing hanging around" to do the follow-up work.

Say I wanted to mod Tomi's example such that it had a scrolling string field. I'd want that class to regularly update its image without being "tickled" by the GUI.

So that is what I really had in mind. How do I implement active objects in LV?

Sorry about the tangent all!

Ben

Link to comment
QUOTE (neB @ Jul 8 2008, 07:35 AM)
So that is what I really had in mind. How do I implement active objects in LV?
I'm not familiar with the term in this context. Can you post a link to an article describing this "active object" concept? I might be able to suggest a recommendation on how to implement.
Link to comment

QUOTE (Ton @ Jul 8 2008, 08:05 AM)

"One NI R&D developer"...
:rolleyes:

The XControl seems like a good solution, but it doesn't have any built in timing capability to update itself. Aristos' example gets around that.

Correct me if I'm wrong, but is the more general idea to essentially have a state machine behind the control?

Joe Z.

edit: grammar == bad

Link to comment

QUOTE (Aristos Queue @ Jul 8 2008, 10:06 AM)

The Wikipedia says

"

The Active Object design pattern decouples method execution from method invocation that reside in their own thread of control.[1] The goal is to introduce concurrency, by using asynchronous method invocation and a scheduler for handling requests.[2]

The pattern consists of six elements[3]:

  • a proxy, which provides an interface towards clients with publicly accessible methods
  • an interface which defines the method request on an active object
  • a list of pending requests from clients
  • a scheduler, which decides which request to execute next
  • the implementation of the active object method.
  • a callback or variable for the client to receive the result.

"

So the approach i am taking is;

The "proxy, which provides an interface" The class provides methods which use queues to post method requests to the back-ground VI (*.VIT).

The "interface which defines the method request " I think I have covered with a type-def'd queue containing an enum that specifies the requested method.

The "list of pending requests " is realized by using the queue.

The "a scheduler, " is implemented in code that checks for method invocations otherwise it handles the "update work" (eg scroll text)

The "the implementation of the active object method. " is realized with appropriate code to handle what is found in the que.

The "a callback or variable for the client to receive the result. " is realized in a response queue that is fed from the results of the code for each method.

The above scheme is just my first attempt at an active object and is my attempt to realize in LV something that matches the description of an "Active Object".

Again thanks all for your replies!

Ben

PS Ton, My boss is already taking a chance by letting me code this app in LVOOP. I'd only make him more nervous if I jumped right to the XControl to handle this part of the design. If I design this properly, I should be able to pass the project to one of my rookies to finish-up.

Link to comment

QUOTE (Aristos Queue @ Jul 8 2008, 04:06 PM)

Well I have to confess that I don't know what the official meaning of an "active object" is..... Google says http://en.wikipedia.org/wiki/Active_Object' rel='nofollow' target="_blank">this. (DOH! Ben got there first.....)

All the same I'd imagine (in LV context) it's an object which has a background process as Ben describes. It could perhaps also be tied in with Events so that it comes into play whenever certain criteria are met. Queues would be another logical interface choice.

I'm working on such a beast right now. I've recently "discovered" user events and am using them to implement an interface to a process spawned in parallel which then feeds back into the original program via Events. All asynchronous. Of course items defined by their interface are perhaps better called "components" than "objects" but maybe we should leave that discussion for another time....

Edit:

I also see nothing in the Wikipedia definition which dictates the use of OOP at all.

However, given the name, I'm sure it is meant to apply to OOP classes with a suitable interface and scheduler.

I still like the idea of getting values back via Event structure. Having VIs for getting the values back requires either polling or restrictions in the concurrency of the solution, no?

Either way, a nice method is required for making requests from the "active Object". Queues are the natural choice. Are there any other realistic possibilities? User Events could also be used here.... Any performance difference to be expected between queues and user events? Advantages disadvantages?

Shane.

Link to comment

QUOTE (shoneill @ Jul 8 2008, 11:10 AM)

...

It could perhaps also be tied in with Events so that it comes into play whenever certain criteria are met. Queues would be another logical interface choice.

I'm working on such a beast right now. I've recently "discovered" user events and am using them to implement an interface to a process spawned in parallel which then feeds back into the original program via Events. All asynchronous. ...

Shane.

Thanks for that suggestion Shane. I am condicuting some architectural research for an app I have yet to officially design. I will keep that in mind as the design develops.

Another idea that I concidered using for active objects that would have their methods invoked from multiple places it to re-use an idea that was inspired by one of Jim Kring's design patterns (Response with notificaton ?). The idea is to inclue a ref to a "response queue" in the request (method invocation) so that the active object can respond entity that invoked it.

Learning as I go...

Ben

Link to comment

QUOTE (Ton @ Jul 8 2008, 11:59 AM)

I wouldn't use a VIT but the following code construct (simple example):

http://lavag.org/old_files/monthly_07_2008/post-2399-1215532702.png' target="_blank">post-2399-1215532702.png?width=400

This also bypasses the 'I don't know which dynamic VIs I need to build' problem.

We recently did this with a class, and it works great!

Ton

:thumbup:

Ohh yes!

Ben

Link to comment

Ben,

You may want to take a look at OpenG Active Object Template(.opg) that is part of class templates I wrote for LVOOP. See OpenG Wiki for more details. Active Object Template is a template for by-reference objects that include a single VI that starts executing when an object instance is created and stops executing when the object instance is closed. The template is meant to be used with Endevo GOOP tool but you can simply create a copy of the class from within LabVIEW as well to use it in your project. Use VIPM to install the template to <LabVIEW>resource\OpenG\openg_object\class_templates. The template requires OpenG Object package to be installed as well.

post-4014-1215584092.png?width=400

Link to comment

QUOTE (Tomi Maila @ Jul 9 2008, 02:15 AM)

Re:Creating these active objects

Going back to my practice app.

I will support multiple picture controls so I set-up a class "Pictures" (note plural) that offers a method "register picture" and uses the picture ref to create an active object Picture". The Picture class object register for events against the picture. The class Pictures maintains a list of registered Picture objects and other methods that are targeted at the class Picture objects. So is good or bad practice to group classes that will have multiple instances into a parent class to allow acces to the children?

This approach effectively gave me by-references access to the unique instances of the Picture objects.

Ben

Link to comment

Excellent video Tomi! And let me be the first to say thank you for not using youtube. The increased resolution of vimeo is nice. Did you set up a green screen to insert the expression flow background? Very cool!

I have also enjoyed all the side discussion. I am consistently amazed at how much I learn by following these threads. :worship:

-Toby

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.