maslab.data
Class DataSource

java.lang.Object
  extended by maslab.data.DataSource
Direct Known Subclasses:
CarOdometryDataSource, DifferentialOdometryDataSource, IntegratedOdometryDataSource

public abstract class DataSource
extends java.lang.Object

A data source publishes data to listeners. The data can either be generated internally (e.g., by a sensor of some type), or from a DataLog. This interface is designed to support both modes. A particular DataSource implementation should have a particular DataEvent implementation as well. E.g., LaserScannerSource should have a LaserScannerData helper class. The class must also support serialization of any one-time configuration information. This information (e.g., where is the laser scanner located) can be used to modify the raw data. The log file should always contain RAW data, and all necessary transform information should be stored in the configuration parameters.


Constructor Summary
DataSource(java.lang.String channelName)
           
 
Method Summary
 void addDataListener(DataListener l)
           
static java.lang.String[] fsplit(java.lang.String s, int maxtoks)
           
 java.lang.String getChannelName()
           
abstract  java.lang.String getParameters()
          Retrieve a (preferrably human readable) string of parameters for this source.
 void notifyLogWriters(double timestamp, java.lang.String data)
          Call this method whenever the source gets new data.
static double parseDouble(java.lang.String s)
           
 SimpleProperties parseProperties(java.lang.String data)
          A helper function, useful for many DataEvent implementations.
 void removeDataListener(DataListener l)
           
abstract  void setParameters(java.lang.String params)
          Set parameters, as read from a configuration file.
abstract  DataEvent stringToEvent(double timestamp, java.lang.String data)
          Called by DataLogReader when a DataEvent record is encountered for this data source.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DataSource

public DataSource(java.lang.String channelName)
Method Detail

addDataListener

public void addDataListener(DataListener l)

removeDataListener

public void removeDataListener(DataListener l)

notifyLogWriters

public void notifyLogWriters(double timestamp,
                             java.lang.String data)
Call this method whenever the source gets new data.


stringToEvent

public abstract DataEvent stringToEvent(double timestamp,
                                        java.lang.String data)
Called by DataLogReader when a DataEvent record is encountered for this data source. The DataSource should instantiate a DataEvent object but should NOT notify the DataListeners.


getParameters

public abstract java.lang.String getParameters()
Retrieve a (preferrably human readable) string of parameters for this source. For example, a laser scanner DataSource might return information about where the laser scanner is mounted. The string may contain any character except newline, but human-readable formats are preferred.


setParameters

public abstract void setParameters(java.lang.String params)
Set parameters, as read from a configuration file.


getChannelName

public java.lang.String getChannelName()

parseProperties

public SimpleProperties parseProperties(java.lang.String data)
A helper function, useful for many DataEvent implementations. static final double[] readDoubleArray(BufferedReader ins) throws IOException { String l; l=ins.readLine(); if (l==null) return null; String toks[]=l.split("\\s+"); double[] ds=new double[toks.length]; for (int i=0;i

fsplit

public static final java.lang.String[] fsplit(java.lang.String s,
                                              int maxtoks)

parseDouble

public static final double parseDouble(java.lang.String s)