05-17-2011 05:56 AM
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
05-17-2011 07:10 AM - edited 05-17-2011 07:14 AM
Like this. This actually creates copies as opposed to referencing the same object.
[edit] Programmatically... Perhaps this isnt what you needed.
05-17-2011 07:13 AM
Thank You Wayne
Can i create the same dynamically?
Regards
Suneel
05-17-2011 07:17 AM
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.
05-17-2011 03:20 PM
Did that help Suneel?
05-17-2011 10:27 PM
05-18-2011 07:56 AM
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.
05-18-2011 08:30 AM
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?
05-18-2011 08:40 AM
@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
05-18-2011 09:05 AM
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.