# Logic Operations

This function block evaluates logical and comparison operations over one or more inputs. Use it to combine boolean checks, compare numeric values, or reduce multiple conditions into a single true/false output.

## 📥 Inputs <a href="#inputs" id="inputs"></a>

`Generic` Accepts any data type. Multiple inputs can be connected and evaluated together.

`Generic` Accepts any data type. (Second default socket; more inputs may be added)

## 📤 Outputs <a href="#outputs" id="outputs"></a>

`Boolean` The resulting true/false value after evaluating the selected logic or comparison.

## 🕹️ Controls <a href="#controls" id="controls"></a>

`Method` Select which logical or comparison operation to apply to the inputs. Common methods include AND, OR, GREATER, SMALLER, EQUALS, and NOT EQUALS.

## 🎨 Features <a href="#features" id="features"></a>

`Multi-input support` Evaluate two or more inputs together, not limited to only two values.

`Flexible input types` Inputs are generic so you can feed numbers, booleans, lists, or other values depending on your scenario.

`Context-aware comparisons` Comparison methods work for both pairwise comparisons and for checking the first input against multiple others.

## 📝 Usage Instructions <a href="#usage" id="usage"></a>

1. Connect one or more values to the inputs. Typical sources are counts, measurement numbers, or boolean signals from other function blocks.
2. Choose the desired operation from the `Method` combobox.
3. The block outputs a single `Boolean` that represents the result of the selected logical/comparison operation.

Examples:

* Use `Method` set to AND when you need all conditions to be true for a pass.
* Use GREATER when checking whether a measured value is higher than a threshold or higher than multiple reference values.
* Use EQUALS to verify that several inputs are identical.

## 📊 Evaluation Behavior <a href="#evaluation" id="evaluation"></a>

* AND returns true only if every input value evaluates to true.
* OR returns true if any input evaluates to true.
* GREATER compares the first input against the second; when more inputs are provided, it checks whether the first input is greater than each of the others.
* SMALLER behaves like GREATER but tests if the first input is lesser.
* EQUALS returns true when the first input equals all other inputs.
* NOT EQUALS returns true if any of the other inputs differ from the first input.

## 💡 Tips and Tricks <a href="#tips-and-tricks" id="tips-and-tricks"></a>

* Combine with detection and counting blocks
  * Connect `Object Count` from `Object Detection` or `Object Detection - Custom` to check if an object count is above a threshold using GREATER, then trigger `Record Video` or `Image Logger`.
* Use with tracking results
  * Feed tracking outputs like `Position - ID List` from `Object_Detection_Tracker` into this block to create rules such as "is any tracked object present" using OR or NOT EQUALS.
* Mask / safety logic
  * Combine outputs from `Mask Detection` or `Safety Equipment Detection` with AND to assert multiple safety conditions are met before raising an alarm or saving a frame.
* Pre-checks and flow control
  * Use this block with `Is None` or `Replace None` to validate inputs before downstream processing. For example, ensure image data exists and a detector produced results before continuing.
* Measurement comparisons
  * Feed numeric outputs from `Measure Position Distance`, `Get Dimension`, or `Mean Value of Image` to GREATER/SMALLER methods to create pass/fail conditions for quality checks.
* Use in automation flows
  * Chain the boolean result to `Led Output`, `Write Text On Image`, `CSV Export`, or `MQTT Publish` to act on detection or measurement outcomes.

## 🛠️ Troubleshooting <a href="#troubleshooting" id="troubleshooting"></a>

* Unexpected false results
  * Check the data types flowing into the inputs. Convert or normalize values (for example, use `Round` or `String Operations`) so comparisons behave as expected.
* Comparisons with multiple inputs behave differently
  * Remember that GREATER and SMALLER compare the first input against the others. If you need pairwise comparisons, feed appropriate pairs or use multiple Logic Operations blocks.
* No output or stuck flow
  * Ensure at least one input is connected or valid. Use `Is None` or `Replace None` to guard against missing values.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.augelab.com/function-blocks/data-logic/logic/logic-operations.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
