LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

get all VIs in memory across multiple LabVIEW application instances

Solved!
Go to solution

I'm trying to get references to all VIs in memory across multiple LabVIEW application instances. Specifically, I'm trying to get VI Refs to VIs (and their subVIs in memory) in another Project Explorer at design-time. (The other VIs are not running.) For example, if you are only interested in VIs in the current App instance (read Project Explorer), you could use the following code:

 

Open Ref to All VIs in Memory.png

 

However, if you have multiple projects open, how can you get the VI references to the VIs in the other project? It seems to me that it would be a different App Ref, but I guess I'm not sure how to get that reference. I am assuming that if I could get that reference, I could use it in the same way as above to get the App.AllVIs list.

 

Any help/clues would be appreciated. Thanks.

_______________________________________________________________
"Computers are useless. They can only give you answers." - Pablo Picasso
0 Kudos
Message 1 of 18
(8,613 Views)

try the "project:Projects[]" property to find all of the project in memory and then dig down into them.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 2 of 18
(8,610 Views)

I have amended the snippet to include all open projects:

 

Open Ref to All VIs in Memory in All Projects.png

 

The problem now is that when I try to open a reference to the VI in order to view it's properties, I get error 1004:

 

Error 1004 occurred at Open VI Reference in -----.vi

Possible reason(s):

LabVIEW:  The VI is not in memory.

To load a VI into memory with the Open VI Reference function, a path must be wired for the VI Path input.

VI Name: -----.vi

 

How is it that the VI is "in memory" when I get the list of VIs in memory, but it is not "in memory" when I try to open the reference to it? I'm trying to open the reference using the VI's name alone. I suppose this is insufficient since the VI exists in the memory space of another project...

 

So now I also need to determine its path in order to open a reference to it? Must this path be the physical path on disk or can it be some sort of project-slash-VI-name-virtual-path-thing that LabVIEW understands?

_______________________________________________________________
"Computers are useless. They can only give you answers." - Pablo Picasso
0 Kudos
Message 3 of 18
(8,605 Views)

THey are in memory when the project ref is open and if you cloise the porject they exit memory.

 

Ben

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

This does not seem to be true. I disabled all Close Reference VIs, but I still get errors when trying to open a reference to the VI by its name alone. This makes sense to me because LabVIEW cannot know which VI you are referring to if the same VI exists in two separate application instances. The key is how to refer to the appropriate instance, and it seems that this is what I am currently failing to do.

 

I also tried to manually build a "path" to the VI using the same nomenclature as found in the application instance shortcut menu on the bottom left corner of the front panel and block diagram windows of the target VIs. This did not work when inputting it as a string, path, or relative path.

 

LabVIEW Help says the following:

"You must use an application reference when you are using VI server properties and methods in one application instance, and you want to interact with a different application instance."

- Working with Application Instances, Editing VIs in Multiple Application Instances

This much is known, but the help offers no explanation as to HOW to interact with [VIs in] a different application instance.

 

Could someone please provide a working example of how one would open a reference to an arbitrary VI that resides in the memory space of another project? Keep in mind that I do not know beforehand the names or paths of these VIs (that's the whole point of what I'm trying to do!).

_______________________________________________________________
"Computers are useless. They can only give you answers." - Pablo Picasso
0 Kudos
Message 5 of 18
(8,589 Views)

After further examination of the 280-some-odd VIs I tried to request properties from, I find that I was able to get properties for about 20% of them. The rest gave the 1004 error. I will now try to investigate why some were valid and others not.

 

At this point it seems to be that references to the VIs that are reentrant did not open. I will try opening them with the reentrant flag... but this will probably not allow me to edit the VI, which is one of my goals.

_______________________________________________________________
"Computers are useless. They can only give you answers." - Pablo Picasso
0 Kudos
Message 6 of 18
(8,578 Views)

So 80% of your VIs are reentrant?  Makes me very curious about the structure of your program...

 

For the reentrant VIs, is it giving you clone copies (if you're using pre-allocate clones)?

0 Kudos
Message 7 of 18
(8,570 Views)

So the VIs that didn't load are indeed the ones from the other project. The VIs that did load are vi.lib VIs. This makes sense since they would be in both memory spaces under the same name. ALL of the VI references from the other project gave the 1004 error.

 

Just to summarize and hopefully not confuse, I want to run Mercury.vi in the My Computer target of Venus.lvproj and have it modify a property of Earth.vi in the My Computer target of Mars.lvproj. How can I do this??

_______________________________________________________________
"Computers are useless. They can only give you answers." - Pablo Picasso
0 Kudos
Message 8 of 18
(8,568 Views)
Solution
Accepted by rwunderl

I just tried the code below.  It is running in one project; I also have open a second project with over 300 VIs and it opens a reference to each of them without any errors.  Are you wiring the application instance reference to Open VI Reference?

open ref to each VI in all projects.png

Message 9 of 18
(8,561 Views)

No, I was not writing the application reference. I can see now how that would work. I was doing my processing in a separate sub VI, after I was gathering VI names. The disconnection left me not noticing that I could do it that way. Now I'll just have to either re-open the app instance later or save it in a cluster while keeping it open.

 

I knew it had to be pretty simple. Thanks!

_______________________________________________________________
"Computers are useless. They can only give you answers." - Pablo Picasso
0 Kudos
Message 10 of 18
(8,557 Views)