Modelica_StateGraph2.Blocks.BooleanFunctions

Functions with Boolean inputs (shall be included in Modelica Standard Library)

Package Content

NameDescription
Modelica_StateGraph2.Blocks.BooleanFunctions.allTrue allTrue Returns true, if all elements of the Boolean input vector are true ('and')
Modelica_StateGraph2.Blocks.BooleanFunctions.anyTrue anyTrue Returns true, if at least on element of the Boolean input vector is true ('or')
Modelica_StateGraph2.Blocks.BooleanFunctions.oneTrue oneTrue Returns true, if exactly one element of the Boolean input vector is true ('xor')
Modelica_StateGraph2.Blocks.BooleanFunctions.firstTrueIndex firstTrueIndex Returns the index of the first element of the Boolean vector that is true and returns 0, if no element is true


Modelica_StateGraph2.Blocks.BooleanFunctions.allTrue Modelica_StateGraph2.Blocks.BooleanFunctions.allTrue

Returns true, if all elements of the Boolean input vector are true ('and')

Information


Extends from Modelica.Icons.Function (Icon for functions).

Inputs

TypeNameDefaultDescription
Booleanb[:]  

Outputs

TypeNameDescription
Booleanresult 

Modelica definition

function allTrue 
  "Returns true, if all elements of the Boolean input vector are true ('and')"
  extends Modelica.Icons.Function;
  input Boolean b[:];
  output Boolean result;
algorithm 
  result := true;
  for i in 1:size(b,1) loop
     result := result and b[i];
  end for;
end allTrue;

Modelica_StateGraph2.Blocks.BooleanFunctions.anyTrue Modelica_StateGraph2.Blocks.BooleanFunctions.anyTrue

Returns true, if at least on element of the Boolean input vector is true ('or')

Information

Extends from Modelica.Icons.Function (Icon for functions).

Inputs

TypeNameDefaultDescription
Booleanb[:]  

Outputs

TypeNameDescription
Booleanresult 

Modelica definition

function anyTrue 
  "Returns true, if at least on element of the Boolean input vector is true ('or')"

  extends Modelica.Icons.Function;
  input Boolean b[:];
  output Boolean result;
algorithm 
  result := false;
  for i in 1:size(b,1) loop
     result := result or b[i];
  end for;
end anyTrue;

Modelica_StateGraph2.Blocks.BooleanFunctions.oneTrue Modelica_StateGraph2.Blocks.BooleanFunctions.oneTrue

Returns true, if exactly one element of the Boolean input vector is true ('xor')

Information

Extends from Modelica.Icons.Function (Icon for functions).

Inputs

TypeNameDefaultDescription
Booleanb[:]  

Outputs

TypeNameDescription
Booleanresult 

Modelica definition

function oneTrue 
  "Returns true, if exactly one element of the Boolean input vector is true ('xor')"

  extends Modelica.Icons.Function;
  input Boolean b[:];
  output Boolean result;
protected 
  Integer count = 0;
algorithm 
  for i in 1:size(b,1) loop
     count := if b[i] then count+1 else count;
  end for;
  result :=count == 1;
end oneTrue;

Modelica_StateGraph2.Blocks.BooleanFunctions.firstTrueIndex

Returns the index of the first element of the Boolean vector that is true and returns 0, if no element is true

Inputs

TypeNameDefaultDescription
Booleanb[:]  

Outputs

TypeNameDescription
Integerindex 

Modelica definition

function firstTrueIndex 
  "Returns the index of the first element of the Boolean vector that is true and returns 0, if no element is true"
   input Boolean b[:];
   output Integer index;
algorithm 
   index :=0;
   for i in 1:size(b,1) loop
      if b[i] then
         index :=i;
         return;
      end if;
   end for;
end firstTrueIndex;

Automatically generated Fri Nov 12 17:27:07 2010.