Class SlidingValue<T>
java.lang.Object
io.openems.edge.common.type.slidingvalue.SlidingValue<T>
- Type Parameters:
T
- the type of the Value
- Direct Known Subclasses:
AbstractNumberSlidingValue
,LatestSlidingValue
Calculates the 'Sliding Value' for a value.
Using the existing subclasses, this class can be used to
- calculate the average of several numeric values
- use the latest value for Enum and Boolean values
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionabstract void
Adds a value.com.google.gson.JsonElement
Gets the value as a JsonElement if it changed.Gets the sliding value, e.g.protected OpenemsType
getType()
Gets the OpenemsType of this SlidingValue.com.google.gson.JsonElement
getValue()
Gets the value as a JsonElement.protected abstract void
Resets the values.
-
Constructor Details
-
SlidingValue
-
-
Method Details
-
addValue
Adds a value.- Parameters:
value
- the value
-
getSlidingValue
Gets the sliding value, e.g. the average of all values.- Returns:
- the sliding value
-
resetValues
protected abstract void resetValues()Resets the values. -
getType
Gets the OpenemsType of this SlidingValue.- Returns:
- the OpenemsType
-
getChangedValueOrNull
public com.google.gson.JsonElement getChangedValueOrNull()Gets the value as a JsonElement if it changed. Resets the values.- Returns:
- the value; or null if it had not changed
-
getValue
public com.google.gson.JsonElement getValue()Gets the value as a JsonElement. Resets the values.- Returns:
- the value; null if is null
-