LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Producer/Consumer(Events)

I am trying to practice using Producer/Consumer(Events) design pattern.  In the attached VI I'm trying to control 3 LED's using front panel controls.  I'm not sure how to extend the time that the LEDs remain lit.  My first guess would be to continue queing a given state until a timer expires.  But, from what I understand, it's not good practice to add to the que in both the producer and consumer loops.  Any advice will be appreciated.  Also, is there a possibility for a race condition in the way I terminate the program on STOP?

 

Thanks in advance.

Message 1 of 3
(2,489 Views)

 


@Vi Joe wrote:

I'm not sure how to extend the time that the LEDs remain lit.


 

You could use the timeout of "dequeue element" and reset to false after the timeout or after another button is pressed. You don't need the wait state.

 

Also make sure to make the enum into a typedef, else this will be difficult to maintain once you want to modify the possible states.

 


@Vi Joe wrote:

Also, is there a possibility for a race condition in the way I terminate the program on STOP?


 

No, that looks OK.

 

Here's a quick draft. In order to eliminate case bloat, I would combine the color events and simply check which one got pressed.

 

Message 2 of 3
(2,482 Views)

I would:

  • stop consumer with Error (it didn't stop, just kept going to init when queue was released)
  • remove ES timeout (this kept enquing waits, making the consumer not respond when the button was pressed)
What a way to spend New Years Day. 🙂

 

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

Message 3 of 3
(2,467 Views)