---
url: /dyad/dev/stdlib/BlockComponents/components/Logical.LogicalSwitch.md
description: Dyad Logical.LogicalSwitch docs.  Logical Switch.
---

# `Logical.LogicalSwitch` {#Logical.LogicalSwitch}

Logical Switch.

The LogicalSwitch switches, depending on the Boolean u2 connector (the middle connector), between the two possible Boolean input signals u1 (upper connector) and u3 (lower connector).

If u2 is **true**, connector y is set equal to u1, else it is set equal to u3.

This component extends from [`BlockComponents.Interfaces.PartialBooleanSI3SO`](../types/Interfaces.PartialBooleanSI3SO.md)

## Usage {#Usage}

`BlockComponents.Logical.LogicalSwitch()`

## Connectors {#Connectors}

* `u1` - This connector represents a boolean signal as an input to a component ([`BooleanInput`](/stdlib/Dyad/connectors/BooleanInput#BooleanInput))

* `u2` - This connector represents a boolean signal as an input to a component ([`BooleanInput`](/stdlib/Dyad/connectors/BooleanInput#BooleanInput))

* `u3` - This connector represents a boolean signal as an input to a component ([`BooleanInput`](/stdlib/Dyad/connectors/BooleanInput#BooleanInput))

* `y` - This connector represents a boolean signal as an output from a component ([`BooleanOutput`](/stdlib/Dyad/connectors/BooleanOutput#BooleanOutput))

## Behavior {#Behavior}

$$ \begin{align}
y\left( t \right) &= ifelse\left( \mathtt{u2}\left( t \right), \mathtt{u1}\left( t \right), \mathtt{u3}\left( t \right) \right)
\end{align}
$$

## Source {#Source}

```dyad
"""
Logical Switch.

The LogicalSwitch switches, depending on the Boolean u2 connector (the middle connector),
between the two possible Boolean input signals u1 (upper connector) and u3 (lower connector).

If u2 is **true**, connector y is set equal to u1, else it is set equal to u3.
"""
component LogicalSwitch
  extends BlockComponents.Interfaces.PartialBooleanSI3SO
relations
  y = ifelse(u2, u1, u3)
metadata {
  "Dyad": {
    "labels": [{"label": "$(instance)", "x": 500, "y": 1100, "rot": 0}],
    "icons": {"default": "dyad://BlockComponents/LogicalSwitch.svg"}
  }
}
end
```

```dyad
"""
Logical Switch.

The LogicalSwitch switches, depending on the Boolean u2 connector (the middle connector),
between the two possible Boolean input signals u1 (upper connector) and u3 (lower connector).

If u2 is **true**, connector y is set equal to u1, else it is set equal to u3.
"""
component LogicalSwitch
  "Connector of first Boolean input signal"
  u1 = BooleanInput() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": -100, "y1": 80, "x2": 0, "y2": 180, "rot": 0}
      },
      "tags": []
    }
  }
  "Connector of second Boolean input signal"
  u2 = BooleanInput() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": -100, "y1": 450, "x2": 0, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  "Connector of third Boolean input signal"
  u3 = BooleanInput() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": -100, "y1": 820, "x2": 0, "y2": 920, "rot": 0}
      },
      "tags": []
    }
  }
  "Connector of Boolean output signal"
  y = BooleanOutput() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 1000, "y1": 450, "x2": 1100, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
relations
  y = ifelse(u2, u1, u3)
metadata {
  "Dyad": {
    "labels": [{"label": "$(instance)", "x": 500, "y": 1100, "rot": 0}],
    "icons": {"default": "dyad://BlockComponents/LogicalSwitch.svg"}
  }
}
end
```

## Test Cases {#Test-Cases}

No test cases defined.

## Related {#Related}

* Examples

* Experiments

* Analyses

* Tests
  * [`Logical`](Logical.LogicalSwitch.md)

  * [`LogicalValidation`](Logical.LogicalSwitch.md)
