LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Sub Panel and References

Solved!
Go to solution

Hi

 

I've a Main.vi including one sub panel to run two different SubVIs sequentially.

In SubVI1 I want to create a reference that I can use in SubVI2.

How can I pass the reference from SubVI1 to SubVI2 so that it is still valid in SubVI2?

 

I try to do this with a functional global but inside SubVI2 i get the error message: 1025.

(see attached example)

 

Laschko

0 Kudos
Message 1 of 7
(2,938 Views)

Hi Laschko,

 

I have customized your code. You programmed some things, doesn't make sense at all. You opened an application reference in SubVI1 and then the SubVI is closed, so the reference is invalid afterwards. Try the example attached.

 

regards

Tobias

0 Kudos
Message 2 of 7
(2,906 Views)

Hi Tobias,

 

Thanks for the answer.

Yes, the code I attached has no useful functionality but it shows the problem on a very easy way.

It's just a simplified example of a problem I have in a bigger test software.

 

There I has to create a TCP/IP-Connection inside the first VI shown in a sub panel.

Afterwards I must stop and close this first VI, start a second VI and shows it in the sub panel.

Now, this VI should use the reference of the TCP/IP-Connection created in the first VI.

But as in the example, the reference in the second VI is not valid and I get the Error: 1025.

(To simplify the example I used an application reference instead of the reference of a TCP/IP-Connection.)

 

So the question that I try to show with the example code is very simple.

How can I pass the reference created in SubVI1 to SubVI2 if I must stop the SubVI1 before SubVI2 starts?

 

Kind regards

Laschko

 

 

 

 

 

0 Kudos
Message 3 of 7
(2,878 Views)

Laschko wrote:

How can I pass the reference created in SubVI1 to SubVI2 if I must stop the SubVI1 before SubVI2 starts?


You can't. I didn't look at your code, but I'm guessing this is the problem you have.

 

Generally, LV automatically destroys a reference when the hierarchy it was created in goes idle. The hierarchy is determined by the top level VI, which is either a VI where you press the run arrow or a VI you run using the Run VI method (which I'm assuming is what happens in your case). Today there is no way of disabling this behavior. Hopefully in the future NI will change it so that references are only destroyed when no one actually uses them.

 

The only way to handle this today is to make sure the reference is first created in a hierarchy which will stay in memory. This can be either your main hierarchy or a daemon which you call in the beginning and has the task of creating the references.


___________________
Try to take over the world!
Message 4 of 7
(2,859 Views)

Hi tst

 

Thanks a lot for the answer!

I expected that it is not possible but I didn't want to believe it!

 

But one question is still unclear for me:

In the example I try to pass the reference with a functional global.

If the SubVI2 reads this functional global it gets the correct reference number, but the reference behind this number is not valid.

 

Why does the functional global only stores the number of the reference but not the reference itself?

 

Kind regards

 

 

 

0 Kudos
Message 5 of 7
(2,829 Views)
Solution
Accepted by topic author Laschko

The problem is not with the reference itself, but with the resource which the reference points to - that resource (a TCP connection, in your case) is automatically cleaned up when the hierarchy goes idle, so the reference which refers to it still exists, but becomes useless.

 

The question is whether you need to use the Run VI method. You might just be able to run the VI itself (or, alternatively, to open the connection in the hierarchy of the main VI).


___________________
Try to take over the world!
0 Kudos
Message 6 of 7
(2,811 Views)

Hi tst

 

Thanks a lot for the explanations!

May be, we should change the test software, so that we open the TCP reference in the hierarchy of the Main.vi!

That's not a nice solution but it works.

0 Kudos
Message 7 of 7
(2,792 Views)