Jump to content

LabVOOP architecture question


Recommended Posts

Hi folks,

I have used LabVOOP before, mainly to implement instrument drivers with base and child classes.

Now I am looking into creating my first LabVOOP architecture and I have a few questions about some implementation details regarding the by Value functionality of LabVOOP.

Say I have an object called Farm that contains an object called ListOfPigs, which handles an array of Pig objects. Now the Pig class has a method called RecordPiglets(BornAlive, StillBorn, Mummified).

In C# I would call that function like this: Farm.Pig[tag].RecordPiglets(7,0,0)

I have no problem getting to the Farm.Pig[tag] point in LabVOOP, i.e. extracting the Pig object in question. But if I now run the RecordPiglets method on that object I will have to update the Pig object in the ListOfPigs object, and then update that object in the Farm object.

I could do that by creating an UpdateObject for every GetObject method in every class. However, that seems a bit unwieldy. Is there an easier way?

Thanks for your help,

Heiko

Link to comment

I have no problem getting to the Farm.Pig[tag] point in LabVOOP, i.e. extracting the Pig object in question. But if I now run the RecordPiglets method on that object I will have to update the Pig object in the ListOfPigs object, and then update that object in the Farm object.

I could do that by creating an UpdateObject for every GetObject method in every class. However, that seems a bit unwieldy. Is there an easier way?

Thanks for your help,

Heiko

Indeed, to preserve dataflow, this is exactly what you have to do.

post-10515-125492401645_thumb.png

If you have many classes, let's say "pigs", "cows" and "goats", then you should add a layer "animal" from which they all inherit. Your Farm class would contain a list of Animals and you can have only one "Write/Read infants" for the Animal class, provided that all animals have the same "bornalive/stillborn/mummified" properties for the infant counts. If you need to override with a different Read/Write for a particular animal, then you can. But it should let you have only one UpdateObject for the whole animals hierarchy.

  • Like 1
Link to comment

I could do that by creating an UpdateObject for every GetObject method in every class. However, that seems a bit unwieldy. Is there an easier way?

I don't think there's an elegant way to do this with by-val objects given your class hierarchy. By-ref objects would do it--they may not be the best solution for your particular situation though.

Link to comment
I would of cause not even consider by value unless I really needed the highest speed.
I on the other hand would not even consider a reference solution unless all else failed.

My solution: Give your ListOfPigs class a method called UpdateOnePig, which takes an index of a pig and instructions on what to do to that pig. The instructions can come in the form of parameters that you pass into the ListOfPigs' VI or a VI Reference that you call. The block diagram of the UpdateOnePig has an InplaceElementStructure that has an Index and Replace array node on it.

post-5877-12550095507_thumb.png

Link to comment

I on the other hand would not even consider a reference solution unless all else failed.

I agree that by value should be used where ever it’s applicable.

By most of my classes are instrument drivers and there I can’t live without references.

Some other classes are Singletons and others uses shared aggregation, and therefore it makes my life easier to use one type for all of them, because if I forget that a particular class is by value I get really strange errors ;-)

This is an example of the different looks and feels when using composite aggregation.

post-941-125503884051_thumb.png

post-941-125503883373_thumb.png

ByRefByValue.zip

Cheers,

Mikael

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.