05-31-2006 06:20 AM
05-31-2006
07:13 AM
- last edited on
11-13-2025
03:48 PM
by
Content Cleaner
quick advise without really talking about how it is coded :
- you certainly agree that it looks a bit like spaghetti, no ? So, the first basic goal, should be "make it more readable"
- then, what if next week you have to add a new function ? Second advice "make it modular", I would advise to work on the architecture (state machine)
- some operation don't have to be performed at every loop execution...
- I also think you can use less local variables and less property nodes
By the way, have you read the "LabVIEW development guidelines" ?
Hope this helps
We have two ears and one mouth so that we can listen twice as much as we speak.
Epictetus
05-31-2006 07:49 AM
I agree with Titou.
Wow! That's an eye-full.
There are some functions like setting audio On / Off that may not need to be in there. Or do they? You'd have to describe what the loop is supposed to do. Same comment for the indicator display settings on property nodes. Do you intend to turn them on/off a number of times during an iteration of the loop?
You should "divide & conquer". By that I mean, use sub-vi's that are function specific. As mentionned by Titou, you should have a look at the development guidelines. Basically, now that you have a working loop, you can improve it by creating some sub-vi's, revisit some items that may not need to be in the loop. As a matter of fact, you could create some control & indicators and maybe transform the loop into a sub-vi as well. 🙂
There are many Case Statements that you could convert to sub-vi's and that way, you could eliminate the global variables by using indicators and wiring directly to them.
However, I would have to say that the value for "Write Flow Data" might become unpredictable due to race conditions. Revisit how the value(s) are set for that one.
But it does look like you had some fun doing this one. Which is the most important thing. To have fun implementing solutions with LV. 🙂
Happy wiring!
JLV
05-31-2006 08:14 AM
Attached is a very basic queue-event structure for your reference. hope it helps 🙂
Best regards
05-31-2006 08:17 AM
hi there
your first LV app and you're using unitialized shift registers and an event structure? well, not that bad in my opinion...! i've seen code much worse inside vi.lib:-)
in addition to the others i suggest to use the event structure whenever it's possible instead of polling controls. that will improve your apps performance. then i recommend to use these famous FGV (fuctional global variables or LV2 style vis. search this forum for more information) instead of global variables. once you have learned how to deal with them you will always use them (well, so do i). i attached an easy example (a picture says more than 1000 words..)
05-31-2006 08:24 AM
We have two ears and one mouth so that we can listen twice as much as we speak.
Epictetus
05-31-2006 08:29 AM
My apologies...
I quickly created the VI for queue structure... and when I mean enum, I am talking about for those Ring controls that already in his VI.
I have queue structure either using enum or string array. I'll leave it open.
Thanks!
05-31-2006 10:09 AM
05-31-2006 10:30 AM
05-31-2006 10:33 AM