LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Com-interop Enum to Switch Case in Lab View

I am using a COM-Interop in Lab-view, I have some functions that return an enum, I want to make a switch-case structure on this enum but I can't, but when I put an indicator to function output I see that the enum returned as expected.

so, my problem is I can't make this switch-case from my enum that exported from interop dll

0 Kudos
Message 1 of 10
(1,225 Views)

any idea?

0 Kudos
Message 2 of 10
(1,172 Views)

@Peterboshra wrote:

I am using a COM-Interop in Lab-view, I have some functions that return an enum, I want to make a switch-case structure on this enum but I can't, but when I put an indicator to function output I see that the enum returned as expected.

so, my problem is I can't make this switch-case from my enum that exported from interop dll


Can you give some example code? How does your COM-Interop work?

0 Kudos
Message 3 of 10
(1,165 Views)

here is an example of a function return from the interface called that called "ITestList" it's return the eTestType enum

 

 

Namespace DataChannel.Interop

    Public Interface ITestList

        Function GetCount() As Integer

        Function GetTestAt() As Integer

        Function GetTestTypeAt(index As Integer) As eTestType

    End Interface

End Namespace

 

0 Kudos
Message 4 of 10
(1,147 Views)

And where and how is eTestType defined? If it is a public definition then you can create an instance of it in LabVIEW. Otherwise not. But you need to know where it is defined, LabVIEW won't know on its own.

Rolf Kalbermatter
My Blog
0 Kudos
Message 5 of 10
(1,136 Views)

yes it's public and I can instance from it, but I can't link it with node output or switch-case I'm totally beginner 🙂

0 Kudos
Message 6 of 10
(1,131 Views)

@Peterboshra wrote:

... when I put an indicator to function output I see that the enum returned as expected.


Can you expand on that? How does that look in LabVIEW? What do you expect and what do you get?

0 Kudos
Message 7 of 10
(1,101 Views)

123.png

this is the output and the ring indicator on it I need to make a switch case from this enum output and according to the output the case switched and do some action 

0 Kudos
Message 8 of 10
(1,096 Views)

You probably need to use the "Coerce To Type" function (under palette: Programming → Numeric → Conversion"

https://www.ni.com/docs/en-US/bundle/labview/page/glang/coerce_to_type.html

 

"If you weren't supposed to push it, it wouldn't be a button."
Message 9 of 10
(1,078 Views)

Ahhh now I understand. Since .net enums are really more sparse enums (even if they are fully consecutive) and LabVIEW doesn't have sparse enums, it translates them into a ring control. But a ring control only has string labels in the UI element, not as part of the data type. And therefore you can't select on that string as it is not part of the datatype.

 

If and only if, this enum is consecutive and not sparse (sparse meaning that it doesn't have a consecutive increasing numeric value corresponding to the enum string, but with some holes in it) you can right click on the ring control and select "Replace" and select an enum from the LabVIEW palette.

 

If you do that with a sparse enum, LabVIEW will reassign the enum values with consecutive increasing numbers and you get a mess as the numeric values don't correspond to the original numeric enum values anymore.

Rolf Kalbermatter
My Blog
Message 10 of 10
(1,070 Views)