06-27-2007 11:53 PM
Can someone explain to me how to effectively utilize queues and notifiers? I understand the fundamental difference between the two but I am having a difficult time establishing when I should use one over the other or how to utilize both of them at the same time.
Essentially what I currently have is a master loop that contains (among other things) an event structure. The event structure contains controls which dictate when notifiers are sent and destroyed. The notifiers “turn on” other loops (all within the same sequence frame as the master loop). These other loops are used for various controls, data logging, etc. Within some of these “sub-loops” I would like to step through a sequence of events – this is where I’m having trouble.
Here is what I would like to happen: When the user clicks a certain button, a notifier is sent to sub-loop-A and it begins to run. The user then selects from a pull-down menu one of a few different options. Depending on the option selected, a specific set of events occur (whose progress is dictated by both user interaction (pressing buttons) and successful events (data being fed back). I would then like the sequence to “reset” and allow the user to select another option from the same menu – I don’t want to exit all the way back out to the main loop and force the user to re-select sub-loop-A again. However, if from the front panel the user selects sub-loop-B I would like sub-loop-A to exit and sub-loop-B to begin running. I have attached a sample of the basic layout I have so far (in LV 8.2) – I apologize in advance – I’m still learning labVIEW and I’m probably not going about this in the most efficient manner.
A couple other things to note – I’m trying avoid polling because speed is important. Also, the template I’ve attached is far from complete – it will require additional sub-loops and additional sequence loops (which I have been advised to use que-based state machines - which I'm also not familiar with).
Any assistance you guys can provide would be great – examples, web links, etc.
Thanks again!
-Erik
06-28-2007 12:23 AM
Hi Erik
Could you post it as LV8.0 as well?
Thomas
06-28-2007 03:20 AM
06-28-2007 10:46 AM
06-28-2007 11:44 AM
06-28-2007 06:00 PM
O.K. - I am still struggling with this. Disregard the last VI I posted - here is a much more compact and commented one (in V8.2 and V8.0). I have received some great feedback from you guys but I'm still not seeing how to lay this out properly - this VI obviously doesn't work but I think it should give you an idea of what I'm trying to do. Any assistance would be greatly appreciated - also, since I'm a beginner feel free to give me good habit/bad habit advice.
Thanks!
-Erik
06-28-2007 10:12 PM
In your second loop, you have two wait on notifiers in a row. Is that what you want to do? I believe it would wait at the first for a notification, get that, move to the second and wait there until another notification comes in. Which won't happen unless the change control command value changes twice. (Wait a minute, last minute observation. Maybe that is happening since it is value change. It will get a new value when pressed, and get another new value when the control is read and latches itself back. Perhaps you would want to set it to Mouse Up instead of value change. Or put the case structure in another case structure so it only executes when the value is true.)
Why are you using extended precision numbers for your notifiers? It looks like a integer would be fine. Probably not a huge difference in memory, but it is unusual to specifiy an extended precision representation.
In Send control command event, you have a case structure. In each case you obtain a notifier for auto and manual, but you only send a notification on one. Why obtain the other?
You may want to obtain your notifiers at the beginning of the program and pass them them to each loop and through each loop using shift registers. I believe each time a notifier is obtained, it uses just a bit more memory. If this is a long running programming, it may lead to memory leaks over time.
Just a few comments on what I observed. Maybe some things don't apply because this is example code rather than your actual code. Otherwise your code seems neat and orderly, and I don't see why this shouldn't work.
06-28-2007 10:51 PM
06-28-2007 10:59 PM
06-28-2007 11:13 PM - edited 06-28-2007 11:13 PM
Yes, I think the is an ideal situation for using notifiers.
I decided to go one step further and clean up the code using only single obtain notifiers and passing the references around by wire.Message Edited by Ravens Fan on 06-29-2007 12:14 AM