Sebastian Posted May 6, 2008 Report Share Posted May 6, 2008 hello everybody, in my thesis project i try to build a generic SubVI that analyze an existing cluster and the bundled datatypes and translate any datatype into a string so that we can write the items of an multibox list. (required an 2-D-array of strings). If the data structure of the cluster well known, than it is easy to do it with a case structure and different convertations. I am wonder if it is possible to read a cluster an analyze the datatype to make a decision witch type of convertation we have to choose. We try to create so to say a more generic solution. I am looking forward to your replies! /Sebastian Quote Link to comment
TobyD Posted May 6, 2008 Report Share Posted May 6, 2008 QUOTE (Sebastian @ May 5 2008, 02:21 PM) hello everybody,in my thesis project i try to build a generic SubVI that analyze an existing cluster and the bundled datatypes and translate any datatype into a string so that we can write the items of an multibox list. (required an 2-D-array of strings). If the data structure of the cluster well known, than it is easy to do it with a case structure and different convertations. I am wonder if it is possible to read a cluster an analyze the datatype to make a decision witch type of convertation we have to choose. We try to create so to say a more generic solution. I am looking forward to your replies! /Sebastian Something like this will get you an array of class types contained in your cluster... http://lavag.org/old_files/monthly_05_2008/post-8758-1210025263.png' target="_blank"> Edit: Probably should have used Controls[] instead of AllObjects[] Quote Link to comment
crelf Posted May 6, 2008 Report Share Posted May 6, 2008 Get a reference to the cluster, then get references to "Controls []" - then (looping over each control) check out the "ClassID" and/or "ClassName" properties. EDIT: TobyD beat me in posting AND added a code screenshot - talk about an overachiever! Quote Link to comment
TobyD Posted May 7, 2008 Report Share Posted May 7, 2008 QUOTE (crelf @ May 5 2008, 03:16 PM) talk about an overachiever! http://lavag.org/old_files/monthly_05_2008/post-8758-1210029080.png' target="_blank"> I ran it and it returned false...I guess I'm still OK :thumbup: Quote Link to comment
crelf Posted May 7, 2008 Report Share Posted May 7, 2008 QUOTE (TobyD @ May 5 2008, 07:12 PM) http://lavag.org/old_files/monthly_05_2008/post-8758-1210029080.png' target="_blank"> I ran it and it returned false...I guess I'm still OK :thumbup: How odd - I ran it on my PC and got a TRUE... Quote Link to comment
CaseyM Posted May 7, 2008 Report Share Posted May 7, 2008 Continuing on this topic... is there a property that tells which type of numeric the control is (i.e. whether it's an I32, DBL, etc.)? Quote Link to comment
BobHamburger Posted May 7, 2008 Report Share Posted May 7, 2008 QUOTE (TobyD @ May 5 2008, 06:08 PM) Something like this will get you an array of class types contained in your cluster... http://lavag.org/old_files/monthly_05_2008/post-8758-1210025263.png' target="_blank"> Edit: Probably should have used Controls[] instead of AllObjects[] This is a little simplistic -- it will only work if the cluster only contains a flat collection of basic LV panel objects. The more generic solution would require recursion, so that any contained structures (clusters within the cluster, arrays, etc.) would be drilled into and analyzed also. For guidance, a good starting point to better understand this challenge (and some great code to learn from) is in the OpenG Toolkit: the Variant Config File VIs perform a lot of these very operations. Quote Link to comment
Götz Becker Posted May 7, 2008 Report Share Posted May 7, 2008 QUOTE (cmay @ May 6 2008, 12:39 AM) Continuing on this topic... is there a property that tells which type of numeric the control is (i.e. whether it's an I32, DBL, etc.)? Hi, I would try and play a little with GetClusterInfo.vi, GetArrayInfo.vi and GetTypeInfo.vi found in <vilib>/Utility/VariantDataType/VariantType.lvlib The VIs in there aren´t documented very well, but you should be able to get the needed information with those out. (Beware... trying to traverse a complex structure programmatically can be tricky ) Quote Link to comment
LAVA 1.0 Content Posted May 7, 2008 Report Share Posted May 7, 2008 ... and if you are looking for another way to look at this challenge, my Save-Restore Nugget on the Dark-Side touches on arbitrary clusters and un-raveling them. Ben Quote Link to comment
Francois Normandin Posted May 7, 2008 Report Share Posted May 7, 2008 QUOTE (cmay @ May 5 2008, 07:39 PM) Continuing on this topic... is there a property that tells which type of numeric the control is (i.e. whether it's an I32, DBL, etc.)? If you haven't changed any default values for limits, you could use the "Data Entry Limits" property to determine which datatype by correlation with expected value for each datatype, but I don't think there is a direct way. Maybe there is something accessible with VI scripting (see Rusty Nails forums), but I haven't found it yet... Quote Link to comment
gb119 Posted May 7, 2008 Report Share Posted May 7, 2008 QUOTE (Sebastian @ May 5 2008, 09:21 PM) in my thesis project i try to build a generic SubVI that analyze an existing cluster and the bundled datatypes and translate any datatype into a string so that we can write the items of an multibox list. (required an 2-D-array of strings). If the data structure of the cluster well known, than it is easy to do it with a case structure and different convertations. I am wonder if it is possible to read a cluster an analyze the datatype to make a decision witch type of convertation we have to choose. We try to create so to say a more generic solution. In your vi.lib/Utility/VariantDatatType folder you will find all kinds of useful vi's for poking around at the datatype of a variant control. Disentangling the datatype of a cluster is a little tricky since you have to handle things like clusters of clusters and clusters of arrays of clusters.... Attached is a quick hack that will give you a string describing the type of any control wired to the variant, including working down arrays and clusters recursively. It doesn't handle refnums, but you can get the basic idea... Download File:post-3951-1210079267.vi Quote Link to comment
Ton Plomp Posted May 7, 2008 Report Share Posted May 7, 2008 Shameless plug: Variant Browser It will traverse through any kind of data-type (and it uses classes too). Ton Quote Link to comment
Mark Balla Posted May 8, 2008 Report Share Posted May 8, 2008 I think it is important to note that the Class name and the Data type are not the same thing especially when dealing with numeric controls. Download File:post-584-1210175033.viI along with help from Aristos, developed a vi that helps categorize a control or indicator into a generic cluster so it can be compared to others. It is discussed this in this thread Here is the code that does the categorizing. Download File:post-584-1210175521.zip Quote Link to comment
Karissap Posted May 9, 2008 Report Share Posted May 9, 2008 If you just care about the type of data including differentiating the type of numeric DBL, I32 etc have a look at the Open G VI "Variant to Header Info". See the attached front panel and block diagram. If you want to handle clusters or arrays in clusters etc you will need to add recursion. Quote Link to comment
Francois Normandin Posted May 9, 2008 Report Share Posted May 9, 2008 QUOTE (Karissap @ May 8 2008, 02:33 AM) If you just care about the type of data including differentiating the type of numeric DBL, I32 etc have a look at the http://wiki.openg.org/Main_Page' rel='nofollow' target="_blank">Open G VI "Variant to Header Info". See the attached front panel and block diagram. OpenG :worship: Quote Link to comment
orko Posted May 9, 2008 Report Share Posted May 9, 2008 QUOTE (mballa @ May 7 2008, 08:56 AM) http://lavag.org/old_files/monthly_05_2008/post-584-1210175023.png' target="_blank"> "GetTypeInfo.vi"... Now that's another VI I didn't know about! BTW, for all those wondering, it can be found here:<LabVIEW>\vi.lib\Utility\VariantDataType\GetTypeInfo.vi 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.