From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
06-30-2015 02:28 PM
In a subVI, I use references to grab current control values and change properties of those controls according to those values. I'm only passing three references in, but even if I array them together to reduce input size, they clutter up my block diagram. They're also preventing me from turning some spaghetti code into a subVI, as they dont remain consistent through the edit->create subvi process. Is there some better way to handle this?
Solved! Go to Solution.
06-30-2015 02:34 PM - edited 06-30-2015 02:36 PM
@ijustlovemath wrote:
In a subVI, I use references to grab current control values and change properties of those controls according to those values. I'm only passing three references in, but even if I array them together to reduce input size, they clutter up my block diagram. They're also preventing me from turning some spaghetti code into a subVI, as they dont remain consistent through the edit->create subvi process. Is there some better way to handle this?
The way you describe is the only way I can think of doing it. I'm curious as to why you feel it's not working correctly if you use "Create subVI"? I do that fairly often and it just seemed to work.
06-30-2015 02:53 PM
Often times it just scoops the reference into the subVI, making a brand new control that I don't really care about. That, or leaves that little "mismatched data type" red triangle. I really just wish I could put references into a subVI in order to clean up the diagram, as they look sort of out of of place.
06-30-2015 02:56 PM
You could put them into a cluster and unbundle as needed.
06-30-2015 03:00 PM
Maybe there's a problem with the way you create the subVIs. Don't incude the terminals themselves.
07-01-2015 04:19 AM
I go for one of the following options:
- Create a non-strict reference terminal on the front panel of the SubVI - useful when it's only one or two references you need.
- Bundle up the references into a cluster and then convert it into a type definition. I can then unbundle any of the references I need within the SubVI. This is good if you want to perform specific actions on specific references in the SubVI (e.g. update string, set colour of button etc.) and it keeps the correct class type
- Create an array of references. This is useful if you want to perform the same action on multiple items of the same class (e.g. setting visible / enabled state which can be done on any control/indicator). They'll get type-casted to the common parent class which means that some specific methods won't be available unless you cast it back inside the SubVI.
07-01-2015 07:53 AM
Thanks for the help! I've used all 3 methods, but they are still sort of cluttered, as you still have to cluster/array/singly pass the references into the subVI, so the reference terminals are still on the main block diagram. Is there any cluster that contains all of the reference terminals, that when unclustered will retain the class of the control references? I know that upcasting happens when different control references are array together, but I want something that doesn't upcast, so as to avoid having to do the casting myself in the subVI (if only to avoid those little red triangles!).
07-01-2015 08:07 AM
I like to logically group the references in a pseudo state machine. In state A I bundle into a cluster the group A references, then go to state B where I bundle group B references and so on. I finally have a Cluster of references that can contain logically grouped clusters of references. I make the final cluster a typedef and I usually create a vi template having this cluster as an input.
On my BD the references are stacked in multiple state cases taking less space.
Ben64
07-01-2015 09:04 AM
07-01-2015 09:24 AM