11-01-2012 01:06 AM
Hi,
I am using a producer/consumer set up and I am only getting one-iteration from my consumer loop. I have probed the cluster wire that feeds the enqueue element of the producer and there is a continuous data stream there. I have a timeout wired to the dequeue element in the consumer loop and have tried different times from 1ms to 1000ms. It is currently at 25ms. There has to be something else that is causing this issue, but I am overlooking it.
I also tried adding an event handler that would detect a value change in the data. That didn't do anything. I have tried to restart my machine to no avail. I am about to shut down and take the battery out of my laptop and reboot (the act of a man out of options).
If anyone could help, I would be indebted.
P Gnu
Solved! Go to Solution.
11-01-2012 01:51 AM
Hi P Gnu
Why are you putting an event handler in the consumer loop ? Moreover there is no time-out for the event handler (default is -1 which implies that the execution of the loop will be suspended till an event occurs and hence the iteration of consumer loop is 0). You could just use a local variable for the stop control to detect the change in stop value.
11-01-2012 03:15 AM
Thanks Javed_H
I thought that I tried that, but either I didn't or I did it while there was another bug. At any rate, the time-out on the event handler did fix it. I appreciate your help.
The reason I am using an event handler rather than a local variable is because I have been told many, many times that the local variable is somewhat of a hack. They gave me other reasons, although they escape me now. I do recognize and agree, however, that the local variable would work. I'm letting the design asthetics of others dictate my code.
Thank you for your input,
P Gnu
11-01-2012 03:55 AM
Glad to know your problem was resolved.
I agree that local variables should be avoided. However the manner in which you are using event handler is not the correct way to stop the consumer loop.
Another approach would be to connect the error terminal to the loop condition of the consumer loop and move the close queue function block after the producer loop. In this manner once you click on stop, the producer loop will stop and close the queue reference due to which an error will be generated in the dequeue element block and this will stop the consumer loop.