LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Opening new VI and pass some Data

Solved!
Go to solution
Solution
Accepted by topic author PMSilva

You'll have to show us the hole (relevant) program.

 

If you use a static VI reference, and than a Open VI Reference with the name, you can use the "Abort" method to stop it. You can do this on start of the program.

 

A better approach is to have a graceful close of the VI. Send it a signal (a queue or a user event).

 

Yet another approach is to start the VI dynamically, to close the ref automatically when running it, and not use a close to close the reference. The VI will be closed (and stopped) when the caller stops. This is tricky, though.

0 Kudos
Message 11 of 21
(1,178 Views)

Shure,

So in my main program, I will have 4 parallel while loops, and send some queue data across them. I am using the queue to also stop that while loops (that works okay):

PMSilva_0-1582726485931.png

 

I have another loop that understands some behaviors, and when I push a button for opening the new VI it works. Also in that new opened VI I have an event that when I close the VI or push the Close button of this VI, send an update status for the main VI. So I open the new VI with this:

PMSilva_1-1582726604246.png

In the main loop of the main program, I am checking for the Stop button or Close windows, to proceed with stoping the program running:

PMSilva_2-1582726695082.png

 

Close Opened Display VI block:

PMSilva_3-1582726719961.png

 

The only problem occurs when I push the Stop button with the new VI opened. It closes and stop the program, but when I start again the program, the status of the new opening VI is being monitored (with the following diagram), and I get "Run top level" when I really should be "idle". As I mentioned, it works fine if i close the new VI, the status is getting update, but when I stop the main program, it closes the new opened VI and the status is not updated when I start the program again. This debug of the new opening VI is monitored inside of one of my loops.

PMSilva_4-1582726862497.png

 

 

 

 

 

0 Kudos
Message 12 of 21
(1,155 Views)

Posting blurry pictures of parts of block diagrams is useless.

"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 13 of 21
(1,144 Views)

Sorry about that... 
Attached is the program that I am building.

0 Kudos
Message 14 of 21
(1,122 Views)

@PMSilva wrote:

The only problem occurs when I push the Stop button with the new VI opened. It closes and stop the program, but when I start again the program, the status of the new opening VI is being monitored (with the following diagram), and I get "Run top level" when I really should be "idle". As I mentioned, it works fine if i close the new VI, the status is getting update, but when I stop the main program, it closes the new opened VI and the status is not updated when I start the program again. This debug of the new opening VI is monitored inside of one of my loops.

FP.Close doesn't stop the VI, it closes the front panel. Use the Abort method to stop it (and FP.Close to close it's panel).

 

A better approach it to make a graceful shutdown. For instance with a user event... If the parallel process is, for example, saving a file, the abort will very likely corrupt the file.

0 Kudos
Message 15 of 21
(1,115 Views)

Thank you so much. This really work without crashing the app.


What is the best approach to send data to another VI? I am using something like this (and works)

PMSilva_0-1582800946481.png

 

0 Kudos
Message 16 of 21
(1,112 Views)

@PMSilva wrote:

Thank you so much. This really work without crashing the app.


What is the best approach to send data to another VI? I am using something like this (and works)

PMSilva_0-1582800946481.png

 


That passes the cluster. But once it's (data) is passes, you won't be able to change it.

 

If you pass the queue reference, the VI you started and the VI that started it will be able to communicate over that queue.

 

Other option are (a non-comprehensive list):

+ user events

+ notifiers

+ control references (you can use VI server to get a VI's controls, and than set it's value)

+ (functional) globals to pass values

+ (functional) globals to pass user events, queues, notifiers, etc.

 

0 Kudos
Message 17 of 21
(1,108 Views)

That option gives me an idea for the future.

In this application, I only need to pass the data to the other VI and process it there.

Thank you for your support.

 

0 Kudos
Message 18 of 21
(1,093 Views)

Do you have an example of how to pass queue reference from one VI to another one?

0 Kudos
Message 19 of 21
(1,088 Views)

@PMSilva wrote:

Do you have an example of how to pass queue reference from one VI to another one?


Make a queue reference indicator. Copy paste it on a (new) VI, and change it to a control. Then connect it to the connector pane.

 

A queue reference isn't different form any other type.

0 Kudos
Message 20 of 21
(1,072 Views)