Package microsim.statistics.functions
Class MovingAverageTraceFunction
java.lang.Object
microsim.statistics.functions.AbstractFunction
microsim.statistics.functions.MovingAverageTraceFunction
- All Implemented Interfaces:
EventListener,DoubleSource,UpdatableSource
This class computes the average of the last values collected from a data source. The number of values used to compute
the average value is specified in the constructor. The mean function return always double values, so it implements
only the
DoubleSource interface.-
Nested Class Summary
Nested classes/interfaces inherited from interface microsim.statistics.DoubleSource
DoubleSource.Variables -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected doubleprotected DoubleSourceprotected IntSourceprotected intprotected LongSourceprotected intprotected static final intprotected static final intprotected static final intprotected intprotected Enum<?>protected double[]Fields inherited from class microsim.statistics.functions.AbstractFunction
timeChecker -
Constructor Summary
ConstructorsConstructorDescriptionMovingAverageTraceFunction(@NonNull DoubleSource source, @NonNull Enum<?> valueID, int windowSize) Creates a basic statistic probe on aDoubleSourceobject.MovingAverageTraceFunction(@NonNull IntSource source, @NonNull Enum<?> valueID, int windowSize) Create a basic statistic probe on aIntSourceobject.MovingAverageTraceFunction(@NonNull LongSource source, @NonNull Enum<?> valueID, int windowSize) Creates a basic statistic probe on aLongSourceobject. -
Method Summary
Modifier and TypeMethodDescriptionvoidCollects a value from the source.doublegetDoubleValue(@NonNull Enum<?> valueID) Returns the result of a given statistic.voidUpdates the source, invoking theAbstractFunction.updateSource()method.Methods inherited from class microsim.statistics.functions.AbstractFunction
isCheckingTime, setCheckingTime, updateSource
-
Field Details
-
TYPE_DBL
protected static final int TYPE_DBL- See Also:
-
TYPE_INT
protected static final int TYPE_INT- See Also:
-
TYPE_LNG
protected static final int TYPE_LNG- See Also:
-
dblSource
-
intSource
-
lngSource
-
type
protected int type -
valueID
-
len
protected int len -
values
protected double[] values -
average
protected double average -
valueCount
protected int valueCount
-
-
Constructor Details
-
MovingAverageTraceFunction
public MovingAverageTraceFunction(@NonNull @NonNull DoubleSource source, @NonNull @NonNull Enum<?> valueID, int windowSize) Creates a basic statistic probe on aDoubleSourceobject.- Parameters:
source- TheDoubleSourceobject.valueID- The value identifier defined by source object.- Throws:
NullPointerException- when any of the input parameters isnull.IllegalArgumentException- whenwindowSizeis< 1.
-
MovingAverageTraceFunction
public MovingAverageTraceFunction(@NonNull @NonNull LongSource source, @NonNull @NonNull Enum<?> valueID, int windowSize) Creates a basic statistic probe on aLongSourceobject.- Parameters:
source- TheLongSourceobject.valueID- The value identifier defined by source object.- Throws:
NullPointerException- when any of the input parameters isnull.IllegalArgumentException- whenwindowSizeis< 1.
-
MovingAverageTraceFunction
public MovingAverageTraceFunction(@NonNull @NonNull IntSource source, @NonNull @NonNull Enum<?> valueID, int windowSize) Create a basic statistic probe on aIntSourceobject.- Parameters:
source- TheIntSourceobject.valueID- The value identifier defined by source object.- Throws:
NullPointerException- when any of the input parameters isnull.IllegalArgumentException- whenwindowSizeis< 1.
-
-
Method Details
-
applyFunction
public void applyFunction()Collects a value from the source.- Specified by:
applyFunctionin classAbstractFunction
-
getDoubleValue
Returns the result of a given statistic.- Specified by:
getDoubleValuein interfaceDoubleSource- Parameters:
valueID- One of theDoubleSource.Variablesconstants representing available statistics.- Returns:
- The computed value.
- Throws:
NullPointerException- when any of the input parameters isnull.
-
onEvent
Updates the source, invoking theAbstractFunction.updateSource()method.- Specified by:
onEventin interfaceEventListener- Overrides:
onEventin classAbstractFunction- Parameters:
type- Accepts only theCommonEventType.UPDATEvalue.- Throws:
NullPointerException- when any of the input parameters isnull.SimulationRuntimeException- whentypeis of not supporter type.
-