Name | Description |
---|---|
Examples | Collection of models that illustrate model use and test models |
Printer | Model that prints values to a file |
printRealArray | Print string to terminal or file |
This model prints to a file or the terminal at a fixed sample interval.
The parameter configuration controls the printing as follows:
configuration | configuration |
1 | print at sample times only |
2 | print at sample times and at end of simulation |
3 | print at end of simulation only |
Type | Name | Default | Description |
---|---|---|---|
Time | samplePeriod | Sample period of component [s] | |
Time | startTime | 0 | First sample time instant [s] |
String | header | "" | Header to be printed |
String | fileName | "" | File name (empty string is the terminal) |
Integer | nin | 1 | Number of inputs |
Integer | configuration | 1 | Index for treating final report (see documentation) |
Integer | minimumWidth | 1 | Minimum width of result |
Integer | precision | 16 | Number of significant digits |
Type | Name | Description |
---|---|---|
input RealInput | x[nin] | Value to be printed |
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 minimumWidth = 1 "Minimum width of result"; parameter Integer precision = 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, minimumWidth=minimumWidth, precision=precision); end when; end if; when terminal() then if configuration >= 2 then Buildings.Utilities.Reports.printRealArray( x=x, fileName=fileName, minimumWidth=minimumWidth, precision=precision); end if; end when; end Printer;
Function that prints a real array to an output file.
Extends from Modelica.Icons.Function (Icon for a function).
Type | Name | Default | Description |
---|---|---|---|
Real | x[:] | Input to be printed | |
String | fileName | "" | File where to print (empty string is the terminal) |
Integer | minimumWidth | 1 | Minimum width of result |
Integer | precision | 6 | Number of significant digits |
Type | Name | Description |
---|---|---|
String | outStr | String to be printed |
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 minimumWidth = 1 "Minimum width of result"; input Integer precision = 6 "Number of significant digits"; output String outStr="" "String to be printed"; algorithm for i in 1:size(x,1) loop outStr :=outStr + " " + realString(number=x[i], minimumWidth=minimumWidth, precision=precision); end for; Modelica.Utilities.Streams.print(string=outStr, fileName=fileName); end printRealArray;