I have a producer(event handler) and consumer(state machine) structure. One of my states says: display message, then wait 5 sec, then display something else, then wait 3 sec, etc, so I have 5 timers with countdowns using the Elapsed time vi.
I also a have a function which is supposed to start this state all over again, so all the timers need to start at the initial time.
For some reason, this is not working, although I am using the reset function on the elapsed time.
Has someone done this before and now how to reset the timers in a producer consumer loop?
Solved! Go to Solution.
Perhaps if you included your code it would be more clear what you are trying to do. It sounds to me like you're wanting to start multiple timers simultaneously, but I may be misunderstanding. If this is the case perhaps you need to build your own elapsed time code - it's really simple.
What is going on here? Why the Producer/Consumer architecture? Is this part of a larger program?
Your queue utilization is a COMPLETE mess and you therefore have race conditions and circular code. You need to implement a proper state machine in your message handling loop. DO NOT LET THE PRODUCER DIRECTLY SET THE STATE. A little trick I do here is to use the queue timeout. You can store the timeout in shift register so you can change it. Set it to -1 to wait forever or some other value. On a timeout (ie, you did not get a message), you perform the next state in your state machine. If you got a message you handle it. Use another shift register to set whether or not to reset your timers.