LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Reusing VI reference

Hi,

 

In my simple application I start a VI that is running on it's own. From time to time I do set a parameter which resets the timer on that VI. At the end, I set the parameter again and wait the VI to shutdown.

What I don't get is, I can set parameters right after I started the VI (image 1), but when I use the reference later again the address of the reference is still here, but the reference is not valid anymore. Any ideas? Any help is appreciated.

 

Thank you,

Urs

 

Spoiler
image 2, ref invalidimage 2, ref invalidimage 1, worksimage 1, works

 

0 Kudos
Message 1 of 15
(3,624 Views)

Hi Adrenalin,

 

there's a coercion dot…

 

To get more detailed answers you should attach code, not just images of code (hidden in a spoiler)!

Why did you choose the NXG tag when you have a problem with default/classic LabVIEW?

 

Idea: instead of using references you could use a plain QMH scheme to send commands/messages between your VIs…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 15
(3,620 Views)

How is this global/AE being called in your code? LabVIEW closes references that were opened once the hierarchy in which they were created stops. If you are opening the reference in one hierarchy that stops, then attempting to use it in another, the reference will be invalid. 

0 Kudos
Message 3 of 15
(3,591 Views)

@GerdW wrote:

Hi Adrenalin,

 

there's a coercion dot…

 

...


Check all of the cases to see which one is stepping in the reference in the Shift Register.

 

The other thing alluded to by Paul is when the VI that opens the reference goes idle, LV cleans up anything that was left open. So that VI you showed us either has to be in a VI that stays in a running state or that VI that you are running has to open a reference to itself to keep it alive.

 

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 15
(3,576 Views)

Why do you have coercion dot in initiate case? Does reference links to VI with different connection pane in other cases? 

0 Kudos
Message 5 of 15
(3,570 Views)

Hi Ben,

 

You're right, this is the issue: The caller vi runs through it's code and then it stops and close it's front panel. It memorizes the reference to the watch-dog vi by the shift register. This is different for the watch-dog vi. Once started, it runs the whole time and just at the very end, I'll send an "complete" command that let the watch-dog shut-down and close it's front panel.

 

Now that we know what the problem is, how can we fix it? Do I need to establish a reference to that vi every time, or is there a way that the reference in the shift register remains valid?

Thanks alot, Urs           

0 Kudos
Message 6 of 15
(3,541 Views)

Hi again,

 

Working on on that question, I do understand more what the main problem is: This call Chain as Paul and Ben mentioned: I want VI A to load/call VI B, but then VI A should complete where as VI B should continue running for hours. I also want to change parameters in VI B via starting/completing Vi A and the same way I want Vi B to terminate. As what I understood is, that the calling chain closes all ref and all running vi's when my VI A stops. I figured out, that I can not only reuse the VI ref to VI B, but VI B is killed by Labview after 30 sec too.

 

Can someone help me how I could have a VI starting another VI and then let the first one stops and the second continue to run?

 

Finally: Sorry, I don't know coercion, nor NXG, nor QMH ...

0 Kudos
Message 7 of 15
(3,524 Views)

@Sapiophile wrote: 

Can someone help me how I could have a VI starting another VI and then let the first one stops and the second continue to run?


When the main VI stops running, the reference to child VI is invalidated. That means there is now no more reference open to the child. So it will stop running. The child needs to open an explicit reference to itself. Not a "this VI" node, but an Open VI Reference. That reference needs to be not closed until the VI should stop.

 


@Sapiophile wrote:

 

Finally: Sorry, I don't know coercion, nor QMH …


Well, there's an opportunity to grow...

 


@Sapiophile wrote:

 

nor NXG...


Question remains why you tagged the thread LabVIEW NXG, if you don't know what it is.

0 Kudos
Message 8 of 15
(3,508 Views)

Hi wiebe,

 

Thank you for your reply. So you're saying, that in principal, I have to acquire a VI ref exactly the same way in VI B as I did in VI A to call VI B  (like: this application, open vi reference, strict typed vi reference, option x80) and then I keep that ref in a shift register until I close VI B I close it with a close ref. I tried, it was running, but I got 2 different references for the same VI A. Without a valid VI ref of VI B, how could I communicate with it, how would you establish the communication between Vi A und Vi B?

 

Uups, that must have been a mistake, I don't know anything about Labview NXG. Can I remove that NXG tag somewhere?

 

What do you all mean by "coercion"? Maybe it's also a language problem that I do not understand ...

 

Regards,

Urs

0 Kudos
Message 9 of 15
(3,496 Views)

wiebe@CARYA wrote:

@Sapiophile wrote: 

Can someone help me how I could have a VI starting another VI and then let the first one stops and the second continue to run?


When the main VI stops running, the reference to child VI is invalidated. That means there is now no more reference open to the child. So it will stop running. The child needs to open an explicit reference to itself. Not a "this VI" node, but an Open VI Reference. That reference needs to be not closed until the VI should stop.

 


Huh? Why would the child stop running just because the caller stopped? It was launched asynchronously, it will keep running unless the caller (or something else) explicitly stops it. 

 

Adrenalin - your VI is stopping after 30 seconds because that is what it is coded to to - you have a 30 second timer that elapses and then stops the loop. If you want it to keep running, don't stop the loop! Similarly, if you want to keep communicating with the VI from your launcher VI, don't stop your launcher!

 

Also, you don't need to use VI server to communicate between two VIs - LabVIEW has many other built in communication mechanisms - queues, events, notifiers etc. Again, each of these is reference based, so you will need to keep the VI hierarchy that created them active or the reference will be closed. 

0 Kudos
Message 10 of 15
(3,492 Views)