John Lokanis Posted April 11, 2007 Report Share Posted April 11, 2007 Not sure if this is a bug or a 'feature' but I have run into an issue that is causing me some grief: I cannot register for an event on a FP object if the FP of the originating VI is not currently open. Here is how to see this: Make a VI that has an event loop structure with a register for events function. Wire a control refnum of a Boolean into the register function and select the value change event. Setup the event structure respond to this event and send the NewVal to the stop loop terminal. Make another VI with a Boolean control and create a refnum for this control. Drop your first VI onto the diagram and wire the refnum to it. Run this second VI and see it wait for you to press the button. Make a third VI that calls the second VI. Close the first two Vis and run this new one. You will get a message that states: "LabVIEW: The VI front panel is not open." OK, so on some level it makes sense to not allow events for FPs that are not open, since you would not be able to manipulate those controls. But, with VI Server calls like Value(Sig), that is not really true. I often 'push' buttons on Vis that are not open to stop them or perform some operation remotely that the user could do if the panel was open. And, I often have Vis that I only show the FP some of the time (such as in a sub-panel when they are selected from a listbox). I still want to pass their FP refs down to their sub-vis and listen for events. So, does anyone know some workaround for this that does not involve polling? That is how I have had to solve this so far, and I dislike polling almost as much as global variables... Thanks for the input. -John Quote Link to comment
Ton Plomp Posted April 12, 2007 Report Share Posted April 12, 2007 Hi John, You can set the state of the front panel to hidden, this way it is loaded into memory but not shown! I haven't checked it but it should work. Make you sure you include the FP when building an app. Ton Quote Link to comment
Ton Plomp Posted April 12, 2007 Report Share Posted April 12, 2007 John, too bad you crossposted this on Info-LabVIEW as well... (were Stephen has given a wunderfull response): QUOTE > So, does anyone know some workaround for this that does> not involve polling? That is how I have had to solve > this so far, and I dislike polling almost as much as > global variables... ;-) Yes. Open the FP window as "Hidden." That's one of the paramters you can pass to the "Open FP" method. When you actually want to display the panel, use the FP.State property to set the state to Visible. If you want your users to be able to close the FP but still have your events fire, intercept the "panel closing?" event, set the panel state to hidden (using the FP.State property) and pass "true" to the Discard terminal so the panel doesn't really close. By the way, there's another reason for disallowing the events unless the panel is open. When the panel is open, we update a lot of things that we don't update when the panel is closed -- all of those things that you can query and set using the VI Server methods/properties. I'm not familiar with the entire list of "things that happen only when the panel is open", but I know that having the panel open, even hidden, is a performance penalty. Having the panel open is an indication that you want us to keep the display aprised of stuff that we'd otherwise skip. Instead of using Value(signaling) for communication, just use a User Event and a Notifier. The programmatic aspects of your application listen for the User Event. One event structure listenting for the event sets a value in a Notifier. When the FP of your VI gets opened, the FP Open event can read the value of the Notifier (using timeout of 0) and update the value of the control/indicator. Pojundery, Stephen R. Mercer -= LabVIEW R&D =- Ton 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.