02-29-2012 11:59 AM
I have an event structure with two events. I want the finalization of the first event to trigger the second event. Both events are triggered by a boolean value change, say "boolean 1" and "boolean 2". Can I have a local variable of boolean 2 inside event 1. By changing its value, it should trigger event 2. However, this doesn't seem to be working. (see attached example)
any help?
Solved! Go to Solution.
02-29-2012 12:13 PM
If you sue the property node one of the options is value(signaling). This will cause the event ot fire in the event case. See below:
02-29-2012 12:38 PM
Tim's reply is the answer you are looking for.
I would like suggest that you create a sub-VI that doesw the work in the second event you want to fire so tht rather than resorting to having one event trigger another, you can simply use the sub-VI that does the work in event_2 after the sub-VI that does the work for event_1.
If you decide to stick one event triggering another, please clearly document the sceme in BOTH events. What you want to avoid is latter deciding event_1 should be triggered by Event_2 and the next thing you know, your app hangs.
Ben
02-29-2012 12:45 PM
Setting a local variable does not trigger an event - you'll have to use Value (signaling) as suggested, or a user event. Also, I see in your VI that it contains only an event structure. You need to put your event structure inside a while loop, otherwise it will exit after the first event occurs.
02-29-2012 01:52 PM
Your VI should look something like this
02-29-2012 11:06 PM
Ben,
Don't worry. I document the **bleep** out of everything.
Nathand,
Yeah, I just threw that together to show a simple demo. I didn't want to upload my whole project and have you trace everything just to answer a simple question. My actual program has the event structure inside a while loop.
Tim,
Thanks for the help.
06-13-2017 09:47 AM
One caveat to the example solution provided by Aeastet is that if you are going to use a Value(Signal) property node to fire the event then the Mechanical Action of the Button associated with the automatically fired event cannot be Latching ... it must be Switched.
06-13-2017 10:32 AM - edited 06-13-2017 10:35 AM
Unless you are a very skilled LabVIEW programmer, I would recommend to stay away from signaling value properties. Also note that the signaled "value changed" event will fire even if the value of boolean 2 did not change, i.e. if you wire the existing value to the signaling property.
Sometimes there are better solutions, for example you could just have one single event for both booleans and use a few case structures to determine what should or should not execute. No need for multiple event cases.
(I assume that boolean 2 can also be operated individually and should only trigger the second event.)
If the booleans are latch action, they are always TRUE when manually triggered (unless the default value is different), so you could just use a sequence of case structures as follows. For switch action booleans (like yours at the moment, but why are they??), you could determine from the ctrlref event data node which one got operated and use that information similarly.
If allowed, you could even have the two cases execute in parallel (for better performance) by eliminating the data dependency, but that depends on the problem.
Here is a quick draft how it could look like (using latched booleans).