Jump to content

Building a variant of arbitrary data type?

Recommended Posts

I'm working towards a Labview 7.1 app that would be a bridge between Excel and a small network of Labrad test instrument servers ( http://en.wikipedia.org/wiki/LabRAD ). Spreadsheet as general purpose test controller in other words, with program steps stored as excel comments.

Labrad supports arbitrarily complex data, described as a string e.g. (b*3s) = cluster of binary and 3d string array. To support this, the labrad interface uses labview variants. It seems logical to stick with variants for the excel interface, to keep it general purpose.

By adapting Jim Kring's 'Universal Probe' http://vi-lib.com/news/UniversalProbe-LabVIEWdat.html, I'm able to pass any labview variant into excel. (User layout choices to follow eventually)

Anybody any hints on going the other way - assembling the values pulled from excel into a labview variant? Inputs are (1) the labrad string describing the data (2) labview data from the individual spreadsheet cells. Pulling the data out of excel is already working, it's assembling the required variant using a string formula that seems tricky.

I suspect the variant will have to be constructed byte by byte - but would some of the openg variant vis help? Being self-taught, the application of some of these is obscure.

After cracking this hurdle, I hope to include it in my existing code with an added 'data direction' input.

I already know of NI App Note 154, http://openg.org/docs/LabVIEW%20Data%20-%201%20of%202.pdf and the openg variant examples on sourceforge.

Cheers, Bob

Link to post
Share on other sites

Since you have the OpenG VIs, you can have a look at the variant config VIs. The one which reads a cluster from the file builds a variant cluster based on the input cluster and you can then convert that variant to your data type. As you point out, this can be somewhat complicated. You should note that it also uses type descriptors which have been changed in LV 8.x and have been made private, so going forward this isn't necessarily a very good idea if you plan on upgrading.

If you are thinking of upgrading, you could look at MGI's read-write anything VIs, which do a similar action, but use VIs which are shipped with LV in 8.x.

Link to post
Share on other sites

I already know of NI App Note 154, http://openg.org/doc...01%20of%202.pdf and the openg variant examples on sourceforge.

Cheers, Bob

Thanks for the post to this App Note I found it an interesting reading. Does anybody know if the part 2 of 2 ever get written and if so does anyone have a copy of it or a link to it please ?


Link to post
Share on other sites

Editing your code in the following way in the 'cluster' should fix your code:


My code shows the edits in the array state, which should be in the cluster state. Remember that an array must have the same datatypes for all elements.


Link to post
Share on other sites

Yair - Thanks for the hints. I'd tried converting the MGI 'read/write anything to file' down to labview 7.1. I got a lot of bad vi messages, so I expect it's the new features you mention that aren't backward compatible. I'll look at those vis more closely as to the technique used. Avoiding being locked into 7.1 is a very good idea, though - so I need to be cautious in any bit-banging approach taken.

DannyT - I've not come across 'LabVIEW Data (2 of 2) in several searches

Ton - thanks for that - I removed the array (as you say it makes no sense) - and your code then produces the cluster, so that would be useful as part of the conversion process.

Link to post
Share on other sites

Join the conversation

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

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.