LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

passing array of clusters to a subvi

Solved!
Go to solution
I have an array of clusters (with different types of controls) that I want to pass to a subvi. I can do it easily by creating a control from the original array of clusters and using that as an input in the subvi. However, if I add or delete an element in the cluster, the whole subvi breaks. I have to recreate the subvi input (Array Ref in the attachment) from the original array of clusters. Is there a way to prevent that? I know it will give me errors if I delete an element that the subvi is using (eg: Chart Ref or Channel) but it would great if it didn't do that as long as I added new controls or deleted controls that aren't used in the subvi. I just plan on adding more controls later on but don't want to edit every single subvi that is using the array of clusters.
0 Kudos
Message 1 of 8
(4,216 Views)

Abdel2,

 

The solution to this is create a typedef control for the cluster and use the typedef cluster in you subVIs to create the array of clusters. Later if you want to add or remove elements from the cluster, just open the typedef and edit it, and say 'Apply Changes'. All loaded VIs referrring the typedef will get updated automatically.

 

To create a typedef of the cluster, right click on the existing cluster and select Advanced>>customize. Once the control opens in a new window, set the control type to Typedef. See attached image.

 

 

Message Edited by kikiduu on 12-27-2008 12:25 AM
------

"A VI inside a Class is worth hundreds in the bush"
യവന്‍ പുലിയാണു കേട്ടാ!!!
0 Kudos
Message 2 of 8
(4,213 Views)

Thanks. I just tried it but it still gives me an error after I modify the cluster elements. How should I create an array of cluster control in the subvi so it automatically gets updated after modifying the original cluster?

Right now, I right click on the array reference and click "Create control". Then I copy the resulting control to the subvi. It puts a little orange start on the front panel control icon. Not sure if that's what's causing the error.

'

0 Kudos
Message 3 of 8
(4,193 Views)

You need to understand type def.

See here

Message Edited by Pnt on 12-27-2008 11:49 AM
0 Kudos
Message 4 of 8
(4,190 Views)

Hi Abdel,

 

See the video attached.  You can open this video with internet explorer.

------

"A VI inside a Class is worth hundreds in the bush"
യവന്‍ പുലിയാണു കേട്ടാ!!!
0 Kudos
Message 5 of 8
(4,168 Views)

I tried loading the video in both Mozzila and IE but it didn't work. In IE, it just shows a very small empty box. In Mozilla, it doesn't run and show any thing but I can see that it's 21 seconds long.

 

So what I understand is that with typedef I can create a input in the subvi that contains the value of a custom control (typedef). It will also update the input type if I modify the typedef. What I am trying to do is pass a reference to the array of clusters rather their the actual value because I need to change the array's properties. To do this, I have to create a control that is a strict array reference. Typedef doesn't seem to make any difference.

 

0 Kudos
Message 6 of 8
(4,151 Views)
Solution
Accepted by topic author abdel2

Ok...You will need flashplayer

 

Try to follow this...

 

1. Create a typedef of the cluster and save it as a .ctl.

2. Open a new VI.

3. Create an array control with  element as the typedef cluster.

4. In the controls palette, go to refnum pallete and place a Contol refnum on the front panel.

5. Right click on the control refnum and select  'Show Control'.

6. Drag and drop the array control into the refnum.

7. Right click on the control refnum and select 'Show Icon'.

8. Use this refnum in your subVIs.

Message Edited by kikiduu on 12-27-2008 10:46 PM
------

"A VI inside a Class is worth hundreds in the bush"
യവന്‍ പുലിയാണു കേട്ടാ!!!
Message 7 of 8
(4,144 Views)

Thanks, it seems to work great now!

 

0 Kudos
Message 8 of 8
(4,136 Views)