MultiportSwitch_IntegerSelector MultiportSwitch_IntegerSelector Icon

Switches.MultiportSwitch_IntegerSelector

MultiportSwitch_IntegerSelector(; name)

A multiport switch that selects one of multiple real-valued inputs based on an integer control signal.

Variables

  • selector: Integer control signal input
  • u1: First real input signal
  • u2: Second real input signal
  • defaultValue: Default real input value
  • y: Output signal

Description

Selects one of multiple input signals based on the integer selector value:

  • When selector = 1: y = u1
  • When selector = 2: y = u2
  • For any other selector value: y = defaultValue

This allows flexible selection between multiple input signals using a single integer index.

Examples

selector = 1  → y = u1
selector = 2  → y = u2
selector = 0 or 3+  → y = defaultValue

Usage

PrimitiveComponents.Switches.MultiportSwitch_IntegerSelector()

Connectors

  • selector - This connector represents an integer signal as an input to a component (IntegerInput)
  • u1 - This connector represents a real signal as an input to a component (RealInput)
  • u2 - This connector represents a real signal as an input to a component (RealInput)
  • defaultValue - 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

\[ \begin{align} y\left( t \right) &= ifelse\left( \mathtt{u1}\left( t \right), ifelse\left( \mathtt{u2}\left( t \right), \mathtt{defaultValue}\left( t \right); \mathtt{selector}\left( t \right) = 2 \right); \mathtt{selector}\left( t \right) = 1 \right) \end{align} \]

Source

"""
    MultiportSwitch_IntegerSelector(; name)

A multiport switch that selects one of multiple real-valued inputs based on an integer control signal.

# Variables
- `selector`: Integer control signal input
- `u1`: First real input signal
- `u2`: Second real input signal
- `defaultValue`: Default real input value
- `y`: Output signal

# Description
Selects one of multiple input signals based on the integer selector value:
- When selector = 1: y = u1
- When selector = 2: y = u2
- For any other selector value: y = defaultValue

This allows flexible selection between multiple input signals using a single integer index.

# Examples

selector = 1 → y = u1 selector = 2 → y = u2 selector = 0 or 3+ → y = defaultValue

"""</span>
<span class="hljs-keyword">component</span> MultiportSwitch_IntegerSelector
&nbsp;&nbsp;<span class="hljs-symbol">selector</span> = <span>Dyad.IntegerInput</span>() {
&nbsp;&nbsp;&nbsp;&nbsp;"Dyad": {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"placement": {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"diagram": {"x1": -40, "x2": 0, "y1": 80, "y2": 120, "sh": 0.04, "sw": 0.04, "rot": 0},
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"icon": {"x1": -40, "x2": 0, "y1": 80, "y2": 120, "sh": 0.04, "sw": 0.04, "rot": 0}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;}
&nbsp;&nbsp;<span class="hljs-symbol">u1</span> = <span>Dyad.RealInput</span>() {
&nbsp;&nbsp;&nbsp;&nbsp;"Dyad": {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"placement": {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"diagram": {"x1": -40, "x2": 0, "y1": 310, "y2": 350, "sh": 1, "sw": 1, "rot": 0},
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"icon": {"x1": -40, "x2": 0, "y1": 310, "y2": 350, "sh": 1, "sw": 1, "rot": 0}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;}
&nbsp;&nbsp;<span class="hljs-symbol">u2</span> = <span>Dyad.RealInput</span>() {
&nbsp;&nbsp;&nbsp;&nbsp;"Dyad": {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"placement": {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"diagram": {"x1": -40, "x2": 0, "y1": 610, "y2": 650, "sh": 1, "sw": 1, "rot": 0},
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"icon": {"x1": -40, "x2": 0, "y1": 610, "y2": 650, "sh": 1, "sw": 1, "rot": 0}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;}
&nbsp;&nbsp;<span class="hljs-symbol">defaultValue</span> = <span>Dyad.RealInput</span>() {
&nbsp;&nbsp;&nbsp;&nbsp;"Dyad": {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"placement": {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"diagram": {"x1": -40, "x2": 0, "y1": 880, "y2": 920, "sh": 1, "sw": 1, "rot": 0},
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"icon": {"x1": -40, "x2": 0, "y1": 880, "y2": 920, "sh": 1, "sw": 1, "rot": 0}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;}
&nbsp;&nbsp;<span class="hljs-symbol">y</span> = <span>Dyad.RealOutput</span>() {
&nbsp;&nbsp;&nbsp;&nbsp;"Dyad": {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"placement": {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"diagram": {"x1": 1000, "x2": 1040, "y1": 480, "y2": 520, "sh": 1, "sw": 1, "rot": 0},
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"icon": {"x1": 1000, "x2": 1040, "y1": 480, "y2": 520, "sh": 1, "sw": 1, "rot": 0}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;}
<span class="hljs-keyword">relations</span>
&nbsp;&nbsp;y = ifelse(selector == 1, u1, ifelse(selector == 2, u2, defaultValue))
<span class="hljs-keyword">metadata</span> {
&nbsp;&nbsp;"Dyad": {"icons": {"default": "dyad://PrimitiveComponents/MultiportSwitch.svg"}}
}
<span class="hljs-keyword">end</span></code></pre>
Flattened Source
"""
    MultiportSwitch_IntegerSelector(; name)

A multiport switch that selects one of multiple real-valued inputs based on an integer control signal.

# Variables
- `selector`: Integer control signal input
- `u1`: First real input signal
- `u2`: Second real input signal
- `defaultValue`: Default real input value
- `y`: Output signal

# Description
Selects one of multiple input signals based on the integer selector value:
- When selector = 1: y = u1
- When selector = 2: y = u2
- For any other selector value: y = defaultValue

This allows flexible selection between multiple input signals using a single integer index.

# Examples

selector = 1 → y = u1 selector = 2 → y = u2 selector = 0 or 3+ → y = defaultValue

"""</span>
<span class="hljs-keyword">component</span> MultiportSwitch_IntegerSelector
&nbsp;&nbsp;<span class="hljs-symbol">selector</span> = <span>Dyad.IntegerInput</span>() {
&nbsp;&nbsp;&nbsp;&nbsp;"Dyad": {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"placement": {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"diagram": {"x1": -40, "x2": 0, "y1": 80, "y2": 120, "sh": 0.04, "sw": 0.04, "rot": 0},
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"icon": {"x1": -40, "x2": 0, "y1": 80, "y2": 120, "sh": 0.04, "sw": 0.04, "rot": 0}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;}
&nbsp;&nbsp;<span class="hljs-symbol">u1</span> = <span>Dyad.RealInput</span>() {
&nbsp;&nbsp;&nbsp;&nbsp;"Dyad": {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"placement": {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"diagram": {"x1": -40, "x2": 0, "y1": 310, "y2": 350, "sh": 1, "sw": 1, "rot": 0},
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"icon": {"x1": -40, "x2": 0, "y1": 310, "y2": 350, "sh": 1, "sw": 1, "rot": 0}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;}
&nbsp;&nbsp;<span class="hljs-symbol">u2</span> = <span>Dyad.RealInput</span>() {
&nbsp;&nbsp;&nbsp;&nbsp;"Dyad": {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"placement": {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"diagram": {"x1": -40, "x2": 0, "y1": 610, "y2": 650, "sh": 1, "sw": 1, "rot": 0},
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"icon": {"x1": -40, "x2": 0, "y1": 610, "y2": 650, "sh": 1, "sw": 1, "rot": 0}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;}
&nbsp;&nbsp;<span class="hljs-symbol">defaultValue</span> = <span>Dyad.RealInput</span>() {
&nbsp;&nbsp;&nbsp;&nbsp;"Dyad": {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"placement": {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"diagram": {"x1": -40, "x2": 0, "y1": 880, "y2": 920, "sh": 1, "sw": 1, "rot": 0},
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"icon": {"x1": -40, "x2": 0, "y1": 880, "y2": 920, "sh": 1, "sw": 1, "rot": 0}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;}
&nbsp;&nbsp;<span class="hljs-symbol">y</span> = <span>Dyad.RealOutput</span>() {
&nbsp;&nbsp;&nbsp;&nbsp;"Dyad": {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"placement": {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"diagram": {"x1": 1000, "x2": 1040, "y1": 480, "y2": 520, "sh": 1, "sw": 1, "rot": 0},
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"icon": {"x1": 1000, "x2": 1040, "y1": 480, "y2": 520, "sh": 1, "sw": 1, "rot": 0}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;}
<span class="hljs-keyword">relations</span>
&nbsp;&nbsp;y = ifelse(selector == 1, u1, ifelse(selector == 2, u2, defaultValue))
<span class="hljs-keyword">metadata</span> {
&nbsp;&nbsp;"Dyad": {"icons": {"default": "dyad://PrimitiveComponents/MultiportSwitch.svg"}}
}
<span class="hljs-keyword">end</span></code></pre>


Test Cases

No test cases defined.

  • Examples
  • Experiments
  • Analyses