LabVIEW Idea Exchange

cancel
Showing results for 
Search instead for 
Did you mean: 
0 Kudos
Wazig

Dynamic Cluster Array

Status: Declined

Any idea that has not received any kudos within a year after posting will be automatically declined.

To make your code reusable as subvi's and have less connector space used the cluster is a way to go, but you need to define the types inside your cluster upfront.

If you want to add an other item inside this cluster you have to rewrite all the subvi's this cluster is wired to...... This is at least annoying. (or dull, boring, dreadful, tedious, dreary, tiresome, aggravating, exasperating, irritating)

 

If you could add new types of variables inside this "Dynamic Cluster Array" on the fly, you can expand the clusters on the fly when needed !

 

Example of a "Dynamic Cluster Array":

 

Dynamic_Cluster_Array_example.png

 Look also to the Search 1D node, to see how you can select an array cluster item.

 

You can read and write the cluster as normal clusters but if you want to read or write a variable that does not exist this variable is added.

Reading and writing this variable will add this variable in all clusters in the array, these variables will get the default value until your software changes this value.

 

This behavior is the same as structures in Matlab

 

John

7 Comments
TCPlomp
Trusted Enthusiast

This sounds like a type-def with super powers to me.

Can you explain what is missing from a typedef right now?

 

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!
TCPlomp
Trusted Enthusiast

Another option is to use a variant with attributes. Each of the attributes can be named after a specific variable.

 

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!
Knight of NI
Also, how does one do type-checking at compile-time if you don't know the structure of the cluster? You could have all sorts of errors in your program because you woudn't be able to perform type-checking.
Wazig
Member

Hello Ton and Smercurio_fc, thanks for your comments.

 

The difference with type-def and variant is that Dynamic Cluster Array behaves like a mini expandable "database" new "records" can be added and the "coloms" you can add and fill at will with your data.

note: nearly all LabVIEW data types can be used, without converting from and to its type.

 

There will be no type-check issue, because the software at runtime needs to add the required variables if not already exists in memory before the use of these variables (if not exist then create before writing data or reading "your defined default")

 

What the real benefit is when you have saved measured data in such a structure, you can develop separate analyzing software without needing to care about types inside as long you have the needed data inside.

Load the saved data file with a Dynamic Cluster Array and use your analyzing routines save the results afterwards.

After analyzing you can add the results to the data to keep all relations between data and results consistent.

 

In a Matlab environment this has proved to be a very good way to let 50+ engineers use measured data, let them work out there own analyzing software add the results and create reports from these data structures.

This without large database overhead, only on file level with all metadata inside these structures.

 

Also searching and selecting the data for example to make reports can be done in a native LabVIEW environment.

This behavior acts like a query in a database environment.

 

John

 

AristosQueue (NI)
NI Employee (retired)

Wazig, I want to echo TCPlomp... Wazig, correct me if I'm wrong... I believe the Get Variant Attribute and the Set Variant Attribute provide the ability to add arbitrarily named data to the variant and retrieve it later by name (or return a given default value if the named attribute does not exist). There is no equivalent to the Search 1D Array, though such a subVI could be written fairly easily I believe for the variants.  The Variant To Data primitive is where the type collision is resolved (i.e., I store string data under name XYZ and then try to retrieve XYZ with a default value of integer, I need to get an error at some point telling me that the string isn't an integer).

 

Side note:  Your "indexing with shift register" is unnecessary. LabVIEW today will see the indexing tunnel on the left and the indexing tunnel on the right and will take care of optimizing the memory behind the scenes.

Wazig
Member

Hello Aristos Queue,

 

Yes, I know that you can accomplish the same functionality with other means, but it's never lean and or clean code. The cluster bundle and unbundle by name are expandable so they are easy to use and it is possible to keep everything downwards compatible. This idea works like a waveform array but it is easier to make your own data cluster. Especially the search option is unique and possible due to this idea. (this search 1D could also select desired waveforms from its data and attributes properties)

 

The Side note: I think it is necessary to have the "indexing with shift register" because you can add "coloms"(-> number of bundled variables)  to the structure while reading or writing, so every cluster in the array is subject to change. This can only be done with a "shift register" like behavior. Think of using this "Dynamic Cluster Array" also inside a while loop without knowing the length of the array and the "width" (-> number of bundled variables) of the cluster.

 

John

Darren
Proven Zealot
Status changed to: Declined

Any idea that has not received any kudos within a year after posting will be automatically declined.