LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Open SubVI from frontpanel with Button

Solved!
Go to solution

Dear LabView Community,

I have an issue regarding the opening of the SubVi from my frontpanel. I searched for online solution but could not find any.

 

My issue is that if I want to open the Subvi front panel with a button on the main Front panel, it activates the button but does not open the front panel. However, if I activate the button before I start the Programm, it opens perfectly fine as soon as I start the programm.

 

Does anyone know how to solve this issue with that brief description? I am sure it is only a small setup problem but I can't find it myself.

Thank you in advance,

 

-P

0 Kudos
Message 1 of 10
(3,640 Views)

Hi,

If we saw your code it would be easier and quicker for everyone.

My first guess is that the button is only read at the start of the program and not in a while loop

Yddet

0 Kudos
Message 2 of 10
(3,602 Views)

Here is the Code. I had to shorten it a bit, but the issue is still the same. Thanks for your help.

Best

-P

0 Kudos
Message 3 of 10
(3,587 Views)

You should include all the useful VIs (and sub-vis) and project files in a zip file so we can test your code properly. 

 

I don't know what your settings are but I would check "Show front panel when called" and "Close afterwards [..]" in the properties of the VI to open.

Yddet_0-1590590526254.png

Yddet

 

0 Kudos
Message 4 of 10
(3,580 Views)

You'd be far better off with an Event Structure for handling the button push events.  That way you know you'll only ever be dealing with one event at a time.  With your code as it is, both the button push case structures could be running in parallel.  You can then share information (for example, a "module is operational" flag) between the cases using shift registers.

 

PsyenceFact

Message 5 of 10
(3,569 Views)

Thanks for your quick response.

The VI I uploaded has the VIs included and shows the exact problem I have when running it. Does it not work for you?

I can not upload everything because it consists partly of a bought software, so this must do...

The options you show are the same I have in the code.

 

0 Kudos
Message 6 of 10
(3,516 Views)

@Rehp wrote:

Thanks for your quick response.

The VI I uploaded has the VIs included and shows the exact problem I have when running it. Does it not work for you?

I can not upload everything because it consists partly of a bought software, so this must do...

The options you show are the same I have in the code.

 


No, it does not work, because (I guess) nobody else has the SubVIs that You want to open in Your code.

 

I guess You are trying to dynamically open the Frontpanel of another VI from within Your VI. This can be done using the VI Server. Static VI references have a method that does exactly what You want: https://labviewwiki.org/wiki/VI_class/Front_Panel.Open_method . It is even named exactly like You would expect.

 

I want to stress the advice given to use event structures. There are still a few days left on the free introductory courses at https://learn.ni.com/training if You are not comfortable with using them.

Message 7 of 10
(3,510 Views)
Solution
Accepted by topic author Rehp

Hi,

The test.vi calls two sub-vis (Initialize and SLpro_CTA-P7) but their code is not included. It is not possible to open them if we don't have all the [file].vi .

Which VI do you want to open when called ? Which button do you push to do so ?

 

Without touching the VI properties, this should work. It opens a VI front panel and runs it. It stops the main.vi until the subvi is finished.

open vi.png

 

PsyenceFact is right about the event structure. This code should go inside an event (without the case structure).

 

Yddet

Message 8 of 10
(3,506 Views)

I will give it a try with the dynamic structures. I had trouble finding it but have it now. Thanks for your help.

Best

-P

0 Kudos
Message 9 of 10
(3,489 Views)

Like the other responders, I see that the subVIs SLpro_CTA - P7 - Status for OPERATE.vi and SubVI_Initialize.vi are missing.  However, I've managed to modify your Test.vi to show the use of an Event Structure to handle the button push events and shift registers the module address and automation refnum.

 

Can you provide a link to a website for the bought software or provide some documentation?  That way we could at least have a look at how it is supposed to work.

 

PsyenceFact

0 Kudos
Message 10 of 10
(3,481 Views)