LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Create Different Instances of a Class

Hi All

Is it possible to create different instances of the same class programmatically

Suppose if i want to have a graphical displays, Can i create a Graph Class and create multiple instances it?

Regards
Suneel 

0 Kudos
Message 1 of 14
(4,188 Views)

class.JPG

Like this. This actually creates copies as opposed to referencing the same object.

 

[edit] Programmatically... Perhaps this isnt what you needed.

0 Kudos
Message 2 of 14
(4,181 Views)

Thank You Wayne

 

Can i create the same dynamically?

 

Regards

Suneel

0 Kudos
Message 3 of 14
(4,179 Views)

Put the class inside of a subvi, with its output connected to the connector pane. Each time you want a new instance, execute the subvi.

0 Kudos
Message 4 of 14
(4,177 Views)

Did that help Suneel?

0 Kudos
Message 5 of 14
(4,159 Views)
Actually  I have a Graph Class that is having a Graphical display vi as a method. I wanted to launch an instance of the Graphical Display on the click of a button. So if the user clicks on the button 4 times, 4 Graphical displays will be launched.
Can i do this using LVOOP?
Regards
Suneel
0 Kudos
Message 6 of 14
(4,147 Views)

Yes, but the usual methods for LabVIEW are still in place.  To do this successfully, you will need to create a launcher method for your display.  The display itself will need to be a VIT (just rename the suffix to .vit) and dynamically loaded to create a new instance, which is why you need the launcher.

 

I assume you will be communicating with the display.  Unnamed queues are usually the best option, so you don't have to worry about creating unique queue names for each instance.

 

If you run into issues, let us know.

 

If you have never dynamically loaded and run VIs, this series may interest you.  The link is to the last item in the series, which has links to the previous items.

0 Kudos
Message 7 of 14
(4,137 Views)

Thank You DFGray

 

Actually i have tried similar to same you have suggested and it was working.

 

I just wanted to know if it can be done without VITs.

 

Is method in a class is dedicated to an instance of the Object created? 

0 Kudos
Message 8 of 14
(4,131 Views)

@Suneel wrote:

Thank You DFGray

 

Actually i have tried similar to same you have suggested and it was working.

 

I just wanted to know if it can be done without VITs.

 

Is method in a class is dedicated to an instance of the Object created? 


If I understand you correctly yes a method will act on the Class instance in the wire it is passed. Provided the class instances are unique.

 

This series of images shows one of the methods I have used.

 

 

 

 

 

Larger version of those images can be found here in my image gallery.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 9 of 14
(4,124 Views)

Actually, you can do it without VITs.  Make your method reentrant.  This will ensure a different instance every time it is called.  I have used this in the past when dynamically launching functional globals for data storage.  I believe it will work with GUIs as well, but have never tried.

0 Kudos
Message 10 of 14
(4,119 Views)