01-01-2011 02:32 PM
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.
01-01-2011 03:12 PM
@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.
01-01-2011 05:26 PM
I would: