I have been working on a project and trying to solve a problem for it for a while but can't seem to find a solution.
So this my simplified problem:
I have 6 different boolean buttons: A, B, C, D, E, F
If A is on, a certain case occurs.. lets call it "yellow"
If B is on, case "red" occurs
If A and B is on, case "pink" occurs
If C is on, case 'blue" occurs
Basically there are many different cases and I have multiple inputs to put into the case selector. I tried using boolean arithmetic and different case structure for each case but didn't like either approaches.
What is the best way to do this? I have attached a simplified vi. with inputs A, B, C.
nice, I was looking for a similar solution, this is what I implemented:
Although I wonder, isn't there a a much more elegant way of indexing a case struct with mutually exclusive booleans?
I'd like something equivalent to the concatenated IF-THEN-ELSIF....ELSIF.... ELSE statements in C-like languages....
Thank you so much.
a case structure can have more than just 2 cases, so you don't need any IF-THEN-ELSEIF-ELSEIF-...-ENDIF monsters...
When your 3 InRange-tests always test the same input "BP" and the ranges don't overlap you might also use Threshold1DArray, which immediatly results in a number!
Hello thanks for the input.
Well my very first implementation of the program was using nested TRUE/FALSE cases so it was ugly, I agree :-)
I know that I can use multiple choices in the case struct, my issue was to index the choices with an array of booleans (yes, as per your question, in my case they are not overlapping intervals so if one boolean is true all the others are zero).
I'm not sure my current implementation (see pic in the last message) is the best, I splitted the cases in a minor case converting the decimal conversion of the boolean array to a string label which pilots the *real* big case struct. I think it is much more "readable", but I feel still missing something.
Sorry if all of this sounds silly but I'm still learning to work with LV :-P
A nice feature of the Case structure is that you can change the radix of the selector label to binary. It makes it easier to see what's going on
To expand on what pcardinale suggested, the radio button acts like a set of mutually exclusive booleans on the front panel and like an enum with numeric output and button label text in the case structure selector labels on the block diagram.