blockSortRuntime
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
| Type | Name | Default | Description |
|---|---|---|---|
| Integer | nin | 0 | Size of input array |
| Integer[:] | idxEquAlt | {i for i in 1:nin} | Indices of lead/lag alternate equipment |
| Integer | nEquAlt | size(idxEquAlt, 1) | Number of lead/lag alternate equipment |
| Real[nEquAlt] | runTim_start | fill(0, nEquAlt) | Staging runtime initial values |
Connectors
| Type | Name | Default | Description |
|---|---|---|---|
| Buildings.Controls.OBC.CDL.Interfaces.BooleanInput[nin] | u1Run | Boolean signal used to assess equipment runtime | |
| Buildings.Controls.OBC.CDL.Interfaces.BooleanInput[nin] | u1Ava | Equipment available signal | |
| Buildings.Controls.OBC.CDL.Interfaces.RealOutput[nEquAlt] | yRunTimLif | Lifetime runtime | |
| Buildings.Controls.OBC.CDL.Interfaces.RealOutput[nEquAlt] | yRunTimSta | Staging runtime | |
| Buildings.Controls.OBC.CDL.Interfaces.IntegerOutput[nEquAlt] | yIdx | Indices of equipment sorted by increasing staging runtime |
Components
| Type | Name | Default | Description |
|---|---|---|---|
| Buildings.Controls.OBC.CDL.Logical.TimerAccumulating[nEquAlt] | timRun | Compute staging runtime | |
| Buildings.Controls.OBC.CDL.Logical.Not[nEquAlt] | off | Return true if equipment off | |
| Buildings.Controls.OBC.CDL.Logical.Sources.Constant[nEquAlt] | u1Res | Signal for staging runtime reset | |
| Buildings.Controls.OBC.CDL.Reals.Sort | sor | Sort equipment by increasing weighted runtime | |
| Buildings.Controls.OBC.CDL.Conversions.BooleanToReal[nEquAlt] | weiOffAva | Weight to be applied to runtime of equipment off and available | |
| Buildings.Controls.OBC.CDL.Reals.Add[nEquAlt] | appWeiOffAva | Apply weights to runtime of equipment off and available | |
| Buildings.Controls.OBC.CDL.Reals.Multiply[nEquAlt] | clrRunUna | Clear runtime of unavailable equipment | |
| Buildings.Controls.OBC.CDL.Logical.And[nEquAlt] | offAva | Return true if equipment off and available | |
| Buildings.Controls.OBC.CDL.Logical.Not[nEquAlt] | una | Return true if equipment unavailable | |
| Buildings.Controls.OBC.CDL.Conversions.BooleanToReal[nEquAlt] | zerUna | Assign zero to unavailable equipment | |
| Buildings.Controls.OBC.CDL.Logical.Timer[nEquAlt] | timUna | Compute time elapsed since equipment is unavailable | |
| Buildings.Controls.OBC.CDL.Reals.AddParameter[nEquAlt] | addWei | Add weight | |
| Buildings.Controls.OBC.CDL.Reals.MultiplyByParameter[nEquAlt] | opp | Take opposite value | |
| Buildings.Controls.OBC.CDL.Reals.Add[nEquAlt] | addWeiUna | Add weight to unavailable equipment | |
| Buildings.Controls.OBC.CDL.Logical.TimerAccumulating[nEquAlt] | timRunLif | Compute lifetime runtime | |
| Buildings.Controls.OBC.CDL.Logical.Sources.Constant[nEquAlt] | fal | Constant | |
| Buildings.Controls.OBC.CDL.Routing.BooleanExtractSignal | u1RunEquAlt | Extract signal for lead/lag alternate equipment only | |
| Buildings.Controls.OBC.CDL.Routing.BooleanExtractSignal | u1AvaEquAlt | Extract signal for lead/lag alternate equipment only | |
| Buildings.Controls.OBC.CDL.Routing.IntegerExtractor[nEquAlt] | resIdxInp | Restore indices consistent with input vectors | |
| Buildings.Controls.OBC.CDL.Integers.Sources.Constant[nEquAlt,nEquAlt] | idxEquAltMat | Indices of lead/lag alternate equipment repeated nEquAlt times | |
| Buildings.Controls.OBC.CDL.Reals.Sources.Constant[nEquAlt] | runTimSta | Staging runtime initial values | |
| Buildings.Controls.OBC.CDL.Reals.Add[nEquAlt] | iniRunTim | Add runtime initial value | |
| Buildings.Controls.OBC.CDL.Reals.Add[nEquAlt] | iniRunTimLif | Add runtime initial value | |
| Buildings.Controls.OBC.CDL.Conversions.BooleanToReal[nEquAlt] | zerAva | Assign zero to available equipment | |
| Buildings.Controls.OBC.CDL.Reals.Multiply[nEquAlt] | clrRunAva | Clear 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.