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
Modifier and TypeFieldDescriptionprotected double
protected DoubleSource
protected IntSource
protected int
protected LongSource
protected int
protected static final int
protected static final int
protected static final int
protected int
protected Enum<?>
protected double[]
Fields inherited from class microsim.statistics.functions.AbstractFunction
timeChecker
-
Constructor Summary
ConstructorDescriptionMovingAverageTraceFunction
(@NonNull DoubleSource source, @NonNull Enum<?> valueID, int windowSize) Creates a basic statistic probe on aDoubleSource
object.MovingAverageTraceFunction
(@NonNull IntSource source, @NonNull Enum<?> valueID, int windowSize) Create a basic statistic probe on aIntSource
object.MovingAverageTraceFunction
(@NonNull LongSource source, @NonNull Enum<?> valueID, int windowSize) Creates a basic statistic probe on aLongSource
object. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Collects a value from the source.double
getDoubleValue
(@NonNull Enum<?> valueID) Returns the result of a given statistic.void
Updates 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 aDoubleSource
object.- Parameters:
source
- TheDoubleSource
object.valueID
- The value identifier defined by source object.- Throws:
NullPointerException
- when any of the input parameters isnull
.IllegalArgumentException
- whenwindowSize
is< 1
.
-
MovingAverageTraceFunction
public MovingAverageTraceFunction(@NonNull @NonNull LongSource source, @NonNull @NonNull Enum<?> valueID, int windowSize) Creates a basic statistic probe on aLongSource
object.- Parameters:
source
- TheLongSource
object.valueID
- The value identifier defined by source object.- Throws:
NullPointerException
- when any of the input parameters isnull
.IllegalArgumentException
- whenwindowSize
is< 1
.
-
MovingAverageTraceFunction
public MovingAverageTraceFunction(@NonNull @NonNull IntSource source, @NonNull @NonNull Enum<?> valueID, int windowSize) Create a basic statistic probe on aIntSource
object.- Parameters:
source
- TheIntSource
object.valueID
- The value identifier defined by source object.- Throws:
NullPointerException
- when any of the input parameters isnull
.IllegalArgumentException
- whenwindowSize
is< 1
.
-
-
Method Details
-
applyFunction
public void applyFunction()Collects a value from the source.- Specified by:
applyFunction
in classAbstractFunction
-
getDoubleValue
Returns the result of a given statistic.- Specified by:
getDoubleValue
in interfaceDoubleSource
- Parameters:
valueID
- One of theDoubleSource.Variables
constants 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:
onEvent
in interfaceEventListener
- Overrides:
onEvent
in classAbstractFunction
- Parameters:
type
- Accepts only theCommonEventType.UPDATE
value.- Throws:
NullPointerException
- when any of the input parameters isnull
.SimulationRuntimeException
- whentype
is of not supporter type.
-