Pstep and PstepDur are both "sample and hold" patterns: One value from levels
is repeated until a duration from durs
elapses. Then, another value is chosen and repeated for the next duration.
Pstep measures elapsed time using the thread's logical time. That is, it assumes it will be evaluated only exactly when needed, not before.
PstepDur measures time based on the input event's delta. Provided that duration keys have already been set in the event, PstepDur may be polled in advance.
See PcollectFinal for an example of a lookahead filter pattern.
Create an instance of PstepDur.
levels |
The values (of any data type) to be sampled and held. |
durs |
The durations for which to hold items from |
repeats |
How many times to repeat, after running out of either |
tolerance |
How close is "close enough" (avoids problems with floating point rounding error in repeated sums). |