Skip to content
LIBRARY
Logical.Switch.md

Logical.Switch

Switch between two Real signals.

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

If u2 is true, the output signal y is set equal to u1, else it is set equal to u3.

Usage

BlockComponents.Logical.Switch()

Connectors

  • u1 - This connector represents a real signal as an input to a component (RealInput)

  • u2 - This connector represents a boolean signal as an input to a component (BooleanInput)

  • u3 - This connector represents a real signal as an input to a component (RealInput)

  • y - This connector represents a real signal as an output from a component (RealOutput)

Behavior

Source

dyad
"""
Switch between two Real signals.

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

If u2 is **true**, the output signal y is set equal to u1, else it is set equal to u3.
"""
component Switch
  "Connector of first Real input signal"
  u1 = RealInput() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": -100, "y1": 130, "x2": 0, "y2": 230, "rot": 0}
      },
      "tags": []
    }
  }
  "Connector of Boolean input signal"
  u2 = BooleanInput() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": -100, "y1": 450, "x2": 0, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  "Connector of second Real input signal"
  u3 = RealInput() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": -110, "y1": 770, "x2": -10, "y2": 870, "rot": 0}
      },
      "tags": []
    }
  }
  "Connector of Real output signal"
  y = RealOutput() {
    "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/Switch.svg"}
  }
}
end
Flattened Source
dyad
"""
Switch between two Real signals.

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

If u2 is **true**, the output signal y is set equal to u1, else it is set equal to u3.
"""
component Switch
  "Connector of first Real input signal"
  u1 = RealInput() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": -100, "y1": 130, "x2": 0, "y2": 230, "rot": 0}
      },
      "tags": []
    }
  }
  "Connector of Boolean input signal"
  u2 = BooleanInput() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": -100, "y1": 450, "x2": 0, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  "Connector of second Real input signal"
  u3 = RealInput() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": -110, "y1": 770, "x2": -10, "y2": 870, "rot": 0}
      },
      "tags": []
    }
  }
  "Connector of Real output signal"
  y = RealOutput() {
    "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/Switch.svg"}
  }
}
end


Test Cases

No test cases defined.