Class LastValueCache

java.lang.Object
org.yamcs.parameter.LastValueCache

public class LastValueCache extends Object
Cache for the last known value of each parameter.

Can also stored a number of n values for certain parameters (required by algorithms and match criterias)

it uses a readwrite lock to synchronize access from multiple threads.

  • Constructor Details

  • Method Details

    • getValue

      public ParameterValue getValue(Parameter param)
      Returns the latest known value for p or null if there is none.
      Parameters:
      param -
      Returns:
    • getValue

      public ParameterValue getValue(Parameter param, int n)
      return the n'th newest value or null if no such a value exist. n has to be smaller or equal with 0.

      If n=0 it is equivalent with getValue(Parameter)

      If n<0 but buffering is not enabled for the parameter or the buffer capacity is smaller than -n+1, an IllegalStateException will be thrown

      Throws:
      IllegalArgumentException - if n>0 or if n<0 and the parameter is constant
      IllegalStateException - if buffering is not enabled or the buffer capacity is smaller than -n+1
    • enableBuffering

      public void enableBuffering(Parameter param, int capacity)
      Configure the parameter cache to remember at least capacity values for the parameter.

      The size has to be at least 2 (because size 1 is by default)

      Throws:
      IllegalArgumentException - if the capacity is smaller than 2 or the parameter is a constant.
    • add

      public void add(ParameterValue pv)
      Adds a new value. If buffering is enabled, the value is added to the buffer, otherwise it replaces the old value (if any)
      Parameters:
      pv -
    • addAll

      public void addAll(Collection<ParameterValue> newValues)
      Add all parameters to the cache
      Parameters:
      newValues -
    • size

      public int size()
    • getValues

      public Collection<ParameterValue> getValues()
      returns all the values from the cache
      Returns: