Overview
This VI is useful for User Interface focused VIs which expect interaction from the Operator on a Front Panel.
Description
An Event Structure is useful for User Interface focused VIs which expect interaction from the Operator on a Front Panel. Dynamic User Events, which are covered in the LabVIEW Core 3 course, are able to generate user events programmatically, and are often a good way to get data back into the Event Structure.With this example, which can seen how to generate a Dynamic User Event from any VI on the same PC as the main VI with the Event Structure. This is achieved by Registering and Generating Events from within a Functional Global Variable (FGV) called in all the relevant VIs. Screenshots of the code within the FGV are below:
Requirements
Steps to Implement or Execute Code
Additional Information or References
VI Block Diagram of "Main VI.vi"
**This document has been updated to meet the current required format for the NI Code Exchange.**
Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.
Please convert your project to LV 8.6 or LV 2009.
Hello Philibuster,
I have performed a 'Save for previous version' in LabVIEW, and saved the code for LabVIEW 2009. What application are you creating that uses this example?
Hi gt3000,
I have been trying to wrap .NET user controls within XControls and need to process and propagate .NET events. It appears that a LV dynamic user event is required to make this happen. The .NET event handler fires a user event by invoking a ‘Fire Event’ action in a FGV global VI. In the XControl the FGV’s event ref is wired into the event structure to provide an event bridge.
An outline of what was planned:
XControl:
1. Init.vi – register the user event via the ‘Register Event’ action which uses ‘Create User Event Function’.
2. When the .NET event fires (on the Façade) it will invoke the FGV ‘Fire Event’ action which generates a user event via the ‘Generate User Event Function’.
3. Uninit.vi – un register the event via the FGV’s ‘Unregister Event’ action which used the ‘Unregister For Events Function’.
At load time when I register the user event in the XControl’s ‘Init.vi’, I request a ‘Register Event’ action and when the Init finishes this registration a ‘Fire Event’ event is unexpectedly generated without being invoked. This is the current problem I’m investigating. I also noticed that .NET generated user events seem to be queued and not processed. I was hoping to see something in your example that would give me a clue as to why this would happen. I also noticed that LV debug breakpoints don’t seem to work.
Note: I replaced the .NET control on the Façade with a simple LV button to simplify things - but with no change in symptoms.
Thanks for your help.
I want to run a vi as a response to occurance of event in the consumer loop.How should I do that?
And what is the disabled block function?
Hi ymadhuri,
Generally, the main VI shows that the third loop at the bottom of the block diagram is causing a User Event which is dealt with in the Producer loop. In your case, you can just use similar code in the Consumer Loop, and then place the VI you would like to execute as a response within the Event Structure that matches as a Sub VI.
As for the Disabled Structure, please ignore it. I had it when I was debugging and then I think I forgot about it after I resized the window. It is bad programming practice to leave Disabled Structures in a 'finalized' code, so that is just a mistake on my behalf.