Package trclib.dataprocessor
Class TrcDataBuffer
java.lang.Object
trclib.dataprocessor.TrcDataBuffer
This class implements a thread-safe data buffer for recording double values. It provides methods to access data
 in the buffer. It also provides methods to return minimum, maximum and average of the data in the buffer.
- 
Field SummaryFields
- 
Constructor SummaryConstructorsConstructorDescriptionTrcDataBuffer(String instanceName, int bufferSize) Constructor: Create an instance of the object.
- 
Method SummaryModifier and TypeMethodDescriptionvoidaddValue(double value) This method adds a value to the end of the buffer.voidclear()This method clears the buffer.doubleThis method calculates the average value in the buffer.Double[]This method returns an array of the buffered values.This method gets the last value in the buffer.This method returns the maximum value in the buffer.This method returns the minimum value in the buffer.getValue(int index) This method returns the indexed value in the buffer.toString()This method returns the instance name and the data in the buffer.
- 
Field Details- 
instanceName
- 
bufferSizeprivate final int bufferSize
- 
bufferedData
 
- 
- 
Constructor Details- 
TrcDataBufferConstructor: Create an instance of the object.- Parameters:
- instanceName- specifies the instance name.
- bufferSize- specifies the maximum buffer size, can be 0 if no maximum limit.
 
 
- 
- 
Method Details- 
toStringThis method returns the instance name and the data in the buffer.
- 
clearpublic void clear()This method clears the buffer.
- 
addValuepublic void addValue(double value) This method adds a value to the end of the buffer.- Parameters:
- value- specifies the value to be added to the buffer.
 
- 
getValueThis method returns the indexed value in the buffer.- Parameters:
- index- specifies the buffer index of the value to retrieve.
- Returns:
- indexed value.
 
- 
getLastValueThis method gets the last value in the buffer.- Returns:
- last value in the buffer, null if the buffer is empty.
 
- 
getBufferedDataThis method returns an array of the buffered values.- Returns:
- array of buffered data, null if buffer is empty.
 
- 
getMinimumValueThis method returns the minimum value in the buffer.- Returns:
- minimum value in the buffer, null if buffer is empty.
 
- 
getMaximumValueThis method returns the maximum value in the buffer.- Returns:
- maximum value in the buffer, null if buffer is empty.
 
- 
getAverageValuepublic double getAverageValue()This method calculates the average value in the buffer.- Returns:
- average value calculated.
 
 
-