LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

LVOOP and incremental data changes via Inheritance - I think I'm way off base here

I may be going way down the wrong track with this idea but I have an idea I would like to implement in LabVIEW using LVOOP and I currently don't see how this can or should be done or what a better alternative might be.

 

I have a hierarchy of "modules" which can each launch asynchronous processes for itself.  Each process has a set of user events it listens to in order to keep their values up to data across multiple instances of the same asynchronous processes.  My headaches occur when I try to build up a hierarchy of user events for the processes.

 

Let's say the base class simply has a boolean event "Stop".  The child adds "Numeric" to the list.  The grandchild adds a further "Path" event to the list.  In order to be able to use the events, I need to get the strictly typed event registration refnum from the objects.  I am running into the problem that this approach is apparently requiring every child to know about the data of its parent which I see as a bad thing. i.e. build a cluster from "This.User Events" and "Parent.User Events" and "Grandparent.User Events" and so on.  Due to the changes in data type, these cannot be DD Vis for retrieving the data, they need to be independent static VIs at each level of the hierarchy.  Hardwiring the events list seems fragile and contrary to proper OOP design.

 

I'm aware that the actor framework implements a different approach by sending object messages instead of user events but hey, I like user events.  I'm not lookign to implement this using Actor framework, so that's not a solution for me.

 

I could alternatively encapsulate the event refnums into carrier objects (and thus have a single "Get Event" DD call for all objects returning a data object with its own hierarchy) but I still have the problem of being able to pass some strictly typed information to the event structure at some point and as such the original problem remains.

 

I probably have a major hole in my thinking but I don't see any way to do this with LV at the moment.  What I am looking for seems to be the ability to define VIs which can be used with the "Call parent implementation" method (or something similar) but which return different strictly typed datasets.  The relationship between any child and its parent is known at compile time so I don't see why this should be fundamentally impossible to implement. 

 

Spoiler

 

An added bonus would be ato allow the output data type to adapt to the wire coming out of the VI, thus presenting the programmer with a strictly-typed, autoupdating output which incorporates all elements from itself down to it's base class but this is just wishful thinking.

 

 

So:

Parent - Get Events returns a registered event refnum for Boolean.  The method "Call parent method" does nothing. Output is a registered refnum for a boolean.

Child - Get Events returns a registered event refnum for a Numeric.  The method "Call parent method" returns a registered refnum for a boolean.  Output is a cluster of a registered refnum for boolean and a Numeric.

Grandchild - Get Events returns a regsitered event refnum for a Path.  The method "Call parent method" returns a cluster of a registered event refnum for blloean and a registered refnum for Numeric.  VI output is a cluster of a regiustered refnum for a Blloean, a Numeric and a Path.

 

Any ideas? Am I finally certified as mad?

0 Kudos
Message 1 of 3
(2,221 Views)

Being true to my avatar, I had an idea.

 

I suppose creating a Property node for each level of the hierarchy exposing the registered event refnums for that level with each property node having the name "Events: Classname" might work.  Then at least the full list of events is available in any given hierarchy and can be bundled as required, right?

 

Nope, doesn't work.  Each level of inheritance creates its own "Events" menu, each with a single entry.  Not pretty.  Possible, do-able but kind of ugly.

0 Kudos
Message 2 of 3
(2,211 Views)

That is a cool application!

 

About that data type: In the reference the datatype of the object is implemented. For that reason it is not possible to do this.

 

I might have a workaround. Just use the variant data type for your events. You can cast any data to that, and in your dynamic dispatched vis you can cast it back. Furthermore you can always use either the reference of the parentclass, or create a new one.

 

Might that work for you? See attached zip.

 

 

0 Kudos
Message 3 of 3
(2,119 Views)