Package se.hendeby.sensordata
Class SensorDataReader
java.lang.Object
se.hendeby.sensordata.SensorDataReader
- Direct Known Subclasses:
FileSensorDataReader,StreamSensorDataReader
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 -
Method Summary
Modifier and TypeMethodDescriptionprotected voidfinalize()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 SensorDataExtract the next received SensorData object Extracts a SensorData object from the receiver queue.abstract voidreset()Reset the data stream/source.abstract voidstart()Start the collection of data.abstract booleanstatus()Acquire the status of the reader.abstract voidstop()Stop the collection of data.
-
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
SensorDataobject.
-
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
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
Stop the collection of data.- Throws:
IOException- If an I/O error is encountered and exception is thrown.
-
finalize
Destructor. Make sure all resources are released on destruction.
-