LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Clearing arrays and clusters automatically

As I said--

Trolling this board has its advantages!!!

 

"LabVIEW- Its OK to have fun" 

 

Don't forget kudos for smercurio 

0 Kudos
Message 11 of 17
(1,689 Views)

RTSLVU wrote:
Smiley Surprised OMG!

Well, altenbach is traveling, so I guess you'll just have to settle for the rest of us. I only managed a 10x reduction. Smiley Very Happy Smiley Very Happy

Message 12 of 17
(1,686 Views)

smercurio_fc wrote:

If I were doing this I would change the structure of the data as the program holds it to make it more flexible. Jeff already alluded to this. For instance, consider this structure:

 

This gives it a more hierachical structure and it greatly benefits from allowing you to use arrays to easily scale your program. For example, let's say you want to add a measurement type. Nothing to change. The data structure already takes that into account. A simple subVI can be used to parse out each section into the structure. Attached is an example (note that the clusters should be typedefs - I did not go that far) of your VI modified to use this structure. As you can see, I do the same thing you were doing in less than 1/10 of the code, and I have the added benefit of a flexible structure. I am not telling you to do it this way, but this is to show you a different approach. It's possible that this may not work too well for what you're doing in the larger program, but it should give you an idea of how to think more hierarchical using arrays and clusters.

 

As for the file format: A different file format would make the parsing a little easier, but it's not mandatory. If I were to choose a different file format I would use a standard .ini file format so that each section can be extract directly with the "Chan", "Label" being keys, or I would use an XML file format since the XML file would give me the structure directly. With XML you define your own file format. You can start here for a general introduction to XML. LabVIEW has some built-in XML tools, and you can also use LabXML or Easy XML from JKI.

Message Edited by smercurio_fc on 04-13-2009 05:15 PM

Ok, so looking at this with a freash set of eyes this morning I have to say I do not understand it (Is it an array of arrays of arrays? ) nor can I figure out how to get anything out of it with out another "Rube Goldberg" .

 

I am begining to regret taking on a project this large...

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 13 of 17
(1,662 Views)

You have arrays of clusters, and the clusters contain some form of identifier and another array of clusters. Using arrays of clusters of arrays is a common way to allow you to create varying length arrays as a "1D" structure. Multidimensional arrays require that the dimensions be rectangular, meaning that if you have 9 columns for one row, then all rows must have 9 column, even if for a specific row you only need to have 4 (and it may only make sense to have 4).

 

In this particular case I took a look at your data and determined that you basically have several lists:

 

  • List of modules, which were called "System 1", "System 2", etc.
  • List of measurements for each module.
  • Triead of channel/label/scale for each measurement


The structure I created has an outer array that's the list of modules. This is an array of clusters. The cluster contains 2 elements: module name and list of measurements that are supposed to be done with that module. The list of measurements is implemented as an array of clusters. The cluster contains 2 elements: measurement type and a list of the triads for each measurement of that specific type. This last part I arbitrarily made it into a cluster of 3 arrays, but it could just as well have been an array of clusters. This last cluster would be a cluster of 3 elements: channel, label, and scale.

At first glance this appears complicated, but it's really not that complicated if you just think of it in hierarchical terms. You're used to looking at the data in a "flat" manner which is why it appears complicated.

 

As for getting the information out, you do not need to resort to Rube Goldberg implementations. For example, if you want to get the list of measurements for a specific module, all you would need to do is this:

 

You can then iterate over the list of measurements and program your device. I don't know what's involved with this part, which is why I said I don't know how well/convenient that structure would be for you. If you show us what's involved in the actual programming of the instruments, then I can comment on that. It's possible that instead of the inner-most structure being a cluster of 3 arrays would be easier if it were an array of clusters as I had mentioned. 

 

My point of showing you this was to have you think differently, and to show that when possible, think hierarchically, as this can often make code more scalable and easier to manage.  Believe it or not. Smiley Wink

Message Edited by smercurio_fc on 04-14-2009 10:42 AM
Message 14 of 17
(1,655 Views)

Maybe I am over complicating things...

 

The data loggers have pre-fab vi's for configuring each type of measurment and scaling if needed.

 

I need to feed it the channels list and scaling factor (or "1" for no scaling)  for each measurment type

 

For instance to configure logger 1 I need to:

send the string  "101,102,103,104,201,202,203,204,301,301,303,304" to the "Config AC Voltage vi"

send the string  "105,106,107,108,109,110,111,112,113,114,205,206,207,208,209,210,211,212,213,214,305,306,307,308,309,310,311,312,313,314" to the Config DC Voltage vi"

send the string "115,116,117,118,119,120,215,216,217,218,219,220,315,316,317,318,319,320" to the "Configure Temperature vi"

 

The scaling array would get indexed into the "config scaling vi" and can be done for all channels in one shot.

 

The label (Loc) would be used when saving the data as the colum headers on the spread sheet (.csv)  

 

I had other ideas for the measurment type like making the scaled current channels display the proper units on the data logger, but it is mainly used to sort the channel by measurment type now.

 

My origonal idea was to make it easy to change the logger configuration if the test setup changes later on, I normally just hard code the channels list.

 

Right now all the data logger modules except for module 3 int logger 2 are wired indentcal and the more I think about it the chances of this changing is very slim so my efforts to implement easy flexibility using the config file may have been a waste of time from the start...

 

 

Message Edited by RTSLVU on 04-14-2009 10:07 AM
========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 15 of 17
(1,637 Views)

What you decide to do is entirely up to you. You had initially asked how to clear arrays and clusters, but the sheer overcomplication of the code you had made the query of clearing moot, as you had a much bigger issue than just how to clear arrays. Nobody here is twisting your arm to say "do it this way". What has been presented are suggestions. Whether they're appropriate for your situation is up to you. Some suggestions, such as modularization (i.e., using subVIs for repetitive operations) are universal, and your code, regardless of how you choose to implement it, would benefit from its implementation.

 

At one of the scale is complete hard-coding, meaning nothing can change as far as hardware. At the other end is programmable configuration. What I had presented was something closer to the latter. What you are talking about now is something closer to the former. You have to decide where you want the implementation to be. Remember though: somebody is probably going to be inheriting this project from you.

Message 16 of 17
(1,618 Views)

RST.....

(I won't include the "LV" portion to protect you)

 

AKA splitstring@"LV";

    return <WEC> ( Wire equivilent code)

 

I almost missed the semicolon and the <tab> / to make the comments

 

Wellcome to LabVIEW!!!

 

Turn off the auto tool selection and HAVE FUN!   (Oppps- did I <tab> or  <Caps-Lock>?````~~~~~Smiley Very Happy 

 

0 Kudos
Message 17 of 17
(1,596 Views)