Buildings.Controls.OBC.CDL.Integers.Sources

Package with blocks that generate source signals

Information

Package with blocks that generate signals.

Package Content

Name Description
Buildings.Controls.OBC.CDL.Integers.Sources.Constant Constant Output constant signal of type Integer
Buildings.Controls.OBC.CDL.Integers.Sources.Pulse Pulse Generate pulse signal of type Integer
Buildings.Controls.OBC.CDL.Integers.Sources.TimeTable TimeTable Table look-up with respect to time with constant segments
Buildings.Controls.OBC.CDL.Integers.Sources.Validation Validation Collection of models that validate the logical sources blocks of the CDL

Buildings.Controls.OBC.CDL.Integers.Sources.Constant Buildings.Controls.OBC.CDL.Integers.Sources.Constant

Output constant signal of type Integer

Buildings.Controls.OBC.CDL.Integers.Sources.Constant

Information

Block that outputs a constant signal y = k, where k is an Integer-valued parameter.

IntegerConstant.png

Parameters

TypeNameDefaultDescription
Integerk Constant output value

Connectors

TypeNameDescription
output IntegerOutputyConnector of Integer output signal

Modelica definition

block Constant "Output constant signal of type Integer" parameter Integer k "Constant output value"; Interfaces.IntegerOutput y "Connector of Integer output signal"; equation y=k; end Constant;

Buildings.Controls.OBC.CDL.Integers.Sources.Pulse Buildings.Controls.OBC.CDL.Integers.Sources.Pulse

Generate pulse signal of type Integer

Buildings.Controls.OBC.CDL.Integers.Sources.Pulse

Information

Block that outputs a pulse signal as shown below.

Pulse.png

The pulse signal is generated an infinite number of times, and aligned with time=shift.

Parameters

TypeNameDefaultDescription
Integeramplitude1Amplitude of pulse
Realwidth0.5Width of pulse in fraction of period [1]
Realperiod Time for one period [s]
Realshift0Shift time for output [s]
Integeroffset0Offset of output signals

Connectors

TypeNameDescription
output IntegerOutputyConnector of Pulse output signal

Modelica definition

block Pulse "Generate pulse signal of type Integer" parameter Integer amplitude=1 "Amplitude of pulse"; parameter Real width( final min=Constants.small, final max=1, final unit="1")=0.5 "Width of pulse in fraction of period"; parameter Real period( final quantity="Time", final unit="s", final min=Constants.small) "Time for one period"; parameter Real shift( final quantity="Time", final unit="s")=0 "Shift time for output"; parameter Integer offset=0 "Offset of output signals"; Interfaces.IntegerOutput y "Connector of Pulse output signal"; protected Logical.Sources.Pulse booPul( final width=width, final period=period, final shift=shift) "Boolean pulse"; Conversions.BooleanToInteger booToInt( final integerTrue=offset+amplitude, final integerFalse=offset) "Boolean to integer conversion"; equation connect(booPul.y,booToInt.u); connect(booToInt.y,y); end Pulse;

Buildings.Controls.OBC.CDL.Integers.Sources.TimeTable Buildings.Controls.OBC.CDL.Integers.Sources.TimeTable

Table look-up with respect to time with constant segments

Buildings.Controls.OBC.CDL.Integers.Sources.TimeTable

Information

Block that outputs Integer time table values.

The block takes as a parameter a time table of a format:

table = [ 0*3600, 2;
          6*3600, 1;
         18*3600, 8];
period = 24*3600;

where the first column of table is time and the remaining column(s) are the table values. The time column contains Real values that are in units of seconds if timeScale = 1. The parameter timeScale can be used to scale the time values, for example, use timeScale = 3600 if the values in the first column are interpreted as hours.

The values in column two and higher must be of type Integer, otherwise the model stops with an error.

Until a new tabulated value is set, the previous tabulated value is returned.

The table scope is repeated periodically with periodicity period.

Parameters

TypeNameDefaultDescription
Realtable[:, :] Table matrix with time as a first table column (in seconds, unless timeScale is not 1) and Integers in all other columns
RealtimeScale1Time scale of first table column. Set to 3600 if time in table is in hours [1]
Realperiod Periodicity of table [s]

Connectors

TypeNameDescription
output IntegerOutputy[nout]Output of the table

Modelica definition

block TimeTable "Table look-up with respect to time with constant segments" parameter Real table[:,:] "Table matrix with time as a first table column (in seconds, unless timeScale is not 1) and Integers in all other columns"; parameter Real timeScale( final unit="1")=1 "Time scale of first table column. Set to 3600 if time in table is in hours"; parameter Real period( final quantity="Time", final unit="s", min=1E-6) "Periodicity of table"; Interfaces.IntegerOutput y[nout] "Output of the table"; protected final parameter Integer nout=size( table, 2)-1 "Dimension of output vector"; final parameter Integer nT=size( table, 1) "Number of time stamps"; parameter Real t0( final quantity="Time", final unit="s", fixed=false) "First sample time instant"; final parameter Real timeStamps[:]( each final quantity="Time", each final unit="s")=timeScale*table[1:end,1] "Time stamps"; final parameter Integer val[:,:]=integer( table[1:end,2:end]+ones( nT, nout)*Constants.small) "Table values as Integer"; Integer idx( fixed=false) "Index for table lookup"; function getIndex "Function to get the index for the table look-up" input Real t( final quantity="Time", final unit="s") "Current time"; input Real period( final quantity="Time", final unit="s") "Time period"; input Real x[:]( each final quantity="Time", each final unit="s") "Time stamps"; output Integer k "Index in table"; protected Real tS( final quantity="Time", final unit="s") "Time shifted so it is within the period"; algorithm tS := mod( t, period); k :=-1; for i in size( x, 1):-1:1 loop if tS >= x[i]-1E-6 then k := i; break; end if; end for; end getIndex; initial equation t0=Buildings.Utilities.Math.Functions.round( x=integer(time/period)*period, n=6); assert( nT > 0, "No table values defined."); // Check that all values in the second column are Integer values for i in 1:nT loop for j in 2:size( table, 2) loop assert( abs( table[i,j]-integer( table[i,j])) < Constants.small, "In "+getInstanceName()+": Table value table["+String(i)+", "+String(j)+"] = "+String( table[i,j])+" is not an Integer."); end for; end for; assert( abs( table[1,1]) < Constants.small, "In "+getInstanceName()+": First time stamp must be zero as otherwise no data is defined for the start of the table."); assert( period-table[1,end] > Constants.small, "In "+getInstanceName()+": Last time stamp in table must be smaller than period."); idx=getIndex( time, period, timeStamps); y[:]=val[idx,:]; equation when {sample(t0+timeStamps[i],period) for i in 1:nT} then idx=getIndex( time, period, timeStamps); y[:]=val[idx,:]; end when; end TimeTable;