LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

State machine fed by value?

This seems really simple but I can't get it to work!
 
I have a case statement fed by a an enumerated constant.  When hooked up, the headers in the case match the strings in the enumerated type.  So far so good,  But I don't want to actually feed the case with the constant, I want to feed it with a number that's stored in an element of an array but still have the headers match the strings in the enumerated type.  I've tried various ways and the only way I could get it to work was ugly - change the constant to a control, get a property node of the strings and index into them.  That seems expensive and, I'm hoping, unnecessary.
 
Is there a simple way to do this?
 
Lee Jay
0 Kudos
Message 1 of 11
(3,597 Views)
The short answer is no.  The problem with enumerated type is that the datatype itself contains both the numeric values and string labels, so you cannot replace an enumerated type with just a number.  Hence why you need to use the index value of the control property node - you had to change it BACK to an enumerated type, and are now just extracting part of the datatype.

I'm curious as to why you want to do this...  I have a hunch as to why, and we might be able to solve your problem another way.  Let us know why you'd like to do this, and we'll try and help some more!
0 Kudos
Message 2 of 11
(3,591 Views)
Lee Jay,

An array of the enum type looks like numerics on the diagram, but still displays the enum strings in the case selector box. This may not be what you want, either, but it is another idea to think about.

Lynn
0 Kudos
Message 3 of 11
(3,586 Views)
I want to do this because I'm choosing which of the cases to enter based on a value that's stored in an array.  Essentially I have a list of data channels (562 of them) that each need to be processed in 1 of 11 ways.  At run time, the particular processing method that needs to be applied to each channel is read out of a file, stored in one column of an array (along with other information like slope and offset, among other things), and then passed into the processing VI.  That VI needs to choose which case to enter for each channel, going through the channels one-by-one in a for loop.
 
Lee Jay
0 Kudos
Message 4 of 11
(3,586 Views)
Put the array processing in a subVI which takes the array as an input and returns the enum value as the output. That output goes to the input of your case structure in your state machine. This subVI could also process error conditions or external Stop commands to direct the state machine to the appropriate next state. The complexity you described in the original post might still be there but would be encapsulated into the subVI.

Lynn
0 Kudos
Message 5 of 11
(3,582 Views)

Am I totally misunderstanding something or is this what you want to do?

Message Edited by Dennis Knutson on 10-31-2006 03:43 PM

Message 6 of 11
(3,570 Views)

Dennis,

That's exactly what I wanted to do.  Thanks a lot!  A can't believe I didn't think of such a simple and obvious solution.  Smiley Happy

Lee Jay

0 Kudos
Message 7 of 11
(3,537 Views)
Sorry for the confusion, but I thought you said you did not want to use constants?
0 Kudos
Message 8 of 11
(3,531 Views)

Maybe I'm misunderstanding but, isn't the numeric feeding the case, just type cast to the constant?

Lee Jay

0 Kudos
Message 9 of 11
(3,528 Views)
Yeah, you're right, but for whatever reason I thought you didn't want to see a constant period.

Sorry for misunderstanding!  It's been a long few days.

Glad Dennis was able to help (as usual)
0 Kudos
Message 10 of 11
(3,522 Views)