LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

first use of queue--advice?

Just wondering if I could get some feedback on my use of a queue. I'm not 100% sure if it was the best option for what I'm doing but I figured I would try it. I had this program working before but it was a huge mess and this has greatly compacted it. I figured at the least it is good practice. I know wires can be straightened, run when open, set certain connectors to required etc. I'm mainly looking for advice on the actual code as I can worry bout other aesthetic stuff later. Thanks!
0 Kudos
Message 1 of 4
(2,688 Views)

The first thing I noticed was that it does not look like you are releasing your queue when you are done with it.

You have error clusters strung through but no error handling that I can see.  A good practice is to use shift registers on your error clusters and place your dequeue in a case with the error cluster wired in it.  That way if an error occurs, you can run an error case to handle it instead of dequeuing that loop.

 

You have a lot of enqueuing and not a lot of dequeues.  It looks like you are running your stated with the preview queue and then dequeuing inside the subvi to get the item out of the queue...  I would suggest running the tates from a dequeue and anything that needs top be scanned constantly, do that in an idle case.  this is done by setting a timeout on your queue and if it times out, send an "idle" to the selector on the case

 

It also looks  like you are enqueing a lot at the oppisite end.  This may be necessary for you your doing, but that can result in your queue building up (i.e. adding more to the queue than you are reading off, espically since you are running your cases from the preview)

 

I can look at it in more depth later but those are the items that pop out at me.

 

You may also want to change your top loop to use an event structure and move all those sub vis that look like they are monitoring or scanning into an idle case as I described earlier.  

 

Try doing a search for "queued state machine" and you will probably find quite a bit of nice advice/archatechure/templates/etc for what you are trying to do.  Specifically it look like you are trying to use it as a producer consumer dual loop structure.....

 

Hope this helps a little

 

Cheers

Greg
Gregory Osenbach
Message 2 of 4
(2,670 Views)

If not using events as suggested on the upper post, at least use a wait on that polling loop (upper loop). Does not look too bad, that code. Implement what you learn and keep on comin'. I hesitate to fight minor miscoding until next revision.

 

Felix

Message 3 of 4
(2,654 Views)
Thanks for the input.

F. Schubert wrote:

If not using events as suggested on the upper post, at least use a wait on that polling loop (upper loop). Does not look too bad, that code. Implement what you learn and keep on comin'. I hesitate to fight minor miscoding until next revision.

 

Felix


Unfortunately there probably wont be a revision by me. This is for my job while at college but Im graduating next weekend and going off to the "real world" where I'll also be using labview. I will direct the person taking over for me to this thread though if they need any advice.I just wanted an overview that I can take with me cuz im sure this wont be the last time i see this architecture :). Thanks again, these forums are helpful as always!

0 Kudos
Message 4 of 4
(2,639 Views)