LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Is there a better way to name cluster elements than making an initially named cluster?

Hello,

I have a cluster with nameless elements that I would like to have names. I want them to have names to make it easier to unbundle this cluster. I cannot name the elements when I bundle them because they are being made from VIs that don't allow me to name them such as `Decimal String to Number.vi`. I have created an external example of how I'm naming the bundle elements currently, but it takes up a lot of room and I feel like there may be a simpler way to name them. I feel there may be some way to name the wires before I cluster them or make a property node for the cluster to rename them. Does anything like this exist?

0 Kudos
Message 1 of 15
(5,447 Views)

Without looking into the VI you attached:

You should pre-define your cluster granting meaningful names to all items. Then use Bundle By Name to replace values appropriatly when passing data from the subVI output to the dataset.

Also you should request meaningful names for subVI parameters as this is a huge requirement for maintainable code!

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
Message 2 of 15
(5,444 Views)

Norbert beat me to it!  My "rule" is that every cluster and every enum that you define must have a TypeDef associated with it.  Not only does this make it trivial to find the silly things when you need to make changes (just search for the TypeDef), but it allows you to change the TypeDef, then find all the effected instances as you repair the Errors that pop up when you redefined the instances.  You can also think of this as a step in "pre-Documentation".

 

Bob Schor

0 Kudos
Message 3 of 15
(5,438 Views)

I am actually refactoring some code and currently am trying to follow all the logic. A lot of bundles are used and they are mostly with unnamed elements, making it pretty difficult to follow what data is going where. I'm currently just trying to follow the logic before redoing a lot of the code. I was thinking of changing a lot of the structure and implement LVOOP to it instead of TypeDefs, but not at this step. Right now, I am hoping for a quick way to name bundle elements without just creating an initialized bundle and then changing each element in a Bundle by Name. 

0 Kudos
Message 4 of 15
(5,432 Views)

What about simply putting names on the constants/subVI parameters?

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 5 of 15
(5,412 Views)

@TheStrangeQuark wrote:

I am hoping for a quick way to name bundle elements without just creating an initialized bundle and then changing each element in a Bundle by Name. 


Make a cluster constant, put meaningful names in for the elements, wire the constant to the top of the Bundle function.  The bundle will use the cluster definition you supplied for all of the names even if you do not use the Bundle By Name.  Just make sure you match the order that is currently defined.



There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 6 of 15
(5,402 Views)

The subVIs are pretty general and it would be difficult to name the parameters. An example of one of the subVIs is to essentially format a string and extract everything between <tag> ... </tag> where an input is the tag. The tag is also what the data between them is. Is there a way to programmatically name parameters? For example, there may be two tag sections as follows:

<names>

bobby hill

Hank Hill

</names>

<ages>

15

47

</ages>

And these are then run through the subVI for extracting things between the tags. So I would first run the subVI with an input of "names" and get back a string of "bobby hill\nHank Hill" which I then could make into an array, and I would run the subVI with an input of "ages" and get a string of "15\n47" which I then could make into an array. So this subVI would need a generic output name that would also not be useful.

0 Kudos
Message 7 of 15
(5,391 Views)

Sorry, I don't see how this is different from what I am already doing? What would be accomplished by wiring it into a Bundle function instead of to a Bundle by Name function? I think this would make it less clear as to what element I am changing. I suspect I may be misinterpreting your suggestion.

0 Kudos
Message 8 of 15
(5,389 Views)

Well, in that case, my label would be "data", "flattened data" or similar. This is by far better than to leave the label completely empty.

 

From the looks, the original developer did not address software design to an appropriate level and then took additional shortcuts during implementation. This is always a bad idea and you are now in the situation that you have to live with the mess. So much about maintainability.....

 

The suggestion from crossrulz makes the re-naming a bit easier (as you only do it for the constants in one place, not the parameters in many places), but is indeed essentially the same recommendation.

What you have to understand (and the original developer messed up) is that cluster is an edit time defining-type of container. If i would require a container for run-time definition which could include *any* type of data, i would pick variant attributes instead.

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
Message 9 of 15
(5,381 Views)

I agree with everything you said. I think for now I'll stick with what I'm doing by an initialized cluster with names. Thanks for your help.

0 Kudos
Message 10 of 15
(5,377 Views)