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

public abstract class SlidingValue<T> extends Object
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 Details

    • SlidingValue

      protected SlidingValue(OpenemsType type)
  • Method Details

    • addValue

      public abstract void addValue(T value)
      Adds a value.
      Parameters:
      value - the value
    • getSlidingValue

      protected abstract Optional<T> 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

      protected OpenemsType 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