06-24-2020 01:49 PM
Hi, everyone!
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?
Best regards
Solved! Go to Solution.
06-24-2020 02:34 PM
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.
06-24-2020 02:58 PM
Hi,
I want the timers to execute one after another, see attached VI and then reset.
Best regards
06-24-2020 02:59 PM
Hi,
I want the timers to execute one after another, see attached VI, and then reset.
Best regards
06-24-2020 03:47 PM - edited 06-24-2020 03:56 PM
What is going on here? Why the Producer/Consumer architecture? Is this part of a larger program?
06-24-2020 04:54 PM
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.
06-24-2020 11:48 PM
All you probably need is an single while loop containing a case structure (or maybe an event structure containing a case structure in the timeout case).
06-25-2020 01:03 AM
Yes, it is part of a larger program, where I need the producer consumer.
06-25-2020 01:06 AM
I thought this is what I do with the timeout case in the event structure by enqueing the Wait state there...
06-25-2020 01:34 AM
See if this can give you some ideas. (i.e. how to switch states after some time).