From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

SubVI window closure

Solved!
Go to solution

Hi!

 

I built a subVI for an Oscilloscope VI that performs signal analysis.

Users should be able to open and close the subVI's window, but I cannot make it work as I wish.

 

What it should do is:

- open the subVI when an on-off control is clicked and start calculations

- close the subVI's window and stop calculations

- redo this passages every time the user needs it

 

What I builts does:

- open the subVI with the button and start calculations properly

- when I close the SUBVI window it opens again whith calculations stopped

- after re-closing, if I open the subVI with the button it does not calcuates

- after re-cliking the button it finally starts working again

 

I have attached the subVI and an example VI reproducing the loop containing the subVI.

 

Do you know a better (and more correct) way to make it work?

 

Thanks!

Mike

MikeNuke, PhD

Politecnico di Milano
Department of Energy, Nuclear Engineering Division
Download All
0 Kudos
Message 1 of 6
(2,522 Views)

If your user closes the window, you button is still set to TRUE.  So the calculations are actually still happening, you just can't see them.  Then you click the button.  But now the value is FALSE, so you will not be getting any calculations done.  You hit the button a third time, and now it is TRUE, so you are making the calculations.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 6
(2,513 Views)

Mmm...

My interpretation:

 

- first "run" by clicking the button: the button is TRUE and the case structure passes TRUE to the local variable, keeping the subVI working.

- If I close the window, instead of passing FALSE from the event structure, the value TRUE is passed (why?), and on the next iteration the subVI is re-opened

- then, if I close the window again it passes FALSE (from the previous closure) and it remains closed

- if I push the button it opens without calculations because FALSE is passed from the second closure

- if I re-push the button it sets to TRUE and finally works

 

What I don't understand is why the subVI does not pass the value FALSE when it is closed, and does it on the next iteration

MikeNuke, PhD

Politecnico di Milano
Department of Energy, Nuclear Engineering Division
0 Kudos
Message 3 of 6
(2,501 Views)

Is it possible that a race condition is occurring?

Maybe the closure of the window happens after the execution of the subVI inside the loop, so on the next loop iteration the subVI is executed again (button value TRUE) and it processes the "panel close" event and passes FALSE.

The same for the secon closure and the re-opening...

MikeNuke, PhD

Politecnico di Milano
Department of Energy, Nuclear Engineering Division
0 Kudos
Message 4 of 6
(2,476 Views)
Solution
Accepted by topic author MikeNuke

I just noticed a nasty race condition you have as well.  If you toggle the button after the terminal was read but before the local variable is written to, your button toggle could be ignored due to the local overwritting your user.

 

What I would do with this setup would be to launch the subVI as a parallel process.  The VI can maintain its own state and what not.  You could then use User Events and/or Queues to send your data to the other process.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 5 of 6
(2,471 Views)

Hi!

I used parallel loops and a queue (new thing for me 🙂 ) and now it works.

Thank you!

 

Mike

MikeNuke, PhD

Politecnico di Milano
Department of Energy, Nuclear Engineering Division
Message 6 of 6
(2,454 Views)