LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

LVOOP Question

I have been playing around with LVOOP using the "Object-Oriented First Steps" class material.

I have successfully converted several AE into classes with some success. 

 

For example:

 

I have three (3) circular buffers (AE) with three different cluster typedefs.

-1D dbl

-2D dbl

-2D wfrm

 

and I decided to integrate that into classes.

 

I attach a series of pictures to hopefully follow the process.

 

this approach seems to be ok for scenarios where you would only have one active implementation (in my case a given circular buffer) iam not sure how would I do it for several buffers at run time.

 

Pic_One.pngPic_Two.pngPic_three.pngPic_four.pngPic_five.png

here is an implementation.

 

I would like to know if there is a better way of implementaing this (for example the variant that i was forced to add) to account for the different data types of my buffers.

also how can i load more than one buffer (current one limits me to only one)

any other pointer regarding LVOOP that may be worth mentioning.

 

any help in this will be greatly appreaciated.

 

 

 

 

 

 

 

 

0 Kudos
Message 1 of 6
(3,094 Views)

Hi,

 

To answer your 2 questions:

- Why did you implement a singleton in the first place? This "First Call" function (and the shift register) is the one that prevents you from instantiating a brand new buffer. Just forget it. It looks like you're doing operations in-place inside the classes so even if you're forking a buffer object, it will point out the same data for that object.

- About the variant, well I suppose the idea is to plot the buffer at some point. Because our UI components are strongly typed, I can not really think of a way to plot different data types. This being said, you don't really need a variant here if you actually set the correct data type (like 1D, or WF...) in the private data of the corresponding classes. Then the dynamic dispatch will take care of playing with the correct data type.

 

Hope this makes sense!

Good luck with OOP learning 🙂

Eric M. - Senior Software Engineer
Certified LabVIEW Architect - Certified LabVIEW Embedded Systems Developer - Certified LabWindows™/CVI Developer
Neosoft Technologies inc.

0 Kudos
Message 2 of 6
(3,065 Views)

Eric,

 

Thanks for answering me.

 

I have various modules that I believe can be leverage using OOP, but I have been struggling in the process.

 

I will show you one such.

 

I have a function (lets call it Lister) that has 5 methods and that manages a list of items that are populated on a Multicolumn Listbox for example.

 Pic-1.PNG

 

Every time I need to use this function (and my “lister entry definition” is different, I have to re create this function again.

 

I haven’t figure out an efficient way to deal with different (cluster type) as well as number of listers to use in run time.

For example I tried to setup my lister class in two different way shown in the following picture.

 

First picture is the same way I have been doing it since I started to play with OOP

In your library create the class ancestor and define the methods

Then in the same library I create the child class (lister) and defined the same methods

(but iam not sure if the methods are always going to be the same Iam not sure this variant is the best because I wouldn’t have to override it with my child)

Also I wouldn’t want to add the childs to the same library, because it would get too big with time, and what I had in mind was to create the child somewhere else and in the main project set the inheritance of that child to the ancestor and that is it. (does this make sense?

 Pic-3.PNG

 

Capture.PNG

 

 

Is there an adventage of making every method a class and inheret from global lister?

Again if this is the way to go hoe exactly would I need to go about it?

This variant I copied from “LV2OO Syle Functional Globals” which I downloaded from the forums and I partially understand.

 

So one more time, one or more listbox with different columns, load this dynamically, and code this new lister the most efficient way is what I haven’t achieved so far.

0 Kudos
Message 3 of 6
(3,018 Views)

El_Tipo wrote:

So one more time, one or more listbox with different columns, load this dynamically, and code this new lister the most efficient way is what I haven’t achieved so far.


Personally, in this situation, if I were to use OOP, I would code the parent class to operate on the most generic data type available. I'd use a 2-D array of strings, and I would implement the parent class methods to act on that 2-D array. Then I'd create helper functions, that would be basically no-ops in the parents, that the child would override to convert the specific cluster into a 2D array of strings, and from an array of strings back to the cluster.

 

The LV2OO example you copied uses a separate class for every action, with every action class inheriting from a common ancestor and every action class implementing at least a Do method. This creates a sort-of plugin architecture; it's flexible, but creating a new action requires an entire class rather than a single method. There are uses for this but I wouldn't copy it until you fully understand it.

0 Kudos
Message 4 of 6
(2,996 Views)

Nathan,

 

why implement it into a 2D array of strings?

the "lister" will always have a cluster as data definition.

 

the methods pretty much manipulate an array of these cluster(s).

 

for simplicity lets say the method will never change

4.png

 

if I dont want to create a new action beside the ones mentioned is the second library I showed is the way to go?

 

1.png

 

 

3.png

 

 

I get frustrated because for brief period of time i think i got it figured out, then i think again and i see a problem.

 

if every method i make it a class then would i have an array of classes as my array of clusters in my scenario?

 

again thanks for the help so far.

 

0 Kudos
Message 5 of 6
(2,985 Views)

My understanding is that you want each child class to represent a different cluster; is that not the case? Are you instead asking about having each element of the array be its own class? And, in order to display the list in a multi-column listbox, don't you need to convert to a 2D array of strings?

 

I don't understand what you mean by initializing your lister. Can you supply some actual, or at least simulated, data?

0 Kudos
Message 6 of 6
(2,973 Views)