LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Using a .net Assembly in Labview whose methods return an Enum

Morning All,

 

I have a dotNet assembly being used in a Labview project. The assembly has a couple of method calls that return a System.Enum type. The enum contains 8 enumerated values and is of the default internal type (int).

 

The methods are being called via an Invoke node in a Labview VI. It noticed that it seemed possible to generate an indicator from the output of these method calls which, I assumed, would create a Enum object based on the enumerated values specified in the dotNet enum type. Instead it appeared to generate a enum type that contained several grouped enumerated values plus an "Other..." option. This is LV 2011 SP1. Labview believes the output of the method to be a long int.

 

Has anyone else attempted this? I guess I could just use the output as a numeric indicator instead, just wondering if this is the only quirk with using enum types.

0 Kudos
Message 1 of 4
(3,627 Views)

Normally, you'd get an actual enum datatype in LabVIEW corresponding to the enum in the .NET assembly. Unless you're dealing with a .NET 4.0 assembly. Are you? In that case, all bets are off, since LabVIEW does not officially support .NET 4.0. .NET 4.0 assemblies usually work, but I've never had that luck. 

 

Please explain what you mean by: "Instead it appeared to generate a enum type that contained several grouped enumerated values plus an "Other..." option" What are "grouped enumerated values?

0 Kudos
Message 2 of 4
(3,621 Views)

Fair enough - here are the details:

 

Enum is as follows (C# targeted for a 3.5 assembly, verbatim): 

 

public enum Result
{
Success,
ParameterError,
DeviceNotExist,
NoDeviceSchema,
TimedOut,
DeviceBusy,
WriteDataWrong,
WriteVerifyFailed,
UnknownException
};

 

Using an invoke node for the assembly method called "Read" (I apologise, our company proxy prevents me from uploading the image), the return from the Read method is shown as a long uint  but is actually an instance of the above Enum. If I right-click on this output regardless and Create an Indicator a Ring is generated with the following Items (both Item string and Value columns):

 

Items "Success, ParameterError, NoDeviceSchema, DeviceBusy, WriteVerifyFailed" , Values "65536"

Items "DeviceNotExist" ,Values "196610"

Items "WriteDataWrong", Values "12"

Items "UnknownException", Values 0

 

Looks like the generation of the ring from the Enum has had a few hic-cups. If I try this a second time, another Item appears at the bottom of the list called "Other...".

Any ideas would be appreciated.

0 Kudos
Message 3 of 4
(3,616 Views)

I have found the cause of this problem - if the VI settings for new Controls / Indicators is set to "Silver" style, then this issue occurs. If the style is set to any other setting (such as Modern) then this problem does not occur.

 

I have replicated the issue on several Labview machines and thus consider it a bug. I have forwarded this issue onto NI support. Thanks for your help.

0 Kudos
Message 4 of 4
(3,611 Views)