LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Incorrect data order during cluster unbundle

I get a mysterious error when I try to unbundle data inside my subVI.

The sequence order of data is changed. See the attached picture of the data structure of my clusters. The structure on the left shows what I put into the subVI. The structure on the right shows what I read inside the subVI.

The problem is that my data is no longer associated with the correct names. Inside my subVI, the data type 'Active Relay' has moved up two positions. But this variable still contains the value of Temp_CH3. So although the name order has changes, the order of data remains unchanges. This is also confirmed by the fact that inside my subVI the last variable inside the cluster, Temp_CH4, still contains the data from 'Active Relay'.

Any good ideas as to why this is happening?


Message Edited by Claus_DK on 11-19-2007 03:50 AM
0 Kudos
Message 1 of 9
(3,282 Views)
Could you show the code of the SubVI, especially bundle/unbundle actions. Preferably you should make the in and output linked to the same typedef.

Ton
Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
0 Kudos
Message 2 of 9
(3,274 Views)

Make sure you use bundle and unbundle by name, to avoid being dependant on the order of the elements inside the cluster.

I would agree with Ton that the most likely issue is that you have two different clusters and that you need to use a typedef. Always use typedefs when you have a cluster or an enum which will be in more than one place (e.g. as an input to a VI).

There was a bug (I think it was fixed in 8.0) where LV would incorrectly relink cluster elements under certain conditions, but I don't think that's what's happening here.


___________________
Try to take over the world!
0 Kudos
Message 3 of 9
(3,262 Views)
I have attached a picture showing how I bundle variables in my main application and how I unbundle the cluster inside the subVI.

I was thinking of using the 'Unbundle by name' inside the subVI, but if I cannot trust that variables and names are associated correctly, that would probably not help me.

I am not familiar with typedefs. I will try to look into that.



Message Edited by Claus_DK on 11-19-2007 05:09 AM
0 Kudos
Message 4 of 9
(3,257 Views)
What names were you expecting?
The names of the locals are only used the first time, when you change them the cluster type in the main VI is not changed.
Note that your data is coerced upon entering the subVI (see red dot), I don't think the order has changed, could you verify that with some testdata?
Secondly I urge you to use a type-def control:
  1. Right click on the control in the subVI, select Advanced, Custimize
  2. In the new window change the type from control to type def (it's in the button bar)
  3. Save the control
  4. Close control and select 'use xxx instead of flow control'
  5. right click on Block Diagram and add the control their.
  6. Use bundle by name to store the data in the cluster
This should remove data coercion, and your code is better readable.

Ton
Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
0 Kudos
Message 5 of 9
(3,231 Views)

Hi Claus,

I have agree with tst and Ton on how they interprested what is happening.

Type definitons will elliminate the issue.

Watch for those coercion dots.  They are a sign that LabVIEW is doing some guessing on your behalf.

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 6 of 9
(3,224 Views)


Watch for those coercion dots.  They are a sign that LabVIEW is doing some guessing on your behalf.

I'm pretty sure it's not guessing!

Ton
Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
0 Kudos
Message 7 of 9
(3,221 Views)

"...not guessing"

OK, how about "making assumptions"?

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 8 of 9
(3,216 Views)
Thank you all for your advice. I am sure it well help me make "nicer" LabVIEW code in the future.

I noted in the cluster control in the subVI that the order of the elements was different from that of the main VI. By right-clicking and choosing 'Reorder Controls in Cluster...' I managed to solve my problem. That certainly explains why data and variable names got mixed up.

But I will look more into your advice about typedefs also. It is always nice to get to know features you didn't know before.
0 Kudos
Message 9 of 9
(3,197 Views)