09-13-2022 01:10 AM
Hi,
I would like to know how to use the get variant attributes function.
When I run the attached vi, I expect to see the contents of the "cluster" controller in the "name" and "value" indicators.
But nothing is displayed.
Expected value
Name"→{"Numeric", "Boolean", "String"}
Value"→{0,FALSE,""}
■Reference
What I would like to do eventually is to read/write values via reference to controllers in other VIs.
However, in the case of clusters, I am having trouble obtaining what the constituent elements are.
(except for clusters, I get the class name of the controller to check)
The flattened string seems to give me the information I need, but the internal representation seems a bit unwieldy.
I think it would be easier if I could get the information in the same way as it is displayed in the "variant" indicator.
I thought that the Variant Attribute Get function could do such a thing, but I don't know how to use it, so I am asking this question.
I would appreciate it if you could tell me if there is a better way other than using the function to get variant attributes.
Thank you in advance.
Solved! Go to Solution.
09-13-2022 03:30 AM - edited 09-13-2022 03:33 AM
Here is a screenshot of the block diagram and front panel.
Thanks in advance.
09-13-2022 03:53 AM
There are no variant attributes in your variant... What you see is values.
There won't be any variant attributes in a variant, unless you put them there with set variant attribute.
If you want the data elements of a cluster use this:
Be warned: going back (data elements to a cluster) is a very more difficult...
09-13-2022 04:01 AM
Hi yuma,
Variant attributes are a way of storing a key-value map inside a variant, which has nothing to do with cluster elements. So this is why you see empty arrays out of the "Get Variant Attribute" function.
To generically access the elements of a variant cluster, you can use the function "Cluster to Array of VData" from the VIPM toolkit "OpenG Toolkit":
09-13-2022 04:22 AM - edited 09-13-2022 04:25 AM
->wiebe@CARYA
Thank you for your detailed explanation.
Your advice helped me to do the readout.
I really appreciate it.
But I also want to write.
Am I correct in recognizing that it is difficult but possible?
Can you tell me about writing as well?
Thank you in advance.
09-13-2022 04:33 AM
Hi raphschru,
Thank you for the information which looks very useful.
I will give it a try.
I will report back if I make any progress.
Thank you.
09-13-2022 04:45 AM
09-13-2022 04:50 AM
Without that toolkit, you need to concatenate flattened data of the individual elements:
09-13-2022 12:53 PM
What specific problem are you trying to solve? For the moment forget about clusters or variants and simply describe what exactly you are trying to accomplish with your code. There may be more appropriate ways to accomplish your end goal than the path you are currently taking.
09-13-2022 07:36 PM
Thanks for your reply.
It certainly sounds like a lot of work.
I will try the toolkit first.