I have a problem with a task in LabView that I thought would be simple and pretty standard, but I am failing to acomplish it nonetheless.
The task: I have a measurement VI that aquires data in a loop. This may take a while, so I want to show the incomplete dataset to the user "as it grows". This should be done in an extra window so I want (need?) to use a SubVI. I want this SubVI's front panel to open at the beginning of the measurement and close at the end.
I put it in the measurement loop, so it gets called after each new datapoint is taken and can display the updated dataset. I set it to "show front panel when called", so it opens at the beginning of the measurement (first iteration of the loop), just as I want it to. But it doesn't close. If I check "Close afterwards if originally closed" it closes after each iteration of the loop, which is very annoying.
Also I tried calling FP.Open
, FP.Run
and FP.Close
with an Invoke node but then I have no idea how to actually call the SubVI in the measurement loop and feed data to it.
Is there a general misconception in my approach? Or is there an obvious solution I failed to spot?
It sounds as if you have the SubVI displaying the data you want and it's just closing the front panel at the right time that you're stuck on. In that case the simplest way to do it is to keep the VI in the measurement loop, with the Show Front Panel When Called
setting checked, and just use the FP.Close
method to close the front panel when the loop is finished:
This implies that you're passing all of your acquired data to the subVI every time round the loop; that's not a problem if the size of the data is small, but a more scalable approach would be a producer/consumer pattern using a queue as Joe suggests. To do this:
FP.Open
and FP.Close
methods on it in your top level VI to open and close its front panel when needed.You'll need to give the subVI some way of knowing when to exit when your top level VI is finished; a convenient way of doing this is to force-destroy the queue in the top level VI which will cause the Dequeue Element
in the subVI to exit with an error.
Another option would be to keep your subVI in the measurement loop, pass it only the new data each time round the loop, but give it a 'memory' using an uninitialized shift register in which it accumulates the acquired data for display. Search the LabVIEW help for functional global variable for more detail on this approach. Again, use the open/close methods from your top level VI to show or hide the front panel.