12-06-2012 04:15 AM
Hey Everyone.
Hope you can help me yet again. What I need is actually tips, because my code works, its just that examples I see around the internet makes think I could do it better.
So I am using QSM inspired by the very nice guide in http://expressionflow.com/2007/10/01/labview-queued-state-machine-architecture/. My issue is how to create the queue references so that the name of the queue shows up in the bundle by name. The only way I can get it to work is by using the obtain queue function and then passing the queue out to the bundle by name, with this strategy the unbundle by name just says "queue out". See attached (1 VI and two typedefs that are required for the VI to run). Since I have 5 different queues it is tedious to remember in which order I ranked them...
Also, in my example I haven't put a sequence around my SubVi like they do in the guide. Simply because my code works just fine without. Can anybody explain the usefulness of the sequence structure?
I hope you can help
Atamsih
Solved! Go to Solution.
12-06-2012 04:17 AM
I've also made this picture that demonstrates what i want from the example in the guide that i linked to... I added the stuff in red.
12-06-2012 04:22 AM
Hi
i could not open your VI as i do not have LV 2011. however, i checked the image you posted.
some of the answers for you:
the sequence structure around the two sub vis ( at the bottom of the picture) is to ensure that the two sub vis start running after the False value is written into the Exit local variable. that is, when the Exit is initialized to a false value, the while loop and the two sub vis begin to execute.
to get the queue names in the cluster, just name the queue reference constants at the bundle function with the names you want
to get the bundle structure on the fore-right of the picture, just create constants of all the elements you wish to bundle and wire to the bundle function
12-06-2012 07:40 AM
You can't rename a queue name. I've tried. I've actually thought this would be a good idea on the LabVIEW Idea Exchange.
As a workaround, every time I get a new queue I add a string control to carry the queue name and bundle it with the queue wire throughout the code. I use configuration files extenstively and the queue names are part of the configuration.
12-06-2012 08:11 AM
Just use "bundle by name", with a cluster constant where you set all the labels to what you want.
12-06-2012 08:30 AM
I didn't realise it was so simple, creating the queue number as a constant did the trick! This will make my script much nicer to look at.
And thank you for the information about the sequences.
To avoid compatibility problems in the future, what labview version should i save to in the future?
12-06-2012 08:31 AM
@drjdpowell wrote:
Just use "bundle by name", with a cluster constant where you set all the labels to what you want.
This is always an option, but sometimes I don't want the overhead of creating an entire new cluster and bundle it by name just to change the name of a variable in a wire. I like the "smallness" of bundle.
12-06-2012 11:01 AM
Just as a general point; I love using queues in subvi's in QDSMs. I normally make a functional global that has two or three states.
First state is "Init" this creates all of the queue referances.
Second state is "Get" fairly basic passes the queue refs that are stored in shift registers out so that they can be used in many places in the software.
Last state is the "Stop" which stops and flushes all the queues.
Makes everything nice and clean.
12-06-2012 02:26 PM
@tsksesa wrote:
Just as a general point; I love using queues in subvi's in QDSMs. I normally make a functional global that has two or three states.
First state is "Init" this creates all of the queue referances.
Second state is "Get" fairly basic passes the queue refs that are stored in shift registers out so that they can be used in many places in the software.
Last state is the "Stop" which stops and flushes all the queues.
Makes everything nice and clean.
A better system is to use a FGV with "Init", "Send", and "Close" states. Since a queue is to be a many-to-one, you initialize the queue where the queue will be read. Then you use the Send to send your commands from anywhere in your program. This keeps the queue reference contained to the reading process and the FGV. And of course Close the reference when you are performing any cleanup.
12-06-2012 10:29 PM
I would usually create a type def cluster control to be used as in my application. so i can name the queue ref as required. the unbundle by name would show me the queue ref name. it may or may not be the same name as the queue.
as mentioned in the above posts, i have action engines which are used commonly in all my projects. the one for Queue has 'Obtain', 'Enqueue', 'Dequeue', 'Flush' and 'Clear' states.
and most of my queues have data type of cluster. the cluster has a string to carry name/step/action and a variant data.