LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

A very simple question

 


@Haneef wrote:

You can make use of formula node.


(See also)

 

0 Kudos
Message 11 of 14
(2,371 Views)

If I were doing this sort of thing (which is a very complex and heavily algorithmic analysis), I would manage the two booleans as a pair, with states representing whether or not they were true or false.  For example, if the first boolean were true and the second false, I would identify this with a "T, F" state.  Taking all possible combinations into account would yield 4 possible state combinations - lets call them "MetaStates", with values of "F, F", "F, T", "T, F", and finally, "T, T". 

 

The other complexity of this system is monitoring the states of the booleans of interest and combining the boolean values into a single result.  This can be done with monitor loops, queues (to pass results around), and the use of special AND operators to generate the MetaState.  A simple examination of the MetaState with a case structure can then be used to compute your result.  See attached code.

Download All
0 Kudos
Message 12 of 14
(2,352 Views)

When dealing with multiple boolean logic (less than 5 booleans) I find it is much easier to read if I convert teh booleans into an array and cast the number as a descriptive enum.

 

This way when I come back to the code a year latter I don't have to start working on the boolean logic but can just read the results.

 

It looks like this.

 

Boolean_to_Enum.JPG

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 13 of 14
(2,324 Views)

@Ben wrote:

Boolean_to_Enum.JPG


Ben - Check out Coerce to Type to make typeconverting/casting operations cleaner syntactically and more robust to datatype changes (e.g., what happens if your Enum was typedef'd, and changed from a U16 to a U8? the U16 conversion in the code would be misleading at best and give incorrect results at worst)

 

CoerceToTypeHere.png

Message 14 of 14
(2,273 Views)