maxDuration function

Requirements.Internal.SlidingWindow.maxDuration  ยท source

Icon of maxDuration

Returns the maximum duration where buffer value is true in the sliding time window

Extends Modelica.Icons.Function

Returns the longest duration, within the sliding time window [t - T, t], of a phase in which the Boolean signal stored in the buffer was true. The buffer must hold the instants at which the signal changed, with alternating values (as stored by the duration checks with push); this is asserted.

The phases are evaluated from the newest to the oldest one: a running true phase (newest value true) counts from its start to t; every closed true phase from its start to its end, clipped to the window; and if the oldest value is false, the signal was true before it, from max(t0, t - T) on. An empty buffer means that the signal has not changed in the window: then the duration is min(T, t - t0) if the current value b is true, else 0. Phases are not merged, and every duration is at most T.

Used by ChecksInSlidingWindow.MinDuration, MaxDuration and BandDuration; tested by TestSlidingWindow.testMaxDuration. The sum of the durations instead of their maximum is accumulatedDuration.

Inputs

NameTypeDescription
buffer inputBufferMemory of sliding window
t inputSI.TimeActual time instant
b inputBooleanActual value at t (used if no element is in the buffer)

Outputs

NameTypeDescription
duration outputSI.TimeMaximum duration where buffer value is true in window