SampleType
- type that is implemented by all samples that are passed to this
sample decimator and that is also implemented by the sample
generated by this sample decimator. Typically, this is the sample
type used by the control-system support that provides the concrete
implementation that inherits from this base class.public abstract class AbstractStatefulSampleDecimator<SampleType extends Sample> extends AbstractSampleDecimator<SampleType>
Abstract base class for sample decimator implementations, handling some of the state management. In addition to storing the channel name and the interval start time and length, this class takes care of handling some of the state when processing samples.
Each sample passed to this class's processSample(Sample)
method is
forwarded to the processSampleInternal(Sample, long, long)
method,
adding the start and end time of the interval for which this sample should be
used. Usually, the start time is the time also specified by the sample and
the end time is the time specified by the next sample. However, when
processing the first sample, the start time is the start time of the interval
that is covered by this decimator. Consequently, when processing the last
sample, the end time is the end time of the interval covered by this
decimator.
The buildDecimatedSample()
method forwards to the
buildDecimatedSampleInternal()
method because it has to make a last
call to processSampleInternal(Sample, long, long)
for the last
sample that has been received but not processed yet.
Constructor and Description |
---|
AbstractStatefulSampleDecimator(String channelName,
long intervalStartTime,
long intervalLength)
Creates the sample decimator and initializes the channel name and the
interval start-time and length with the specified values.
|
Modifier and Type | Method and Description |
---|---|
void |
buildDecimatedSample()
Builds the decimated sample.
|
protected abstract void |
buildDecimatedSampleInternal()
Builds the decimated sample.
|
void |
processSample(SampleType sample)
Processes a sample, updating the internal state with the information from
the sample.
|
protected abstract void |
processSampleInternal(SampleType sample,
long startTime,
long endTime)
Processes a sample, updating the decimators internal state.
|
getChannelName, getIntervalLength, getIntervalStartTime
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getDecimatedSample, getDecimatedSampleEstimatedSize
public AbstractStatefulSampleDecimator(String channelName, long intervalStartTime, long intervalLength)
channelName
- name identifying the channel covered by this sample decimator.intervalStartTime
- start time of the interval covered by this sample decimator.
The time is specified as the number of nanoseconds since epoch
(January 1st, 1970, 00:00:00 UTC).intervalLength
- length of the interval covered by this sample decimator. The
length is specified in nanoseconds.public final void buildDecimatedSample()
SampleDecimator
SampleDecimator.processSample(Sample)
has been called at least once. It must be
called before calling SampleDecimator.getDecimatedSample()
or
SampleDecimator.getDecimatedSampleEstimatedSize()
.
SampleDecimator.processSample(Sample)
must not be called again after calling
this method and this method must only be called once. This method may
throw an IllegalStateException
if the specified call order is
violated. However, there is no guarantee that such an exception is
thrown.public final void processSample(SampleType sample)
SampleDecimator
Processes a sample, updating the internal state with the information from
the sample. This method must be called for every sample that is is in the
interval specified by the start time and length (as returned by
SampleDecimator.getIntervalStartTime()
and SampleDecimator.getIntervalLength()
).
The first sample passed to this method must have a time stamp that is
less than or equal to the interval start-time. This method must be called
at least once before calling SampleDecimator.buildDecimatedSample()
. It must not
be called after calling SampleDecimator.buildDecimatedSample()
. This method may
throw an IllegalStateException
if the specified call order is
violated. However, there is no guarantee that such an exception is
thrown.
sample
- sample that shall be processed, updating the sample
decimator's internal state.protected abstract void buildDecimatedSampleInternal()
SampleDecimator.getDecimatedSample()
. This method is only called once and only
after all calls to processSampleInternal(Sample, long, long)
have been made.protected abstract void processSampleInternal(SampleType sample, long startTime, long endTime)
Processes a sample, updating the decimators internal state. This method has to be implemented by child classes in order to process source samples. The specified start time is the start of the interval for which the specified sample should be used (inclusive). The specified end time is the end of the interval for which the specified sample should be used (exclusive). Both times are specified as the number of nanoseconds since epoch (January 1st, 1970, 00:00:00 UTC).
Usually, the start time is the time also specified by the sample and the end time is the time specified by the next sample. However, when processing the first sample, the start time is the start time of the interval that is covered by this decimator. Consequently, when processing the last sample, the end time is the end time of the interval covered by this decimator.
sample
- sample that shall be processed.startTime
- start time of the interval for which the specified sample
shall be used.endTime
- end time of the interval for which the specified sample shall
be used.Copyright © 2011–2017 aquenos GmbH. All rights reserved.