08-01-2013 02:01 PM
Hi guys,
I have a hard time to understand others code.
Can someone tell me the 200 iterations I marked(yellow) in the file, where that number come from
I think it somehow relative to the left side number 4 and 50 but I am not sure
Thanks
Solved! Go to Solution.
08-01-2013 02:39 PM
Not enough code is shown to figure it out. I'm guessing a local variable or property node for the "pause" button is written - either in another case in the case statement, or by the orange wire that drops off the bottom of the image in the middle of the right hand side.
08-01-2013 02:45 PM
These yellow blobs are not LabVIEW objects and they are not even near any relevant LabVIEW code. I don't see where "iterations" would come from. You don't even show a loop (except for part of a left loop border)!
You need to attach the actual code.
08-01-2013 02:52 PM - edited 08-01-2013 02:55 PM
You need to show more code. What you are displaying is an inner Case Structure (a conditional statement that can handle different opperations depending on True or False evaluations -- This is like an "if" and "else if" statement in textual programming languages).
You need to show us where the boolean for "pause" is because that is stopping the outer While Loop (and juding by the comments, there may be even more outer loops than that. It is hard to tell). This will likely explain why it is running 200 iterations. The case structure just handles different opperations depending on which iteration it is on.
What you are seeing are just textual comments. These are created by double clicking anywhere and typing. They are used to help document code for future readability.
08-01-2013 03:12 PM - edited 08-01-2013 03:13 PM
Thank you all for reply
The actual code are pretty big and I am not sure someone can take that much time to take a look.
My question was at "Sweep Conditional', the last block inside the while loop
The all yellow blobs were all my drawing for easy find, sorry for the confusion.
I knew the they are just textual comments which is why I am asking the question about 200 because I did not get it
Thanks
08-01-2013 03:23 PM
The loop will stop when the stop button is pressed and under no other conditions.
(Sorry, this code is unmaintanable. My monitor is not big enough to really look at it.)
08-01-2013 03:30 PM
I knew the stop button in this case
I just do not know there the 200 come from inside the "Sweep", I mean how the 200 been counts
Thanks anyway
08-01-2013 04:46 PM
Wow, this code shows some very bad practices.
It's not really 200, it's 50. And it's based on Temp Setpoint, Current Temp, and some value that ends up in a shift register. Oh, under the "Temperature Monitoring Graph" label, there's an Increment that gets compared to 50. Set a conditional breakpoint to pause at 49, turn on highlighting, and try to read the tea leaves.
08-01-2013 06:10 PM
Wow! About the only things you can say that are good about this code is that the wires are relatively neat (though they do flow under objects and backwards at times) and there appears to be lots of comments. Whether the comments are accurate or not is another matter. Beyond that this code is screaming to be rewritten so that it is easier to understand and maintain. There are much better design patterns to use such as a state machine. That alone would help this code dramatically. More use of subVIs would also help quite a bit.
Just out of curiosity I ran this through the VI Analyzer and it failed 40 out of 86 tests. Half of the tests that failed reached the maximum number to report so I am not sure how many instances of these specific tests there actually are. BTW, the block diagram is 8740 x 1124. The cyclomatic complexity was quite high. As reported: "The diagram of this VI has cyclomatic complexity of 117 which is more than the user-specified limit (20). Code with high cyclomatic complexity is difficult to debug and maintain. Move some decision points (case structures, loops, etc.) into sub-VIs so that each module can be tested independently, and easily maintained."
I feel sorry for you or anyone else that needs to work on this code.
08-02-2013 07:47 AM
Perhaps the only thing about this code that is connected to the Real World is that the FP has a "little, bitty" control to the left and above everything else that is labeled "Region of Interest" and when you go to the BD, it's not connected to anything. There's a whole lot of other stuff that's not connected to anything, too, especially error wires that start at seemingly random places and then just stop, like the original writer didn't really want to know what errors there might be.
Cameron