LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Can I use type definitions to avoid having to edit multiple VI's when I update a control that is being accessed by reference number in several VI's?

Can I use type definitions to avoid having to edit multiple VI's when I update a control that is being accessed by multiple VI's?
I'v been passing to each subVI, a cluster that contains 3 reference numbers to my 3 control clusters.
The subVI's access the data from the controls on the top level front panel and sometimes updates their values.
 
Thank you for any suggestions you have.
Ken
0 Kudos
Message 1 of 10
(3,248 Views)

Of course you can! That's what they're for. Right click the control and select Advanced -> Customize. At the top of this window you will see a dropdown box that says "control." Change this to "Type def." Edit the control as necessary and save it. Now go to any sub VIs that use it and replace each control with the new type def. The easiest way to do this is to right click the control, then select Replace -> Select a Control. Browse to your newly created typedef and select it.

Now when you want to edit the control, you can right click an instance of it and select "Open Type Def." Any changes you make will affect all instances of the typedef.

0 Kudos
Message 2 of 10
(3,247 Views)

Okay, I have the controls converted to strict type definitions.  But when I update the controls, my links where I'm passing a cluster of control REFERENCES to my subVI's breaks.  To fixes I have to remake an indicator from the build cluster function, convert it to a control, and place it in the subVI's.

Or do you mean, I can make my cluster of control references be a type definition?

Ken

0 Kudos
Message 3 of 10
(3,240 Views)
Yes, if you're passing a cluster of references, the cluster needs to be a type def, not the elements in it. Then if you change a control that you're referencing and the type of reference changes, you just need to update the type def. Also, a strict type def is only needed if you want the appearance of the control to be the same everywhere. For what you're doing you don't need it to be strict.
Message 4 of 10
(3,228 Views)
I'm either not making my question clear or I'm not understanding your instruction.  So, I've attached a very simple example.  The example has a main front panel with two control clusters each with its own typedef.  The block diagrams shows that I'm bundling the references to the two control clusters and passing them to a subVI.  If I change the typedef of either control cluster by adding another control to it, the link to my subVI breaks.
0 Kudos
Message 5 of 10
(3,218 Views)

Ok, I see what you're doing wrong. The cluster with the references needs to be a typedef. When you change one of the clusters of controls, the reference type changes. This will make the cluster of references change. So for your example, all of your clusters should be typedefs. It may seem confusing with all these typedefs, but trust me it's worth it when you figure it all out.

Also, you might as well just bundle the 2 clusters you have into one cluster to pass to the sub VI if you really want only one input. There's no need to use references just to get the values in the sub VI.

0 Kudos
Message 6 of 10
(3,213 Views)
Since I kept my example simple, so that it did not show that I needed to pass the references so that I could changes some of the values on the controls instead of just to get the values of the controls.
 
How do I make the cluster of references be a typedef?
 
Ken
0 Kudos
Message 7 of 10
(3,208 Views)
The same way you did the others. It's still just a cluster, the only difference is the data type it contains. Right-click, go to advanced -> customize and change it to a typedef.
0 Kudos
Message 8 of 10
(3,200 Views)

Thank you for your help, my example is working.  Please look the my revised example and let me know if I'm making it more complicated than necessary.  In order for it to work,

1.  I created a cluster on my front panel to hold the control group reference numbers,
2.  Converted it to typedef,
3.  Used bundle with name to stuff the control reference numbers into my RefCluster,
4.  Used the RefCluster typedef in my subVI,
5.  In the subVI, I had to add a variant to data command before using the data.

I also extended the example to actually change values on the front panel to verify that it worked as I intended.

Ken

0 Kudos
Message 9 of 10
(3,189 Views)
Looks like you got the hang of it. You even figured out that you should use the typedef constant for the variant to data conversion. If you need any more help, just ask.
0 Kudos
Message 10 of 10
(3,184 Views)