LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Qeued numeric values from boolean controls

Solved!
Go to solution

Hi everyone, I would appreciate if someone could help with this. The scenario is as follows:

I have the front panel shown below, each checkbox should send a numeric value, I already get the required value by means of a case structure, the problem comes as I should be able to mark one or more of the checkboxes, the question is, How can I put in a queue the value of all the selected checkboxes? It is because I need to take one of them at a time. 

 1FrontPanel.PNGBlockDiagram.PNG

I hope, I explained well and somebody could help.

Thanks for all.

 

0 Kudos
Message 1 of 13
(3,871 Views)
Solution
Accepted by topic author JEmmanuelH

I'm not sure what you want to do, but if you want to check each Boolean one at a time to see if it is True or False, then you are almost there.  You have created an Array of the Booleans.  If you know about Arrays and about For loops, you'll know that you can bring the Array (wire) into the For loop through a default "indexing" tunnel which gives you the Array elements one at a time.  So if you had L1, L1+N, and L1+N+PE True and all the rest False, then the For loop would see the values True, False, False, True, False, False, True, with the first "True" corresponding to L1 and the last to L1+N+PE.

 

Is this what you are trying to do?

 

Bob Schor

0 Kudos
Message 2 of 13
(3,843 Views)

First of all thanks for replying, then I should say that no, that is not what I want to do. What I'm looking for is to get the numeric values in a qeue of each marked boolean control, discriminating the nonmarked checkboxes. For example, if I marked L1+N and L1+PE I should get an array with [17,25] wich are the corresponding numeric values for those boolean controls.

Hope this is sufficient information. Thanks.

0 Kudos
Message 3 of 13
(3,808 Views)

I don't understand what you mean by "the numeric values in a qeue of each marked boolean control".  What numeric values are you talking about?  What do you mean by "a queue"?

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 4 of 13
(3,803 Views)

What I mean with "Numeric values" is that each boolean control has a predetermined numeric value (that is why I´m using the case structure), then what I mean with "Qeued" is that if I mark more than one of the checkboxes I need to know which of them were marked and have the corresponding number available for later processing.

PS: My approach to "qeue" is an array, is there a better solution?

Thanks for all.

0 Kudos
Message 5 of 13
(3,791 Views)
Solution
Accepted by topic author JEmmanuelH

A queue is something specific, different from an array, so mixing up the terms is confusing. If you're saying that you've assigned an arbitrary numeric value to each of your boolean controls and want to create an array containing the numeric values of the individual controls that are set, then here's what I would do: Instead of converting the array of booleans into a numeric value and using that to select a single case, I'd create a matching array of integers, one for each of your boolean controls, and then wire both the boolean and integer arrays into a For loop with auto indexing enabled for both arrays. The loop will be very simple, it'll just have a conditional indexing array output, with the boolean wired to the conditional terminal, and the integer wired to the output. The result will be that for each true boolean (each checked boolean control), the resulting array will have one integer element (the corresponding numeric value).

0 Kudos
Message 6 of 13
(3,769 Views)

@arteitle wrote:

A queue is something specific, different from an array, so mixing up the terms is confusing. If you're saying that you've assigned an arbitrary numeric value to each of your boolean controls and want to create an array containing the numeric values of the individual controls that are set, then here's what I would do: Instead of converting the array of booleans into a numeric value and using that to select a single case, I'd create a matching array of integers, one for each of your boolean controls, and then wire both the boolean and integer arrays into a For loop with auto indexing enabled for both arrays. The loop will be very simple, it'll just have a conditional indexing array output, with the boolean wired to the conditional terminal, and the integer wired to the output. The result will be that for each true boolean (each checked boolean control), the resulting array will have one integer element (the corresponding numeric value).


To complete this thought, you only really need the three main ones if the "+" ones really mean "add those numbers together".  When you obtain your array of numbers, just take the SUM of the array using "Add Array Elements"  the other way, with boxes for each combination, is a kludge.  Actually adding the selected numbers together is the correct way.  It's also more scalable.  Imagine how many "plus" combinations you'd have to have if you added two more Booleans.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 7 of 13
(3,755 Views)

I´m sorry for the confusing explanation. At the end the conditional indexing array output was the solution. It already does what I wanted to. Shown below I pasted the actual block diagram, just in case. Thanks for all.Capture.PNG

0 Kudos
Message 8 of 13
(3,739 Views)

In your first version, you changed an array of Booleans into a number, then had to "decode" the number, which was clumsy and error-prone.  Congratulations in adopting using the Boolean array "as it" and processing each "bit" to "do it's thing".

 

But you didn't fully learn your lesson, as you again have an "information-obscuring" Boolean-to-number-to-interpret-the-numbers routine at the end.  I'm guessing that if OK or Cancel is true, you stop the loop, and if OK is true, you pass the Array of values out (I'm not sure what happens if Cancel is true, but let's assume you pass out an empty Array.  There are various ways to clearly indicate this logic.  One would be to send the OR of OK and Cancel to the Stop indicator of the While Loop, and use the OK as input to a Select function to choose whether you output the Array or an Empty Array.  Another would be to use little nested Cases, one with OK wired to it and the inner with Cancel wired to it, to be processed only if OK is False).

 

If you have Simple Logic, don't complicate it by going to Numeric and then decoding the number.

 

Bob Schor

Message 9 of 13
(3,722 Views)

Hi Bob Schor, you are absolutely right. I have coded what you suggested and even when there is no functionality difference I agree that is a better idea. Thank you very much for your help.

Best regards to all.

0 Kudos
Message 10 of 13
(3,710 Views)