LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

question regarding event cases

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

Greetings Johannes
Using LabVIEW 7.1 and 2009 recently
0 Kudos
Message 1 of 12
(3,554 Views)
instead of using an event you could use a state machine to accomplish this, but if you prefer using an event case you can use buttons to signify your event A and event B and use the value change event
Message Edited by Harold Timmis on 10-16-2009 09:07 AM
Harold Timmis
htimmis@fit.edu
Orlando,Fl
*Kudos always welcome:)
0 Kudos
Message 2 of 12
(3,551 Views)

And this is what a producer-consumer system is for.  Trigger the sub-routines via queues or notifiers.  Here is a simple example

 

 three consumer.png

Message Edited by Jeff Bohrer on 04-06-2010 11:20 AM
Message Edited by Jeff Bohrer on 04-06-2010 11:21 AM

"Should be" isn't "Is" -Jay
0 Kudos
Message 3 of 12
(3,420 Views)

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.

Message 4 of 12
(3,413 Views)
If I didn't want a state machine, I'd use the Event Structure and Register For Dynamic Events. Have case A and B fire the C event.
Richard






0 Kudos
Message 5 of 12
(3,401 Views)

Why would you use Dynamic Events.  A simple event structure would do:

 

Events_BD1.png   Events_BD2.png

 

 

- tbob

Inventor of the WORM Global
0 Kudos
Message 6 of 12
(3,393 Views)

tbob wrote:

Why would you use Dynamic Events.  A simple event structure would do:

 

Events_BD1.png   Events_BD2.png

 

 


I might not want two copies of Event 3 subvi.

 

looks easy 2 me...

And the Op expressed that repeating the code is undesireable:

"Now I am thinking of simply copying the code for routine 3 into both event cases for event A and B. 😞 "

Message Edited by Broken Arrow on 04-06-2010 12:28 PM
Richard






0 Kudos
Message 7 of 12
(3,387 Views)
I would like to point out the original post is 6 months old :). I hope he got his answer by now. That said, I guess it's always good to provide answers in case someone else comes along with the same problem.
0 Kudos
Message 8 of 12
(3,350 Views)

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. 


"Should be" isn't "Is" -Jay
0 Kudos
Message 9 of 12
(3,330 Views)

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 Smiley Wink )


"Should be" isn't "Is" -Jay
0 Kudos
Message 10 of 12
(3,329 Views)