LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

open multiple sub vis from main vi

Solved!
Go to solution

I am developing an application that consist of a main VI and several sub VIs that include different utilities. I would like to be able to open multiple utilities (sub VIs) at the same time from the main VI. So far I have noticed that when opening a sub VI from the main VI, the main VI gets stuck in the execution of the sub VI and cannot perform any other operations until the sub VI is closed.

 

Does anyone know of a way around this?

0 Kudos
Message 1 of 28
(3,376 Views)

Check out this thread:http://forums.ni.com/t5/LabVIEW/subVI/m-p/2223756#M708575


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 28
(3,368 Views)

This is a basic feature of LabVIEW.  You can create parallel path.

You need to understand the data flow concept behind the execution of the code in LabVIEW.

You can experiment by using highlight execusion.

 

Back to your question.  Yes, most people know if a way around your problem.

Depending on how you want to code it (scalability), there are many ways to accomplish this.

The simplest way is to wire the VI's in parallel.  WIll it do what you want?  Maybe... probably.

Is it the best solution for your code?  Dunno..  Haven't seen your code.  Dunno what it does.

 

Can it be done?  Of course..  Think of your sub-vi's as seperate functions.  Just as you can wire functions from your function palette in parallel, so can you do it with subVIs.

 

I'll whip up a quick snippet.

0 Kudos
Message 3 of 28
(3,358 Views)

That's not exactly what I was looking for. Maybe I should try to explain better:

 

The main VI of my application has the ability to open several different utilities. One utility to control a servo, one utility to program an IC, to name a few. I want to be able to call these utilities from the main VI and use multiple utilities at the same time. For instance, if I wanted to control the motion of a servo while programming an IC, I would want to open and use 2 utilities at the same time. Each utility has a fully functional front panel with controls and an event structure, so moving the while loop from the sub VI to the main VI as proposed in the above thread would not solve this problem.

 

I would like to avoid having seperate applications for the different utilities.

 

Any ideas?

0 Kudos
Message 4 of 28
(3,356 Views)
Solution
Accepted by topic author hazmat87

OK..  I'll skip what I was about to post...  😉

 

What you need is to use a producer-consumer architecture, where your producer is an event handler.  It will take care of the operator selections.
The consumer loop will be a state machine.  It will process the buttons that were pushed.

 

The trick is to use an Open VI Reference with an Invoke Node.  At the Invoke Node, select Run VI and set the Wait Until Done to False.

 

 

In the appropriate state of the state machine, wire the path of the appropriate subVI to the vi path terminal of the Open VI Reference.

At the end (wxit program state) close the references.  I would also recommend using type def enum to select the states.

0 Kudos
Message 5 of 28
(3,352 Views)

I get an error when trying the invoke node method.

 

Error.jpg

 

The VI called out in the error is the sub VI that is being called from the main app.

 

Any idea on what could be causing this?

0 Kudos
Message 6 of 28
(3,340 Views)

Another option to consider:

 

User Events can be used to open and stop your sub vis.

 

Attached is a barebones example in LV 2010.

 

steve

--------------------------------------------------------------------------------------------------------------------------
Help the forum when you get help. Click the "Solution?" icon on the reply that answers your
question. Give "Kudos" to replies that help.
--------------------------------------------------------------------------------------------------------------------------
0 Kudos
Message 7 of 28
(3,321 Views)

Is your vi already running when you call it using this method?

 

It might be running with its panel closed.  You might want to add another Invoke Node for Front Panel Open (FP Open). 

I think I mentionned that you have to close the reference at the end, when you exit.

 

But typically error 1000 is because the VI you are calling is already running.  If you want multiple instances of the same VI to run in parallel, you have to make it re-entrant.

0 Kudos
Message 8 of 28
(3,313 Views)

@stevem181 wrote:

Another option to consider:

 

User Events can be used to open and stop your sub vis.

 

Attached is a barebones example in LV 2010.

 

steve


Steve,

 

You have to be careful when using the method you suggested which is to do the calls within the Event Structure itself.  I did not look at your code, but I am familiar with people's misfortunes at using this style.  In other words, I've had to debug many people's programs who were not careful about the fact that the program was held inside the event structure; which caused the program not to respond to operator selections.  

 

 

0 Kudos
Message 9 of 28
(3,312 Views)

You could start your VIs using the "Start Asynchronous Call". You will need to use some type of user event/queue or notifier to control your subVIs if you want to have a single Stop in yo9ur application.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 10 of 28
(3,290 Views)