06-23-2017 07:36 AM
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?
06-23-2017 07:40 AM - edited 06-23-2017 07:41 AM
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!
06-23-2017 07:47 AM
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
06-23-2017 07:53 AM
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.
06-23-2017 08:39 AM
What about simply putting names on the constants/subVI parameters?
06-23-2017 08:50 AM
@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.
06-23-2017 09:06 AM
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.
06-23-2017 09:10 AM
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.
06-23-2017 09:22 AM - edited 06-23-2017 09:23 AM
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.
06-23-2017 09:26 AM
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.