LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I close a sub-VI window from a loop after several iterations?

Hi all,

I am trying to use a sub-VI like a dialogue box, but I'm having trouble getting exactly what I need:

My main program has data acquisition running the whole time, so I don't want to pass control to the subVI or if the user takes too long (which will probably happen), then the buffers over-run and the whole thing crashes.

Global variables are one solution, but they are very slow and the main program is already huge and slow enough.

One potential solution is to construct the subVI so it doesn't contain any loops and so it passes it's useful data when the user finally gets around to pressing the OK (or Cancel) button. The problem is I set the VI to 'open when called', but not 'close whe
n done' (otherwise it would close every cycle and "blink"). When the user pressed OK, VI server sets the 'close when done' property and calls the subVI yet again, but the subVI's front panel is already open, so when I call it, it doesn't close.

Is there a way to force the window closed with VI server? Is there another way to force a window closed? Is there a totally different solution to this problem?

Any thoughts would be a great help. Thanks,
Casey
0 Kudos
Message 1 of 4
(3,071 Views)
Hello,

1) If you put your main code and sub-vi in different while loops, so execution is multitasking. Sub-vi don't stop main loop. For sinchronization use notifier or queue.

2) For dinamic opening and closing FP of sub-vi use VI server: property FP.Open. Set it True when you want open and set it false when you want close.
0 Kudos
Message 2 of 4
(3,071 Views)
Thank you Nadav-

The #2 answer, using FP.Open to close the front panel is exactly what I needed.

For #1, multitasking, I have another question. If I wanted to pass data from the sub-VI (user prompt) routine, back to the main VI without having the main VI wait for the sub-VI, is there a clean and efficient way to do this?

Thanks a lot,
Casey
0 Kudos
Message 3 of 4
(3,071 Views)
Nadav already answered this question. Use a queue.

Before the two loops start, create a queue and pass its ref to both loops.

In the GUI loop queue the parameters whenever the user says OK.

In the DAQ loop checks the queue to see if there are updates,....

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 4
(3,071 Views)