LBL logo

Buildings.Utilities.Reports

Library with models that facilitates the reporting of values

Information

This package contains components models to report values to files.

Extends from Modelica.Icons.VariantsPackage (Icon for package containing variants).

Package Content

NameDescription
Buildings.Utilities.Reports.Printer Printer Model that prints values to a file
Buildings.Utilities.Reports.printRealArray printRealArray Print string to terminal or file
Buildings.Utilities.Reports.Examples Examples Collection of models that illustrate model use and test models


Buildings.Utilities.Reports.Printer Buildings.Utilities.Reports.Printer

Model that prints values to a file

Buildings.Utilities.Reports.Printer

Information

This model prints to a file or the terminal at a fixed sample interval.

The parameter configuration controls the printing as follows:

configurationconfiguration
1 print at sample times only
2 print at sample times and at end of simulation
3 print at end of simulation only

Extends from Modelica.Blocks.Interfaces.DiscreteBlock (Base class of discrete control blocks).

Parameters

TypeNameDefaultDescription
TimesamplePeriod Sample period of component [s]
TimestartTime0First sample time instant [s]
Stringheader""Header to be printed
StringfileName""File name (empty string is the terminal)
Integernin1Number of inputs
Integerconfiguration1Index for treating final report (see documentation)
IntegerminimumLength1Minimum length of result string
IntegersignificantDigits16Number of significant digits

Connectors

TypeNameDescription
input RealInputx[nin]Value to be printed

Modelica definition

model Printer "Model that prints values to a file"
  extends Modelica.Blocks.Interfaces.DiscreteBlock;

  parameter String header="" "Header to be printed";
  parameter String fileName="" "File name (empty string is the terminal)";
  parameter Integer nin=1 "Number of inputs";
  parameter Integer configuration = 1 
    "Index for treating final report (see documentation)";
  parameter Integer minimumLength =  1 "Minimum length of result string";
  parameter Integer significantDigits = 16 "Number of significant digits";
  Modelica.Blocks.Interfaces.RealInput x[nin] "Value to be printed";

initial algorithm 
  if (fileName <> "") then
    Modelica.Utilities.Files.removeFile(fileName);
  end if;
  Modelica.Utilities.Streams.print(fileName=fileName, string=header);
equation 
  if configuration < 3 then
  when {sampleTrigger, initial()} then
      Buildings.Utilities.Reports.printRealArray(
                                      x=x, fileName=fileName,
                                      minimumLength=minimumLength,
                                      significantDigits=significantDigits);
  end when;
  end if;
  when terminal() then
    if configuration >= 2 then
       Buildings.Utilities.Reports.printRealArray(
                                      x=x, fileName=fileName,
                                      minimumLength=minimumLength,
                                      significantDigits=significantDigits);
   end if;
  end when;
end Printer;

Buildings.Utilities.Reports.printRealArray Buildings.Utilities.Reports.printRealArray

Print string to terminal or file

Information

Function that prints a real array to an output file.

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

Inputs

TypeNameDefaultDescription
Realx[:] Input to be printed
StringfileName""File where to print (empty string is the terminal)
IntegerminimumLength1Minimum width of result
IntegersignificantDigits6Number of significant digits

Outputs

TypeNameDescription
StringoutStrString to be printed

Modelica definition

function printRealArray "Print string to terminal or file"
  extends Modelica.Icons.Function;
  input Real[:] x "Input to be printed";
  input String fileName="" "File where to print (empty string is the terminal)";
  input Integer minimumLength =  1 "Minimum width of result";
  input Integer significantDigits = 6 "Number of significant digits";
  output String outStr="" "String to be printed";
algorithm 
  for i in 1:size(x,1) loop
     outStr :=outStr + "  "
                     + String(x[i],
                              minimumLength=minimumLength,
                              significantDigits=significantDigits);
  end for;
  Modelica.Utilities.Streams.print(string=outStr, fileName=fileName);
end printRealArray;

Automatically generated Tue Jan 8 08:32:40 2013.