org.openuat.sensors
Class ParallelPortPWMReader

java.lang.Object
  extended by org.openuat.sensors.SamplesSource
      extended by org.openuat.sensors.AsciiLineReaderBase
          extended by org.openuat.sensors.ParallelPortPWMReader

public class ParallelPortPWMReader
extends AsciiLineReaderBase

This class implements a reader for the data format generated by the small Linux native code (a C command line program) to sample pulse-width modulated sensors (e.g. accelerometers) using a standard parallel port. Because the output format reports a new value whenever a change on the parallel port occurs, this class implements sampling with a defined sample rate to generate equidistant sample points.

Version:
1.0
Author:
Rene Mayrhofer

Field Summary
static int VALUE_RANGE
           
 
Fields inherited from class org.openuat.sensors.AsciiLineReaderBase
port, reader, reopenStreamFrom
 
Fields inherited from class org.openuat.sensors.SamplesSource
maxNumLines
 
Constructor Summary
ParallelPortPWMReader(java.io.InputStream stream, int samplerate)
          Initializes the parallel port PWM log reader.
ParallelPortPWMReader(java.lang.String filename, int samplerate)
          Initializes the parallel port PWM log reader.
 
Method Summary
 TimeSeries_Int.Parameters getParameters_Int()
          Instead of to [-1;1], these integer parameters map to [-1024;1024], i.e.
 TimeSeries.Parameters getParameters()
          Provides appropriate parameters for interpreting the values to normalize to the [-1;1] range.
static void main(java.lang.String[] args)
           
protected  void parseLine(java.lang.String line)
          A helper function to parse single line of the format produced by parport-pulsewidth.
 
Methods inherited from class org.openuat.sensors.AsciiLineReaderBase
dispose, handleSample
 
Methods inherited from class org.openuat.sensors.SamplesSource
addSink, addSink, addSink, emitSample, emitSample, getMaxNumLines, removeSink_Int, removeSink, removeSink, simulateSampling, start, stop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

VALUE_RANGE

public static final int VALUE_RANGE
See Also:
Constant Field Values
Constructor Detail

ParallelPortPWMReader

public ParallelPortPWMReader(java.lang.String filename,
                             int samplerate)
                      throws java.io.FileNotFoundException
Initializes the parallel port PWM log reader. It only saves the passed parameters and opens the InputStream to read from the specified file, and thus implicitly to check if the file exists and can be opened.

Parameters:
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.
samplerate - The sample rate in Hz.
Throws:
java.io.FileNotFoundException - When filename does not exist or can not be opened.

ParallelPortPWMReader

public ParallelPortPWMReader(java.io.InputStream stream,
                             int samplerate)
Initializes the parallel port PWM log reader. It only saves the passed parameters. This is an alternative to @see #ParallelPortPWMReader(String, int) and should only be used in special cases.

Parameters:
stream - Specifies the InputStream to read from.
samplerate - The sample rate in Hz.
Method Detail

parseLine

protected void parseLine(java.lang.String line)
A helper function to parse single line of the format produced by parport-pulsewidth. This method creates the samples and emits events.

Specified by:
parseLine in class AsciiLineReaderBase
Parameters:
line - The line to parse.

getParameters

public TimeSeries.Parameters getParameters()
Provides appropriate parameters for interpreting the values to normalize to the [-1;1] range.

Specified by:
getParameters in class SamplesSource

getParameters_Int

public TimeSeries_Int.Parameters getParameters_Int()
Instead of to [-1;1], these integer parameters map to [-1024;1024], i.e. MAXIMUM_RANGE in TimeSeries_Int.

Specified by:
getParameters_Int in class SamplesSource

main

public static void main(java.lang.String[] args)
                 throws java.io.IOException
Throws:
java.io.IOException


2005-2009, Rene Mayrhofer.