Jump to content

Using variant and set/get attribute


Recommended Posts

Hi All,

 

I had a question about variant data and variant attributes specifically. I have different datatypes, and for having a nice and neat wiring, I am storing an array of clusters made of a variant and a data tag, so I can insert a new datatype w/o changing anything and with no i/o problems. I use normal search for tag and retrieve data VI, and the same thing for adding new data or changing data.image.png.9fa148114328d21d0e77cb0940ede817.png

My qusetion was: can i Just use variant attributed to do the same? something like this?

image.png.4ec7094f78c4ae16b5929794e72e0b0d.png

 

Are there any draw backs that I do not know of? 

 

Cheers,

M

Edited by Mahbod Morshedi
Link to comment

Is there a reason you are doing this, instead of having a type def'd cluster?  Then you can use the Bundle/Unbundle by name to get and set values within a single wire?  Then probing is easier, and adding or updating data types can be done by updating that one cluster.  Typically Variant Attributes are used in places where an architecture wants to abstract away some transport layer that can't be known at runtime.  In your case we know the data type of all the individual elements.  If you were doing some kind of flatten to a Variant, then sending over TCP, you'd want some standard way to unwrap everything once it got back.  I've also seen it used where a single User Event handles many different events, by using the Variant as the data type.  Then each specific User Event will have a Variant to Data to convert back to whatever that specific event wants.  There isn't anything wrong with what you are doing, I'm just unsure if it is necessary.

  • Like 1
Link to comment

Thank you for the reply,
Well, I'm very new at Labview, and the software I am developing is for my use. The problem with that is that I know the work and am learning more and more tricks that push me to add more features to the app, and now it has become too big. I am carrying too many unsorted clusters throughout the app that need proper organisation. I also am carrying too many wires in the shift registers (dynamic data, hardware and acq parameters, raw data, copy of the original raw data, worked and formatted data and copy of the original of those for history and undid purposes. I am also adding a completely new experiment to this software, which treats data differently, but the internal would be the same.
As you can see, I am out of my depth, and this is a way for me to manage the data across the VIs in different formats and unbundle on the fly based on technique and application.

This a the original post I made a while a go that lead me to this decitsion, thanks to ShaunR and the data has gotten bigget since:

I was just wondering about the "array with tag" or "Var attribute" since there is not much information about the latter. I am unsure if the data is more susceptible to corruption, gets lost, or if there are other complications I do not know about. 
Really! I appreciate your reply. It took a while for someone to reply to this one.


Cheers,

M

Link to comment
On 3/9/2024 at 10:36 PM, Mahbod Morshedi said:

I was just wondering about the "array with tag" or "Var attribute" since there is not much information about the latter. I am unsure if the data is more susceptible to corruption, gets lost, or if there are other complications I do not know about. 

The variant attribute cannot have duplicates. If you set it, it overwrites the previous values. With the "array with tag" you can have duplicates.

  • Like 1
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
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.