LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Event Structure, sub VI does not pops up when clicking it to launch

Hello Labview guys,

 

I am a very new using event structures, I have developed a very small VI that should open a sub VI. The problem is that when you click on the main program the button run it does nothing and then you are not able to stop it clicking the stop button. The weird thing is that if have open the subVI and click run on the main VI it starts running. Believe me I don't know what to do. Does anybody here can help me out on this issue?

I will really appreciate your support

 

SergeArmz

 

PD

I'm attaching both codes for reference

Download All
0 Kudos
Message 1 of 7
(3,206 Views)

I would consider using a case statement instead of an event structure, almost making a state machine and using the button is change states. also having 2 boolean inputs to the outside while stop button (even with 1 of then negated) can conflict really easily, maybe consider adding an OR Gate on the outside of the event structure. Adding a Value to the timeout input of the event structure would be a good idea. i would also use an out terminal instead of a waveform indicator on the output of your subVI.

 

Best of luck

___________________________________________________________________
"I have not failed. I've just found 10000 ways that won't work." - Thomas A. Edison
0 Kudos
Message 2 of 7
(3,199 Views)

When you click the button it does start the subVI. However, the subVI front panel remains closed, so you cannot stop it. Since the event structure by default locks the front panel (of Main.vi) until the code inside the event case completes, the program locks up.

 

There are several things you should do to fix this:

1. Never put any code inside an event case which takes more than a few milliseconds to execute. When the event needs to start a lengthy process, the lengthy process must be in a separate loop parallel to the loop containing the event structure.  Look at the Producer/Consumer (Events) Design Pattern or template to see a recommended way of handling this situation.

2. The subVI needs to be set up to display its front panel. Go to VI properties >> Window Appearance >>Customize and check "Show front panel when called" and "Close afterwards if originally closed"

3. Remove the Timeout Event case. It will never execute, so why have it?

4. Remove the Not and the wiring from the Play button to the stop terminal. It will always be false, so just let the default tunnel value do its job.

 

Lynn

0 Kudos
Message 3 of 7
(3,189 Views)

Thanks johnsold,

 

As I told you guys I'm a newbie on the event structures stuff, I did the steps you mentioned and it works well, it showed up the sub VI, the only thing I have not fixed is the matter to stop the sub VI clicking the stop botton on the main VI, what am I missing there?

 

thanks again

 

SergeArmz 

0 Kudos
Message 4 of 7
(3,179 Views)

Hello SergeArmz,

 

I would like to share with you the following link where you can find a very simple way (VI Server) to stop a SubVI's execution from the Main VI. The VI Server is a collection of functions that allows programmatic access to LabVIEW objects and functionalities.

 

http://digital.ni.com/public.nsf/allkb/E38991F4A3892B6F86256E44004C5963?OpenDocument

 

This example doesn´t use the event structure, but serves as a basis for understanding how the VI Server works in order to call and stop a subVI.

 

For example in your application

Call SubVI.PNG

In the other hand, when you click the stop botton in the Main VI you can stop-close the subVI and the Main VI.Stop SubVI.PNG

 

Best Regards.

 

Antonio S.
Applications Engineer - NI Mexico
0 Kudos
Message 5 of 7
(3,089 Views)

If the subVI is to pop up when it runs, generally you would not be trying to stop it from the front panel of the main VI.  That seems like a good way to confuse the user. What does this button stop? What does that button stop? Why does this one stop both VIs and that one only stops one VI? As Antonio S. showed, you can do it, but you may want to think about how to give your users a consistent experience.

 

Lynn

0 Kudos
Message 6 of 7
(3,078 Views)

@johnsold wrote:

If the subVI is to pop up when it runs, generally you would not be trying to stop it from the front panel of the main VI.  That seems like a good way to confuse the user. What does this button stop? What does that button stop? Why does this one stop both VIs and that one only stops one VI? As Antonio S. showed, you can do it, but you may want to think about how to give your users a consistent experience.

 

Lynn


Not to mention he showed a deprecated method.  Besides, killing VI executions should just be avoided in general.  You should let the VI stop itself so that it has a chance to perform some clean up.  Maybe use a User Event or a Queue to send a stop command would be much preferable than just killing it.


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 7 of 7
(3,070 Views)