04-20-2011 06:08 AM
Hi,
This VI performs a instrument control. Some parameters need to be adjusted while VI is running.
Producer/Comsumer design pattern is used to implement it. The producer catches the events of
value change of parameters. The comsumer goes to corresponding state to deal with the change.
VI has been attached please give any your comments, suggestions, and advices. THANK YOU.
Guoguang Qian
04-20-2011 07:12 AM
I have not looked at your code from a functionality point of view (plus I did not run it).
However, I must say that it is among the cleanest, well organized code that I have read on this forum. Great job.
Your code is readable, scalable and maintainable. 3 important attributes.
You are relatively new on this forum. How long have you been coding? Very nice code.
There is only one minor thing that I might change. Not important, really...
Instead of reading the entire cluster, I would simply read the needed values in the states where they are needed.
If your code grows, you may need that real-estate in the future.
Nevertheless, it is a minor point. I still like the way you wrote your code.
04-20-2011 10:21 AM
Thank you for your feedback. I am sorry you can can run it to check its functionality.
I shoud use simulated code so you can run it without any instruments.
I familiarized with LabVIEW for long time but I am only CLAD. I am studying to persue
CLD certification. How about you? Thank you.
Guoguang
05-05-2011 11:53 AM
I agree with Ray that you have solid coding style. I would say you're ready for the CLD test if you want the certification. One thing I would suggest is to make your diagram a little smaller so that it could be edited easily on a smaller monitor. I believe the rule used to be it should fit in 800x600 but that may be too stringent now with all the nice, cheap BIG flat screens out there.
Anyway, nice job overall. Are you looking for feedback on anything specific? Have you used the VI profiling tools to analyze your code?
05-05-2011 12:19 PM
Thank you for your suggestions and for your encourging.
I am still hesitate to take CLD. But it is my goal in near future.
This code is for my test project that uesd to be data flow style.
Now I try to use design pattern to modify it. The goal is that while
test is running VI can handle UI events like START, RECONFIGHURE,
and STOP. At the beginning I use SSM to do it couldn't work. So I then
try P/C-QSM pattern. I made serveral modifications.
But I am not sure if the code is consistent with the standard way to
do the test. So I post it here. Hope someone can review it and give some
ideas to improve it.
Thank You!
05-05-2011 12:39 PM
Very Clean style! Lacks VI documentation and a meaningful icon but. Well organized scalable and readable. Nicely done!
A couple of issues with the exact implementation that you could use to improve performance.
1: there is a potential race condition that you don't see now (see #2) I would read "parameters" in the val change event and pass them in the queue.
2: in the val change event the "initialize" command should have priority over the rest of the queued up operations. since every case generates a queue cmd each time the val change event fires the length of the queue increases by 1 and this will get undesireable. Flush the QUEUE in the initialize case and in the val change case enqueue at opposite end.
Very nice work
05-05-2011 01:59 PM
Hi,
your style is good, but I'd like to highlight the fact that you used express VIs in a sub VI (I know I'm mean)
Some wires may be cleaned in some sub VIs (best for the reader)
Anyway your coding style is good, maybe a few improvements (documentation, wires) will make your code better.
Regards
05-05-2011 02:55 PM
Good code. For your CLD, I recommand using the simplest approach. Usually, a regular state machine will do the job.
05-05-2011 03:36 PM
Jeff,
Thank you for your comments and suggestions.
Based on your feedback I have modified the code and attached it.
Please review it and check if I have made something wrong.
Thank you!
Guoguang
05-05-2011 03:42 PM
JYang,
Thank you for your suggestions
Guoguang