LIBRARY
Math.BooleanToInteger
Convert Boolean to Integer signal.
This block computes the output y as Integer equivalent of the Boolean input u:
y = if u then integerTrue else integerFalsewhere u is of Boolean and y of Integer type, and integerTrue and integerFalse are parameters.
This component extends from BlockComponents.Interfaces.PartialBooleanSI
Usage
BlockComponents.Math.BooleanToInteger(integerTrue=1, integerFalse=0)
Parameters:
| Name | Description | Units | Default value |
|---|---|---|---|
integerTrue | Output signal for true Boolean input | – | 1 |
integerFalse | Output signal for false Boolean input | – | 0 |
Connectors
u- This connector represents a boolean signal as an input to a component (BooleanInput)y- This connector represents an integer signal as an output from a component (IntegerOutput)
Behavior
Source
dyad
"""
Convert Boolean to Integer signal.
This block computes the output `y` as Integer equivalent of the Boolean input `u`:
```
y = if u then integerTrue else integerFalse
```
where `u` is of Boolean and `y` of Integer type, and `integerTrue` and `integerFalse` are parameters.
"""
component BooleanToInteger
extends BlockComponents.Interfaces.PartialBooleanSI
"Connector of Integer output signal"
y = IntegerOutput() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 1000, "y1": 450, "x2": 1100, "y2": 550, "rot": 0}
},
"tags": []
}
}
"Output signal for true Boolean input"
parameter integerTrue::Integer = 1
"Output signal for false Boolean input"
parameter integerFalse::Integer = 0
relations
y = ifelse(u, integerTrue, integerFalse)
metadata {
"Dyad": {
"labels": [{"label": "$(instance)", "x": 500, "y": 1100, "rot": 0}],
"icons": {"default": "dyad://BlockComponents/BooleanToInteger.svg"}
}
}
endFlattened Source
dyad
"""
Convert Boolean to Integer signal.
This block computes the output `y` as Integer equivalent of the Boolean input `u`:
```
y = if u then integerTrue else integerFalse
```
where `u` is of Boolean and `y` of Integer type, and `integerTrue` and `integerFalse` are parameters.
"""
component BooleanToInteger
"Connector of Boolean input signal"
u = BooleanInput() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": -100, "y1": 450, "x2": 0, "y2": 550, "rot": 0}
},
"tags": []
}
}
"Connector of Integer output signal"
y = IntegerOutput() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 1000, "y1": 450, "x2": 1100, "y2": 550, "rot": 0}
},
"tags": []
}
}
"Output signal for true Boolean input"
parameter integerTrue::Integer = 1
"Output signal for false Boolean input"
parameter integerFalse::Integer = 0
relations
y = ifelse(u, integerTrue, integerFalse)
metadata {
"Dyad": {
"labels": [{"label": "$(instance)", "x": 500, "y": 1100, "rot": 0}],
"icons": {"default": "dyad://BlockComponents/BooleanToInteger.svg"}
}
}
endTest Cases
No test cases defined.
Related
Examples
Experiments
Analyses
Tests