PositionalSwitch_NotEqual Icon
Switches.PositionalSwitch_NotEqual
This component acts as a conditional selector that switches between two real-valued input signals.
The selection is based on whether the control signal (switch_primary) is not equal to a specified threshold, within a small tolerance range.
If the absolute difference between switch_primary and Threshold is greater than Tolerance, the output follows input_primary. Otherwise, it follows input_secondary.
Example: Threshold = 1.0 Tolerance = 0.0001
- switchprimary = 1.0 → output = inputsecondary (within tolerance → equal)
- switchprimary = 1.002 → output = inputprimary (not equal)
- switchprimary = 0.99995 → output = inputsecondary (within tolerance → equal)
- switchprimary = 0.9 → output = inputprimary (not equal)
Usage
PrimitiveComponents.Switches.PositionalSwitch_NotEqual(threshold, tolerance=0.0001)
Parameters:
| Name | Description | Units | Default value |
|---|---|---|---|
threshold | Threshold | – | |
tolerance | Tolerance | – | 0.0001 |
Connectors
switch_primary- This connector represents a real signal as an input to a component (RealInput)input_primary- This connector represents a real signal as an input to a component (RealInput)input_secondary- This connector represents a real signal as an input to a component (RealInput)switch_position- This connector represents a real signal as an output from a component (RealOutput)
Behavior
\[ \begin{align} \mathtt{switch\_position}\left( t \right) &= ifelse\left( \left| - \mathtt{threshold} + \mathtt{switch\_primary}\left( t \right)\right| > \mathtt{tolerance}, \mathtt{input\_primary}\left( t \right), \mathtt{input\_secondary}\left( t \right) \right) \end{align} \]
Source
"""
This component acts as a conditional selector that switches between two real-valued input signals.
The selection is based on whether the control signal (`switch_primary`) is **not equal**
to a specified threshold, within a small tolerance range.
If the absolute difference between `switch_primary` and `Threshold` is greater than `Tolerance`,
the output follows `input_primary`. Otherwise, it follows `input_secondary`.
Example:
Threshold = 1.0
Tolerance = 0.0001
- switch_primary = 1.0 → output = input_secondary (within tolerance → equal)
- switch_primary = 1.002 → output = input_primary (not equal)
- switch_primary = 0.99995 → output = input_secondary (within tolerance → equal)
- switch_primary = 0.9 → output = input_primary (not equal)
"""
component PositionalSwitch_NotEqual
switch_primary = Dyad.RealInput() {
"Dyad": {
"placement": {
"diagram": {"x1": -40, "x2": 0, "y1": 480, "y2": 520, "sh": 0.04, "sw": 0.04, "rot": 0},
"icon": {"x1": -40, "x2": 0, "y1": 480, "y2": 520, "sh": 0.04, "sw": 0.04, "rot": 0}
}
}
}
input_primary = Dyad.RealInput() {
"Dyad": {
"placement": {
"diagram": {"x1": -40, "x2": 0, "y1": 110, "y2": 150, "sh": 0.04, "sw": 0.04, "rot": 0},
"icon": {"x1": -40, "x2": 0, "y1": 110, "y2": 150, "sh": 0.04, "sw": 0.04, "rot": 0}
}
}
}
input_secondary = Dyad.RealInput() {
"Dyad": {
"placement": {
"diagram": {"x1": -40, "x2": 0, "y1": 850, "y2": 890, "sh": 0.04, "sw": 0.04, "rot": 0},
"icon": {"x1": -40, "x2": 0, "y1": 850, "y2": 890, "sh": 0.04, "sw": 0.04, "rot": 0}
}
}
}
switch_position = Dyad.RealOutput() {
"Dyad": {
"placement": {
"diagram": {"x1": 1000, "x2": 1040, "y1": 480, "y2": 520, "sh": 1, "sw": 1, "rot": 0},
"icon": {"x1": 1000, "x2": 1040, "y1": 480, "y2": 520, "sh": 1, "sw": 1, "rot": 0}
}
}
}
"Threshold"
parameter threshold::Real()
"Tolerance"
parameter tolerance::Real = 0.0001
relations
switch_position = ifelse(abs(switch_primary - threshold) > tolerance, input_primary, input_secondary)
metadata {
"Dyad": {
"labels": [
{"label": "$(instance)", "x": 500, "y": 1100, "rot": 0},
{"label": "!= $(threshold)", "x": 500, "y": -150, "rot": 0}
],
"icons": {"default": "dyad://PrimitiveComponents/Switch.svg"}
}
}
end
Flattened Source
"""
This component acts as a conditional selector that switches between two real-valued input signals.
The selection is based on whether the control signal (`switch_primary`) is **not equal**
to a specified threshold, within a small tolerance range.
If the absolute difference between `switch_primary` and `Threshold` is greater than `Tolerance`,
the output follows `input_primary`. Otherwise, it follows `input_secondary`.
Example:
Threshold = 1.0
Tolerance = 0.0001
- switch_primary = 1.0 → output = input_secondary (within tolerance → equal)
- switch_primary = 1.002 → output = input_primary (not equal)
- switch_primary = 0.99995 → output = input_secondary (within tolerance → equal)
- switch_primary = 0.9 → output = input_primary (not equal)
"""
component PositionalSwitch_NotEqual
switch_primary = Dyad.RealInput() {
"Dyad": {
"placement": {
"diagram": {"x1": -40, "x2": 0, "y1": 480, "y2": 520, "sh": 0.04, "sw": 0.04, "rot": 0},
"icon": {"x1": -40, "x2": 0, "y1": 480, "y2": 520, "sh": 0.04, "sw": 0.04, "rot": 0}
}
}
}
input_primary = Dyad.RealInput() {
"Dyad": {
"placement": {
"diagram": {"x1": -40, "x2": 0, "y1": 110, "y2": 150, "sh": 0.04, "sw": 0.04, "rot": 0},
"icon": {"x1": -40, "x2": 0, "y1": 110, "y2": 150, "sh": 0.04, "sw": 0.04, "rot": 0}
}
}
}
input_secondary = Dyad.RealInput() {
"Dyad": {
"placement": {
"diagram": {"x1": -40, "x2": 0, "y1": 850, "y2": 890, "sh": 0.04, "sw": 0.04, "rot": 0},
"icon": {"x1": -40, "x2": 0, "y1": 850, "y2": 890, "sh": 0.04, "sw": 0.04, "rot": 0}
}
}
}
switch_position = Dyad.RealOutput() {
"Dyad": {
"placement": {
"diagram": {"x1": 1000, "x2": 1040, "y1": 480, "y2": 520, "sh": 1, "sw": 1, "rot": 0},
"icon": {"x1": 1000, "x2": 1040, "y1": 480, "y2": 520, "sh": 1, "sw": 1, "rot": 0}
}
}
}
"Threshold"
parameter threshold::Real()
"Tolerance"
parameter tolerance::Real = 0.0001
relations
switch_position = ifelse(abs(switch_primary - threshold) > tolerance, input_primary, input_secondary)
metadata {
"Dyad": {
"labels": [
{"label": "$(instance)", "x": 500, "y": 1100, "rot": 0},
{"label": "!= $(threshold)", "x": 500, "y": -150, "rot": 0}
],
"icons": {"default": "dyad://PrimitiveComponents/Switch.svg"}
}
}
endTest Cases
No test cases defined.
Related
- Examples
- Experiments
- Analyses