ecologylab.sensor.gps
Class SimGPS

java.lang.Object
  extended by ecologylab.generic.Debug
      extended by ecologylab.sensor.gps.GPS
          extended by ecologylab.sensor.gps.SimGPS
All Implemented Interfaces:
gnu.io.SerialPortEventListener, java.awt.event.ActionListener, java.util.EventListener

public class SimGPS
extends GPS
implements java.awt.event.ActionListener

A simulated GPS that uses a text file containing NMEA sentences to drive a GPS-based application. Usage: Instantiate with a text file containing NMEA sentences. Like normal NMEA setences, each line should end with \r\n. Register one or more GPSDataListeners to listen to it. Call either start w/ the number of milliseconds between sends. -OR- Call sendSentence (to handle it interactively).

Author:
Zach

Nested Class Summary
static class SimGPS.PlayMode
           
 
Field Summary
 
Fields inherited from class ecologylab.sensor.gps.GPS
incomingDataBuffer
 
Constructor Summary
SimGPS(java.io.File nmeaSentenceTextFile, SimGPS.PlayMode mode)
           
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
           
 boolean connect()
          Calls start with a 250ms delay.
 boolean connected()
           
 void disconnect()
          Calls stop();
 void sendSentence()
          Sends the next sentence in the file.
 void start(int millisecondsBetweenSends)
           
 void stop()
           
 
Methods inherited from class ecologylab.sensor.gps.GPS
addGPSDataListener, getBaudRate, getPortName, handleIncomingChars, removeGPSDataListener, serialEvent
 
Methods inherited from class ecologylab.generic.Debug
classSimpleName, closeLoggingFile, debug, debug, debug, debug, debugA, debugA, debugA, debugI, debugI, debugI, error, error, getClassName, getClassName, getInteractive, getPackageName, getPackageName, getPackageName, initialize, level, level, level, logToFile, print, print, println, println, println, println, println, println, printlnA, printlnA, printlnA, printlnI, printlnI, printlnI, printlnI, setLoggingFile, show, show, superString, toggleInteractive, toString, toString, warning, warning, weird, weird
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SimGPS

public SimGPS(java.io.File nmeaSentenceTextFile,
              SimGPS.PlayMode mode)
       throws java.io.IOException
Parameters:
nmeaSentenceTextFile -
mode -
Throws:
java.io.IOException
Method Detail

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
Specified by:
actionPerformed in interface java.awt.event.ActionListener

start

public void start(int millisecondsBetweenSends)

stop

public void stop()

sendSentence

public void sendSentence()
Sends the next sentence in the file.


connect

public boolean connect()
                throws gnu.io.PortInUseException,
                       gnu.io.UnsupportedCommOperationException,
                       java.io.IOException,
                       java.util.TooManyListenersException
Calls start with a 250ms delay.

Overrides:
connect in class GPS
Returns:
true if connection was successful, false otherwise.
Throws:
gnu.io.PortInUseException
gnu.io.UnsupportedCommOperationException
java.io.IOException
java.util.TooManyListenersException

connected

public boolean connected()
Overrides:
connected in class GPS

disconnect

public void disconnect()
Calls stop();

Overrides:
disconnect in class GPS