LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Passing Clusters to a SubVi

Hi!
 
I wish to pass a cluster of clusters to a subVi by reference, and then retreive the data in the subVi.  I know I can use variants or other ways of creating polymorphic data, but  the problem with this is that the size of the clusters vary so I cannot define the data type when it comes to converting the variant to data.  I also do not want to create a polymorphic Vi and take into consideration every single cluster size possible.
Does anyone have any suggestions?
 
Thanks
0 Kudos
Message 1 of 11
(4,473 Views)
Hi NahoY:

I would make the control be a Strict TypeDef, and then pass it's reference to the subVI.

In the subVI, you can get the property VALUE of the reference, and then use the function to convert the variant to the Strict typedef. Then in the subvi you will have the value you want.

Tip 1: To make a control to be a strict typedef: right-click on the outer box of your cluster, and select advanced. Then choose STRICT TYPEDEF CONTROL, instead of Control in the toolbar. And then save it. When you close the window you will be asked if you want to replace the control and select yes.

Hope it helps,
Aitortxo.
0 Kudos
Message 2 of 11
(4,455 Views)
Hi Aitortxo,
 
what is the function to convert the variant to the strict type def?  Is it variant to data?  And if yes, what type do I wire to that function?
Thanks for the help!
 
 
0 Kudos
Message 3 of 11
(4,451 Views)

Hi

I have the feeling that not only the data in the cluster changes but also the type of the cluster of clusters.

This is not allowed in labview.
If you really need that use a variant, but before ask youeself twice or three times why do I want to use the same subvi with differetn types of data.

If the datatype changes, maybe the subvi has to change!

 

greetings from the Netherlands
Message 4 of 11
(4,444 Views)

Thanks for the input Albert

I found way to solve my problem.  What I finally decided to do was to convert the cluster into an array (same type of data in cluster) and then convert this into a variant.  I then passed the size of the array as a variant attribute.  Since the type of data stayed the same (strings), I could then rebuild the array in the sub-Vi with the "intialize array" function and pass that as the type for the "variant to data" function.  I had to make a few compromises but it seems to be the easiest way to do what I want.  Hope this could help someone and thanks for the help everyone!

 

0 Kudos
Message 5 of 11
(4,438 Views)
Hi NahoY:

Yes, it's Variant to Data function and the input you need is a constant of the typedef.

Then at the output you'll have the cluster you want

Hope it helps,
Aitortxo.
0 Kudos
Message 6 of 11
(4,424 Views)

I still have the feeling that things are implemented more difficult then necessary.

Why don't you pass the array as an array to the subvi?

No length is needed because labview knows always the length of an array!

greetings from the Netherlands
Message 7 of 11
(4,422 Views)
I have to agree with you Albert!
 
This sounds like it is getting more complicated than it has to be.
 
Naho,
 
could you post some sample code (zipped) so we can advise?
 
Ben
 
Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 8 of 11
(4,412 Views)
I cant pass it as an array since the lenght changes... the type stays the same though.
0 Kudos
Message 9 of 11
(4,397 Views)
Ok forget about it!  I understand what you meant.  Yes you guys are right, I was making this complicated for nothing!
0 Kudos
Message 10 of 11
(4,388 Views)