Class MovingWindowProcessor
- java.lang.Object
-
- com.inductiveautomation.gateway.tags.history.processing.processors.AbstractEmittingProcessor
-
- com.inductiveautomation.gateway.tags.history.processing.processors.MovingWindowProcessor
-
- All Implemented Interfaces:
DataHandler
,DataProcessor
public class MovingWindowProcessor extends AbstractEmittingProcessor
This process has a certain window size. As values are put in, for each window, the Min/Max/Avg are emmitted. If a value is not provided for a window, the previous value is returned as the average. Cannot deal with backfill data - it is ignored.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
MovingWindowProcessor.MovingWindowProcessFactory
-
Constructor Summary
Constructors Constructor Description MovingWindowProcessor()
MovingWindowProcessor(int windowSizeMS)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected int
compare(RawTagValue a, RawTagValue b)
protected RawTagValue
compare(RawTagValue curVal, RawTagValue other, boolean min)
void
configure(int windowSizeMS, long windowAlignmentTime)
Sets the parameters of this processor.protected void
finishUpTo(long time)
void
flush()
Indicate that the handler won't get any more data, at least for a while.protected boolean
isAveragable(RawTagValue value)
protected void
processValue(RawTagValue value)
When this function is called, we know that we're in the current window.void
putValue(RawTagValue inValue)
Insert a value into the handler.protected void
updateAverage(RawTagValue newValue)
-
Methods inherited from class com.inductiveautomation.gateway.tags.history.processing.processors.AbstractEmittingProcessor
emitValue, takeProcessed
-
-
-
-
Method Detail
-
configure
public void configure(int windowSizeMS, long windowAlignmentTime)
Sets the parameters of this processor. Window size is the width of the window, and must be >0. WindowAlignment is a time that should be used as the first window, and aligned to for other values. That is, all values will have timestamps that are window size multiples away from this time. If <=0, the first value time will be used for the alignment.
-
putValue
public void putValue(RawTagValue inValue)
Description copied from interface:DataHandler
Insert a value into the handler.
-
flush
public void flush() throws java.lang.Exception
Description copied from interface:DataHandler
Indicate that the handler won't get any more data, at least for a while.- Throws:
java.lang.Exception
-
isAveragable
protected boolean isAveragable(RawTagValue value)
-
processValue
protected void processValue(RawTagValue value)
When this function is called, we know that we're in the current window. It evaluates min, max, and updates the running average.
-
compare
protected RawTagValue compare(RawTagValue curVal, RawTagValue other, boolean min)
-
compare
protected int compare(RawTagValue a, RawTagValue b)
-
updateAverage
protected void updateAverage(RawTagValue newValue)
-
finishUpTo
protected void finishUpTo(long time)
-
-