| Name | Description |
|---|---|
| Show Integer value from numberPort or from number input field in diagram layer dynamically | |
| Logical 'and': y = u[1] and u[2] and ... and u[nu] | |
| Logical 'or': y = u[1] or u[2] or ... or u[nu] | |
| Logical 'xor': y = oneTrue(u) (y is true, if exactly one element of u is true, otherwise it is false) | |
| Logical 'nand': y = not ( u[1] and u[2] and ... and u[nu] ) | |
| Logical 'nor': y = not ( u[1] or u[2] or ... or u[nu] ) | |
| Output y is true, if the input u has a rising edge, otherwise it is false (y = edge(u)) | |
| Output y is true, if the input u has a falling edge, otherwise it is false (y = edge(not u)) | |
| Output y is true, if the input u has either a rising or a falling edge and otherwise it is false (y=change(u)) | |
| Set Boolean expression that is associated with the first active input signal | |
| Delay a rising edge of the input, but do not delay a falling edge. |
Modelica_StateGraph2.Blocks.MathBoolean.ShowValue
| Type | Name | Default | Description |
|---|---|---|---|
| Boolean | use_activePort | true | = true, if activePort enabled |
| Boolean | active | false | Boolean variable to visualize if use_activePort=false (time varying) |
| Type | Name | Description |
|---|---|---|
| input BooleanInput | activePort | Boolean variable to be shown in diagram layer if use_activePort = true |
| output BooleanOutput | active2 |
block ShowValue
"Show Integer value from numberPort or from number input field in diagram layer dynamically"
parameter Boolean use_activePort = true "= true, if activePort enabled";
input Boolean active=false
"Boolean variable to visualize if use_activePort=false (time varying)";
Modelica.Blocks.Interfaces.BooleanInput activePort if use_activePort
"Boolean variable to be shown in diagram layer if use_activePort = true";
Modelica.Blocks.Interfaces.BooleanOutput active2;
equation
if use_activePort then
connect(activePort, active2);
else
active2 = active;
end if;
end ShowValue;
Modelica_StateGraph2.Blocks.MathBoolean.And
| Type | Name | Description |
|---|---|---|
| input BooleanVectorInput | u[nu] | |
| output BooleanOutput | y |
block And "Logical 'and': y = u[1] and u[2] and ... and u[nu]" extends Modelica_StateGraph2.Blocks.Interfaces.PartialBooleanMISO; equation y = Modelica_StateGraph2.Blocks.BooleanFunctions.allTrue(u);end And;
Modelica_StateGraph2.Blocks.MathBoolean.Or
| Type | Name | Description |
|---|---|---|
| input BooleanVectorInput | u[nu] | |
| output BooleanOutput | y |
block Or "Logical 'or': y = u[1] or u[2] or ... or u[nu]" extends Modelica_StateGraph2.Blocks.Interfaces.PartialBooleanMISO; equation y = Modelica_StateGraph2.Blocks.BooleanFunctions.anyTrue(u);end Or;
Modelica_StateGraph2.Blocks.MathBoolean.Xor
| Type | Name | Description |
|---|---|---|
| input BooleanVectorInput | u[nu] | |
| output BooleanOutput | y |
block Xor "Logical 'xor': y = oneTrue(u) (y is true, if exactly one element of u is true, otherwise it is false)" extends Modelica_StateGraph2.Blocks.Interfaces.PartialBooleanMISO; equation y = Modelica_StateGraph2.Blocks.BooleanFunctions.oneTrue(u);end Xor;
Modelica_StateGraph2.Blocks.MathBoolean.Nand
| Type | Name | Description |
|---|---|---|
| input BooleanVectorInput | u[nu] | |
| output BooleanOutput | y |
block Nand "Logical 'nand': y = not ( u[1] and u[2] and ... and u[nu] )" extends Modelica_StateGraph2.Blocks.Interfaces.PartialBooleanMISO; equation y = not Modelica_StateGraph2.Blocks.BooleanFunctions.allTrue(u);end Nand;
Modelica_StateGraph2.Blocks.MathBoolean.Nor
| Type | Name | Description |
|---|---|---|
| input BooleanVectorInput | u[nu] | |
| output BooleanOutput | y |
block Nor "Logical 'nor': y = not ( u[1] or u[2] or ... or u[nu] )" extends Modelica_StateGraph2.Blocks.Interfaces.PartialBooleanMISO; equation y = not Modelica_StateGraph2.Blocks.BooleanFunctions.anyTrue(u);end Nor;
Modelica_StateGraph2.Blocks.MathBoolean.RisingEdge
A rising edge of the Boolean input u results in y = true at this time instant. At all other time instants, y = false.
Extends from Interfaces.PartialBooleanSISO (Partial block with a BooleanInput and a BooleanOutput signal).
| Type | Name | Default | Description |
|---|---|---|---|
| Boolean | pre_u_start | false | Value of pre(u) at initial time |
| Type | Name | Description |
|---|---|---|
| output BooleanOutput | y | |
| input BooleanInput | u |
block RisingEdge "Output y is true, if the input u has a rising edge, otherwise it is false (y = edge(u))" parameter Boolean pre_u_start = false "Value of pre(u) at initial time"; extends Interfaces.PartialBooleanSISO; initial equation pre(u) = pre_u_start; equation y = edge(u);end RisingEdge;
Modelica_StateGraph2.Blocks.MathBoolean.FallingEdge
A falling edge of the Boolean input u results in y = true at this time instant. At all other time instants, y = false.
Extends from Interfaces.PartialBooleanSISO (Partial block with a BooleanInput and a BooleanOutput signal).
| Type | Name | Default | Description |
|---|---|---|---|
| Boolean | pre_u_start | false | Value of pre(u) at initial time |
| Type | Name | Description |
|---|---|---|
| output BooleanOutput | y | |
| input BooleanInput | u |
block FallingEdge "Output y is true, if the input u has a falling edge, otherwise it is false (y = edge(not u))" parameter Boolean pre_u_start = false "Value of pre(u) at initial time"; extends Interfaces.PartialBooleanSISO; protected Boolean not_u = not u; initial equation pre(not_u) = not pre_u_start; equation y = edge(not_u);end FallingEdge;
Modelica_StateGraph2.Blocks.MathBoolean.ChangingEdge
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.
Extends from Interfaces.PartialBooleanSISO (Partial block with a BooleanInput and a BooleanOutput signal).
| Type | Name | Default | Description |
|---|---|---|---|
| Boolean | pre_u_start | false | Value of pre(u) at initial time |
| Type | Name | Description |
|---|---|---|
| output BooleanOutput | y | |
| input BooleanInput | u |
block 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))" parameter Boolean pre_u_start = false "Value of pre(u) at initial time"; extends Interfaces.PartialBooleanSISO; initial equation pre(u) = pre_u_start; equation y = change(u);end ChangingEdge;
Modelica_StateGraph2.Blocks.MathBoolean.MultiSwitch
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 to pre(y) depending on the parameter use_pre_as_default:
// 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];
| Type | Name | Default | Description |
|---|---|---|---|
| Boolean | expr[nu] | fill(false, nu) | y = if u[i] then expr[i] else y_default (time varying) |
| 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 |
| Type | Name | Description |
|---|---|---|
| input BooleanVectorInput | u[nu] | Set y = expr[i], if u[i] = true |
| output BooleanOutput | y | Output depending on expression |
block MultiSwitch
"Set Boolean expression that is associated with the first active input signal"
input Boolean expr[nu]=fill(false, nu)
"y = if u[i] then expr[i] else y_default (time varying)";
parameter Boolean use_pre_as_default=true
"set true to hold last value as default (y_default = pre(y))";
parameter Boolean y_default=false
"Default value of output y if all u[i] = false";
parameter Integer nu(min=0) = 0 "Number of input connections";
Modelica_StateGraph2.Blocks.Interfaces.BooleanVectorInput u[nu]
"Set y = expr[i], if u[i] = true";
Modelica.Blocks.Interfaces.BooleanOutput y(start=y_default,fixed=true)
"Output depending on expression";
protected
Integer firstActiveIndex;
equation
firstActiveIndex = BooleanFunctions.firstTrueIndex(u);
y = if firstActiveIndex == 0 then (if use_pre_as_default then pre(y) else y_default) else
expr[firstActiveIndex];
end MultiSwitch;
Modelica_StateGraph2.Blocks.MathBoolean.OnDelay
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.
Extends from Interfaces.PartialBooleanSISO (Partial block with a BooleanInput and a BooleanOutput signal).
| Type | Name | Default | Description |
|---|---|---|---|
| Time | delayTime | Delay time [s] |
| Type | Name | Description |
|---|---|---|
| output BooleanOutput | y | |
| input BooleanInput | u |
block OnDelay
"Delay a rising edge of the input, but do not delay a falling edge."
extends Interfaces.PartialBooleanSISO;
parameter Modelica.SIunits.Time delayTime "Delay time";
protected
Boolean delaySignal(start=false,fixed=true);
discrete Modelica.SIunits.Time t_next;
initial equation
pre(u) = false;
pre(t_next) = time - 1;
algorithm
when u then
delaySignal := true;
t_next := time + delayTime;
elsewhen not u then
delaySignal := false;
t_next := time - 1;
end when;
equation
if delaySignal then
y = time >= t_next;
else
y = false;
end if;
end OnDelay;