Jump to content

Dynamic Names and Values from Variants


Recommended Posts

Hi there!

I've played around with a piece of my Programm where I have to create an array of clusters where a cluster has two emenents: a NAME and a VALUE for the specific name.

I Would like to use something like the firt Screenshot as an Input (Bundle the Variables to a cluster).

Then, inside the SubVI I would like to generate said Array of Clusters based on the Label of the Controls that I use as Inputs to the cluster.

post-27848-0-12638800-1364997492.png

As a Result I would like to get something like this:

post-27848-0-35084800-1364997729.png

The thing is that I can't seem to get the Data out of the Variant - On the Frontpanel, the indicator for the variant shows all the information I need...

post-27848-0-85696800-1364997933.png

How do I get the Information out of there? Any Ideas?

Edited by kull3rk3ks
Link to post

Use the Variant Attribute.  You can have an attribute named "Potato" and set the value to 100.  Then Set another attribute (on the same variant) called "Apple" with a value of 13.  Then read the attribute with the name "Potato" and you will get your 100 back.  You will need to tell the Read Attribute function what the data type of Potato is but that's the only catch.

Link to post

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.

  • Similar Content

    • By Taylorh140
      So sometimes when you do protocol decoding it is convenient to use a variant to store decoded data. For example you might have a 2 bit enumeration that is decoded like this:
      00 -> Good
      01 -> Bad
      10 -> Ugly
      11 -> Catastrophic
      If you cast the value to an enumeration that contains these values before hand you can see them on the variant control. If you use a Ring you will only see a value. 
      I know that the LV flatten to string contains the enumeration strings but the encoding is a bit of a mystery, although it looks like the openg palette has figured some of it out to some degree. But to me it doesn't look like there is any reason i couldn't generate an enum to use inside the scope of a variant. Has anyone done this, or know how to generate the string for this purpose. 

    • By Fred chen
      Hi
       
      When I call the DLL, there is a structure:
      struct Signal { uint32 nStartBit; uint32 nLen; double nFactor; double nOffset; double nMin; double nMax; double nValue; uint64 nRawValue; bool is_signed; char unit[11]; char strName[66]; char strComment[201]; };  
       
      There is another  Message structure to the above Signal:
       
      struct Message { uint32 nSignalCount; uint32 nID; uint8 nExtend; uint32 nSize; Signal vSignals[513]; char strName[66]; char strComment[201]; }  
        The point is  Signal vSignals[513];
       
      I've tried to solve it like this,but the program will crash.
       
      How to create struct Message ,any good suggestions?  Thanks a lot.
       

      message.vi
    • By Taylorh140
      After working on the set cluster element by name xnode, it made me realize i could use the same concept to convert a variant array to a cluster. The technique is actually pretty simple, the xnode generates a case structure for each element in a cluster in cluster order, wherein a bundle by name is used to set the value and an unbundle by name is used to get the type, a variant to data is used to convert the data. This has some benefits over some methods, you are not limited to 255 elements, although that is not usually the case some of us are paranoid that clusterosaurus giganticous will be larger than expected. It also has a draw back  that is that when converting from a variant array all the elements must have unique, non-blank names, and this is usually the case. 

      I think this technique (though very brute-force) might be useful for some other things let me know what you guys think.

      VariantArrayToCluster.zip
    • By Taylorh140
      This Xnode allows setting a cluster element by label string without using references. I pulled a great deal of inspiration from Hooovahhs Variant Array to cluster xnode, which i suppose this could be used for, another benefit is its not limited to 255 elements. Its mostly experimental because I haven't used it much. 
       
      SetClusterElement.zip

      SetClusterElementLV2013.zip
    • By Porter
      Is there any way to automatically wire an index array block to a bundle by name block?

      Auto-wire (pressing space) just adds one wire.
      Note that my cluster contains data of different types so converting the cluster to an array doesn't work.
      If there is a quick-drop shortcut for this I would be very impressed.
×
×
  • Create New...

Important Information

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