Jump to content

After "Variant-Array to Variant-Cluster" all attributes are gone


Recommended Posts

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

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

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

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

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

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

QUOTE (orko @ Apr 18 2008, 08:18 PM)

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?

post-11302-1208761157.png?width=400

Link to comment

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

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

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

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.