SlidingWindow package
Requirements.Internal.SlidingWindow
ยท source
Ring buffer of the Boolean value changes in a sliding time window, and the functions operating on it (used by ChecksInSlidingWindow)
Extends Modelica.Icons.Package
Implementation of the sliding time windows of
ChecksInSlidingWindow. A Boolean signal is
represented by the instants at which it changed, stored in a ring buffer, the record
Buffer, together with the window length
T. The functions create the buffer (init),
store a change (push), remove the elements that
left the window (removeOldest,
nextLeaving), read elements
(firstValue,
lastValue,
indexValue,
indexTime,
numberOfValues) and evaluate the window
(maxDuration,
accumulatedDuration).
The size of the buffer is fixed by the constant nBuffer = 20: at most 20 changes (or rising edges)
can be held in one window. If more occur, push prints a warning and the result of the check may not
be correct (as stated in the documentation of the Requirements package). The functions are tested by
TestSlidingWindow.
Contents
| Name | Kind | Description | |
|---|---|---|---|
| Buffer | record | Memory of sliding window | |
| init | function | Initialize a sliding window buffer | |
| push | impure function | Store an element on the sliding window buffer and remove elements that are older as the window length | |
| removeOldest | function | Remove all elements from the buffer that are about to leave the sliding time window | |
| nextLeaving | function | Return time instant when the oldest element is leaving the buffer | |
| firstValue | function | Returns the newest value | |
| lastValue | function | Returns the oldest value | |
| indexValue | function | Returns the value at buffer index | |
| indexTime | function | Returns the time value at buffer index | |
| numberOfValues | function | Returns the number of values in the buffer | |
| maxDuration | function | Returns the maximum duration where buffer value is true in the sliding time window | |
| accumulatedDuration | function | Returns the accumulated duration where buffer value is true in the sliding time window |
Parameters
| Name | Type | Description |
|---|---|---|
nBuffer constant | Integer | Length of buffer |