Class 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.
      value - the value
    • getSlidingValue

      protected abstract Optional<T> getSlidingValue()
      Gets the sliding value, e.g. the average of all values.
      the sliding value
    • resetValues

      protected abstract void resetValues()
      Resets the values.
    • getType

      protected OpenemsType getType()
      Gets the OpenemsType of this SlidingValue.
      the OpenemsType
    • getChangedValueOrNull

      public getChangedValueOrNull()
      Gets the value as a JsonElement if it changed. Resets the values.
      the value; or null if it had not changed
    • getValue

      public getValue()
      Gets the value as a JsonElement. Resets the values.
      the value; null if is null