Class SensorDataReader

java.lang.Object
se.hendeby.sensordata.SensorDataReader
Direct Known Subclasses:
FileSensorDataReader, StreamSensorDataReader

public abstract class SensorDataReader extends Object
Base class to extract SensorData from data streams. This class is intended as a base when implementing readers for SensorData objects, for example reading from network for file.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    Destructor.
    protected abstract double[]
    get(long maxDiff)
    Get a set of data with matching time stamp.
    double[][]
    getAll(long maxDiff)
    Get all available measurements.
    double[][]
    getNext(long maxDiff)
    Get the next available measurement.
    abstract SensorData
    Extract the next received SensorData object Extracts a SensorData object from the receiver queue.
    abstract void
    Reset the data stream/source.
    abstract void
    Start the collection of data.
    abstract boolean
    Acquire the status of the reader.
    abstract void
    Stop the collection of data.

    Methods inherited from class java.lang.Object

    clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • SensorDataReader

      public SensorDataReader()
  • Method Details

    • get

      protected abstract double[] get(long maxDiff)
      Get a set of data with matching time stamp. Reads the next available SensorData objects and return the measurements less than maxDiff milliseconds apart in a double vector, where the index in the vector is given by the SensorData's offset value.
      Parameters:
      maxDiff - Milliseconds between measurements to be considered from the same sample time.
      Returns:
      A double array containing the measurements from the next available timestamp
    • getAll

      public double[][] getAll(long maxDiff)
      Get all available measurements. Extract all available measurements, where maxDiff determines how far apart two measurements may be to be considered stemming from the same sample time.
      Parameters:
      maxDiff - Milliseconds between measurements to be considered from the same sample time.
      Returns:
      An array with with double arrays, where each element in the inner array is an double array as returned from getNext(long). This matches an matrix with as many rows as measurements im MATLAB.
    • getNext

      public double[][] getNext(long maxDiff)
      Get the next available measurement. Extract the next available measurements, where maxDiff determines how far apart two measurements may be to be considered stemming from the same sample time.
      Parameters:
      maxDiff - Milliseconds between measurements to be considered from the same sample time.
      Returns:
      An array with with double arrays, where each element in the outer array represents individual measurements (the first being the time) in milliseconds. The positions of the individual measurements are given by the offset field in the respective SensorData object.
    • getSensorData

      public abstract SensorData getSensorData()
      Extract the next received SensorData object Extracts a SensorData object from the receiver queue.
      Returns:
      A SensorData object of null if there is no more queued objects.
    • reset

      public abstract void reset()
      Reset the data stream/source. The meaning of this operation might differ between different sources.
    • start

      public abstract void start() throws IOException
      Start the collection of data.
      Throws:
      IOException - If an I/O error is encountered an exception is thrown.
    • status

      public abstract boolean status()
      Acquire the status of the reader.
      Returns:
      True is returned as long as the reader is expected to not fail on the next call.
    • stop

      public abstract void stop() throws IOException
      Stop the collection of data.
      Throws:
      IOException - If an I/O error is encountered and exception is thrown.
    • finalize

      protected void finalize() throws Throwable
      Destructor. Make sure all resources are released on destruction.
      Overrides:
      finalize in class Object
      Throws:
      Throwable