|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.openuat.sensors.SamplesSource
public abstract class SamplesSource
This is a base class for emitting samples to a list of registers SamplesSink objects. It imlements handling the listeners and the background thread for doing the sampling.
| Field Summary | |
|---|---|
protected int |
maxNumLines
The maximum number of data lines to read from the device - depends on the sensor. |
| Constructor Summary | |
|---|---|
protected |
SamplesSource(int maxNumLines,
int sleepBetweenReads)
Initializes the reader base object. |
| Method Summary | |
|---|---|
void |
addSink(int[] lines,
SamplesSink_Int[] intSinks)
Registers a sink, which will receive all new values as they are sampled. |
void |
addSink(int[] lines,
SamplesSink[] doubleSinks)
Registers a sink, which will receive all new values as they are sampled. |
void |
dispose()
This causes the reader to be shut down properly by calling stop(). |
protected void |
emitSample(double[] sample)
This method should be called by the parseLine method to send samples to all registered listeners. |
protected void |
emitSample(int[] sample)
This method should be called by the parseLine method to send samples to all registered listeners. |
int |
getMaxNumLines()
Returns the maximum number of lines that can be sampled. |
abstract TimeSeries_Int.Parameters |
getParameters_Int()
|
abstract TimeSeries.Parameters |
getParameters()
Each time samples source must be able to provide the appropriate parameters for normalizing its values to the [-1;1] range. |
protected abstract boolean |
handleSample()
This method is called whenever a sample should be read from the respective source, and it should in turn call emitSample to send the new sample to all registered listeners. |
boolean |
removeSink_Int(int[] lines,
SamplesSink_Int[] intSinks)
Removes a previously registered sink. |
boolean |
removeSink(int[] lines,
SamplesSink[] doubleSinks)
Removes a previously registered sink. |
void |
simulateSampling()
Simulate sampling by reading all available lines from the spcified file. |
void |
start()
Starts a new background thread to read from the file and create sample values as the lines are read. |
void |
stop()
Stops the background thread, if started previously. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected int maxNumLines
| Constructor Detail |
|---|
protected SamplesSource(int maxNumLines,
int sleepBetweenReads)
#port needs to
be initialized separately before starting and sampling.
filename - The log to read from. This may either be a normal log file
when simulation is intended or it can be a FIFO/pipe to read
online data.maxNumLines - The maximum number of data lines to read from the device -
depends on the sensor.sleepBetweenReads - The number of milliseconds to sleep between two
reads from filename. Set to 0 to do blocking reads
(i.e. as fast as the file can give something back).| Method Detail |
|---|
public void addSink(int[] lines,
SamplesSink[] doubleSinks)
throws java.lang.IllegalArgumentException
doubleSinks - The time series to fill. This array must have the same number of
elements as the number of lines specified to the constructor.lines - The set of lines on the device to read. Must be an integer
array with a minimum length of 1 and a maximum length specified to
the constructor, containing the indices of the lines to read. These
indices are counted from 0 to maxNumLines-1. E.g. for a parallel
port (see ParallelPortPWMReader), this corresponds to data lines
DATA0 to DATA7. E.g. for a 3D accelerometer (see WiTiltRawReader),
this corresponds to 0=X, 1=Y, 2=Z.
java.lang.IllegalArgumentException
public void addSink(int[] lines,
SamplesSink_Int[] intSinks)
throws java.lang.IllegalArgumentException
intSinks - The time series to fill. This array must have the same number of
elements as the number of lines specified to the constructor.lines - The set of lines on the device to read. Must be an integer
array with a minimum length of 1 and a maximum length specified to
the constructor, containing the indices of the lines to read. These
indices are counted from 0 to maxNumLines-1. E.g. for a parallel
port (see ParallelPortPWMReader), this corresponds to data lines
DATA0 to DATA7. E.g. for a 3D accelerometer (see WiTiltRawReader),
this corresponds to 0=X, 1=Y, 2=Z.
java.lang.IllegalArgumentException
public boolean removeSink(int[] lines,
SamplesSink[] doubleSinks)
doubleSinks - The time series to stop filling.lines - The set of lines with which this sink has been registered.
addSink(int[], SamplesSink[])
public boolean removeSink_Int(int[] lines,
SamplesSink_Int[] intSinks)
intSinks - The time series to stop filling.lines - The set of lines with which this sink has been registered.
addSink(int[], SamplesSink[])public void start()
public void stop()
public void dispose()
public int getMaxNumLines()
public void simulateSampling()
protected void emitSample(double[] sample)
sample - The current sample.protected void emitSample(int[] sample)
sample - The current sample.protected abstract boolean handleSample()
public abstract TimeSeries.Parameters getParameters()
public abstract TimeSeries_Int.Parameters getParameters_Int()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||