Jump to content

determine datatypes in a cluster


Recommended Posts

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

Link to comment

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! :D

Link to comment

QUOTE (TobyD @ May 5 2008, 06:08 PM)

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.

Link to comment

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 :wacko: )

Link to comment

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...

Link to comment

QUOTE (Sebastian @ May 5 2008, 09:21 PM)

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...

post-3951-1210079388.png?width=400

Download File:post-3951-1210079267.vi

Link to comment

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.

post-584-1210175023.png?width=400

Download File:post-584-1210175033.vi

I 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

Link to comment

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.

post-8228-1210227916.png?width=400

post-8228-1210227936.png?width=400

Link to comment

QUOTE (Karissap @ May 8 2008, 02:33 AM)

OpenG :worship:

Link to comment

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.

×
×
  • Create New...

Important Information

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