12-21-2009 04:50 PM
12-21-2009 05:52 PM
12-22-2009 08:44 AM
12-22-2009 08:54 AM
I am not very good with long and complicated sentences. Could you show us some code instead? 🙂
12-22-2009 01:12 PM
12-22-2009 01:30 PM
When you press an Abort button it flushes the queue. In your Queue loops what happens if a queue is read while the queue is empty? You do not test for timeout even though you have a timeout specified and you do not have a default case specified. What is the default value of the Action enum?
You do not need both a Wait function and a timeout in the Queue loops.
Stacked sequence structures should be avoided because they hide code and defeat the advantages of dataflow.
Local variables should not be used where wires will work.
Lynn
12-22-2009 01:35 PM
12-22-2009 01:37 PM - edited 12-22-2009 01:41 PM
12-22-2009 03:17 PM
You do have a default case specified. Because of the large number of spaces in the title "--Empty Queue-- ", I did not notice the default designation. Sorry.
When a Dequeue function times out, the "timed out?" boolean is True and the "element" output is the default vale for the datatype. You are right about the function returning immediately if data becomes available. Typically the "timed out?" boolean is tested and the appropriate action is taken if no data is in the queue. You have handled that with your default case. If the timed out action needed to be different from the action produced by the default values of the element, then your method would not work. For example if the queue element was a boolean and you did not want to change the value if the queue timed out, you would use the "timed out?" boolean to select a case which passed the old data through rather than forcing it to be the boolean default of False.
Can you set the dequeue timeout to 50 ms and eliminate the Wait function? Or is it important to take the default action after 10 ms but still wait?
What is the purpose of the timeout on the Enqueue in Queue Loop 1 which does not appear in Queue Loop 2? Normally an Enqueue would only wait if the queue size was limited and yours is not.
Lynn
12-22-2009 03:32 PM - edited 12-22-2009 03:34 PM
The only reason for the 50ms wait is that at times there will 10-11 elements in the queue and I didn't want to max out the CPU running them all back to back. The queue should never be empty except for right after a flush.
The lack of a timeout in the second loop was just an oversight. I don't think I need a timeout for the Enqueue functions in either loop - as you point out.