LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

simplying my code

hi there.
can someone give me pointers on cleaning up my code?








Message Edited by krispiekream on 05-13-2008 06:04 PM
Best regards,
Krispiekream
Download All
0 Kudos
Message 1 of 27
(4,490 Views)
I don't think anyone can clean up code by looking at an image of it, especially since we don't know what all the subpanels are doing.
 
It seems the globals are used to communicate with the subpanels. Is this correct?
 
First you need to answer the most important question: Does the program work correctly? Are there performance issues?
 
If it works, it is probably not worth throwing more man hours at it unless there is a good reason.
 
There are plenty of very awkward code constructs. I already mentioned some of them (e.g. the small inner while loops) elsewhere.
 
Here are some pointers:
 
Look for duplicate code and consolidate it onto a FOR loop. For example, you need only one "insert VI" and all the trimmings, if you would
just autoindex over an array of filenames. (upper right). Same for reading all the files below it.
 
Here are some other random obervations, your code is full of similar things:
 
Setting a boolean array to all false while keeping the size the same can be done in many ways. The lower one is probably more efficient.
 
 
Creating an interger array of 0...19999 can be done without a shift register (bottom).
 
These are really just details. You probably should work on the overall dataflow. The problems are much deeper. 🙂
 


Message Edited by altenbach on 05-13-2008 04:37 PM
Download All
0 Kudos
Message 2 of 27
(4,466 Views)
yes, the code works probably. throwing more man power is okay.
i have nothing better to do but play with improving my labview skills anyway..Smiley Very Happy

it used to be stacked sequences and i turned all the sequences into that.
the stacked sequence is smaller, but it has alot of frames. 10....
i just want to make sure that 1 big frame is better than 10 stacked frames..
i still believe that the stack sequences does look better if i am just looking at the block diagram.





Message Edited by krispiekream on 05-13-2008 06:44 PM
Best regards,
Krispiekream
0 Kudos
Message 3 of 27
(4,460 Views)
A few comments:
In the top-left you change the value of the table every-time, I don't think there is a need for it.
In the center you build a path with string functions, bad-bad-bad. In the top section you do absolutly the same in the correct way.
I would create several initialize states, one for every function: set-locals, set-globals, fill sub-panels, load CSV's
The lower-state machine is string based, replace this with an enum.
Don't us the Stop.VI function, create a special exit-state for this.
Use clusters to hold various data-types, an array with strings you convert at will is a bad idea (what is the localization point is changed?)

If you can get your hands on the State Diagram Toolkit use it, create your state machine, fill in your code and rewrite.

Good luck,

Ton
Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
0 Kudos
Message 4 of 27
(4,435 Views)
thanks for your help!!!

Best regards,
Krispiekream
0 Kudos
Message 5 of 27
(4,387 Views)
can you give me a little more details on this?
"I would create several initialize states, one for every function: set-locals, set-globals, fill sub-panels, load CSV's"
i am not quite understand this one.
thanks
Best regards,
Krispiekream
0 Kudos
Message 6 of 27
(4,380 Views)
In you lower half of th screen you have a while loop with something that looks like a state machine.

In this state machines I would use several initializer states.

Ton
Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
0 Kudos
Message 7 of 27
(4,377 Views)
"In the center you build a path with string functions, bad-bad-bad. In the top section you do absolutly the same in the correct way."

i tried to do this..but it does not work

am i approaching that method the right way?





Message Edited by krispiekream on 05-19-2008 02:35 PM
Best regards,
Krispiekream
0 Kudos
Message 8 of 27
(4,363 Views)
ok, everything is working now.
thanks!
Best regards,
Krispiekream
0 Kudos
Message 9 of 27
(4,352 Views)


krispiekream wrote:
i tried to do this..but it does not work

Get rid of the "\" in the strings!
0 Kudos
Message 10 of 27
(4,351 Views)