Dan07 Posted September 16, 2012 Report Share Posted September 16, 2012 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 Quote Link to comment
Mellroth Posted September 16, 2012 Report Share Posted September 16, 2012 ... 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 Quote Link to comment
jgcode Posted September 16, 2012 Report Share Posted September 16, 2012 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 Quote Link to comment
Dan07 Posted September 16, 2012 Author Report Share Posted September 16, 2012 (edited) 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 September 16, 2012 by Dan07 Quote Link to comment
ned Posted September 17, 2012 Report Share Posted September 17, 2012 Note: crossposted to the NI forums forums.ni.com/t5/LabVIEW/Open-subvi-into-subpanel-and-handle-events/m-p/2158254 Quote Link to comment
Dan07 Posted September 17, 2012 Author Report Share Posted September 17, 2012 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. Quote Link to comment
ned Posted September 17, 2012 Report Share Posted September 17, 2012 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. Quote Link to comment
Dan07 Posted September 17, 2012 Author Report Share Posted September 17, 2012 Ok, I agree with you. I will follow your advice. Thanks a lot. Dan07. Quote Link to comment
Zyl Posted September 17, 2012 Report Share Posted September 17, 2012 (edited) 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 September 17, 2012 by Zyl Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.