Bonagel Posted April 18, 2008 Report Share Posted April 18, 2008 Hi there, this is my first post in this forum - so I hope it's the right category... In my application I have to use the openG's "Set Cluster Element by Name" VI. The new elements I am setting into this cluster may have attributes. My problem is, that the elements that had attributes lose them after passing the "Set Cluster Element by Name" VI. I think that the problem is the "flatten-to-string" operation inside the "Array of VData to VCluster" VI in the "Set Cluster Element by Name" VI, because the attributes are ignored here... Is there any way to solve this problem? Link to comment
jpdrolet Posted April 18, 2008 Report Share Posted April 18, 2008 QUOTE (Bonagel @ Apr 17 2008, 12:16 PM) Hi there, this is my first post in this forum - so I hope it's the right category... In my application I have to use the openG's "Set Cluster Element by Name" VI. The new elements I am setting into this cluster may have attributes. My problem is, that the elements that had attributes lose them after passing the "Set Cluster Element by Name" VI. I think that the problem is the "flatten-to-string" operation inside the "Array of VData to VCluster" VI in the "Set Cluster Element by Name" VI, because the attributes are ignored here... Is there any way to solve this problem? If you want an element of a cluster to have attributes, the only way is to make the element a variant. Variant and waveform are the only datatypes that can have attributes. Here you have a cluster with two integers which can't have attributes. Link to comment
Bonagel Posted April 19, 2008 Author Report Share Posted April 19, 2008 QUOTE (jpdrolet @ Apr 17 2008, 05:32 PM) If you want an element of a cluster to have attributes, the only way is to make the element a variant. Variant and waveform are the only datatypes that can have attributes. Here you have a cluster with two integers which can't have attributes. okay you are right... but in my application I got also variants in my cluster. I changed my example program and it still doesn't work. Like I wrote in my first post I suggest that the flattened data string inside the VI does not contain the attribute information... http://lavag.org/old_files/monthly_04_2008/post-11302-1208501912.png' target="_blank"> Link to comment
Jim Kring Posted April 19, 2008 Report Share Posted April 19, 2008 QUOTE (Bonagel @ Apr 18 2008, 12:02 AM) okay you are right... but in my application I got also variants in my cluster. I changed my example program and it still doesn't work. Like I wrote in my first post I suggest that the flattened data string inside the VI does not contain the attribute information... I see your point. You are correct. Set Data Name (and probably several other of the OpenG VIs) do not preserve the variant's attributes. I don't think the attributes survive the Variant to Flattened String and Flattened String to Variant operations (the attributes aren't in the flattened data or type descriptor). The only way to preserve the attributes would be to read them all on the incoming variant and write them in the outgoing variant. It might be feasible, but would take a bit of work and could have some performance implications. Link to comment
Bonagel Posted April 19, 2008 Author Report Share Posted April 19, 2008 QUOTE (Jim Kring @ Apr 18 2008, 07:15 AM) I see your point. You are correct. Set Data Name (and probably several other of the OpenG VIs) do not preserve the variant's attributes. I don't think the attributes survive the Variant to Flattened String and Flattened String to Variant operations (the attributes aren't in the flattened data or type descriptor). The only way to preserve the attributes would be to read them all on the incoming variant and write them in the outgoing variant. It might be feasible, but would take a bit of work and could have some performance implications. Thanks Jim for your suggestion - but it leads to my next question: how can I programmaticly get access to a clusterelement without using any flatten-to-string-operation? Link to comment
Jim Kring Posted April 19, 2008 Report Share Posted April 19, 2008 QUOTE (Bonagel @ Apr 18 2008, 02:15 AM) Thanks Jim for your suggestion - but it leads to my next question: how can I programmaticly get access to a clusterelement without using any flatten-to-string-operation? Unfortunately, I don't know of any way to do it without flattening to string. Link to comment
jpdrolet Posted April 19, 2008 Report Share Posted April 19, 2008 Ha! that is a different story and I did see it coming. There is a subtlety here that I'll try to explain. What the VI does is to assign the content of the incoming variant to the cluster element. Still the content is an integer (without attributes) and it is assigned to the variant cluster element. See the content of output cluster: first element is an empty variant and second element is an integer, not a variant thus no attributes. You have changed the type of the cluster from {Variant,Variant} to {Variant,Integer}. Now if you use Variant to Data to convert the variant to the original typed cluster, it will work because it allows the conversion of an integer to a variant. Now what you have to do is to insert another To Variant node to wrap the variant into a variant so the VI handles the input content as a variant and keep its attributes. Be careful that the name of the embedded variant is set correctly or use that name input. Link to comment
Jim Kring Posted April 19, 2008 Report Share Posted April 19, 2008 QUOTE (jpdrolet @ Apr 18 2008, 10:20 AM) Now what you have to do is to insert another To Variant node to wrap the variant into a variant so the VI handles the input content as a variant and keep its attributes. Be careful that the name of the embedded variant is set correctly or use that name input. I tried this and it doesn't seem to keep the variant attributes. Attributes don't survive the flatten-unflatten process: Download File:post-17-1208546218.vi Link to comment
orko Posted April 19, 2008 Report Share Posted April 19, 2008 Jim, I believe what he was trying to get at is if you protect the variant by wrapping it up into another variant, the flatten won't kill the attributes: Link to comment
Bonagel Posted April 22, 2008 Author Report Share Posted April 22, 2008 QUOTE (orko @ Apr 18 2008, 08:18 PM) Jim,I believe what he was trying to get at is if you protect the variant by wrapping it up into another variant, the flatten won't kill the attributes: Thanks for your answers! @ orko: yes this is what I am trying to do! And your sollution works, but I think I can't use your sollution inside OpenG's "Array of VData to VCluster" VI... I could protect my attributes by wrapping them into a variant, but how do I unwrap them "inside" the cluster? Link to comment
jpdrolet Posted April 22, 2008 Report Share Posted April 22, 2008 QUOTE (Bonagel @ Apr 21 2008, 03:00 AM) Thanks for your answers! @ orko: yes this is what I am trying to do! And your sollution works, but I think I can't use your sollution inside OpenG's "Array of VData to VCluster" VI... I could protect my attributes by wrapping them into a variant, but how do I unwrap them "inside" the cluster? You don't need to modify OpenG VIs as they work as intended. You just need to wrap the variant element into a variant: http://lavag.org/old_files/monthly_04_2008/post-447-1208784179.png' target="_blank"> That is required since LVdata VIs work on the content of the variant on input. Link to comment
Bonagel Posted April 22, 2008 Author Report Share Posted April 22, 2008 QUOTE (jpdrolet @ Apr 21 2008, 02:46 PM) You don't need to modify OpenG VIs as they work as intended. You just need to wrap the variant element into a variant one aim of my application is to create clusters dynamicly... so i need a way to get (among others) a variant with its attributes into a cluster programaticly. and i need it there without wrapping it into something else, so that i can later get access to each of the clusters element directly... Link to comment
jpdrolet Posted April 22, 2008 Report Share Posted April 22, 2008 QUOTE (Bonagel @ Apr 21 2008, 10:01 AM) one aim of my application is to create clusters dynamicly... so i need a way to get (among others) a variant with its attributes into a cluster programaticly. and i need it there without wrapping it into something else, so that i can later get access to each of the clusters element directly... That is exactly what the post code does. The variant element cluster is accessible directly with its attributes after the Variant To Data conversion. To unwrap a variant[variant], use Variant to Data with a variant for type input. Can you explain if you need something else? Link to comment
Bonagel Posted April 22, 2008 Author Report Share Posted April 22, 2008 QUOTE (jpdrolet @ Apr 21 2008, 03:15 PM) That is exactly what the post code does. The variant element cluster is accessible directly with its attributes after the Variant To Data conversion. To unwrap a variant[variant], use Variant to Data with a variant for type input. Can you explain if you need something else? Before disagreeing with you, i should have tried your code... it works perfectly!!! Thanks a lot!!! Link to comment
Jim Kring Posted April 22, 2008 Report Share Posted April 22, 2008 QUOTE (orko @ Apr 18 2008, 01:18 PM) I believe what he was trying to get at is if you protect the variant by wrapping it up into another variant, the flatten won't kill the attributes: Hi Joe, I see what you're saying. I should have read the various postings more carefully :headbang: I'm happy that you all were able to solve the problem -Jim Link to comment
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now