Buildings.Utilities.Plotters.BaseClasses

Package with base classes for Buildings.Utilities.Plotters

Information

This package contains base classes that are used to construct the models in Buildings.Utilities.Plotters.

Extends from Modelica.Icons.BasesPackage (Icon for packages containing base classes).

Package Content

Name Description
Buildings.Utilities.Plotters.BaseClasses.Backend Backend Backend implementation for the plotter
Buildings.Utilities.Plotters.BaseClasses.PartialPlotter PartialPlotter Partial block for plotters
Buildings.Utilities.Plotters.BaseClasses.sendReal sendReal Function that sends an array of Real values to be written to the html file
Buildings.Utilities.Plotters.BaseClasses.sendString sendString Function that prints a string to the html file
Buildings.Utilities.Plotters.BaseClasses.sendTerminalString sendTerminalString Function that prints the string to be added at the end of the html file

Buildings.Utilities.Plotters.BaseClasses.Backend

Backend implementation for the plotter

Information

Class derived from ExternalObject having two local external function definitions, named destructor and constructor respectively.

These functions create and release an external object that allows multiple plotters to write to the same html output file.

Extends from ExternalObject.

Modelica definition

class Backend "Backend implementation for the plotter" extends ExternalObject; function constructor "Construct the data structure that allows multiple plotters writing to the same html file" input String fileName "Name of html file to which this block prints"; input String instanceName "Name of the instance of this plotter"; input Integer nDbl "Number of double values in the array that is sent at each sampling time"; output Backend plt "Pointer to data structure for this plotter"; external "C" plt = plotInit(fileName, instanceName, nDbl); end constructor; function destructor "Release storage of plotter backend" input Backend plt; external "C" plotFree(plt); end destructor; end Backend;

Buildings.Utilities.Plotters.BaseClasses.PartialPlotter Buildings.Utilities.Plotters.BaseClasses.PartialPlotter

Partial block for plotters

Buildings.Utilities.Plotters.BaseClasses.PartialPlotter

Information

Partial block that implements the basic functionality used by the scatter and the time series plotters.

Extends from Modelica.Blocks.Icons.Block (Basic graphical layout of input/output block).

Parameters

TypeNameDefaultDescription
StringfileNameplotConfiguration.fileNameName of html file
Stringintroduction""Introduction text written below title and above the plot
Activation
TimesamplePeriodplotConfiguration.samplePeriodSample period of component [s]
LocalActivationactivationBuildings.Utilities.Plotters...Set to true to enable an input that allows activating and deactivating the plotting
TimeactivationDelayplotConfiguration.activation...Time that needs to elapse to enable plotting after activate becomes true [s]
Labels
StringtitlegetInstanceName()Title of the plot
Stringlegend[n] String array for legend, such as {"x1", "x2"}

Connectors

TypeNameDescription
input RealVectorInputy[n]y-data
input BooleanInputactivateSet to true to enable plotting of time series after activationDelay elapsed

Modelica definition

partial block PartialPlotter "Partial block for plotters" extends Modelica.Blocks.Icons.Block; outer Buildings.Utilities.Plotters.Configuration plotConfiguration "Default plot configuration"; parameter String fileName = plotConfiguration.fileName "Name of html file"; parameter Modelica.SIunits.Time samplePeriod(min=1E-3) = plotConfiguration.samplePeriod "Sample period of component"; parameter String title = getInstanceName() "Title of the plot"; parameter String introduction = "" "Introduction text written below title and above the plot"; parameter Integer n = 0 "Number of independent data series (dimension of y)"; parameter String[n] legend "String array for legend, such as {\"x1\", \"x2\"}"; parameter Buildings.Utilities.Plotters.Types.LocalActivation activation= Buildings.Utilities.Plotters.Types.LocalActivation.use_activation "Set to true to enable an input that allows activating and deactivating the plotting"; parameter Modelica.SIunits.Time activationDelay(min=0)=plotConfiguration.activationDelay "Time that needs to elapse to enable plotting after activate becomes true"; Modelica.Blocks.Interfaces.RealVectorInput y[n] "y-data"; Modelica.Blocks.Interfaces.BooleanInput activate if (activation == Buildings.Utilities.Plotters.Types.LocalActivation.use_input) "Set to true to enable plotting of time series after activationDelay elapsed"; Boolean active "Flag, true if plots record data"; protected parameter Modelica.SIunits.Time t0(fixed=false) "First sample time instant"; parameter String insNam = Modelica.Utilities.Strings.replace( getInstanceName(), ".", "_") "Name of this instance with periods replace by underscore"; parameter Boolean connectPoints= (activation == Buildings.Utilities.Plotters.Types.LocalActivation.always) or (activation == Buildings.Utilities.Plotters.Types.LocalActivation.use_activation and plotConfiguration.activation == Buildings.Utilities.Plotters.Types.GlobalActivation.always) "Flag, true if points should be connected in plots"; parameter String plotMode = "mode: '" + (if connectPoints then "lines+" else "") + "markers'," "Configuration to connect or disconnect the points"; Modelica.Blocks.Interfaces.BooleanInput activate_internal "Internal connector to activate plots"; discrete Modelica.SIunits.Time tActivateLast "Time when plotter was the last time activated"; output Boolean sampleTrigger "True, if sample time instant"; Buildings.Utilities.Plotters.BaseClasses.Backend plt= Buildings.Utilities.Plotters.BaseClasses.Backend( fileName=fileName, instanceName=insNam, nDbl=n+1) "Object that stores data for this plot"; initial equation t0 = time; Buildings.Utilities.Plotters.BaseClasses.sendString( plt=plt, string=" <h1>" + title + "</h1> " + (if (Modelica.Utilities.Strings.length(introduction) > 0) then "<p>" + introduction + "</p>" else "") + " <div id=\"" + insNam + "\"></div> <script> "); tActivateLast = time-2*activationDelay; equation if (activation == Buildings.Utilities.Plotters.Types.LocalActivation.use_input) then connect(activate, activate_internal); elseif (activation == Buildings.Utilities.Plotters.Types.LocalActivation.use_activation) then activate_internal = plotConfiguration.active; elseif (activation == Buildings.Utilities.Plotters.Types.LocalActivation.always) then activate_internal = true; end if; when (activate_internal) then tActivateLast = time; end when; active = activate_internal and time >= tActivateLast + activationDelay; // sample only if the plotter is active sampleTrigger = active and sample(t0, samplePeriod); end PartialPlotter;

Buildings.Utilities.Plotters.BaseClasses.sendReal Buildings.Utilities.Plotters.BaseClasses.sendReal

Function that sends an array of Real values to be written to the html file

Information

External function that prints the array of Real values x to the plot object. The number of elements in x is declared in the contructor Buildings.Utilities.Plotters.BaseClasses.Backend.

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

Inputs

TypeNameDefaultDescription
Backendplt Plot object
Realx[:] Array of Real values to be sent to printer

Modelica definition

function sendReal "Function that sends an array of Real values to be written to the html file" extends Modelica.Icons.Function; input Buildings.Utilities.Plotters.BaseClasses.Backend plt "Plot object"; input Real[:] x "Array of Real values to be sent to printer"; external "C" plotSendReal(plt, x); end sendReal;

Buildings.Utilities.Plotters.BaseClasses.sendString Buildings.Utilities.Plotters.BaseClasses.sendString

Function that prints a string to the html file

Information

External function that prints string to the plot object.

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

Inputs

TypeNameDefaultDescription
Backendplt Plot object
Stringstring String to be printed

Modelica definition

function sendString "Function that prints a string to the html file" extends Modelica.Icons.Function; input Buildings.Utilities.Plotters.BaseClasses.Backend plt "Plot object"; input String string "String to be printed"; external "C" plotSendString(plt, string); end sendString;

Buildings.Utilities.Plotters.BaseClasses.sendTerminalString Buildings.Utilities.Plotters.BaseClasses.sendTerminalString

Function that prints the string to be added at the end of the html file

Information

External function that prints string to the plot object. The string will be added at the end of the html file.

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

Inputs

TypeNameDefaultDescription
Backendplt Plot object
Stringstring String to be printed

Modelica definition

function sendTerminalString "Function that prints the string to be added at the end of the html file" extends Modelica.Icons.Function; input Buildings.Utilities.Plotters.BaseClasses.Backend plt "Plot object"; input String string "String to be printed"; external "C" plotSendTerminalString(plt, string); end sendTerminalString;