08-14-2009 06:47 PM
Is there a way to identify Error Clusters?
The only thing I've come with so far is get a Ref to all Controls, cast to Cluster, get Refs to all Cluster Controls and look to see if there's a boolean, numeric and a string and nothing else. Of course I can look at all the labels and make sure they are what they should be. But in what I'm doing the cluster name may not be "Error In" or "Error Out".
I thought maybe they would be tied back to the error controls in the ...vi.lib/errorclust.llb, but they are not type defs. But they are not type defs so I can't use that property.
I also looked at the BasicObjectFlags property, but if you build an error cluster with the same settings as the built in ones, that comes back the same.
I'm thinking I'm going to have to settle for "sure enough" based on the fact that it is a cluster and the label names. But if there a better way...
Thanks
Ed
08-15-2009 01:30 AM
NI does this by parsing the typedescriptor to be of a cluster with three elements, being an boolean, int32, and string in that order. When you select Flatten To String and select the Convert 7.x option you still get the old style typedescriptor that can be used for such things. the parsing of the typedescriptor is a little complicated but basically you only want to see that the lower byte of the second word in there is 0x50, then 3, and then 3 times the typedescriptor for the individual elements. Take a look at the OpenG Variants tools how they are doing that for typedescriptor parsing.
Rolf Kalbermatter
08-15-2009 04:30 AM
Rather than parsing type descriptors you can extract the information from the variant returned by the value property. Somewhere in vi.lib there are a folder of "VariantType" vis (in a support or utlity sub directory of vi.lib from memory) - these provide all the tools you need to work out whether a variant is a cluster of boolean, numeric, string.
08-17-2009 07:33 AM
As Rolf said, an error cluster is defined internally as a cluster containing a boolean, an I32, and a string, in that order. Names and labels do not matter (or there would be localization issues).
You can find the type tools in <vi.lib>\Utility\VariantDataType. I would recommend you use these, since they were created for this type of issue. You also do not need scripting to use them.
You can also find type information using the Class ID and Class Name properties. Class Name properties have been known to change, but Classs IDs have not and should not. I usually use Class Name only to find generic, top-level information (e.g. search for Constant in the Class Name to find constants).
08-17-2009 10:02 AM
Thanks Guys,
This should give me enough to figure it out.
Ed