From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

event structure: have one event trigger another event

Solved!
Go to solution

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?

0 Kudos
Message 1 of 8
(10,835 Views)
Solution
Accepted by topic author tir38

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:

 

Example.png

Tim
GHSP
Message 2 of 8
(10,831 Views)

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

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 3 of 8
(10,826 Views)

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.

0 Kudos
Message 4 of 8
(10,823 Views)

Your VI should look something like this

Tim
GHSP
Message 5 of 8
(10,808 Views)

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.

0 Kudos
Message 6 of 8
(10,792 Views)

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.

Jacob K
0 Kudos
Message 7 of 8
(8,554 Views)

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).

 

 

 

0 Kudos
Message 8 of 8
(8,547 Views)