Class 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 Detail

      • SampleBuffer

        public SampleBuffer​(String channel_name,
                            int capacity,
                            ArchDBRTypes archdbrtype,
                            PVMetrics pVMetrics)
        Create sample buffer of given capacity
        Parameters:
        channel_name -  
        capacity -  
        archdbrtype - ArchDBRTypes
        pVMetrics - 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