Class WindowTimeRTIndicator
java.lang.Object
com.wualabs.qtsurfer.engine.indicators.core.AbstractRTIndicator
com.wualabs.qtsurfer.engine.indicators.core.AbstractIncrementalRTIndicator
com.wualabs.qtsurfer.engine.indicators.core.AbstractDecorableIncrementalRTIndicator
com.wualabs.qtsurfer.engine.indicators.helpers.OnChangeRTIndicator
com.wualabs.qtsurfer.engine.indicators.helpers.WindowTimeRTIndicator
- All Implemented Interfaces:
ClockAware, Resettable, RTIndicator
Time-based windowed indicator that batches updates over a configurable duration.
Updates are accumulated via the decorated indicator, but change notifications
are only fired when the elapsed time since the last window boundary exceeds
the configured window duration. Supports an optional delay mode where the
decorated indicator is only updated at window boundaries.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceImplemented by a listener that needs to know which window fired it.static enumNested classes/interfaces inherited from class OnChangeRTIndicator
OnChangeRTIndicator.OnChangeListener -
Constructor Summary
ConstructorsConstructorDescriptionWindowTimeRTIndicator(long windowTime) WindowTimeRTIndicator(long windowTime, RTIndicator indicator) WindowTimeRTIndicator(WindowTimeRTIndicator.WindowTime windowTime, RTIndicator indicator) WindowTimeRTIndicator(Duration windowTime, RTIndicator indicator) -
Method Summary
Modifier and TypeMethodDescriptionvoidBinds this window to a listener that asks for it, so the listener can read the boundaries above.The boundaries of the window being reported, read straight off this indicator during the notification — no state store involved.booleanvoidsetClockSupplier(Supplier<Clock> clockSupplier) voidsetDelayUpdates(boolean delayUpdates) voidsetEnableEvents(boolean enableEvents) voidtick()Advance internal clock the windowTime Useful for testsdoubleupdate(double newValue) Processes a new value with time-window gating.Methods inherited from class OnChangeRTIndicator
clearOnChangeListeners, getStateStore, hasListeners, nextValue, notifyOnChange, notifyOnChange, removeOnChangeListener, setStateStoreSupplier, toStringMethods inherited from class AbstractDecorableIncrementalRTIndicator
getIndicator, resetMethods inherited from class AbstractIncrementalRTIndicator
getLastUpdateValue, getPeriodCycles, getPeriods, getPrevValue, initValue, isPeriodic, isReady, prevNextValue, setPeriods, tickValueMethods inherited from class AbstractRTIndicator
equals, getDisplayHint, getMeta, getValue, hashCode, hide, isPoison, setValue, toString, withDisplayHint, withMeta
-
Constructor Details
-
WindowTimeRTIndicator
-
WindowTimeRTIndicator
-
WindowTimeRTIndicator
public WindowTimeRTIndicator(long windowTime) -
WindowTimeRTIndicator
-
WindowTimeRTIndicator
-
-
Method Details
-
getWindowTimeDuration
-
tick
public void tick()Advance internal clock the windowTime Useful for tests -
getPrevInstant
The boundaries of the window being reported, read straight off this indicator during the notification — no state store involved.- Returns:
- when the window that last closed had opened, or null before the first boundary
-
getCurrInstant
- Returns:
- when that window closed, which is also where the currently open one starts; null before the first update
-
addOnChangeListener
Binds this window to a listener that asks for it, so the listener can read the boundaries above.- Overrides:
addOnChangeListenerin classOnChangeRTIndicator- Parameters:
listener- the listener to register
-
setClockSupplier
- Specified by:
setClockSupplierin interfaceClockAware- Overrides:
setClockSupplierin classAbstractDecorableIncrementalRTIndicator
-
setDelayUpdates
public void setDelayUpdates(boolean delayUpdates) -
isEnableEvents
public boolean isEnableEvents()- Overrides:
isEnableEventsin classOnChangeRTIndicator
-
setEnableEvents
public void setEnableEvents(boolean enableEvents) - Overrides:
setEnableEventsin classOnChangeRTIndicator
-
update
public double update(double newValue) Processes a new value with time-window gating. On the first call, captures the initial timestamp and delegates to the parent. On subsequent calls, checks if the window duration has elapsed since the last boundary. If so, it advances the boundary — recording the closed window's instants on this indicator, where listeners read them — and fires the notification. If the window has not elapsed, the indicator retains its previous value (suppresses intermediate changes). In delay mode, the decorated indicator is only updated at window boundaries.- Specified by:
updatein interfaceRTIndicator- Overrides:
updatein classAbstractDecorableIncrementalRTIndicator- Parameters:
newValue- the new input value- Returns:
- the indicator value (updated only at window boundaries)
-