LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Remembering an undefined number of arrays.

I have an undefined number of arrays (usually 3-5, but can be different) which i need to 'remember' within a LabVIEW VI. Each array may need to be called up in the future for a variety of things, or even overwritten.

 

I am currently storing the default (3 arrays) in three seperate shift registers in the main while loop of my VI but this arrangement is unsatisfactory when the number of arrays to be stored is unknown. The array size is not set in stone and can vary up to 200 points. However, the arrays should be the same size as each other.

 

Does anyone have ideas on how this can be done? The only idea i've had is to use 'functional globals' but i don't know how to create Reentrant VIs with my version of LabVIEW (if it's even possible). I use LabVIEW 6.1 - the Full development system (i think that's what it's called).

 

Thank you in advance.

 

James

 

P.S. I can view VIs up to LabVIEW 8.5

 

P.P.S.  Perhaps i should add that each array is allocated a name in a 1D array of strings (the number of arrays is changed by adding or removing elements in this array) and are initialised 'blank'. Only one array is edited or used at a time and the 'active' array is selected using a menu ring.

Message Edited by James Mamakos on 06-16-2009 03:01 PM


Never say "Oops." Always say "Ah, interesting!"

0 Kudos
Message 1 of 10
(2,865 Views)

Store the 5 arrays in a cluster.  So you have a cluster of 5 arrays.  Each array can then be a different datatype and different length.  If you only need 3 arrays, then you can just ignore the 4th and 5th arrays in the cluster.

 

With a functional global, you can do anything.  Store and get the single cluster.  Store and get 5 different arrays.  It all depends on what you are really trying to do.  By the way, a functional global uses a non-reeentrant VI.  It will work in LV6.1.  They were used all the way back in LV2  (thus the alternate name LV2 style globals).  A reentrant VI doesn't work for functional globals.

0 Kudos
Message 2 of 10
(2,852 Views)

James,

 

Try putting your arrays into a queue.  As long as the arrays are all the same datatype, the lengths can be different.

 

Lynn 

0 Kudos
Message 3 of 10
(2,848 Views)

I do not know how many arrays i may have. I currently have a default of 3, but this could eventually be anything up to 50 or more - i really don't know. The user defines this themselves.

 

I need to know (programmatically) exactly how many arrays there are, and also the size of the largest array. At the moment, i have a default size of 80 elements, but this could eventually be anything up to 200 or more.

 

Each array is acted on separately (one at a time) whether this is to read, write, or overwrite the elements within it.

 

I want to be able to change the associated name of an array without altering any data stored in it. I may need each array to have the option of differing in size to the others (one reason why i cannot merely store them as rows in a 2D array), though this is not essential for now.

 

Basically, i want to create a generic method of storing an undefined number of arrays of an undefined size, and being able to call up and edit them in the future without constantly reading and writing from a data file. The details i've given above are just to give an idea of the limitations and requirements i have.

 

If anything is still unclear, i will try to find another way of saying it.

 

James

 

P.S. As a background of the intended use, i am running a series of identical tests at different temperatures. Each test produces a 1D array of datapoints, and each array is associated to a particular temperature. Each array has its own associated name (to aid selection and viewing both after and during the tests) which will usually be the temperature that the data was collected at. However, there may well be a need for the user to manually name some or all arrays.

 

Their names are currently stored in a seperate array of strings, and each array is selected using a menu ring. The size of the data arrays is determined by the number of datapoints inputted. When a new array name is created (as a new element in the array of strings), a new 'blank' array is then created ready for data to be stored in it.

 

The data from the arrays is then displayed on graphs on the FP, and can be written into excel.



Never say "Oops." Always say "Ah, interesting!"

0 Kudos
Message 4 of 10
(2,832 Views)

James,

 

Extending my earlier suggestion of using  a queue: Create a cluster (typedef) with a string containing the name, an integer with the length of the array, and the array.  Put the cluster into the queue.

 

Create some wrapper VIs which locate the desired cluster by name, read or write data, and whatever other functions you may need.

 

Lynn 

0 Kudos
Message 5 of 10
(2,827 Views)

Using the queues, how would i be able to access the arrays in a random order without emptying and refilling the queue to see if the name in each cluster matches the one i'm looking for? It seems quite long-winded.

 

Also, i know i've heard of these elsewhere in the forums but what do you mean by a wrapper VI in this instance - how would it work? The only way i've implemented them before is to quickly make specific VIs running off a very general/generic VI.



Never say "Oops." Always say "Ah, interesting!"

0 Kudos
Message 6 of 10
(2,822 Views)

The Get Queue Status function can return all the elements of the queue in an array without dequeuing and enqueing each element individually.  The name may have been somewhat different in LV 6.1.

 

A wrapper VI in this case would include the Get Queue Status function and the search by name.  A separate VI for Read, Write, Overwrite, and any other actions (Add Array?) would incorporate the core functions and the specific action.  Thus you could have a VI which does a Read.  It has the queue reference and the name of the array as inputs and the array contents as output (plus error in and out of course).  The Write VI would have name of the array and contents as inputs with the error cluster being the only output.

 

Some programmers prefer to create an enum containing commands for all the actions and put everything in one VI.  Either way can work well, depending on the circumstances of your program. 

 

Lynn 

 

 

  

0 Kudos
Message 7 of 10
(2,816 Views)

Okay - that makes sense. I am one of those who often uses enums to get multiple functions out of a VI. 🙂

 

I'll give your suggestion a go, and get back to you (probably tomorrow).

 

Thank you.

 

James



Never say "Oops." Always say "Ah, interesting!"

0 Kudos
Message 8 of 10
(2,812 Views)

Normally, I would just make an array of clusters, each cluster containing an array of data (as well as any additional measurement information such as a text field to hold the name, etc.).  Then all the data arrays can be different lengths, the names can be changed, and there is an arbitrary number of measurements possible. Storing your measurements as clusters in an array would be simpler to access than using a queue or writing a lot of wrapper VI's, I would think.

 

-- James 

0 Kudos
Message 9 of 10
(2,795 Views)

You may well be right. I will experiment a bit with different methods when i get back to work tomorrow.

 

Thank you for your suggestions so far. 🙂



Never say "Oops." Always say "Ah, interesting!"

0 Kudos
Message 10 of 10
(2,781 Views)