LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Strictly typed Enum reference "is not a simple up or down cast" of strictly typed enum reference

Solved!
Go to solution

Running into a weird problem with Enums. I'm trying to dynamically populate an enum to allow for some dynamic dispatching during a user input phase. I'm almost done, and this happens:

 

The front panel on the right is the "Setup Enum" vi. On the left is the main VI, with a strictly typed enum control reference going into that VI. I've attached the vi hierarchy; open "Choose Curve.vi" to troubleshoot.

0 Kudos
Message 1 of 6
(3,688 Views)
Solution
Accepted by topic author ijustlovemath

Solved this issue by changing to Ring datatype. One more issue, when I modify the label/increment-decrement property on this control manually, the code for changing the label via a property node doesn't work unless I run the subVI individually. I have the subvi ("All Curves Base Setup.vi") open (edit: same behavior no matter if the VI is open or closed). Why is this?

0 Kudos
Message 2 of 6
(3,682 Views)

Also solved. The problem was that the Label property is not modifiable at runtime. I used the Caption property instead, which has much the same function.

0 Kudos
Message 3 of 6
(3,671 Views)

I didn't check your actual code, but to be clear, making the enum reference strict causes it to look at the values of the enum too, so two strict enum references which point to different enums don't match, as you see. For your wiring to work, the enum reference control on the subVI would have to be non-strict or they would have to match.

 

Even if they did match, that wouldn't help you, because like the label, the strings of an enum can't be set while the VI they're in is run mode, because they are part of the data type. As you saw, a ring is the appropriate option for this use case.


___________________
Try to take over the world!
0 Kudos
Message 4 of 6
(3,632 Views)
Can control references be not strict? Or do we just ignore coercion dots in this case?
0 Kudos
Message 5 of 6
(3,621 Views)

@ijustlovemath wrote:
Can control references be not strict?

Absolutely. If you right click a control and select Create>>Reference, then that will output a strict reference, but the control shown in your subVI certainly doesn't need to be strict. You can right click it play with it, you can drag other types into it to change the class, etc.

 

Even with the strict references, you could wire two incompatible strict references into a Build Array and it will simply change the reference type of the array to the common class (and show you the coercion).


___________________
Try to take over the world!
0 Kudos
Message 6 of 6
(3,610 Views)