07-04-2007 12:39 PM
@nistudent wrote:
surely that is rubbish, labview follows a data flow, if you label your variables in a manner which makes the task obvious then surely it is possible to generate a tool that allows the automatic generation of a flow diagram at least for each of the loops in the program, hence saving me the annoying and time wasting task of documenting all this code, which shouldnt have to be part of the job.
So you're saying that documenting code is not the programmers job??? That is a very interesting statement. You might as well say that Einstein should not have bothered publishing his theory of relativity, but just scrawl E=mc² on a subway tunnel! 😮
"Annoying" and "time wasting" are some pretty strong words! Maybe programming is not something you should be doing for the rest of your life then. Programming is always a big waste of time. You spend maybe 5% on the creative and fun part (algorithm developement), then waste the remaining 95% on UI usability, debugging, debugging some more, adding features, documentation, debugging again, fixing bugs discovered by customers, revise documentation, etc. It is all part of the job! And IF you look at it right, all these steps can be fun. (and with LabVIEW, they typically are!) 🙂
A well written program des not really have "variables" per se, so I am not sure what you mean by the first sentence. In LabVIEW, the wire is the variable. You have controls and indicators (Which should be named descriptively, especially if you turn them into connectors) that tap into them and retain their own data copies, as well as local variables which are simply secondary access points to front panel objects. Of course we also have now shared variables, which is again more a communication tool between independent code segements.
For documentation, It is more important to modularize your code into blocks labeled with something that describes the function. If you use descriptive names for your subVIs, you're almost there. ;).
07-04-2007 03:25 PM - edited 07-04-2007 03:25 PM
Message Edited by LV_Pro on 07-04-2007 04:25 PM

07-05-2007 03:06 AM - edited 07-05-2007 03:06 AM
@nistudent wrote:
surely that is rubbish, labview follows a data flow, if you label your variables in a manner which makes the task obvious then surely it is possible to generate a tool that allows the automatic generation of a flow diagram at least for each of the loops in the program, hence saving me the annoying and time wasting task of documenting all this code, which shouldnt have to be part of the job.
One thing that has not been mentioned well so far. IMO documentation of software especially software written in LabVIEW should not even attempt to document the actual code, which in the case of LabVIEW is already graphical, just in another way to fill a few more hundred pages when printed out. The opposite is true! It should give a concise overview of what the software does globally without bothering about every single loop, LabVIEW primitive etc. All an automated tool could do is recreate the exact details as are already present in the LabVIEW diagram in yet another graphical way and in such a way fill probably several 100 pages with some sort of clueless graphics that are easily implemented in a single screen LabVIEW diagram (a modest UI state machine for instance). Except wasting paper it won't do any good for anyone since nobody will bother to look at such an idiotic thing as looking at the LabVIEW diagram will be a lot more straigthforward anyway.
This of course does assume that you took some care to follow at least a minimal style guide in some way. Maybe a different documentation after the fact could be helpful if you created a program that consists of many stacked sequences, countless globals and locals and a diagram that you have to scroll over 10 screens to see what it does, but such a diagram can't possibly be analyzed by an automated tool intelligently after the fact and if you still would attempt that, such a tool would either have to give up at some point (if it is smart enough) or create a documentation that would be even worse to read than the original diagram. So there you are again with manually creating such documentation after the fact and in fact spending that time instead to clean up the code and make it more readable might be much better spend time IMO.
Program documentation should IMO rather give a very global picture of the entire application structure, and in many cases can also go on a different documentation level into detail by documenting a particular algorithme or something but it should not be yet another way to say exactly the same that the LabVIEW diagram already does, and here is where the automated tools simply can't help since they only can stupidly translate but not comprehend what the code does.
Rolf Kalbermatter
Message Edited by rolfk on 07-05-2007 10:16 AM
07-05-2007 06:46 AM
07-05-2007 07:05 AM
or whatever the LV equivalent of that would be. The rule of thumb I use is that in general I don't try to explain how LV works and I don't describe things that are obvious if you simply read the code. You need to expend the ink on explaining the things that might not be immediately obvious. For example I have a technique for doing limit checking on an entire array of values at once even if there is a different limit for each value. This technique depends heavily on the way LV propagates and responds to the floating point value "NaN" and the way it works is certainly not "immediately obvious" - so I document the heck out of that.printline(); \\print a blank line
07-05-2007 07:40 AM
Hmmm... I think we have to make the distinction between :
mikeporter a écrit:
In the past there have been people who have proposed structures like, "Every line of code shall be documented" which in variably led to things like:printline(); \\print a blank line
We have two ears and one mouth so that we can listen twice as much as we speak.
Epictetus
07-09-2007 02:40 PM
07-10-2007 06:25 AM
Ok, we're getting somewhere. I like the feedback I am getting. Just to clarify a few points
A) I have been asked to produce documentation of my code so that it can be programed in a different language, (embedded C). my labview code is fully documented to sytle guideline etc, but obviously this isnt much use to someone who has never seen labVIEW before. so it is far more the paper format I am talking about.
B) by variables i meant controls, (and indicators) ie each "local variable" is a refering to the original control. By naming them something of use ie. "motor speed" then it would be pretty obvious what was happening at the point where you write "20" to "motor speed" in an automated documenter. The way I have written my VISIO diagram is to have an intial page with all the controls on them and every time they are read or written to i have a reference to that control. now i appreciate this makes data flow for linear flow diagrams a tad dificult but it is the same when reading a piece of labview code and determining the flow and if any race conditions are occuring.
I have broken down every case into a flow diagram and every subVI in the case into a sub VI. I dont have any globals etc and am using a standard state machine format.
surely there is a standard out there that people use to document labview code for other programmers in a different language, and if yes surely there must be a way to automate it so that we dont have to spend 95% of our time doing the "non-interesting" and highly time consumeing side of our jobs as by the sound of it we'd all be alot happier. Lion tamers and all.
ps. I like the vi heirachy idea as a simple overview.
07-10-2007 06:53 AM
07-10-2007 07:18 AM
Other than the fact that you are abusing locals as variables (they should normally only be used to update control values or in quick and dirty apps), you're also ignoring the fact that there can be many ways in which a piece of code can be written and that an automated tool can not be taught just one of them. You say you're using a standard state machine format, but there is no such thing. There are common formats and there are templates provided by NI, but there is no standard.
In the same way, there is no standard for documenting LV code. There are numerous options like:
For what it's worth, I don't think there is usually any real point in documenting LV code for other languages. When you write code, you're supposed to use it, not to go and rewrite it in another language which may have a completely different paradigm. If you do want to rewrite, you usually take the design documents which were written before the code and you might use the code as an additional resource.
What you do usually document for other languages are interfaces. For example, if you were going to export LV functions in a DLL, then you would document the interface so that it could be called from other languages, but not the internal document. An example of this would be when I interact with an external DLL - I am given the documentation of the interface, but I have absolutely no idea what the code looks like.