Jump to content

Using Class in parallel Loops


Recommended Posts

Hello LAVAs!

I began with OOP and want to use one Class in two parallel while loops.

I have created a class with a Enum Member and Read and Write this member VIs (Set& Get Methods).

So the upper loop should Increment this Enum on Buttonclick. I Read this Enum using Read, increment and Write the enum.

The bottom loop should Read the enum and Swith the Switch-Case structure. But nothing happens.

Can You explain me please why it doesn't work?

Thank You, Regards, Eugen

Link to comment

QUOTE (Eugen Graf @ Apr 15 2008, 05:28 PM)

Do NI want in the next time implement this feature or it will always stay by "pass by value"?

This is probably the single biggest issue users have with LVOOP (at least users who are used to GOOP). The document Chris linked to goes into this in some detail, with the bottom line that in the future, by-ref support might be implemented, but I wouldn't hold my breath. If you want by-ref, you can use the options mentioned by the others.

QUOTE

If not, I don't see any advantages in use LVOOP.

That's because you're looking at it from the wrong frame of reference. You're used to GOOP, which works by reference and is very convenient and powerful. LVOOP can probably do that, with the appropriate wrappers, but it was also designed to do other stuff where you don't care about using a single instance of an object in different parts of your code. There are all kinds of examples you can find online to see where LVOOP gives you more power. Searching through this board should provide you with some.

The key is in understanding that the use cases for LVOOP are not necessarily the same as the ones for GOOP.

Link to comment

QUOTE (Yen @ Apr 15 2008, 05:45 PM)

That's because you're looking at it from the wrong frame of reference.

Shucks, you beat me to it!

I was just going to say the same thing. I'm currently coding in C#, By-Reference Class usage and all. I can see the appealy of both sides.....

Shane.

Link to comment

Maybe you should try the referenced based version, which you can get from the GOOP Development Suite (GDS).

Currently there are 2 referenced based versions of GOOP the GDS supports, but soon there will be another GOOP-flavor.

BTW, Version 2.5 was just released (as yesterday).

Cheers,

Mikael

Link to comment

So, ok. I will use a task (loop) for each class and communicate over queues, notifiers or user events.

Can anybody explain me please when I should use dynamic member VIs and when to use static member VIs?

And the next question is how can I define class members so, if I add new members or remove some members, all member VIs will update the class cluster? Should I define the class cluster as typedef for it?

Thank You.

Link to comment

QUOTE (Eugen Graf @ Apr 21 2008, 09:13 AM)

And the next question is how can I define class members so, if I add new members or remove some members, all member VIs will update the class cluster? Should I define the class cluster as typedef for it?
You can't have the class cluster be a typedef directly (for a long list of hotly debated reasons during the design phase of LVClasses that I'm not going into now). But you can put a cluster inside the main cluster and typedef that. Doing so would also save you from ever having to update the Bundle/Unbundle nodes, since you'd just unbundle the cluster as a whole and bundle the cluster as a whole, not each individual element.

I'll let someone else field the static/dynamic dispatch question.

Link to comment

QUOTE (Eugen Graf @ Apr 21 2008, 04:13 PM)

Can anybody explain me please when I should use dynamic member VIs and when to use static member VIs?

You use VIs with dynamic dispatch inputs to override the implementations of parent classes.

For example, if you have the class "animal" and a child class "dog" and a grandchild class "poodle" and you create a "speak" method for each class, then wiring a poodle object into the DD input will return "woof" and wiring a cat object will return "meow". You should follow the link Chris provided earlier for more details. Also, Tomi's blog had a tutorial about inheritance in LVOOP.

QUOTE

And the next question is how can I define class members so, if I add new members or remove some members, all member VIs will update the class cluster? Should I define the class cluster as typedef for it?

The class data already acts as a private typedef for all member VIs in the class. That's the encapsulation mechanism.

Link to comment

Ok, thank you for answers!

1) Where can I see if a member VI is dynamically or statically defined (e.g. if I get a OOP project from other people)?

2) Can I change a static member VI to dynamical and back after definition? Should I always take better dynamical?

3) Can I use one dynamical member VI on more than one loop in my programm parallely (for copies of the same class) or it's the same as staticaly use in this issue? Reentrant VI is other thing as statical or dynamical member VI?

QUOTE

Doing so would also save you from ever having to update the Bundle/Unbundle nodes, since you'd just unbundle the cluster as a whole and bundle the cluster as a whole, not each individual element.

Is there a possibility to update Bundle/Unbundle Node by rightklicking or sth. like this?

QUOTE

The class data already acts as a private typedef for all member VIs in the class. That's the encapsulation mechanism.

Yes, right, but I think e.g. if I change a name of an member, my Bundle/Unbundle will not be automatically updated like if I use Strickt Type Definitions.

Link to comment

You should note that dynamic dispatch has nothing at all to do with dynamically loaded VIs. It refers to VIs which override the implementation of the parent class. The VIs themselves are loaded with the rest of the class.

The answer to your other question is that the class data type acts like a typedef, so you shouldn't have any problem.

LVOOP is a big thing. You should really take the time to read the relevant material, because you can't expect to learn it based on what you already know.

Link to comment

QUOTE (Eugen Graf @ Apr 22 2008, 03:09 AM)

1) Where can I see if a member VI is dynamically or statically defined (e.g. if I get a OOP project from other people)?
90% of the time you shouldn't care. But if you need to care, look at the terminal conpane of the VI. If the class input has a dotted line around it, that's a dynamic dispatch VI. QUOTE

2) Can I change a static member VI to dynamical and back after definition?

Sure. Popup on the conpane terminal, select "This terminal is..." and choose the one you want. QUOTE

Should I always take better dynamical?

No. You should choose the one that matches your functionality. There are trade-offs to both options.

QUOTE

3) Can I use one dynamical member VI on more than one loop in my programm parallely (for copies of the same class) or it's the same as staticaly use in this issue? Reentrant VI is other thing as statical or dynamical member VI?

Reentrancy is supported for dynamic dispatch VIs in LV8.5, but not LV8.2.

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
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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.