From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Subpanel InsertedVI ref always invalid when using VI Server

Solved!
Go to solution

I'm trying to gain access to subpanel controls (in an executable) via VI server but it doesn't seem to be allowing me to get a valid reference to the inserted VI (1026:  VI Reference is Invalid).  If I use the exact same code in the executable itself, it works just fine.

 

Attached is the executable and the VI that I'm using to try and retrieve a reference to the subpanel's VI.

 

Any ideas why this is happening?

Download All
0 Kudos
Message 1 of 11
(3,660 Views)
I'm sorry but I can't look at your code. How are you launching the VIs going in the subpanel? Is the VI reentrant? Some launch methods do not give valid references to the clone that is launched.

Mike...

PS: I just did a series of posts on subpanels in my blog.

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 2 of 11
(3,635 Views)

I'm currently in the process of reading your blogs about subpanels but in the mean time, here is the code snippet of my executable.  At the bottom, in the conditional disable diagram, is the code that is in the VIServer_TestingSubpanels.vi.

 

I've tried both reentrant and non-reentrant settings for the subpanel.  The subpanel in the attached executable above is reentrant.

0 Kudos
Message 3 of 11
(3,619 Views)

After reading more on subpanels and reading your blog, I'm still unclear as to why I'm having an issue or what might be a method to work around the issue.

 

Maybe a little context will help:

 

The executables that I create will be manipulated by an external program created by another group within the company.  So, what they have done is create a DLL that uses the VI server to access front panel controls and indicators from a LabVIEW-built application.  This currently works just fine for anything that is on the main VI's front panel.  But, what I am trying to do is create hardware specific subpanels for the controls that actually do the interfacing with the hardware.  There are several different pieces of hardware with which we will interact, each having its own subpanel in the same main application.  So, they need to be able to 1) find which VI is running in the subpanel programmatically and 2) interact with that subpanel via VI server within the DLL.

 

Any thoughts are definitely appreciated.

0 Kudos
Message 4 of 11
(3,572 Views)
Ohhhh... That's easy.

There is a subpanel property that will return a reference to the VI that is currently in the subpanel. From that you can get the name of the VI and store it somewhere VI Server can find it -- like a FGV. Once the remote process has the VI's name the rest should be a piece o'cake.

The only thing different with using VI Server from an external source is that you need a reference to the copy of LabVIEW where the VI you want to access is loaded. And all you need to get that is the IP address or network name of the computer its on (use 'localhost' if its on the same computer), and the port the LabVIEW application is listening on.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 5 of 11
(3,564 Views)

@mikeporter wrote:
Ohhhh... That's easy.

There is a subpanel property that will return a reference to the VI that is currently in the subpanel. From that you can get the name of the VI and store it somewhere VI Server can find it -- like a FGV.


And that brings us back to the topic of this thread.  The subpanel property is called "InsertedVI" and it always returns an invalid (but non-zero) reference when it's trying to access it from outside the executable.  When I use the same code inside the exectuable, it works fine (see this image of the executable source code; the code in the conditional disable diagram is the code I'm using in the external VI where I'm getting the invalid reference which means I can't get any information about the subpanel's inserted VI) .

 

I can successfully get all the references to the main application's front panel which is how I am able to get the reference to the subpanel itself.

0 Kudos
Message 6 of 11
(3,551 Views)
OK, as long as the VI is in the subpanel the reference should be valid. What version of LabVIEW are you using. I have tested this with 2014 and as soon as the VI is removed from the subpanel the reference goes invalid. There could be a race condition where the VI changes between the time you fetch the reference and you go to use it.

Is the code you posted originally still current?

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 7 of 11
(3,540 Views)

Did you test my code that I posted along with the executable?  I haven't been able to work on it since I posted so it's still current.

 

I don't see any race condition as long as I run the VIServer_TestingSubpanels VI while the executable is currently running (which is how I'm testing it) and there is only one subpanel VI (and there will only ever be one VI in the subpanel during execution in my context).

 

I am using LabVIEW 2013 SP1.

0 Kudos
Message 8 of 11
(3,533 Views)
Solution
Accepted by topic author NathanJD

Ok, I see the problem, VI references are local to the instance of LabVIEW that generate them. When you read the VI reference, you are getting the correct numeric value (as shown by the fact that it is on-zero). However, in the development environment from which you are accessing the executable, the reference is not valid. That reference is only valid in the executable's envirnment. What you need to do in the executable is to get the name of the VI in the subpanel when you insert it and store that name in a FGV. Then from your remote application, read that FGV -- and you will have the VI name. 

 

Mike...


Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
Message 9 of 11
(3,516 Views)

Ok so basically, the two applications are "playing in two different sandboxes" which makes sense.

 

Thanks for your help Mike.

0 Kudos
Message 10 of 11
(3,469 Views)