LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

vi cleanup

Good morning,

            This might be a bit unusual, but I am putting this out there strictly for comments and opinions.  It does exactly what I want it to but I think it looks pretty ugly and am wanting some opinions on how to make it more effecient, eye appealing code, or just 'better'.

 

What I am doing is allowing the user to select from a drop down list of available files , press 'Process' and it reads a CSV file that is two columns of strings, 3 columns of doubles with a header row.  I am wanting to sort the data out to one array of strings for channel names, and a 2D array of strain variables.

 

I am then also allowing the user to decide how many strain channels will be used and if there is a tach channel to be included with the data file, and where the user wants the data file to be saved.

 

All this data will be gathered together into a cluster and sent to the main VI which will then provide the daqmx and display functions.

 

The 'OK' button is the stop button.  I have included the relevant subVI as well as an example CSV file.

 

Thanks for the time.

 

Tim

Download All
0 Kudos
Message 1 of 4
(2,549 Views)

I would recommend using an Event Structure.  You can make a Process->Value Changed and a Stop->Value Changed events to handle your button presses.  Use a timeout.  Something like 100ms should be more than fast enough.  Then I recommend using shift registers instead of feedback nodes.  The shift registers will be a little cleaner in this instance.  I also thing you are writing "old" values (a loop iteration slow) to your cluster due to the location of the feedback nodes in the wire path.

 

Avoid wires that go right-to-left.  That makes things a lot harder to read.

 

If you are getting a single colum, use Index Array, not the Array Subset and then having to reshape the array.

 

If you are using the Delete From Array with the length set to 1, just don't wire it up.  It will be a little more efficient and easier to read.

 

Don't read the file twice.  File IO is the slowest thing you could do.  Just read it all as strings and then convert the values that need to be doubles.

 

Here is your subVI cleaned up.  Much easier to read.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 2 of 4
(2,526 Views)

Perfect!  Thanks.  l attempted shift registers when I first put it together, but of course you can't put shift registers on a case structure, I don't know why it didn't occur to me to put it on the while loop. Much better, and down to one instance of open file.  Thank you for the ideas. 

 

I will look further into incorporating the Event Structure.

 

Tim

Message 3 of 4
(2,499 Views)

Dear Tim,

 

crossrulz solved your problem rating 5* obviously, so please accept a solution or give Kudos, whichever is appropriate. Thank you in the name of the community.

 

Cheers,

0 Kudos
Message 4 of 4
(2,427 Views)