LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Automatically resize cluster based on number of elements within

Solved!
Go to solution

PhilipJoeP wrote:
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.

 


What you are asking can be done using scripting. I have done exactly that.

 

If NI is helping you with this issue then tell them exactly waht you are attempting and ask them to write a VI that creates the cluster. Tell them you don't need to see how they are doing it, you just need that fuctionality.

 

If you are ambitious check the Scripting Forum and the Code repository on LAVA. I believe Ton has written that code.

 

Have fun!

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 11 of 32
(1,608 Views)

PhilipJoeP wrote:
In this post, I want to go from the .txt file of SAME TYPE data to a cluster of this data. 
I need to figure out a way to take, for example, a .txt file of 300 or more same data type elements

It does not matter if they're the same or not. The situation is the same as what was discussed in the previous post. 

0 Kudos
Message 12 of 32
(1,606 Views)
Well, what you said was "if have a .txt file of 5 integer elements, I want the VI to produce a cluster indicator of exactly 5 numeric indicators ".  That implies that if the file has six elements, you want a cluster fo exactly 6 numeric indicators. That is creating the cluster dynamically and you simply cannot do that. You can set the Array to Cluster to the the maximum of 256 and you will always have a cluster of that size. The actual data in the cluster elements will vary but the number of elements never will. I don't know how your dll will behave if you always pass a cluster of the maximum size with default data in some of the elements. I also don't know how you can get around the limitation of a maximum of 256 elements. The only thing I can think of offhand is to use a different programming language and create a wrapper that accepts a LabVIEW array and dynamically creates a container that you would pass to this other dll.
Message 13 of 32
(1,605 Views)

Ben,

 

Do you have any example VI's or scripts?  I've tried searching the scripting forum, but I never know what I am looking for (since scripting is something i have never done).  Are there any forum posts I should look at specifically?

 

Thanks

0 Kudos
Message 14 of 32
(1,581 Views)

Dennis Knutson wrote:
The only thing I can think of offhand is to use a different programming language and create a wrapper that accepts a LabVIEW array and dynamically creates a container that you would pass to this other dll.

 

Dennis,


Thanks for the response.  However, the whole purpose of me creating the cluster is to that I can save it as a type def.  The method you explained above requires me to do this at runtime for each isntance of that data cluster type.  It's unfortunate that NI didn't think the array to cluster converter through enough that it would accept a larger size array.  I need to do some research on how big a cluster can be, or figure out what it's limitations are.

 

Thanks for the help.

0 Kudos
Message 15 of 32
(1,580 Views)

PhilipJoeP wrote:

It's unfortunate that NI didn't think the array to cluster converter through enough that it would accept a larger size array.


You can wire in an array as big as you want. You're still only going to get out a maximum of 256. Smiley Wink

 

0 Kudos
Message 16 of 32
(1,579 Views)

smercurio_fc wrote:

PhilipJoeP wrote:

It's unfortunate that NI didn't think the array to cluster converter through enough that it would accept a larger size array.


You can wire in an array as big as you want. You're still only going to get out a maximum of 256. Smiley Wink

 


 

This I'm aware of.  Am I wrong to comment on the limitation of 256 elements for the convert array to cluster fucntion?
0 Kudos
Message 17 of 32
(1,572 Views)
Not at all. I would suggest providing an input to the Product Suggestion Center.
0 Kudos
Message 18 of 32
(1,568 Views)

You would need scripting in order to programatically create a cluster, you would need scripting to programatically create a type def. You have a limitation with the Array to Cluster. And in another post, you've been told you cannot use a simple type cast. It sounds like you should reevaluate your decision not to use the simulation toolkit. The amount of time you've already spent on this subject has probably exceeded the cost of the toolkit. I know I've wasted too much time.

 

And in regards to scripting, I had a recent converstation with one of the NI scripting gurus. He was of the opinion that scripting will never be officially supported. He also stated that it is somewhat fragile and that every release of LabVIEW has required extensive modifications to existing scripts.

 

Your choice - the toolkit, scripting, or wrapper dlls. 

0 Kudos
Message 19 of 32
(1,555 Views)

PhilipJoeP wrote:

Ben,

 

Do you have any example VI's or scripts?  I've tried searching the scripting forum, but I never know what I am looking for (since scripting is something i have never done).  Are there any forum posts I should look at specifically?

 

Thanks


 

No they all seemed to have been lost in a hard drive crash from some years ago.

 

LAVAG.org has a scripting forum.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 20 of 32
(1,545 Views)