LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

open multiple sub vis from main vi

Solved!
Go to solution

 

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.


Ray,

 

Thank you for the feedback on something you did not look at.Smiley Wink

 

Given the following block diagram, please identify the “program” inside the event structure.

 

user events.png

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 11 of 28
(863 Views)

 

You are triggering a user event inside the event structure? 😮

And I would assume that you have event structures inside the sub-vi?!?  😮 😮

 

Yikes..

0 Kudos
Message 12 of 28
(858 Views)

@Ray.R wrote:

 

You are triggering a user event inside the event structure? 😮

And I would assume that you have event structures inside the sub-vi?!?  😮 😮

 

Yikes..


I don't see any issues with the way Steve is using events. I regularly fire events from within an event structure. I have not run into any issues doing so. Why do you claim generating a user event within an event structre is problematic?

 



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
Message 13 of 28
(847 Views)

It is an unusual approach, where you need to be careful that the sub-vi's event structure does not cause a deadlock.

If it is well implemented there is no problem. 

 

I recall a post on these forums where the person had created such a deadlock.  Maybe I get jumpy when I see such implementations on the forum..  😄

0 Kudos
Message 14 of 28
(842 Views)

Ok, back to the Original Posters issues ...


 


What was not mentioned in this example:

 

Your sub vis can not be located on your block diagram (you are dynamically opening them).

The path to the subvis must be relative to the main vi if you need to build an exe. (Expect path issues until you figure it out)

LabVIEW does not know these subvis exist so when building applications you have to manually include them in the build specification.

You need to create code to close each subvi.

Would you like to Profile your code? Sorry - Dynamically called vis don't show up (as of LV2010 anyway).

 

Several of these items are reasons why I try to stay away from Dynamically calling vis.

 

But even saying all that, they can be made to work and do provide one benefit: They free up memory when you close them.

 

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 15 of 28
(830 Views)

There are many ways to implement the solution.  He has been presented a few.

That's the beauty of life:  choices.

 

I did not mean to knock down your suggestions.  I was merely stating observations from years of helping others in this forum.  And you are correct in stating that there are caveats to the solution I offered.  There was no indication that the OP wanted to build an executable.  I did not realize that this had to become a p***ing contest.

 

 

0 Kudos
Message 16 of 28
(824 Views)

I was able use the open VI reference > Run VI method to do what I needed. I'm not to comfortable with user events yet, so I didn't get to explore that option.

 

It seems like this should be easier to do though...

Message 17 of 28
(821 Views)

So I have something similar that I am trying to do but I get the same error when I try to call the same VI a second time.  The subVI pops up with a progress bar on it that goes from 0 to 100 and it displays the number of seconds left as defined by the user's input (the example just has a constant).  In any case once it counds down to zero it ends the loop in the subVI and closes the front panel.  Then as you can see below in the code I have been using to call it - I close the references.  Now I can't figure out why it is still running after doing this.  The front panel of the subVI will not close until it gets out of the while loop and the only things after that are a close front panel method and a close reference.  Then the VI should stop running I would think since there is no more code for it to run.

 

Below is an example of the code I am trying to use to call the subVI.

 

example.png

0 Kudos
Message 18 of 28
(796 Views)

Actually as I've been trying to figure this out I noticed that if I run the main VI with highlight execution on there is no error, but when I run it without highlight execution there is.  What would cause that?

0 Kudos
Message 19 of 28
(787 Views)

What is the error?



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 20 of 28
(784 Views)