Buildings.Obsolete.Controls.OBC.CDL.Discrete

Package with obsolete discrete blocks

Information

Package that contains obsolete models for discrete controls.

Package Content

Name Description
Buildings.Obsolete.Controls.OBC.CDL.Discrete.DayType DayType Block that outputs a signal that indicates week-day or week-end
Buildings.Obsolete.Controls.OBC.CDL.Discrete.MovingMean MovingMean Discrete moving mean of a sampled input signal
Buildings.Obsolete.Controls.OBC.CDL.Discrete.Examples Examples Collection of models that illustrate model use and test models

Buildings.Obsolete.Controls.OBC.CDL.Discrete.DayType Buildings.Obsolete.Controls.OBC.CDL.Discrete.DayType

Block that outputs a signal that indicates week-day or week-end

Buildings.Obsolete.Controls.OBC.CDL.Discrete.DayType

Information

This block outputs a signal that indicates the type of the day. It can for example be used to generate a signal that indicates whether the current time is a work day or a non-working day. The output signal is of type Buildings.Obsolete.Controls.OBC.CDL.Types.Day.

The parameter nout determines how many days should be sent to the output. For applications in which only the current day is of interest, set nout=1. For applications in which the load is predicted for the next 24 hours, set nout=2 in order to output the type of day for today and for tomorrow.

The transition from one day type to another always happens when the simulation time is a multiple of 1 day. Hence, if the simulation starts for example at t=-3600 seconds, then the first transition to another day will be at t=0.

Parameters

TypeNameDefaultDescription
Integernout2Number of days to output. Set to two for one day predictions
Daydays[:]{Buildings.Obsolete.Controls...Array where each element is a day indicator
IntegeriStart1Index of element in days at simulation start

Connectors

TypeNameDescription
output DayTypeOutputy[nout]Type of the day for the current and the next (nout-1) days

Modelica definition

model DayType "Block that outputs a signal that indicates week-day or week-end" parameter Integer nout(final min=1)=2 "Number of days to output. Set to two for one day predictions"; parameter Buildings.Obsolete.Controls.OBC.CDL.Types.Day[:] days={Buildings.Obsolete.Controls.OBC.CDL.Types.Day.WorkingDay,Buildings.Obsolete.Controls.OBC.CDL.Types.Day.WorkingDay,Buildings.Obsolete.Controls.OBC.CDL.Types.Day.WorkingDay,Buildings.Obsolete.Controls.OBC.CDL.Types.Day.WorkingDay,Buildings.Obsolete.Controls.OBC.CDL.Types.Day.WorkingDay,Buildings.Obsolete.Controls.OBC.CDL.Types.Day.NonWorkingDay,Buildings.Obsolete.Controls.OBC.CDL.Types.Day.NonWorkingDay} "Array where each element is a day indicator"; parameter Integer iStart( min=1, max=size( days, 1))=1 "Index of element in days at simulation start"; Obsolete.Controls.OBC.CDL.Interfaces.DayTypeOutput y[nout] "Type of the day for the current and the next (nout-1) days"; protected parameter Real samplePeriod( final quantity="Time", final unit="s")=86400 "Sample period of component"; output Integer iDay( min=1, max=size( days, 1)) "Pointer to days that determines what day type is sent to the output"; parameter Real firstSample( final quantity="Time", final unit="s", fixed=false) "Time when the sampling starts"; output Boolean sampleTrigger "True, if sample time instant"; output Boolean skipIDayIncrement "If true, don't increment iDay in first sample"; initial equation iDay=iStart; firstSample=ceil( time/86400)*86400; // skipIDayIncrement is true if the simulation starts at midnight. skipIDayIncrement=abs( firstSample-time) < 1E-8; equation for i in 1:nout loop y[i]=days[mod( iDay+i-2, size( days, 1))+1]; end for; sampleTrigger=sample( firstSample, samplePeriod); when sampleTrigger then skipIDayIncrement=false; if pre(skipIDayIncrement) then iDay=pre(iDay); else iDay=mod( pre(iDay), size( days, 1))+1; end if; end when; end DayType;

Buildings.Obsolete.Controls.OBC.CDL.Discrete.MovingMean Buildings.Obsolete.Controls.OBC.CDL.Discrete.MovingMean

Discrete moving mean of a sampled input signal

Buildings.Obsolete.Controls.OBC.CDL.Discrete.MovingMean

Information

Block that outputs the sampled moving mean value of an input signal. At each sampling instant, the block outputs the average value of the past n samples including the current sample.

At the first sample, the block outputs the first sampled input. At the next sample, it outputs the average of the past two samples, then the past three samples and so on up to n samples.

Extends from Modelica.Icons.ObsoleteModel (Icon for classes that are obsolete and will be removed in later versions).

Parameters

TypeNameDefaultDescription
Integern Number of samples over which the input is averaged
TimesamplePeriod Sampling period of component [s]

Connectors

TypeNameDescription
input RealInputuContinuous input signal
output RealOutputyDiscrete averaged signal

Modelica definition

block MovingMean "Discrete moving mean of a sampled input signal" extends Modelica.Icons.ObsoleteModel; parameter Integer n(min=2) "Number of samples over which the input is averaged"; parameter Modelica.Units.SI.Time samplePeriod(min=1E-3) "Sampling period of component"; Buildings.Controls.OBC.CDL.Interfaces.RealInput u "Continuous input signal"; Buildings.Controls.OBC.CDL.Interfaces.RealOutput y "Discrete averaged signal"; protected parameter Modelica.Units.SI.Time t0(fixed=false) "First sample time instant"; Boolean sampleTrigger "Trigger samples at each sampling instant"; Integer iSample(start=0, fixed=true) "Sample numbering in the simulation"; Integer counter(start=0, fixed=true) "Number of samples used for averaging calculation"; Integer index(start=0, fixed=true) "Index of the vector ySample"; discrete Real ySample[n]( start=vector(zeros(n,1)), each fixed=true) "Vector of samples to be averaged"; initial equation t0 = time; y = u; equation sampleTrigger = sample(t0, samplePeriod); algorithm when sampleTrigger then index := mod(iSample, n) + 1; ySample[index] := u; counter := if counter == n then n else counter + 1; y := sum(ySample)/counter; iSample := iSample + 1; end when; end MovingMean;