LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Case structure with two selectors

Hi all
 
Once again I'm wondering...
 
...if it is possible to wire more than one value to a case structure. I'm just working on a project and came to a point where I have to nest case structures. I have two enums and depending on both enums I set a value.
 
How would it be to have more selectors so that the following code extract could be "drawn" with just one case structure?
 
enum X1 = {manual, auto}
enum X2 = {red, green}
 
if(X1 == manual && X2 == red)
  ...
else if(X1 == auto && X2 == red)
....
 
Maybe something useful for new LV versions, if it does not exist yet.
 
Thomas
Using LV8.0
--------------------------------------------------------------------
Don't be afraid to rate a good answer... 😉
--------------------------------------------------------------------
Message 1 of 17
(7,300 Views)

Thomas,

I have seen nothing to indicate that they will have more than one value for an input to a case structure.  It is up to the developer to put in the pre-logic before getting to the case structure.  With multiple enums there can be many choices so I guess the best way to handel it is to use nested case structures.

Matt

Matthew Fitzsimons

Certified LabVIEW Architect
LabVIEW 6.1 ... 2013, LVOOP, GOOP, TestStand, DAQ, and Vison
0 Kudos
Message 2 of 17
(7,267 Views)

I like that idea. It could be another optional feature at the edge of the case structure.

I have given it some thought and implemented like this

The main problem is keeping the valid conditions and the enum for case selection sync'd together.

David

 

Message Edited by David Crawford on 06-23-2006 01:14 PM

Download All
Message 3 of 17
(7,262 Views)
I think you need to create a compound enum (X1 == manual && X2 == red) by yourself before the case structure, and then have the single value control the case statement execution.

Multiple case inputs sounds like a bug trap.

Just picture the beginners adding a new case input for every possible case state.  Ouch.

I think it's too fuzzy and contra-logical to have more than a single input.

My 0.02 SFr.-

Shane.
Using LV 6.1 and 8.2.1 on W2k (SP4) and WXP (SP2)
Message 4 of 17
(7,259 Views)
@David - Great solution. I might remember it one day ;).
 
@Shane - You could have given me at least "en stutz" ;);). Well, I see your point, but in every textual language exists this possibility. Although your argument is acceptable (the compound enum), I prefer to have enums without combinations. Ok, maybe the values would make some sense, but I like it better if they are separate. In addition, what should I do if one input is an enum and the other a boolean? And now don't say "use DavidCrawford's solution" ;).
 
Thomas
Using LV8.0
--------------------------------------------------------------------
Don't be afraid to rate a good answer... 😉
--------------------------------------------------------------------
Message 5 of 17
(7,250 Views)

One method of doing this is converting to strings and concatinating the cases.  Now you should be able to handle any permutation of inputs with a single case structure.

 

Paul

Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
Message 6 of 17
(7,242 Views)

here is a workaround ....

BUT  you loose the flexibility to use type defs  . its bad for debugging  ......   

I did that years ago as an state MC ( one enum for status another for action)  and NO NO NEVER AGAIN

Since that time I always found a nice way to do my state MC with one enum.

Use a nested case as an subvi to merge to one enum, or ....

 

Greetings from Germany
Henrik

LV since v3.1

“ground” is a convenient fantasy

'˙˙˙˙uıɐƃɐ lɐıp puɐ °06 ǝuoɥd ɹnoʎ uɹnʇ ǝsɐǝld 'ʎɹɐuıƃɐɯı sı pǝlɐıp ǝʌɐɥ noʎ ɹǝqɯnu ǝɥʇ'


Message 7 of 17
(7,238 Views)

here is an example using the string format functions, it allows you to combind any number of enums and treat them as a single string.  You can even handle ranges of cases.  See the "Auto+"..."Auto+~" which should handle any color string enum value.  I used the '~' because it has the highest ASCII code and will allow for almost any color string name.  This is a good question made me think and this is the first thought that came to my mind.  I am curious to see how others approch this problem.

 

Paul

Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
Message 8 of 17
(7,223 Views)

whow 6 answers in 40min and David had a nice solution that results to ONE case selector

 

Greetings from Germany
Henrik

LV since v3.1

“ground” is a convenient fantasy

'˙˙˙˙uıɐƃɐ lɐıp puɐ °06 ǝuoɥd ɹnoʎ uɹnʇ ǝsɐǝld 'ʎɹɐuıƃɐɯı sı pǝlɐıp ǝʌɐɥ noʎ ɹǝqɯnu ǝɥʇ'


Message 9 of 17
(7,222 Views)

And this although it is friday afternoon.. :D:D

Anyway - some nice solutions. Maybe a member of the "blue bars" could also give a comment. Will see...

Using LV8.0
--------------------------------------------------------------------
Don't be afraid to rate a good answer... 😉
--------------------------------------------------------------------
0 Kudos
Message 10 of 17
(7,210 Views)