02-08-2009 08:45 PM
I'm using a queue to pass data between two state machines that operate two tabs on a tabbed dialog. Data on the setup tab is supposed to be placed on the queue in one state machine and retrieved by the second state machine.
When run, the queue always returns the initial data that I used to set up the queue.
I worked from the Queue Basics vi, modifying the data type and the queue length.
I went back to that example and made the same modifications and it worked ok. The only difference then is the use of state machines instead of simple while loops.
I have attached an image of the two state machines linked by the queue.
Solved! Go to Solution.
02-08-2009 09:12 PM
Do you have any wires from the left hand loop to the right that aren't showing in the picture? How are you determining that nothing is popped off the queue? Is the state required to write the values to the queue in the left loop being met?
02-08-2009 09:29 PM
Debugging from screen shots is typically difficult - it's even more so when we don't get to see the entire block diagram.
Can you post the code itself?
Mike...
02-08-2009 09:30 PM
Thanks for picking this up Putnam.
The loops are entirely independent, that was the point of the queue. I have highlighted the execution and watched the values being popped off the queue. When the data on the setup tab are modified, the modified values are bundled and the bundle is placed on the queue, but the bundle that is popped is always the initial one.
I have a work around for now as you can see using local variables to pass the data, and the queue simply synchronises the two loops.
Cheers;
Peter.
02-08-2009 09:37 PM
Thanks Mike. I was hoping It would be something in the way that I had set up the queues or handled the data afterwards. I*could* post the code, but a quick count has it at about 14MB most of it runs fine, just not the queue.
I have just had another hack at the Queues example, changing the top left and top right loops to state machines, and it still runs.
Cheers;
peter.
02-09-2009 12:55 AM - edited 02-09-2009 12:57 AM
Just like Mike told, there is very little that anyone can suggest from the image that you have posted. The portion that you have posted looks perfect to me provided the data that you are passing to the queue is correct.
You might have done this already but just to confirm... have you verified (by placing probe to the 'element' input of the Enqueue VI) that the data that you are bundling and writing is different from the initial setup values?
Is there any other place in your code where you are writing to this queue?
Is the Dequeue VI giving any error?
Also, why did you limit your queue size to one?
02-09-2009 06:55 AM - edited 02-09-2009 06:58 AM
Peter Cusack wrote:When the data on the setup tab are modified, the modified values are bundled and the bundle is placed on the queue, but the bundle that is popped is always the initial one.
...
Peter.
That looks like the 'Get queue element' times out, in that event the default value of the queue is returned.
Check for 'Timed Out?' output.
Now if it times out you have a whole other problem.
Had a second look at your code, and you didn't connected time out so that won't happen.
However you have a sized queueu of length 1. What if the second (read) loop doesn't finish and don't clear the queue fast enough? Then the write loop will be locked.
Using a sized queue without a timeout on the write part is a bad move.
For a single sized queue I would recommend a notifier.
Ton
Ton
02-09-2009 05:10 PM
Thanks for the insights guys. I was prompted to try some things that couldn't make any difference, and one did.
I changed the way that the Queue is initiated to use a Bundle by Name that was initiated with Constants, rather than to use a Bundle Constant.Interestingly, the prototype for the Bundle by Name, which is required, is a Bundle Constant.
The pathology seems to be that if the Queue is initialised with a Bundle Constant, then it passes a Bundle Constant. The attempt to change the fields in the Bundle Constant by using a Bundle by Name fail without generating an error and the Queue passes on the Bundle Constant.
I have attached an image for those who can tell what a program written in a graphical language does by looking at it.
Cheers;
Peter.
02-09-2009 05:19 PM
Thanks kikiduu.
I limited the size of the queue to 1 element because I only want the Monitor loop to use the last set of setup values.If theMonitor loop was behind the Setup loop by say 10 values, then the user would have lost touch with the process. I could, with the insight that this gives, used a Notifier instead of a Queue.
Thanks again to everyone.
Cheers;
Peter.
02-09-2009 09:05 PM
I only have a couple of years experience. Something I caught on to is that the examples have a lot of legacy in them. They are ok for learning a concept, but aren't always good for using for your development architecture. Techniques have advanced a lot since some of those examples were written. You would be better off using one of the templates and expanding it using the tips you find from the veterns on this board. I played around with that example and wouldn't use it as a basis for a ground up program.