# Package Modelica.​Blocks.​MathBooleanLibrary of Boolean mathematical functions as input/output blocks

### Information

This package contains basic mathematical operations on Boolean signals.

The new features are:

• If useful, blocks may have an arbitrary number of inputs (e.g., "And" block with 2,3,4,... Boolean inputs). This is based on the "connectorSizing" annotation which allows a tool to conveniently handle vectors of connectors.
• The blocks are smaller in size, so that the diagram area is better utilized for trivial blocks such as "And" or "Or".

Extends from `Modelica.​Icons.​Package` (Icon for standard packages).

### Package Contents

NameDescription
`And`Logical 'and': y = u[1] and u[2] and ... and u[nu]
`ChangingEdge`Output y is true, if the input u has either a rising or a falling edge and otherwise it is false (y=change(u))
`FallingEdge`Output y is true, if the input u has a falling edge, otherwise it is false (y = edge(not u))
`MultiSwitch`Set Boolean expression that is associated with the first active input signal
`Nand`Logical 'nand': y = not ( u[1] and u[2] and ... and u[nu] )
`Nor`Logical 'nor': y = not ( u[1] or u[2] or ... or u[nu] )
`Not`Logical 'not': y = not u
`OnDelay`Delay a rising edge of the input, but do not delay a falling edge.
`Or`Logical 'or': y = u[1] or u[2] or ... or u[nu]
`RisingEdge`Output y is true, if the input u has a rising edge, otherwise it is false (y = edge(u))
`Xor`Logical 'xor': y = oneTrue(u) (y is true, if exactly one element of u is true, otherwise it is false)

## Block Modelica.​Blocks.​MathBoolean.​MultiSwitchSet Boolean expression that is associated with the first active input signal

### Information

The block has a vector of Boolean input signals u[nu] and a vector of (time varying) Boolean expressions expr[:]. The output signal y is set to expr[i], if i is the first element in the input vector u that is true. If all input signals are false, y is set to parameter "y_default" or the previous value of y is kept if parameter use_pre_as_default = true:

```  // Conceptual equation (not valid Modelica)
i = 'first element of u[:] that is true';
y = if i==0 then (if use_pre_as_default then pre(y)
else y_default)
else expr[i];
```

The usage is demonstrated, e.g., in example Modelica.Blocks.Examples.BooleanNetwork1.

### Parameters

TypeNameDefaultDescription
`Boolean``use_pre_as_default``true`set true to hold last value as default (y_default = pre(y))
`Boolean``y_default``false`Default value of output y if all u[i] = false
`Integer``nu``0`Number of input connections

### Inputs

TypeNameDefaultDescription
`Boolean``expr[nu]``fill(false, nu)`y = if u[i] then expr[i] else y_default (time varying)

### Connectors

TypeNameDescription
`input ``BooleanVectorInput``u[nu]`Set y = expr[i], if u[i] = true
`output ``BooleanOutput``y`Output depending on expression

## Block Modelica.​Blocks.​MathBoolean.​AndLogical 'and': y = u[1] and u[2] and ... and u[nu]

### Information

The output is true if all inputs are true, otherwise the output is false.

The input connector is a vector of Boolean input signals. When a connection line is drawn, the dimension of the input vector is enlarged by one and the connection is automatically connected to this new free index (thanks to the connectorSizing annotation).

The usage is demonstrated, e.g., in example Modelica.Blocks.Examples.BooleanNetwork1.

If no connection to the input connector "u" is present, the output is set to false: y=false.

Extends from `Modelica.​Blocks.​Interfaces.​PartialBooleanMISO` (Partial block with a BooleanVectorInput and a BooleanOutput signal).

### Parameters

TypeNameDefaultDescription
`Integer``nu``0`Number of input connections

### Connectors

TypeNameDescription
`input ``BooleanVectorInput``u[nu]`Vector of Boolean input signals
`output ``BooleanOutput``y`Boolean output signal

## Block Modelica.​Blocks.​MathBoolean.​OrLogical 'or': y = u[1] or u[2] or ... or u[nu]

### Information

The output is true if at least one input is true, otherwise the output is false.

The input connector is a vector of Boolean input signals. When a connection line is drawn, the dimension of the input vector is enlarged by one and the connection is automatically connected to this new free index (thanks to the connectorSizing annotation).

The usage is demonstrated, e.g., in example Modelica.Blocks.Examples.BooleanNetwork1.

If no connection to the input connector "u" is present, the output is set to false: y=false.

Extends from `Modelica.​Blocks.​Interfaces.​PartialBooleanMISO` (Partial block with a BooleanVectorInput and a BooleanOutput signal).

### Parameters

TypeNameDefaultDescription
`Integer``nu``0`Number of input connections

### Connectors

TypeNameDescription
`input ``BooleanVectorInput``u[nu]`Vector of Boolean input signals
`output ``BooleanOutput``y`Boolean output signal

## Block Modelica.​Blocks.​MathBoolean.​XorLogical 'xor': y = oneTrue(u) (y is true, if exactly one element of u is true, otherwise it is false)

### Information

The output is true if exactly one input is true, otherwise the output is false.

The input connector is a vector of Boolean input signals. When a connection line is drawn, the dimension of the input vector is enlarged by one and the connection is automatically connected to this new free index (thanks to the connectorSizing annotation).

The usage is demonstrated, e.g., in example Modelica.Blocks.Examples.BooleanNetwork1.

If no connection to the input connector "u" is present, the output is set to false: y=false.

Extends from `Modelica.​Blocks.​Interfaces.​PartialBooleanMISO` (Partial block with a BooleanVectorInput and a BooleanOutput signal).

### Parameters

TypeNameDefaultDescription
`Integer``nu``0`Number of input connections

### Connectors

TypeNameDescription
`input ``BooleanVectorInput``u[nu]`Vector of Boolean input signals
`output ``BooleanOutput``y`Boolean output signal

## Block Modelica.​Blocks.​MathBoolean.​NandLogical 'nand': y = not ( u[1] and u[2] and ... and u[nu] )

### Information

The output is true if at least one input is false, otherwise the output is false.

The input connector is a vector of Boolean input signals. When a connection line is drawn, the dimension of the input vector is enlarged by one and the connection is automatically connected to this new free index (thanks to the connectorSizing annotation).

The usage is demonstrated, e.g., in example Modelica.Blocks.Examples.BooleanNetwork1.

If no connection to the input connector "u" is present, the output is set to false: y=false.

Extends from `Modelica.​Blocks.​Interfaces.​PartialBooleanMISO` (Partial block with a BooleanVectorInput and a BooleanOutput signal).

### Parameters

TypeNameDefaultDescription
`Integer``nu``0`Number of input connections

### Connectors

TypeNameDescription
`input ``BooleanVectorInput``u[nu]`Vector of Boolean input signals
`output ``BooleanOutput``y`Boolean output signal

## Block Modelica.​Blocks.​MathBoolean.​NorLogical 'nor': y = not ( u[1] or u[2] or ... or u[nu] )

### Information

The output is false if at least one input is true, otherwise the output is true.

The input connector is a vector of Boolean input signals. When a connection line is drawn, the dimension of the input vector is enlarged by one and the connection is automatically connected to this new free index (thanks to the connectorSizing annotation).

The usage is demonstrated, e.g., in example Modelica.Blocks.Examples.BooleanNetwork1.

If no connection to the input connector "u" is present, the output is set to false: y=false.

Extends from `Modelica.​Blocks.​Interfaces.​PartialBooleanMISO` (Partial block with a BooleanVectorInput and a BooleanOutput signal).

### Parameters

TypeNameDefaultDescription
`Integer``nu``0`Number of input connections

### Connectors

TypeNameDescription
`input ``BooleanVectorInput``u[nu]`Vector of Boolean input signals
`output ``BooleanOutput``y`Boolean output signal

## Block Modelica.​Blocks.​MathBoolean.​NotLogical 'not': y = not u

### Information

The output is false if at least one input is true, otherwise the output is true.

The input connector is a vector of Boolean input signals. When a connection line is drawn, the dimension of the input vector is enlarged by one and the connection is automatically connected to this new free index (thanks to the connectorSizing annotation).

The usage is demonstrated, e.g., in example Modelica.Blocks.Examples.BooleanNetwork1.

Extends from `Modelica.​Blocks.​Interfaces.​PartialBooleanSISO_small` (Partial block with a BooleanInput and a BooleanOutput signal and a small block icon).

### Connectors

TypeNameDescription
`input ``BooleanInput``u`Boolean input signal
`output ``BooleanOutput``y`Boolean output signal

## Block Modelica.​Blocks.​MathBoolean.​RisingEdgeOutput y is true, if the input u has a rising edge, otherwise it is false (y = edge(u))

### Information

A rising edge of the Boolean input u results in y = true at this time instant. At all other time instants, y = false.

The usage is demonstrated, e.g., in example Modelica.Blocks.Examples.BooleanNetwork1.

Extends from `Modelica.​Blocks.​Interfaces.​PartialBooleanSISO_small` (Partial block with a BooleanInput and a BooleanOutput signal and a small block icon).

### Parameters

TypeNameDefaultDescription
`Boolean``pre_u_start``false`Value of pre(u) at initial time

### Connectors

TypeNameDescription
`input ``BooleanInput``u`Boolean input signal
`output ``BooleanOutput``y`Boolean output signal

## Block Modelica.​Blocks.​MathBoolean.​FallingEdgeOutput y is true, if the input u has a falling edge, otherwise it is false (y = edge(not u))

### Information

A falling edge of the Boolean input u results in y = true at this time instant. At all other time instants, y = false.

The usage is demonstrated, e.g., in example Modelica.Blocks.Examples.BooleanNetwork1.

Extends from `Modelica.​Blocks.​Interfaces.​PartialBooleanSISO_small` (Partial block with a BooleanInput and a BooleanOutput signal and a small block icon).

### Parameters

TypeNameDefaultDescription
`Boolean``pre_u_start``false`Value of pre(u) at initial time

### Connectors

TypeNameDescription
`input ``BooleanInput``u`Boolean input signal
`output ``BooleanOutput``y`Boolean output signal

## Block Modelica.​Blocks.​MathBoolean.​ChangingEdgeOutput y is true, if the input u has either a rising or a falling edge and otherwise it is false (y=change(u))

### Information

A changing edge, i.e., either rising or falling, of the Boolean input u results in y = true at this time instant. At all other time instants, y = false.

The usage is demonstrated, e.g., in example Modelica.Blocks.Examples.BooleanNetwork1.

Extends from `Modelica.​Blocks.​Interfaces.​PartialBooleanSISO_small` (Partial block with a BooleanInput and a BooleanOutput signal and a small block icon).

### Parameters

TypeNameDefaultDescription
`Boolean``pre_u_start``false`Value of pre(u) at initial time

### Connectors

TypeNameDescription
`input ``BooleanInput``u`Boolean input signal
`output ``BooleanOutput``y`Boolean output signal

## Block Modelica.​Blocks.​MathBoolean.​OnDelayDelay a rising edge of the input, but do not delay a falling edge.

### Information

A rising edge of the Boolean input u gives a delayed output. A falling edge of the input is immediately given to the output.

Simulation results of a typical example with a delay time of 0.1 s is shown in the next figure.

The usage is demonstrated, e.g., in example Modelica.Blocks.Examples.BooleanNetwork1.

Extends from `Modelica.​Blocks.​Interfaces.​PartialBooleanSISO_small` (Partial block with a BooleanInput and a BooleanOutput signal and a small block icon).

### Parameters

TypeNameDefaultDescription
`Time``delayTime` Delay time

### Connectors

TypeNameDescription
`input ``BooleanInput``u`Boolean input signal
`output ``BooleanOutput``y`Boolean output signal