08-07-2013 01:38 PM
Hi,
I want to communicate between 2 VI, so I have a global variable (boolean) that gives the order to an event tool to run. The problem is the fact that event loop does not accept global variable, I found in the forum that I can use user event. Of course, the second VI works normally when I push the button (boolean) in it to run the event loop. Please can someone explain to me how to do this, I am a chemist.
Thank you.
Solved! Go to Solution.
08-08-2013 06:13 AM
You need to register the receiving Event structure for the event you want it to receive.
To do it in two VIs, you'll need to share the user event reference between them.
08-08-2013 01:54 PM
If the two event structures are in different VI (which they should be) all you have to do is give the user event a name and acquire a reference to the same event name in both VIs.
What you should probably do is look up the producer/consumer design pattern template. There are two versions of it, you want the version that uses the user-defined events. This template will give you a good model for using the events, and you might want to consider it as a structure for your entire program.
Mike...
08-08-2013 02:43 PM
08-08-2013 04:57 PM
Thank you guys for your help. My program is running.
08-08-2013 07:13 PM
User events can have names. If two VIs acquire event references and use the same event name, they will both end up with references to the same event. Give the same even name in both VIs and the code will work.
Note that you "acquire" a reference to an event, and then at the end "release" the reference (and not "create" and "destroy" references). LV does the creating and destroying of references behind the scenes by keeping track of the number of references to a named event that have been acquired and not released.
Mike...
08-09-2013 06:04 AM