LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Automatically resize cluster based on number of elements within

Solved!
Go to solution

I am trying to use the following VI to convert the provided .txt file into a cluster indicator of numeric values.  So far, the VI works perfectly.  However, I would like the cluster to resize to the number of elements it contains based off the number of integers in the .txt file.

 

Therefore, if have a .txt file of 5 integer elements, I want the VI to produce a cluster indicator of exactly 5 numeric indicators (as well as to resize the cluster borders to fit these numeric indicators).  If I then load a different .txt file of only 3 integer elements and run the VI, I would like the cluster indicator to then only have 3 elements and resize.

 

Of course, I want this functionality without having to close or re-code the VI.  Apparently, I can’t initialize the number of elements within a cluster to default value.  Brute force is always a solution.  However, my application may contain hundreds of elements, hence why I would want this to be done automatically.

 

I don’t think there is a property node or invoke node solution to this (or at least I can’t find it).  Is there any way to use a state machine that in the first state deletes any previous cluster and in the next state populates it?

 

Any help would be much appreciated!

 

Thanks.

Download All
0 Kudos
Message 1 of 32
(6,935 Views)
Your VI will always create a cluster of 9 elements (no more and no less) and it does not matter what, if anything is in the file. You cannot dynamically specify how many elements should be in the cluster.
Message 2 of 32
(6,923 Views)

hi

i am not sure it is correct but I am thinking at the array_to_cluster conversion. an array can be automatically created (just read all the stuff in a while loop then index the output) then you can convert it to a cluster ?

regards

0 Kudos
Message 3 of 32
(6,917 Views)
That's not the same thing. The Array to Cluster function will return a fixed cluster. The default size is 9 elements. This can be changed by right-clicking on the function and setting the size, but it cannot be changed at run-time. Also, all elements in the cluster will have the same datatype.
Message 4 of 32
(6,910 Views)
ok, thanks (as I said, I am not sure it is correct ) Smiley Happy
0 Kudos
Message 5 of 32
(6,892 Views)

It sounds like you're only loading Integers from the text file, no?

If so, add them to an integer array (or double for more general behaviour) and it'll be general.

 

If there's some administrative reason for the cluster then you can add an array inside the cluster to make it dynamic, the cluster itself wont be, however.

 

And/or you can ofcourse make an array of the cluster ...

 

/Y

Message Edited by Yamaeda on 05-19-2009 02:44 AM
G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 6 of 32
(6,888 Views)

Basically, I’m trying to go from a .txt or CSV file with a list of integers (doubles, etc…) and want a cluster indicator to be created containing each element in the list as its own numeric indicator.  All the numbers in the list would be the same data type.  I cannot use an array or an array within the cluster for my application.  I also cannot use an array of clusters. 

 

I have to feed data to a .dll file, and for some reason arrays do not work correctly in a cluster for this application.  The number of elements in the list could easily break 256, the limit for the array to cluster function.  I’m not sure what the element/size limit is for a cluster.

0 Kudos
Message 7 of 32
(6,849 Views)

PhilipJoeP wrote:
 

I have to feed data to a .dll file, and for some reason arrays do not work correctly in a cluster for this application.  The number of elements in the list could easily break 256, the limit for the array to cluster function.  I’m not sure what the element/size limit is for a cluster.


Well, this changes the equation quite a bit now, doesn't it. I don't think dynamically creating clusters is really your solution. Perhaps you can provide some more information about this DLL. Passing arrays to DLLs has been done for quite some time now. Have you looked at the example that ships with LabVIEW called (appropriately) "Call DLL"? It shows how to pass lots of different datatypes. 

0 Kudos
Message 8 of 32
(6,841 Views)
In this thread you were told that you cannot dynamically create clusters with a variable number of elements. LabVIEW has not changed in the last month.
Message 9 of 32
(6,838 Views)
Dennis, Yes, this post you provided me looks very familiar.  Smiley Happy  However, what I was talking about in that post is completely different from what I'm discussing in this post.  In that post, I wanted to auto generate a cluster of various data types.  In this post, I want to go from the .txt file of SAME TYPE data to a cluster of this data.  Reason is, we've run into major problems passing LabView arrays into a DLL created using Simulink.  NI is working with us to figure out why.  Within the Simulink model (DLL) we are using a bus object (similar to a cluster) with an array inside of it.  When testing the model in Simulink, all works fine.  It's when we wire an array in a cluster (in LabView) to the array in DLL that we have problems.  One of our work-around is, replace the array in our cluster with a cluster of same data type numeric controls. (Resulting with a cluster within a cluster… the inner cluster basically replacing our array)   When we map the inner cluster of elements to the array in the DLL, all works fine.  So it's a LabView array problem and probably how it's allocated in memory. Sooo... now I’m interested in trying to automate the creation of a cluster of same data type elements.  In the example VI I attached to this post, I convert a .txt file, to an array, to a cluster.  I can run the VI (which populates the cluster) and then i can change the resulting cluster to a control, type def it, and then use it again elsewhere.  However, it looks as if my solution attached will only create a cluster of at most 256 elements (based on the limitation in the "array to cluster" function).    I need to figure out a way to take, for example, a .txt file of 300 or more same data type elements and (using the procedure I outlined above) create a type def cluster control that I can use in other VIs.   I am not trying to create the cluster dynamically during run time.  And of course, the VI I used above would not be in any of my application VIs.  It's simply used as a work around.  Hopefully i am being clear.

 

0 Kudos
Message 10 of 32
(6,813 Views)