SampleType
- type that is implemented by all samples that are generated by the
control-system support to which this listener got passed.public interface SampleListener<SampleType extends Sample>
Modifier and Type | Method and Description |
---|---|
void |
onSampleReceived(ControlSystemChannel channel,
SampleType sample,
int estimatedSampleSize)
Notifies the listener that a new sample is available.
|
void onSampleReceived(ControlSystemChannel channel, SampleType sample, int estimatedSampleSize)
Notifies the listener that a new sample is available. This method is called by the control-system support for the associated channel when it detects that the value of the channel has changed in the control-system and the new value is archived.
In general, it is expected that samples are received with incrementing time stamps. However, the archiving code will silently discard samples that skip back in time, so the control-system support does not have to check time stamps explicitly.
The channel
that is passed to this method must be the exact
instance that was returned from the call to
ControlSystemSupport.createChannel(String, java.util.Map, SampleBucketId, SampleListener)
to which this sample listener got passed. This is important because the
archiving code tests the channel
for object identity in
order to ensure that it does not accidentally process samples for
control-system channel instances that have been destroyed.
After queuing the sample and processing it internally, the archiving code
will eventually call
ControlSystemSupport.writeSample(Sample, SampleBucketId, int)
in
order to write the sample to the database.
The code calling this method can expect that it will not block and will return quickly.
channel
- channel instance that received the specified
sample
.sample
- sample that was received.estimatedSampleSize
- estimated size of the sample when serialized into the database
(in bytes). This information is used by the archiving code to
keep track of the total size of the samples that are stored
inside a bucket. As storing too much (or too little) data in a
single bucket has an impact on performance, the archiving code
will decide to start a new bucket when a certain size has been
reached. Therefore, this estimate should be as accurate as
possible.Copyright © 2011–2017 aquenos GmbH. All rights reserved.