10-16-2009 08:03 AM
Hello,
how can I solve this problem?
I have several events and several routines to be performed.
Event A should start routine 1
Event B should start routine 2
and
Event A or B should also start routine 3 (if A or B or both)
How can I amplement that?
First I tried to add two more event cases for each A and B, that does not work.
Then I tried setting a flag by changing a boolean value in event case A and in event case B. By creating another event case for that boolean value change, I could run routine 3, but that does not work either (the event structure does not recognize the change of the boolean value, probably because some other event case is performed when the boolean value changes?).
Now I am thinking of simply copying the code for routine 3 into both event cases for event A and B. 😞
Is there a better way?
Johannes
LabVIEW 7.1
10-16-2009 08:05 AM - edited 10-16-2009 08:07 AM
04-06-2010 11:18 AM - edited 04-06-2010 11:21 AM
And this is what a producer-consumer system is for. Trigger the sub-routines via queues or notifiers. Here is a simple example
04-06-2010 11:31 AM
Jeff has given the best answer because it is scaleable.
Something quicker and dirtier is to put a case structure after the event structure but still inside the while loop. (Assuming your event structure is in a while loop.) The A and B event set a boolean to true. This gets wired to the case and in the event of true, the 3rd process starts. (Make sure to wire all other cases to a false boolean.)
Another way, which I think you were trying, is to fire an event in the event structure. To do this you have to have a front panel control. Let us call it ButtonC. Get a reference or property node to ButtonC. You will need one each for event case A and B. The property you are looking for is Value(Signaling). The Signaling part means that changing that property will create an event. Wire this to your change value and then create the ButtonC change value event.
Wiring a boolean to a control won't cause an event.
04-06-2010 12:08 PM
04-06-2010 12:18 PM
Why would you use Dynamic Events. A simple event structure would do:
04-06-2010 12:23 PM - edited 04-06-2010 12:28 PM
tbob wrote:Why would you use Dynamic Events. A simple event structure would do:
![]()
I might not want two copies of Event 3 subvi.
looks easy 2 me...
"Now I am thinking of simply copying the code for routine 3 into both event cases for event A and B. 😞 "
04-06-2010 12:36 PM
04-06-2010 02:03 PM
Tbob-
I'm a bit uncomfortable with your solution. Putting sub vis in events should be practiced with caution. The event woun't complete until the sub-vi returns and the UI becomes unresponsive. Same with the case structure outside the event but in the while loop. you block the event structure from firing untill the case structure completes. You could dynamically lauch a vi and set wait for completion to False- but it better be a reenterant vi so it does not block itself and cause the same problem (since the invoke node won't return until the vi launches- or it returns an error if it waits too long (Hmmmm what's the time-out? is there one?)
IM(not so)HO, It's much more desireable to disconnect the event and the reaction to the event with a P-C archetecture.
04-06-2010 02:07 PM
cgibson wrote:Jeff has given the best answer because it is scaleable. Thanks
Another way, which I think you were trying, is to fire an event in the event structure. To do this you have to have a front panel control. Let us call it ButtonC. Get a reference or property node to ButtonC. You will need one each for event case A and B. The property you are looking for is Value(Signaling). The Signaling part means that changing that property will create an event. Wire this to your change value and then create the ButtonC change value event.
Wiring a boolean to a control won't cause an event.
Caution here too. The Value property does not fire an event. The Value(signaling) property ALWAYS fires an event even if the value does not change (be sure to compare OldVal and NewVal to fire only when changed )