Modelica_StateGraph2.Blocks.MathInteger

Blocks with input and output signals of type Integer

Package Content

NameDescription
Modelica_StateGraph2.Blocks.MathInteger.ShowValue ShowValue Show Integer value from numberPort or from number input field in diagram layer dynamically
Modelica_StateGraph2.Blocks.MathInteger.Sum Sum Sum of Integers: y = k[1]*u[1] + k[2]*u[2] + ... + k[n]*u[n]
Modelica_StateGraph2.Blocks.MathInteger.Product Product Product of Integer: y = u[1]*u[2]* ... *u[n]
Modelica_StateGraph2.Blocks.MathInteger.MultiSwitch MultiSwitch Set Integer expression that is associated with the first active input signal
Modelica_StateGraph2.Blocks.MathInteger.TriggeredAdd TriggeredAdd Add input to previous value of output, if rising edge of trigger port


Modelica_StateGraph2.Blocks.MathInteger.ShowValue Modelica_StateGraph2.Blocks.MathInteger.ShowValue

Show Integer value from numberPort or from number input field in diagram layer dynamically

Modelica_StateGraph2.Blocks.MathInteger.ShowValue

Parameters

TypeNameDefaultDescription
Booleanuse_numberPorttrue= true, if numberPort enabled
Integernumber0Number to visualize if use_numberPort=false (time varying)

Connectors

TypeNameDescription
input IntegerInputnumberPortNumber to be shown in diagram layer if use_numberPort = true
output IntegerOutputnumber2 

Modelica definition

block ShowValue 
  "Show Integer value from numberPort or from number input field in diagram layer dynamically"
  parameter Boolean use_numberPort = true "= true, if numberPort enabled";
  input Integer number=0 
    "Number to visualize if use_numberPort=false (time varying)";
  Modelica.Blocks.Interfaces.IntegerInput numberPort if use_numberPort 
    "Number to be shown in diagram layer if use_numberPort = true";
   Modelica.Blocks.Interfaces.IntegerOutput number2;
equation 
  if use_numberPort then
     connect(numberPort, number2);
  else
     number2 = number;
  end if;

end ShowValue;

Modelica_StateGraph2.Blocks.MathInteger.Sum Modelica_StateGraph2.Blocks.MathInteger.Sum

Sum of Integers: y = k[1]*u[1] + k[2]*u[2] + ... + k[n]*u[n]

Modelica_StateGraph2.Blocks.MathInteger.Sum

Information

Extends from Modelica_StateGraph2.Blocks.Interfaces.PartialIntegerMISO (Partial block with an IntegerVectorInput and an IntegerOutput signal).

Parameters

TypeNameDefaultDescription
Integerk[nu]fill(1, nu)Input gains

Connectors

TypeNameDescription
input IntegerVectorInputu[nu] 
output IntegerOutputy 

Modelica definition

block Sum 
  "Sum of Integers: y = k[1]*u[1] + k[2]*u[2] + ... + k[n]*u[n]"
   extends Modelica_StateGraph2.Blocks.Interfaces.PartialIntegerMISO;
   parameter Integer k[nu] = fill(1,nu) "Input gains";
equation 
  y = k*u;

end Sum;

Modelica_StateGraph2.Blocks.MathInteger.Product Modelica_StateGraph2.Blocks.MathInteger.Product

Product of Integer: y = u[1]*u[2]* ... *u[n]

Modelica_StateGraph2.Blocks.MathInteger.Product

Information

Extends from Modelica_StateGraph2.Blocks.Interfaces.PartialIntegerMISO (Partial block with an IntegerVectorInput and an IntegerOutput signal).

Connectors

TypeNameDescription
input IntegerVectorInputu[nu] 
output IntegerOutputy 

Modelica definition

block Product "Product of Integer: y = u[1]*u[2]* ... *u[n]"
   extends Modelica_StateGraph2.Blocks.Interfaces.PartialIntegerMISO;
equation 
  y = product(u);

end Product;

Modelica_StateGraph2.Blocks.MathInteger.MultiSwitch Modelica_StateGraph2.Blocks.MathInteger.MultiSwitch

Set Integer expression that is associated with the first active input signal

Modelica_StateGraph2.Blocks.MathInteger.MultiSwitch

Information


The block has a vector of Boolean input signals u[nu] and a vector of (time varying) Integer 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];

Parameters

TypeNameDefaultDescription
Integerexpr[nu]fill(0, nu)y = if u[i] then expr[i] elseif use_pre_as_default then pre(y) else y_default
Integery_default0Default value of output y if use_pre_as_default=false, as well as pre(y) at initial time
Booleanuse_pre_as_defaulttrue= true, y holds its last value if all u[i]=false, otherwise y=y_default

Connectors

TypeNameDescription
input BooleanVectorInputu[nu]Set y = expr[i], if u[i] = true
output IntegerOutputyOutput depending on expression

Modelica definition

block MultiSwitch 
  "Set Integer expression that is associated with the first active input signal"

  input Integer expr[nu]=fill(0, nu) 
    "y = if u[i] then expr[i] elseif use_pre_as_default then pre(y) else y_default";
  parameter Integer y_default=0 
    "Default value of output y if use_pre_as_default=false, as well as pre(y) at initial time";

  parameter Boolean use_pre_as_default=true 
    "= true, y holds its last value if all u[i]=false, otherwise y=y_default";
  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.IntegerOutput y "Output depending on expression";

protected 
  Integer firstActiveIndex;
initial equation 
  pre(y) = y_default;
equation 
  firstActiveIndex = BooleanFunctions.firstTrueIndex(u);
  y = if firstActiveIndex > 0 then expr[firstActiveIndex] else 
      if use_pre_as_default then pre(y) else y_default;
end MultiSwitch;

Modelica_StateGraph2.Blocks.MathInteger.TriggeredAdd Modelica_StateGraph2.Blocks.MathInteger.TriggeredAdd

Add input to previous value of output, if rising edge of trigger port

Modelica_StateGraph2.Blocks.MathInteger.TriggeredAdd

Information

Extends from Interfaces.PartialIntegerSISO (Partial block with a IntegerInput and an IntegerOutput signal).

Parameters

TypeNameDefaultDescription
Booleanuse_resetfalse=true, if reset port enabled
Booleanuse_setfalse=true, if set port enabled and used as default value when reset
Integery_start0Initial and reset value of y if set port is not used

Connectors

TypeNameDescription
output IntegerOutputy 
input IntegerInputu 
input BooleanInputtrigger 
input BooleanInputreset 
input IntegerInputset 

Modelica definition

block TriggeredAdd 
  "Add input to previous value of output, if rising edge of trigger port"
  extends Interfaces.PartialIntegerSISO;

  parameter Boolean use_reset = false "=true, if reset port enabled";
  parameter Boolean use_set = false 
    "=true, if set port enabled and used as default value when reset";
  parameter Integer y_start = 0 
    "Initial and reset value of y if set port is not used";

  Modelica.Blocks.Interfaces.BooleanInput trigger;
  Modelica.Blocks.Interfaces.BooleanInput reset if use_reset;
  Modelica.Blocks.Interfaces.IntegerInput set if use_set;
protected 
  Modelica.Blocks.Interfaces.BooleanOutput local_reset;
  Modelica.Blocks.Interfaces.IntegerOutput local_set;
initial equation 
  pre(y) = y_start;
equation 
  if use_reset then
     connect(reset, local_reset);
       if use_set then
         connect(set, local_set);
       else
         local_set = y_start;
       end if;
  else
     local_reset = false;
     local_set = 0;
  end if;

  when {trigger, local_reset} then
     y = if local_reset then local_set else pre(y) + u;
  end when;
end TriggeredAdd;

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