From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Enum cohersion Dot on Case Statement

Solved!
Go to solution

Eveining all,

 

I have been modifiying the attached vi today to add the ability to handle multiple different Enum U16's.

 

Previously there was only one typedefed Enum U16 in the Controls passed to the Controls[] input and therefore the Enum typedef constant was in the Enum U16 Case.

 

Because there are now 2 different typedefed Enum U16 in a new Control that is passed into the Controls[] input, I had to change the vi as Varient to Data function was causing an Error when Varient didn't match with any of the types. To do this I added the new case structure and wired the TypedeInfo output of the Varient Type fuction via a Unbundel by name to the case selector terminal. Inside each case I put a constant of the Enum Typedef that needs to be passed to the Varient to data vi. unfortunatly as the Enum Constants are not of the same type, the output tunnel of the new case structure is cohursts so that the data out is the Digtal Display of the Enum and not the Item name.

 

 

This therfore means that the output of the Varient to data function now outputs the Digital Display number and not the Item Name. Unfortunatly this messing things up downstream.

 

It there anyway to not cohurst and pass the Item names rather than the Digital Display. I guess it would be possible to do it with a selctor funtion, but then this dosn't allow for possible futher changes.

 

Any Ideas

 

Regards 

 

M

0 Kudos
Message 1 of 3
(3,027 Views)
Solution
Accepted by topic author Munchuk

If you use 'format into string' or 'type cast' with an enum, it will convert it to a string which you can wire into the selector of a case structure. Because your type-definitions are different, you will always get the coercion.

 

In your VI you would need to move the variant to data inside the case structure and then put that inside the Enum U16 case. Something like this should work:

2015-11-26_17-45-00.png

 

Oh, there is also an OpenG function called 'Get Strings from Enum' which returns the currently selected enum value and all of the strings in the enum.


LabVIEW Champion, CLA, CLED, CTD
(blog)
0 Kudos
Message 2 of 3
(3,021 Views)

Many Thanks Sam,

 

I feel like a **bleep** for not thinking of that way to do it.

 

Regards

0 Kudos
Message 3 of 3
(2,979 Views)