Taylorh140 Posted January 26, 2018 Report Share Posted January 26, 2018 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. Quote Link to comment
Taylorh140 Posted January 26, 2018 Author Report Share Posted January 26, 2018 I So it wasn't so bad to put this together. I hope it ends up being useful! Variant_Scoped_Enum.vi Quote Link to comment
drjdpowell Posted January 26, 2018 Report Share Posted January 26, 2018 Are you aware of "Get Numeric Information" in the vi.lib\Utility\Data Type? Gives you the enum strings. One doesn't need to use Flattening to work with Variants anymore. Quote Link to comment
Taylorh140 Posted January 26, 2018 Author Report Share Posted January 26, 2018 (edited) Yeah, I was actually doing the opposite. Using an array of strings and a value generating a enum at runtime. I was afraid what i was trying to do might be confusing. I might be getting encoded data from a device and to decode it instead of using a cluster (which contains a great deal of useful information apart from the values) using variant attributes. Since the specification is sometimes in a document it is easier to pull from that source as apposed to decoding everything using LV wires and clusters. However when looking at variant attributes especially for enumerations its hard to see what the value actually means. this allows me to have a probe view of the data that looks like the right as apposed to the left. Edited January 26, 2018 by Taylorh140 details Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.