blockSortRuntime

Sort equipment by increasing staging runtime

Information

This block implements the rotation logic for identical parallel staged equipment that are lead/lag alternated.

Two runtime points are defined for each equipment. The Lifetime Runtime is the cumulative runtime of the equipment since equipment start-up. This point is not readily resettable by operators. Lifetime Runtime should be stored to a software point on the control system server so the recorded value is not lost due to controller reset, loss of power, programming file update, etc. The Staging Runtime is an operator resettable runtime point that stores cumulative runtime since the last operator reset.

In the case of available equipment, when more than one equipment is off or more than one is on, the equipment with the most operating hours as determined by Staging Runtime is made the last stage equipment and the one with the least number of hours is made the lead stage equipment.

In the case of unavailable equipment, the equipment that alarmed most recently is sent to the last position. The equipment in alarm automatically moves up in the staging order only if another equipment goes into alarm.

Details

The sorting logic is implemented using the following method.

  • If a unit is on and available, its staging runtime is used as is.
  • If a unit is off and available, its staging runtime is increased by 1E10 s.
  • If a unit is unavailable, its staging runtime is replaced by 1E20 s minus the time elapsed since it became unavailable.
  • A unique instance of the sorting block is then used to order the different units.

This is effectively the same as sorting the units within the three following subsets: units that are on and available, units that are off and available, units that are unavailable. In particular, the order index of a given unit remains unchanged if it is the only element of a given subset. Note that the staging runtime and the time elapsed since an equipment became unavailable are both computed from Boolean signals (u1Run and u1Ava). These are discrete-time, piecewise constant variables, which is why the caveat in the documentation of Buildings.Controls.OBC.CDL.Reals.Sort for purely continuous time-varying variables does not apply here. Therefore, no sampling is performed before sorting the equipment runtimes.

To facilitate integration into the plant controller, the input vectors cover the full set of equipment, including equipment that may not be lead/lag alternate. The output vectors cover only the subset of lead/lag alternate equipment, and the vector of sorted equipment provides indices with respect to the input vectors (full set of equipment).

Parameters

TypeNameDefaultDescription
Integernin0Size of input array
Integer[:]idxEquAlt{i for i in 1:nin}Indices of lead/lag alternate equipment
IntegernEquAltsize(idxEquAlt, 1)Number of lead/lag alternate equipment
Real[nEquAlt]runTim_startfill(0, nEquAlt)Staging runtime initial values

Connectors

TypeNameDefaultDescription
Buildings.Controls.OBC.CDL.Interfaces.BooleanInput[nin]u1RunBoolean signal used to assess equipment runtime
Buildings.Controls.OBC.CDL.Interfaces.BooleanInput[nin]u1AvaEquipment available signal
Buildings.Controls.OBC.CDL.Interfaces.RealOutput[nEquAlt]yRunTimLifLifetime runtime
Buildings.Controls.OBC.CDL.Interfaces.RealOutput[nEquAlt]yRunTimStaStaging runtime
Buildings.Controls.OBC.CDL.Interfaces.IntegerOutput[nEquAlt]yIdxIndices of equipment sorted by increasing staging runtime

Components

TypeNameDefaultDescription
Buildings.Controls.OBC.CDL.Logical.TimerAccumulating[nEquAlt]timRunCompute staging runtime
Buildings.Controls.OBC.CDL.Logical.Not[nEquAlt]offReturn true if equipment off
Buildings.Controls.OBC.CDL.Logical.Sources.Constant[nEquAlt]u1ResSignal for staging runtime reset
Buildings.Controls.OBC.CDL.Reals.SortsorSort equipment by increasing weighted runtime
Buildings.Controls.OBC.CDL.Conversions.BooleanToReal[nEquAlt]weiOffAvaWeight to be applied to runtime of equipment off and available
Buildings.Controls.OBC.CDL.Reals.Add[nEquAlt]appWeiOffAvaApply weights to runtime of equipment off and available
Buildings.Controls.OBC.CDL.Reals.Multiply[nEquAlt]clrRunUnaClear runtime of unavailable equipment
Buildings.Controls.OBC.CDL.Logical.And[nEquAlt]offAvaReturn true if equipment off and available
Buildings.Controls.OBC.CDL.Logical.Not[nEquAlt]unaReturn true if equipment unavailable
Buildings.Controls.OBC.CDL.Conversions.BooleanToReal[nEquAlt]zerUnaAssign zero to unavailable equipment
Buildings.Controls.OBC.CDL.Logical.Timer[nEquAlt]timUnaCompute time elapsed since equipment is unavailable
Buildings.Controls.OBC.CDL.Reals.AddParameter[nEquAlt]addWeiAdd weight
Buildings.Controls.OBC.CDL.Reals.MultiplyByParameter[nEquAlt]oppTake opposite value
Buildings.Controls.OBC.CDL.Reals.Add[nEquAlt]addWeiUnaAdd weight to unavailable equipment
Buildings.Controls.OBC.CDL.Logical.TimerAccumulating[nEquAlt]timRunLifCompute lifetime runtime
Buildings.Controls.OBC.CDL.Logical.Sources.Constant[nEquAlt]falConstant
Buildings.Controls.OBC.CDL.Routing.BooleanExtractSignalu1RunEquAltExtract signal for lead/lag alternate equipment only
Buildings.Controls.OBC.CDL.Routing.BooleanExtractSignalu1AvaEquAltExtract signal for lead/lag alternate equipment only
Buildings.Controls.OBC.CDL.Routing.IntegerExtractor[nEquAlt]resIdxInpRestore indices consistent with input vectors
Buildings.Controls.OBC.CDL.Integers.Sources.Constant[nEquAlt,nEquAlt]idxEquAltMatIndices of lead/lag alternate equipment repeated nEquAlt times
Buildings.Controls.OBC.CDL.Reals.Sources.Constant[nEquAlt]runTimStaStaging runtime initial values
Buildings.Controls.OBC.CDL.Reals.Add[nEquAlt]iniRunTimAdd runtime initial value
Buildings.Controls.OBC.CDL.Reals.Add[nEquAlt]iniRunTimLifAdd runtime initial value
Buildings.Controls.OBC.CDL.Conversions.BooleanToReal[nEquAlt]zerAvaAssign zero to available equipment
Buildings.Controls.OBC.CDL.Reals.Multiply[nEquAlt]clrRunAvaClear runtime of available equipment

Revisions

  • June 10, 2026, by Antoine Gautier:
    Corrected runtime weighting for unavailable units. Updated handling and default value of runtime initialization.
    This is for #4624.
  • March 29, 2024, by Antoine Gautier:
    First implementation.