LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Integer to Enum conversion

Hello I have the same issue. I have attached my VI, does anyone notices the error? It seems that if you touch the "default" transitions it starts giving some errors but not sure why, is it maybe an error from the tool?

0 Kudos
Message 21 of 25
(383 Views)

Start by making a type defined control for your enum.  All of your enums should be linked to that type def.  The type def enum must have all of the possible states in it.  As it stands now, you have a bunch of different enums with a single value, which is not going to work.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 22 of 25
(347 Views)

Hi, first of all thanks for your answer. The problem that I have been seeing in the example that I attach now and works correctly is that if you change the Enum Constant inside the Block Diagram (the one that I have marked in red) then it starts giving the same error. I changed it to see what happens and then is when starts giving this error. After that, it is imposible to fix it again. Do you know how can fix it?

mariazuay99_1-1701342219713.png

 

 

0 Kudos
Message 23 of 25
(314 Views)

Wow!  I've been using State Machines and Enums for years (decades?), and I couldn't figure out your Block Diagram!  [I've also not explored the State Diagram toolkit].  

 

Type-def'ed Enums are amazing.  I created one having the values "One", "Two", "Three", "Four" and wrote a simple For Loop that ran through them twice (by counting to 8).

Enum DemoEnum Demo

 This is a "State Machine" that goes to the (circular) "Next State" because that's what I told it to do.  You could, instead, do as you have done, put a Case Statement for each of the possible States, and choose (and place on the Shift-register Wire going to the right edge) the "Next" State.  Because all of your Enums are tied to a fixed TypeDef, there should be no ambiguity nor problem with the code.

 

I didn't recognize the little function inside the inner While Loop that has the index "i" and the Enum (value "n <= 1") as inputs going into a Case.  [I'm guessing it is equivalent to "Index the Enum starting at "n <= 1" by "i"].

 

Are you trying to create a Sieve of Eratothenes?

 

Bob Schor

0 Kudos
Message 24 of 25
(292 Views)

@Bob_Schor wrote:

I didn't recognize the little function inside the inner While Loop that has the index "i" and the Enum (value "n <= 1") as inputs going into a Case.  [I'm guessing it is equivalent to "Index the Enum starting at "n <= 1" by "i"].


Coerce To Type


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 25 of 25
(286 Views)