LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Open subvi into subpanel and handle events

Solved!
Go to solution

Hello,

I am trying to run a code where I have a "Main VI" with a header and a SubPanel. As I change the value of the Selector into the header, the SubPanel should show a SubVI. Into the SubVI I have buttons that will generate random numbers for the Indicator 1 (SubVI 1) and for Indicator 2 (SubVI 2). The idea is, as I push the button for random number generation, the Indicator will be updated even if the SubVI currently showed into the SubPanel of the Main VI is not the one that contains the indicator that will get the new random number.

I created references cluster (strict type def) to make things easier. Find attached a zip file. Uncompress all files to one single folder and run Initialization VI.vi file. An error message (1001 - Front Panel is not open) will pop up and Main VI.vi don't open, as it was to supposed to.

I changed "Windows appearance" to Default, Dialog, etc. and tried almost everything but I am not getting the expected result. 

Of course this code is just an example to show what I want to achieve, that's why it is so simple.

Thanks all.

Dan07.

0 Kudos
Message 1 of 11
(7,538 Views)
Anyone?
0 Kudos
Message 2 of 11
(7,468 Views)

You need to re-think your approach.  Your Main VI is opening properly, but you also have it set to close if originally closed.  That means it closes immediately, since there's nothing to keep it running.  If you start with the Main VI front panel open, you'll see that it does in fact insert one of the subVIs into the subpanel.  However, both those subVIs also terminate immediately, and you can't capture events on VIs that aren't running.  If you put a loop in your main and subpanel VIs to keep them running, they won't finish so the event VI won't start.  I'm not sure exactly what your goal is but it just won't work the way you're trying to do it now.

0 Kudos
Message 3 of 11
(7,463 Views)

Hello Nathand

 

My goal is:

 

I want to have a main VI (lets call it as MAIN) that will have a splitter. The upper panel will be a header with a Selector Control. The lower panel will be a subpanel. Into this subpanel I want to load several subvis as I change the Selector Control. Into these Subvis I want to have controls that will generate information that will be presented into indicators in the same Subvi and in other Subvis. Even if I have SUBVI 1 loaded into MAIN vi, when I push a button (for example) in SUBVI 1 I want that the action trigger a event that will be handled by another VI (EVENTS HANDLER) and the result will be new information showed into indicators at the same Subvi where event was generated (SUBVI 1 in this example) or in other Subvi (SUBVI 2 for example). In other words, events triggered from SUBVI 1 could affect indicators in SUBVI 1 and SUBVI 2, and events triggered from SUBVI 2 could affect indicators in SUBVI 1 and SUBVI 2.

 

In summary, five VIs:

 

INITIALIZATION (to populate clusters with real references)

SUBVI 1

SUBVI 2

MAIN

EVENTS HANDLER.

 

Help.

 

Thanks.

 

Dan07.

0 Kudos
Message 4 of 11
(7,448 Views)
Solution
Accepted by topic author dan07

Do you definitely need that structure?  Normally I would expect Main to be the top-level VI, and Initialization to be a subVI.  If you're not restricted to that particular VI structure, perhaps you could instead describe the effect that you want to achieve and let others suggest how you might accomplish it, instead of describing the implementation you want.  For example, in your current structure you know how many possible subVIs you might embed in the subpanel.  Given that, it might be easier to place a tab control on the Main front panel and hide the tab selectors.  Assign one page to each subVI - either embed one subVI in each page, or set up the controls for each page that correspond to the ones needed by that subVI.  Use the enumeration as the tab selector.

Message 5 of 11
(7,384 Views)

Nathand

 

I did some tests following your advices and after couple changes the code is running well. I am using the Main.vi as the Top-Level VI. I removed the splitter and the subpanel and I am using the Tab Control (with embedded SubVIs) controlled by the Enum.

 

Thaks a lot for the ideas.

 

Dan07.

0 Kudos
Message 6 of 11
(7,375 Views)

I had some time and I tried to imagine a possible solution using subpanels.

In the mean time you have found a better solution.

Probably the use of a tab control leads to a simpler and clearer diagram.

But if you are curious try to take a look to my solution.

I call a first time each of the SubVI in "Init state" just to get the reference of their numeric indicator in a references array.

Then I call all the three subVI in parallel (they must be running when their panel is called).

The "Run" indicator is used for stopping all the subVI when End button is pressed.

 

I have attached a zip file with all the needed VIs, saved in LV2010.

 

Cheers.

 

Marco

Message 7 of 11
(7,363 Views)
Could you please save the files for 8.6 version?

Thanks.
0 Kudos
Message 8 of 11
(7,348 Views)
Message 9 of 11
(7,345 Views)

It doesn't work as intented for me...

Your main runs, but the subpanels do not show. Maybe because the instance of subvi running does not match with the VIref you obtain in the "init" case

 

spms00_2-1676383605503.png

 

 

 

Note: I know this is a zombie thread, but the question regularly arise, I'm stuck trying to do something similar myself

0 Kudos
Message 10 of 11
(1,584 Views)