LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

State Structure will not allow me to change state name.

Solved!
Go to solution

I'm reworking a state machine that we use for bench testing of parts.  The program has state name that pertain to a certain component and I want to change the name to reflect the new component to be tested.  The program uses a enum constant to select the next state and the first problem I had was changing the labeling in the enum.  Ever time I changed the name in the enum it would just return to the earlier name.  I deleted the enum and tried again but got the same results.  This morning I stated over with a new enum and was able to get the labeling correct but now the state machine labeling has converted back to a numeric list and will not allow me to change back to the state machine labels.  Any ideas why?

 

 

0 Kudos
Message 1 of 28
(3,773 Views)

Some of you state constants are plain, while some are type definitions (which you have not attached).

 

Make it a strict type definition and make sure that all instances point to it. To add or remove states, edit the type definition.

 

(If done right, there should not be any red coercion dots anywhere near the state wires. Currently your diagram seems to have the measles :D))

Message 2 of 28
(3,767 Views)

The problem you have is that the enum was not typedef'd.  So, you have a slew of individual enums.  Rings would allow you to change the text in one and leave the others the same since the string is not part of the value.

 

With an enum, the string is part of the value, so all your enums have to be identical.  It looks like your incoming shift register has a typedef wired to it.  Use this and replace every state enum with the typedef.  This way when you update the typedef item list, all enums are updated.

 

The reason your case statement reverted to numbers is the conflict in the enums.  Your case 0 has non-typedefed enums, and your shift register is typedef'd.  Replace all the enums with the typedef and it will return to the string name.

Message 3 of 28
(3,761 Views)

@altenbach wrote:

[...] 

Make it a strict type definition and make sure that all instances point to it. To add or remove states, edit the type definition.

[...] 



Hey altenbach, why "strict" if the typedef exists as a constant?

Richard






0 Kudos
Message 4 of 28
(3,756 Views)

non-strict should be enough for enums as in this case.

 

(I was thinking of the case of rings, where you would need strict.)

0 Kudos
Message 5 of 28
(3,752 Views)

Altenbach,

 

Thanks for your input after reading your input and Matthew I realized that hadn't removed all of the earlier enums and I had conflicting enums.  Once I removed the enum on input to the while loop I was able to get the state to change.  Thanks again for all you input it sure help when I only get to write code maybe once a year.

0 Kudos
Message 6 of 28
(3,746 Views)

Hi Matt,

 

that is twice in one week you have been there to help.  As I have written to Altenback that the information in both of your postings has help me.  I believed I had removed all the previous earlier enums but left one on the input to the while loop.  Once I removed that one I was able to get my state machine back and the labeling is now working.

 

Many Thanks,

0 Kudos
Message 7 of 28
(3,744 Views)

When I first opened the VI I though something wierd had happened because I had seen the VI before.  It took me a second to realize I hadn't somehow opened an old VI.

0 Kudos
Message 8 of 28
(3,741 Views)

Matthew,

 

I'm still having this trouble, how do you "typedef" an enum.

0 Kudos
Message 9 of 28
(3,733 Views)

In LabVIEW 2011, you can create a typedef directly from a diagram constant. In earlier versions, temporarily change the constant into a control.

you already have a typedef, so right-click the constant...open typedef,
0 Kudos
Message 10 of 28
(3,725 Views)