10-26-2018 10:44 AM
Hello Forum.
I ran into an issue, and I'm not sure if there is a switch I need to flip or if there is something I'm doing wrong.
I'm using LabVIEW 2015 SP1
Version 15.0.1f10 (32-bit)
I have a type def I'm using that is rather large, and I use property nodes to update/read as needed. I went in to change the tabbing order in the cluster, and it changed the linkage of the nodes. I've never seen anything like this before. Can anyone tell me why this happens? I will not be able to share the VI due to business reasons.
Here is the tabbing order pre-change:
Here are the nodes pre change:
Here is the tabbing order post change (I only did a couple since the changes would be catastrophic for me):
And the nodes post change:
10-26-2018 12:06 PM
Just to be clear to anyone who reads this, here's the situation:
The user created a cluster typedef. Then he created a VI with an instance of that typedef on its panel; on its diagram, he created static references to controls *inside* the typedef instance.
I think LabVIEW did the correct thing. That is not same necessarily as the *expected* thing. Let's see if we can talk this through and identify if there's a better behavior possible. I don't think there is, but many minds can see solutions one cannot.
Consider... if you had renamed one of those controls inside the cluster, you'd want the property nodes to update, right? A cluster of "{A, B, C}" that you rename to "{A, D, C}", you'd expect a property node linked to B would change to be linked to D. And, indeed, LabVIEW does that.
So that's correct behavior.
If you had "{A, B, C}" and you change the labels of two of them to be "{B, A, C}", you also want the property nodes to update. And, indeed, they do.
So that's correct behavior.
Well, that's what happened here. From the caller VI's point of view, you did a massive rename operation, and the property nodes correctly followed suit. Each one matched up with the control that was in the index position it used before.
The obvious response: "Well, a rename and a reorder are not the same operation and LabVIEW should modify caller's differently."
The problem is that LabVIEW cannot assume that all callers are in memory when the edit is made. A caller may load long after the edit has been made, and all callers need to update in the same way regardless of whether they were in memory or not. So... the edit is made. The caller loads. All the caller knows is the before and after state of the typedef. It doesn't know anything about how the edit was made -- it may not even be the same machine where the edit was made. So what can it do? Well, either LabVIEW could use name matching OR LabVIEW could use index matching, but it cannot do both. In order to be smart about the edit, it would have to know what edit was made, and the typedefs do not have that kind of versioning record.
Could we add that kind of versioning record? We could -- the private data control of LabVIEW classes record the kind of edit that was made. Classes did it to be able to manage the data mutation of flattened strings between class versions. Would that be desirable for typedefs? I'm honestly not sure. On the negative side, it can become a significant weight for LV classes, and typedefs are much more broadly used. On the positive side, it would help more situations than just this one -- reordering items in a typedef'd enum vs renaming items in a typedef'd enum, for example.
Regardless, we do not have that record today. And without that record, LabVIEW has to pick one behavior and go with it. And I suspect that because reordering elements is much rarer than renaming, the decision was made to use the indexes to line back up.
I suppose another option is that we could say if the name AND the index do not match then always break the caller VI and force users to manually update all such nodes. That seems less helpful, but perhaps higher safety.
So, that's the reason for the behavior. It's not a bug. It's a feature. Just not a feature you wanted, I'm afraid.
10-26-2018 12:08 PM
PS: I said, "and all callers need to update in the same way regardless of whether they were in memory or not." I take that as axiomatic. Obviously, it's software... we could make it do whatever. The consistency seems to me to be rather critical. If you want to debate this point, feel free to post, but I think it would be very bad behavior and unlikely to shift. But I'm open to arguments.
10-26-2018 12:14 PM
Augh.... not what I wanted to hear. lol.
10-26-2018 12:19 PM - edited 10-26-2018 12:20 PM
@AristosQueue (NI)The user created a cluster typedef. Then he created a VI with an instance of that typedef on its panel; on its diagram, he created static references to controls *inside* the typedef instance.
AristosQueue,
Is there better type of reference to use here other than static? Is there a better practice to use to get the tab changes to follow like the other changes? I really don't want to walk though and change 100+ references simply because I want to change the tabbing order.
10-26-2018 12:32 PM
So, back to the original problem, which seems overly complicated. All you probably need is a 1D array of clusters, each element corresponding to one row. Keep the array in a shift register and update elements as you go. No need for property nodes. If you want, add disabled string elements for the labels.
10-26-2018 12:53 PM
@altenbach wrote:
So, back to the original problem, which seems overly complicated. All you probably need is a 1D array of clusters, each element corresponding to one row. Keep the array in a shift register and update elements as you go. No need for property nodes. If you want, add disabled string elements for the labels.
I would mark that as the solution.
Ben
10-26-2018 01:11 PM
I don't know that is a solution, it may be "a" solution, but not "the" solution. I'm sorry, but the whole thing seems a bit bizarre to me. Whether or not my coding method is the best (I'm sure it's not), the tabbing index controlling the linkage of the node was very unexpected.
10-26-2018 01:15 PM
Thanks Altenbach.
10-26-2018 01:29 PM
@Speaks wrote:
I don't know that is a solution, it may be "a" solution, but not "the" solution. I'm sorry, but the whole thing seems a bit bizarre to me. Whether or not my coding method is the best (I'm sure it's not), the tabbing index controlling the linkage of the node was very unexpected.
It depends on you perspective. What you are changing is not specifically the tab order. You are changing the order in which the nodes are linked to the cluster. Tabbing just happens to follow that order.