Class SampleBuffer
- java.lang.Object
-
- org.epics.archiverappliance.engine.model.SampleBuffer
-
public class SampleBuffer extends Object
Buffer for the samples of one channel.Assumes that one thread adds samples, while a different thread removes them. When the queue size is reached, older samples get dropped.
- Version:
- Initial version:CSS, 4-Jun-2012, Luofeng Li:added codes to support for the new archiver
- Author:
- Kay Kasemir
-
-
Constructor Summary
Constructors Constructor Description SampleBuffer(String channel_name, int capacity, ArchDBRTypes archdbrtype, PVMetrics pVMetrics)
Create sample buffer of given capacity
-
Method Summary
Modifier and Type Method Description boolean
add(DBRTimeEvent value)
Add a sample to the queue, maybe dropping older samplesvoid
addYearListener(YearListener yearListener)
add the year listener to this bufferint
getCapacity()
String
getChannelName()
ArrayListEventStream
getCombinedSamples()
get the combined ArrayListEventStream of the previous and the currentArrayListEventStream
getCurrentSamples()
get current ArrayListEventStreamArrayListEventStream
getPreviousSamples()
get the previous ArrayListEventStreamint
getQueueSize()
static boolean
isInErrorState()
void
resetSamples()
static void
setErrorState(boolean error)
Set the error state.String
toString()
-
-
-
Constructor Detail
-
SampleBuffer
public SampleBuffer(String channel_name, int capacity, ArchDBRTypes archdbrtype, PVMetrics pVMetrics)
Create sample buffer of given capacity- Parameters:
channel_name
-capacity
-archdbrtype
- ArchDBRTypespVMetrics
- PVMetrics
-
-
Method Detail
-
getChannelName
public String getChannelName()
- Returns:
- channel name of this buffer
-
getCurrentSamples
public ArrayListEventStream getCurrentSamples()
get current ArrayListEventStream- Returns:
- ArrayListEventStream
-
getCombinedSamples
public ArrayListEventStream getCombinedSamples()
get the combined ArrayListEventStream of the previous and the current- Returns:
- ArrayListEventStream
-
resetSamples
public void resetSamples()
-
getPreviousSamples
public ArrayListEventStream getPreviousSamples()
get the previous ArrayListEventStream- Returns:
- ArrayListEventStream
-
getCapacity
public int getCapacity()
- Returns:
- Queue capacity, i.e. maximum queue size.
-
getQueueSize
public int getQueueSize()
- Returns:
- Current queue size, i.e. number of samples in the queue.
-
isInErrorState
public static boolean isInErrorState()
- Returns:
true
if currently experiencing write errors
-
setErrorState
public static void setErrorState(boolean error)
Set the error state.- Parameters:
error
-
-
add
public boolean add(DBRTimeEvent value)
Add a sample to the queue, maybe dropping older samples- Parameters:
value
- DBRTimeEvent- Returns:
- boolean true if we need to increment the event count.
-
addYearListener
public void addYearListener(YearListener yearListener)
add the year listener to this buffer- Parameters:
yearListener
- the interface of yearListener
-
-