org.openuat.sensors
Class TimeSeriesBundle

java.lang.Object
  extended by org.openuat.sensors.TimeSeriesBundle
Direct Known Subclasses:
TimeSeriesAggregator, TimeSeriesAlignment

public abstract class TimeSeriesBundle
extends java.lang.Object

This class implements a collection of multiple time series that belong together, for example multiple dimensions from a single sensor. It keeps the time series of the first step, i.e. the pre-processing that does a linear transformation to [-1;1] and detects active/quiescent segments, internally. Using the getSinks() method, these internally managed TimeSeries objects can be registered with the samples source. After an active segment ends, this class emits the aggregated segment.

Version:
1.0
Author:
Rene Mayrhofer

Field Summary
protected  int curActiveSegmentLength
          Holds the number of sample in the current active segment or -1 if no line is active at the moment.
protected  double[] curSample
          This is just a buffer to keep the current sample dimension until all dimensions have been received and can thus be aggregated into a new value appended to aggregatedSeries.
protected  int[] curSample_Int
          And the integer version.
protected  int curSampleIndex
          Holds the index of the last complete sample that has been received.
protected  boolean[] curSampleReceived
          Used to mark the sample dimensions that have already been received.
protected  org.openuat.sensors.TimeSeriesBundle.TimeSeriesSinks firstStageHandlers
          Holds the TimeSeriesSink objects that are registered as sinks with the firstStageSeries objects.
protected  TimeSeries[] firstStageSeries
          These are the time series for the first stage.
protected  TimeSeries_Int[] firstStageSeries_Int
          And the integer version.
protected  int maxSegmentSize
          The maximum segment size to use, as passed to the constructor.
protected  int minSegmentSize
          The minimum segment size to use, as passed to the constructor.
protected  java.util.Vector samplesSinks
          Holds all registered sinks that should receive active, aggregated samples.
protected  java.util.Vector samplesSinks_Int
           
protected  java.util.Vector segmentsSinks
          Holds all registered sinks that should receive active, aggregated, completed segments.
protected  java.util.Vector segmentsSinks_Int
           
protected  int windowSize
          This window size as passed to the constructor.
 
Constructor Summary
protected TimeSeriesBundle(int numSeries, int windowSize, int minSegmentSize, int maxSegmentSize)
          Constructs all internal buffers and the time series.
 
Method Summary
 void addNextStageSamplesSink(SamplesSink_Int sink)
           
 void addNextStageSamplesSink(SamplesSink sink)
          Registers a sink which will receive all samples within active segments immediately after they have been aggregated into one dimension.
 void addNextStageSegmentsSink_Int(SegmentsSink_Int sink)
           
 void addNextStageSegmentsSink(SegmentsSink sink)
          Registers a sink which will receive all active segments when they are complete.
 void forceToQuiescent()
          This method forces the embedded time series to quiescent and thus the accumulated segment to be sent out.
 SamplesSink_Int[] getInitialSinks_Int()
          Returns the first stage sink objects that can be registered with the samples source.
 SamplesSink[] getInitialSinks()
          Returns the first stage sink objects that can be registered with the samples source.
 boolean removeNextStageSamplesSink(SamplesSink_Int sink)
           
 boolean removeNextStageSamplesSink(SamplesSink sink)
          Removes a previously registered sink.
 boolean removeNextStageSegmentsSink(SegmentsSink_Int sink)
           
 boolean removeNextStageSegmentsSink(SegmentsSink sink)
          Removes a previously registered sink.
 void reset()
          Resets the time series to the state as created when freshly constructing it.
protected abstract  void sampleAddedLine(int lineIndex, double sample, int numSample)
           
protected abstract  void sampleAddedLine(int lineIndex, int sample, int numSample)
           
 void setActiveVarianceThreshold(double activeVarianceThreshold)
          Sets the activeVarianceThreshold for all internally kept time series.
 void setActiveVarianceThreshold(int activeVarianceThreshold)
           
 void setMultiplicator(double multiplicator)
          Sets the multiplicator for all internally kept time series.
 void setMultiplicator(int multiplicator)
           
 void setOffset(double offset)
          Sets the offset for all internally kept time series.
 void setOffset(int offset)
           
 void setParameters(TimeSeries_Int.Parameters pars)
           
 void setParameters(TimeSeries.Parameters pars)
          Sets the parameters for all internally kept time series.
 void setSubtractTotalMean(boolean subtractTotalMean)
          Sets the subtractTotalMean for all internally kept time series.
 void setSubtractWindowMean(boolean subtractWindowMean)
          Sets the subtractWindowMean for all internally kept time series.
protected abstract  void toActiveFirstLine(int numSample)
           
protected abstract  void toQuiescentLastLine(int numSample)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

firstStageSeries

protected TimeSeries[] firstStageSeries
These are the time series for the first stage. The objects are responsible for an initial linear transform of the sample values to [-1;1] and for detecting active/quiescent segments within the single dimensions.


firstStageSeries_Int

protected TimeSeries_Int[] firstStageSeries_Int
And the integer version.


firstStageHandlers

protected org.openuat.sensors.TimeSeriesBundle.TimeSeriesSinks firstStageHandlers
Holds the TimeSeriesSink objects that are registered as sinks with the firstStageSeries objects.


curSample

protected double[] curSample
This is just a buffer to keep the current sample dimension until all dimensions have been received and can thus be aggregated into a new value appended to aggregatedSeries.


curSample_Int

protected int[] curSample_Int
And the integer version.


curSampleReceived

protected boolean[] curSampleReceived
Used to mark the sample dimensions that have already been received. It is managed solely by TimeSeries#addSample


curSampleIndex

protected int curSampleIndex
Holds the index of the last complete sample that has been received. This is the index received in the addSample method.


windowSize

protected int windowSize
This window size as passed to the constructor.

See Also:
#TimeSeriesAggregator(int, int, int, int)

minSegmentSize

protected int minSegmentSize
The minimum segment size to use, as passed to the constructor.

See Also:
#TimeSeriesAggregator(int, int, int, int)

maxSegmentSize

protected int maxSegmentSize
The maximum segment size to use, as passed to the constructor.

See Also:
#TimeSeriesAggregator(int, int, int, int)

segmentsSinks

protected java.util.Vector segmentsSinks
Holds all registered sinks that should receive active, aggregated, completed segments. Elements in this list are of type SegmentsSink.


segmentsSinks_Int

protected java.util.Vector segmentsSinks_Int

samplesSinks

protected java.util.Vector samplesSinks
Holds all registered sinks that should receive active, aggregated samples. Elements in this list are of type SamplesSink.


samplesSinks_Int

protected java.util.Vector samplesSinks_Int

curActiveSegmentLength

protected int curActiveSegmentLength
Holds the number of sample in the current active segment or -1 if no line is active at the moment.

Constructor Detail

TimeSeriesBundle

protected TimeSeriesBundle(int numSeries,
                           int windowSize,
                           int minSegmentSize,
                           int maxSegmentSize)
Constructs all internal buffers and the time series.

Parameters:
numSeries - The number of time series to use, i.e. the dimensionality of the input space.
windowSize - The time window size to use for detecting active/quiescent segments. This is specified as the number of samples in the window.
minSegmentSize - The minimum size of an active segment to be regarded significant enough to be sent to listeners.
maxSegmentSize - If set to something other than -1, specifies the maximum size of an active segments. If an active segment is longer than this number of samples, it will be sent to the listeners as soon as it reaches this length. The remainders of longer segments will be discarded. Set to -1 to disable this functionality, otherwise must be >=minSegmentSize.
Method Detail

reset

public void reset()
Resets the time series to the state as created when freshly constructing it.


getInitialSinks

public SamplesSink[] getInitialSinks()
Returns the first stage sink objects that can be registered with the samples source.

Returns:
The sink objects to be registered.

getInitialSinks_Int

public SamplesSink_Int[] getInitialSinks_Int()
Returns the first stage sink objects that can be registered with the samples source.

Returns:
The sink objects to be registered.

setOffset

public void setOffset(double offset)
Sets the offset for all internally kept time series.

See Also:
TimeSeries.setOffset(double)

setOffset

public void setOffset(int offset)

setMultiplicator

public void setMultiplicator(double multiplicator)
Sets the multiplicator for all internally kept time series.

See Also:
TimeSeries.setMultiplicator(double)

setMultiplicator

public void setMultiplicator(int multiplicator)

setSubtractWindowMean

public void setSubtractWindowMean(boolean subtractWindowMean)
Sets the subtractWindowMean for all internally kept time series.

See Also:
TimeSeries.setSubtractWindowMean(boolean)

setSubtractTotalMean

public void setSubtractTotalMean(boolean subtractTotalMean)
Sets the subtractTotalMean for all internally kept time series.

See Also:
TimeSeries.setSubtractTotalMean(boolean)

setActiveVarianceThreshold

public void setActiveVarianceThreshold(double activeVarianceThreshold)
Sets the activeVarianceThreshold for all internally kept time series.

See Also:
TimeSeries.setActiveVarianceThreshold(double)

setActiveVarianceThreshold

public void setActiveVarianceThreshold(int activeVarianceThreshold)

setParameters

public void setParameters(TimeSeries.Parameters pars)
Sets the parameters for all internally kept time series.

See Also:
TimeSeries.setParameters(org.openuat.sensors.TimeSeries.Parameters)

setParameters

public void setParameters(TimeSeries_Int.Parameters pars)

addNextStageSegmentsSink

public void addNextStageSegmentsSink(SegmentsSink sink)
Registers a sink which will receive all active segments when they are complete.

Parameters:
sink - The sink to push new aggregated segments to.

addNextStageSegmentsSink_Int

public void addNextStageSegmentsSink_Int(SegmentsSink_Int sink)

removeNextStageSegmentsSink

public boolean removeNextStageSegmentsSink(SegmentsSink sink)
Removes a previously registered sink.

Parameters:
sink - The sink to stop pushing segments to.
Returns:
true if removed, false if not (i.e. if it has not been added previously).

removeNextStageSegmentsSink

public boolean removeNextStageSegmentsSink(SegmentsSink_Int sink)

addNextStageSamplesSink

public void addNextStageSamplesSink(SamplesSink sink)
Registers a sink which will receive all samples within active segments immediately after they have been aggregated into one dimension.

Parameters:
sink - The sink to push new aggregated segments to.

addNextStageSamplesSink

public void addNextStageSamplesSink(SamplesSink_Int sink)

removeNextStageSamplesSink

public boolean removeNextStageSamplesSink(SamplesSink sink)
Removes a previously registered sink.

Parameters:
sink - The sink to stop pushing segments to.
Returns:
true if removed, false if not (i.e. if it has not been added previously).

removeNextStageSamplesSink

public boolean removeNextStageSamplesSink(SamplesSink_Int sink)

forceToQuiescent

public void forceToQuiescent()
This method forces the embedded time series to quiescent and thus the accumulated segment to be sent out. It should only be called when ending a simulation to make sure that the active segment gets forwarded when the accelerometer data didn't become "quiet" before ending the recording.


toActiveFirstLine

protected abstract void toActiveFirstLine(int numSample)

toQuiescentLastLine

protected abstract void toQuiescentLastLine(int numSample)

sampleAddedLine

protected abstract void sampleAddedLine(int lineIndex,
                                        double sample,
                                        int numSample)

sampleAddedLine

protected abstract void sampleAddedLine(int lineIndex,
                                        int sample,
                                        int numSample)


2005-2009, Rene Mayrhofer.