Skip to content
LIBRARY
Math.BooleanToReal.md

Math.BooleanToReal

Convert Boolean to Real signal.

This block computes the output y as Real equivalent of the Boolean input u:

y = if u then realTrue else realFalse

where u is of Boolean and y of Real type, and realTrue and realFalse are parameters.

This component extends from BlockComponents.Interfaces.PartialBooleanSI

Usage

BlockComponents.Math.BooleanToReal(realTrue=1.0, realFalse=0.0)

Parameters:

NameDescriptionUnitsDefault value
realTrueOutput signal for true Boolean input1.0
realFalseOutput signal for false Boolean input0.0

Connectors

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

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

Behavior

Source

dyad
"""
Convert Boolean to Real signal.

This block computes the output `y` as Real equivalent of the Boolean input `u`:

```
y = if u then realTrue else realFalse
```

where `u` is of Boolean and `y` of Real type, and `realTrue` and `realFalse` are parameters.
"""
component BooleanToReal
  extends BlockComponents.Interfaces.PartialBooleanSI
  "Connector of Real output signal"
  y = RealOutput() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 1000, "y1": 450, "x2": 1100, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  "Output signal for true Boolean input"
  parameter realTrue::Real = 1.0
  "Output signal for false Boolean input"
  parameter realFalse::Real = 0.0
relations
  y = ifelse(u, realTrue, realFalse)
metadata {
  "Dyad": {
    "labels": [{"label": "$(instance)", "x": 500, "y": 1100, "rot": 0}],
    "icons": {"default": "dyad://BlockComponents/BooleanToReal.svg"}
  }
}
end
Flattened Source
dyad
"""
Convert Boolean to Real signal.

This block computes the output `y` as Real equivalent of the Boolean input `u`:

```
y = if u then realTrue else realFalse
```

where `u` is of Boolean and `y` of Real type, and `realTrue` and `realFalse` are parameters.
"""
component BooleanToReal
  "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 Real output signal"
  y = RealOutput() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 1000, "y1": 450, "x2": 1100, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  "Output signal for true Boolean input"
  parameter realTrue::Real = 1.0
  "Output signal for false Boolean input"
  parameter realFalse::Real = 0.0
relations
  y = ifelse(u, realTrue, realFalse)
metadata {
  "Dyad": {
    "labels": [{"label": "$(instance)", "x": 500, "y": 1100, "rot": 0}],
    "icons": {"default": "dyad://BlockComponents/BooleanToReal.svg"}
  }
}
end


Test Cases

No test cases defined.