Package org.yamcs.parameter
Class LastValueCache
java.lang.Object
org.yamcs.parameter.LastValueCache
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 criteria)
it uses a readwrite lock to synchronize access from multiple threads.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(ParameterValue pv) Adds a new value.void
addAll
(Collection<ParameterValue> newValues) Add all parameters to the cachevoid
enableBuffering
(Parameter param, int capacity) Configure the parameter cache to remember at least capacity values for the parameter.Returns the latest known value for p or null if there is none.getValueFromEnd
(Parameter param, int n) return the n'th newest value or null if no such a value exist. n has to be greater or equal with 0.returns all the values from the cachereturns a list of parameter values for all the parameters having the persistence flag setint
size()
-
Constructor Details
-
LastValueCache
public LastValueCache() -
LastValueCache
-
-
Method Details
-
getValue
Returns the latest known value for p or null if there is none.- Parameters:
param
-- Returns:
-
getValueFromEnd
return the n'th newest value or null if no such a value exist. n has to be greater 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 constantIllegalStateException
- if buffering is not enabled or the buffer capacity is smaller than -n+1
-
enableBuffering
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
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
Add all parameters to the cache- Parameters:
newValues
-
-
size
public int size() -
getValues
returns all the values from the cache- Returns:
-
getValuesToBePersisted
returns a list of parameter values for all the parameters having the persistence flag setThe list may be empty if no parameter has the flag set
-