LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to get a DVR to persist after creating VI closes?

Solved!
Go to solution

Hi All,

 

I am trying out some new architectures and I am hitting a problem. I hope you can help.

 

What I want to do is create a DVR in a toplevel VI and then pass this DVR to a second VI which I then run using the invoke node. In particular I want it to be an asymetric call so I have set 'wait until done' flag to false.

 

A valid reference is passed  to the second VI. However when the toplevel VI stops the the reference (now also in the second VI) is destroyed. I tried both options with the 'Auto Dispose Ref' flag (and I believe this isn't relative anyway).

 

Can anyone help out?

 

Many thanks in advance,

Dave

 

 

0 Kudos
Message 1 of 10
(3,186 Views)
Solution
Accepted by topic author DeltaJ

take advantage of what you have observed;

 

DVR is alive as long as the creator is alive.

 

So create the DVR in a sub-VI that is also part of th hierachy of the VI you spawn.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 2 of 10
(3,184 Views)

That's exactly the workaround I've just started while waiting for an answer;-)

 

Dave

Message 3 of 10
(3,181 Views)

@DeltaJ wrote:

That's exactly the workaround I've just started while waiting for an answer;-)

 

Dave


 

Then pat yourself on the back for me.

 

As far as I known that is the only "Correct Answer".

 

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 10
(3,176 Views)

Actually I've just been thinking - would the synchonous call to the spawned VI means that right after the invoke node is the perfect place to delete the DVR after you are finished using it (assuming you only use it in the spawned VI)?

0 Kudos
Message 5 of 10
(3,175 Views)

@Ben wrote:

@DeltaJ wrote:

That's exactly the workaround I've just started while waiting for an answer;-)

 

Dave


 

Then pat yourself on the back for me.

 

As far as I known that is the only "Correct Answer".

 

Ben

 


Smiley Very Happy

0 Kudos
Message 6 of 10
(3,170 Views)

@DeltaJ wrote:

Actually I've just been thinking - would the synchonous call to the spawned VI means that right after the invoke node is the perfect place to delete the DVR after you are finished using it (assuming you only use it in the spawned VI)?


 

If you are talking about "Call by refernence", I would say yes.

 

Otherwise you will have to ensure that the sub-VI completes or use another mechanism to know whn the DVR can be destroyed.

 

Please report what worked so others can follow you.

 

Have fun!

 

Ben

 

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 7 of 10
(3,169 Views)

Yes call by reference was what I was thinking about.

 

Thanks again for your help and comments Ben,

 

Dave

 

 

 

 

0 Kudos
Message 8 of 10
(3,167 Views)

In this particular case, if you do the timing correctly, you can pass the data while allowing the original DVR to die.  The sequence would be something like this:

 

  1. Create DVR and populate it in original VI.
  2. Launch second VI.
  3. Destroy DVR in second VI - this will output the original data in an in-place manner.
  4. Create a new DVR and populate with this in-place data.
  5. Send acknowledge that second VI is finished to first VI so it can exit.

You end up with the same data in a new DVR, still in-place, if you are careful, and you don't have to worry about a subVI to keep the DVR alive.

Message 9 of 10
(3,148 Views)

Thank you for the suggestion DF - its an approach I will keep in mind for the future!

0 Kudos
Message 10 of 10
(3,141 Views)