alphaone Posted October 17, 2005 Report Share Posted October 17, 2005 Hi, I wrote a sub VI whose parameter is variant. and i must convert this parameter to normal by "Variant to Data" function. How can i know which type this variant will be?? As the following figure shows,the variant may contain totally different types ,how to set the "type" of "Variant to Data" function as what i need?? Quote Link to comment
Jim Kring Posted October 17, 2005 Report Share Posted October 17, 2005 Hi,I wrote a sub VI whose parameter is variant. and i must convert this parameter to normal by "Variant to Data" function. How can i know which type this variant will be?? As the following figure shows,the variant may contain totally different types ,how to set the "type" of "Variant to Data" function as what i need?? Download OpenG Commander and install the lvdata package. This has tools for variant introspection and manipulation. Quote Link to comment
alphaone Posted October 17, 2005 Author Report Share Posted October 17, 2005 Download OpenG Commander and install the lvdata package. This has tools for variant introspection and manipulation. Thank you,but i don't wanna use OpenG in my program, is there another method? Quote Link to comment
Yair Posted October 17, 2005 Report Share Posted October 17, 2005 Thank you,but i don't wanna use OpenG in my program, is there another method? If you want to set a control, you can try using the VI class "Set Control Value (Variant)" method. This will allow you to use a variant directly, but has its own dangers and downsides. If you want to convert the data into a wire, you will have to have duplicate code at least to some degree, because the wire coming out of the function can only have one data type. You can have this duplicated code in polymorphic VIs, but that will also require some work. The OpenG VIs use the Type Descriptor to process the data. You could do the same, but since the work was already done, it seems a shame to do it all over. Quote Link to comment
Aitor Solar Posted October 17, 2005 Report Share Posted October 17, 2005 Yes, it's easily done looking the descriptors. Time ago, I prepared an evolutioned version of the OpenG method, so if the variant is an array or a cluster, it says what kind of contents has (so the answer is "array of I32" instead just "array", or "array of clusters of string, boolean, refnum", etc). I hope you'll find it useful. Keep in mind is just a VI I did for a particular purpose in a project, it's not really hard-validated. Just works for usual tasks. Saludos, Aitor Download File:post-1450-1129539061.llb Quote Link to comment
Jim Kring Posted October 17, 2005 Report Share Posted October 17, 2005 Thank you,but i don't wanna use OpenG in my program, is there another method? Yes, you can read "<LabVIEW>\manuals\datastrg.pdf" and write your own tools. Quote Link to comment
alphaone Posted October 18, 2005 Author Report Share Posted October 18, 2005 Download OpenG Commander and install the lvdata package. This has tools for variant introspection and manipulation. Thanks,i have read it. I can use the "typedescriptor" to judge what data type the variant contains. but , how about cluster?? we can see the types contained in a cluster,but we can't create a cluster by the types,at least i can't. because the parameter "type" of "Variant to Data" need a real cluster not a typedescriptor. Yes, it's easily done looking the descriptors. Time ago, I prepared an evolutioned version of the OpenG method, so if the variant is an array or a cluster, it says what kind of contents has (so the answer is "array of I32" instead just "array", or "array of clusters of string, boolean, refnum", etc).I hope you'll find it useful. Keep in mind is just a VI I did for a particular purpose in a project, it's not really hard-validated. Just works for usual tasks. Saludos, Aitor Thanks,your vi is nice.i can analyse the types contained by a variant. But how to use the type descriptor to create real controls?? Quote Link to comment
Jim Kring Posted October 18, 2005 Report Share Posted October 18, 2005 Thanks,i have read it. I can use the "typedescriptor" to judge what data type the variant contains. but , how about cluster?? we can see the types contained in a cluster,but we can't create a cluster by the types,at least i can't. because the parameter "type" of "Variant to Data" need a real cluster not a typedescriptor.Thanks,your vi is nice.i can analyse the types contained by a variant. But how to use the type descriptor to create real controls?? You need to parse and construct data strings and type descriptors. This is not trivial. You might as well use the OpenG tools -- why do you think that you shouldn't use them? Quote Link to comment
alphaone Posted October 18, 2005 Author Report Share Posted October 18, 2005 You need to parse and construct data strings and type descriptors. This is not trivial. You might as well use the OpenG tools -- why do you think that you shouldn't use them? how to construct?use Quote Link to comment
Aitor Solar Posted October 18, 2005 Report Share Posted October 18, 2005 For example, i want to control VSA by GPIB,so pass the GPIB address and center freqenecy. At other time,i want control my AWG, so pass a different type parameters.That's why i use variant as a sub vi's parameter. Why not to use a polymorphic VI, then? Saludos, Aitor Quote Link to comment
alphaone Posted October 18, 2005 Author Report Share Posted October 18, 2005 Why not to use a polymorphic VI, then?Saludos, Aitor Sorry,i am novice to lv. i havn't learn about Polymorphic yet. and i don't know how many types will be used. Quote Link to comment
PJM_labview Posted October 18, 2005 Report Share Posted October 18, 2005 and my project is not complex to use Goop, so i don't want to install it. and i think it will be better if you do this by yourself. There might be a communication break down here. OpenG Tools and Libraries accessible through OpenG commander are not Goop Class. The OpenG Tools are made of several libraries such as File IO, Arrays Manipulation, String Manipulation, Application Controls, LV Data Tools (<- This is the one that will interest you) and more. Each of these library are packaged in a special zip fil called "ogp" (for OpenG Package) and can be installed in your system by using OpenG Commander (See image below for a screen shot of the commander showing a list of the most recent packages). One of these packages is a Goop Class template (hence maybe the confusion), but this one of many. If you do not want to use the Free OpenG Tools, this is fine. But why redo the work that someone has already done ? PJM Quote Link to comment
Michael Aivaliotis Posted October 25, 2005 Report Share Posted October 25, 2005 how to construct?use "unflatten from string" or "unflatten to variant"?and my project is not complex to use Goop, so i don't want to install it. and i think it will be better if you do this by yourself. maybe i havn't expressed my question clearly.that is : A sub vi's parameter is variant. In this sub vi, i have to transfer variant to a real control even a cluster. then ,i use this cluster to control my equipments. For example, i want to control VSA by GPIB,so pass the GPIB address and center freqenecy. At other time,i want control my AWG, so pass a different type parameters.That's why i use variant as a sub vi's parameter. The cluster maybe the following struct: Equipment ID VISA command ... Testment ID Testing parameter ... that's all ,so i want to transfer the variant to a cluster,after all ,i don't know the detail of the variant at design phase util the vi is running. If you don't know what the datatype is at design time then you have a significant challenge ahead of you. I've done exactly what you describe using variants for a flexible test system I built, however I used the OpenG variant tools. The OpenG variant tools are really cool! :thumbup: You can do everything you describe. They were created by the one and only jpdrolet . The best part... you don't have to write a single line of code. Quote Link to comment
alphaone Posted October 25, 2005 Author Report Share Posted October 25, 2005 If you don't know what the datatype is at design time then you have a significant challenge ahead of you. I've done exactly what you describe using variants for a flexible test system I built, however I used the OpenG variant tools. The OpenG variant tools are really cool! :thumbup: You can do everything you describe. They were created by the one and only jpdrolet . The best part... you don't have to write a single line of code. Oh,it's a good news! i have already been despaired.Can i download only the Variant Tools of Goop? My comany's network blocks me and i can not user Commander to do it. Thanks. Quote Link to comment
WMassey Posted October 25, 2005 Report Share Posted October 25, 2005 Can i download only the Variant Tools of Goop? My comany's network blocks me and i can not user Commander to do it. That's a very good question. I'd like to update the OpenG libraries on a machine that is no longer connected to an open network. I wonder what folder of files I need to copy from an up-to-date machine to effectively update a machine where Commander won't work... Quote Link to comment
Jim Kring Posted October 25, 2005 Report Share Posted October 25, 2005 I have posted info on how to do this here: There are a couple ways to get all of the OpenG packages. 1) You can download them individually. Most of them are located here: http://sourceforge.net/projects/opengtoolkit 2) You can download them all using Commander on a machine that has internet access and then transfer them to the computer that does not have internet access. Commander keeps all of it's packages in a "cache" folder. You can see the location of the cache by navigating to Tools (menu) >> Options (menu) >> Advanced (button) >> Cache (tab). Quote Link to comment
alphaone Posted October 26, 2005 Author Report Share Posted October 26, 2005 I have posted info on how to do this here: Great!i get a hope! :thumbup: 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.