Jump to content
Sign in to follow this  
Dan07

Open subvi into subpanel and handle events

Recommended Posts

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.

Example.zip

Share this post


Link to post
Share on other sites

...

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.

...

The reason you get this error is that you cannot register for FP events for controls on a VI that is not in memory. And, you cannot keep the front panels opened since you want to show hide the VIs in the SubPanel control.

Event if you try to register for control events while the FP is in memory, the event registration goes invalid when the FP is closed.

My best bet, even though I haven't tried it, is to use UserEvents instead. Or if you want to play safe, use Notifiers or Queues to do the signalling.

/J

Share this post


Link to post
Share on other sites

The reason you get this error is that you cannot register for FP events for controls on a VI that is not in memory... ...Event if you try to register for control events while the FP is in memory, the event registration goes invalid when the FP is closed.

There is a workaround for this

Yair helped me here with when I had the same problem

Not saying it would fix your problem, but worth looking at

Cheers

Share this post


Link to post
Share on other sites

Hello all,

I am aware about the fact that Front Panel must be open in order to Events Handler VI can Handle the events. However, even using User Events I can't achieve the expected result.

In short, 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.

Edited by Dan07

Share this post


Link to post
Share on other sites

Sorry about that but I was just trying to post my questions to as much people as possible. I am quite new to LAVA, is it not allowed to post the same question on different forums?

Sorry for any inconvenience.

Dan07.

Share this post


Link to post
Share on other sites

There's no problem posting to multiple forums, but when you do so it's polite to note that you've posted it elsewhere. That way you avoid being asked the same questions in multiple places, and people trying to help you can read the related forums before they duplicate work that was already done elsewhere.

Share this post


Link to post
Share on other sites

Hi,

If I understand well, the two subVIs you load in your subpanel run as thread in background. And you control which one to show.

When I have to do this, I use User Events. The creation of the user event is done in a FGV. Get and Set actions too, so that I can share the user event reference to any threads I want.

So, first create a FGV with Init, Get and Set actions. Then use it wth 'init' action in your initialization VI. Then launch your subVIs 1 & 2.

In these subVIs, use the FGV with 'Get' action to register for the events.

You then only have to send events in your main VIs using the 'Set' action to share data through your threads.

Remember to create one FGV per user event type (ex: one FGV to send data to one specific thread, another to send data to all threads). It works pretty well, and the front panel of your threads (subVIs) do not have to show up.

Edited by Zyl

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.