ecologylab.sensor.gps
Class GPS

java.lang.Object
  extended by ecologylab.generic.Debug
      extended by ecologylab.sensor.gps.GPS
All Implemented Interfaces:
gnu.io.SerialPortEventListener, java.util.EventListener
Direct Known Subclasses:
SimGPS

public class GPS
extends Debug
implements gnu.io.SerialPortEventListener

Buffers data from a GPS device for use in a Java application. Can produce instances of GPSData, which encapsulate the sensor data at some time. Uses GPSDeviceProfiles to handle multiple different types of GPS equipment, based on the type of data it produces.

Author:
Zachary O. Toups (toupsz@cs.tamu.edu)

Field Summary
protected  java.lang.StringBuilder incomingDataBuffer
           
 
Constructor Summary
protected GPS()
          No-argument, do-nothing constructor for simulator subclass that will not use a port.
  GPS(gnu.io.CommPortIdentifier portId, int baud)
           
  GPS(java.lang.String portName, int baud)
          Instantiate a GPS device on a given port and baud rate.
 
Method Summary
 void addGPSDataListener(GPSDataListener l)
           
 boolean connect()
          Connects to the GPS device based on the portName, baud, and device profile and activates the connection.
 boolean connected()
           
 void disconnect()
          Deactivates the current GPS device and closes out the port.
 int getBaudRate()
          Gets the baud rate of the port.
 java.lang.String getPortName()
           
protected  void handleIncomingChars()
           
 void removeGPSDataListener(GPSDataListener l)
           
 void serialEvent(gnu.io.SerialPortEvent event)
           
 
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
 

Field Detail

incomingDataBuffer

protected java.lang.StringBuilder incomingDataBuffer
Constructor Detail

GPS

public GPS(java.lang.String portName,
           int baud)
    throws gnu.io.NoSuchPortException,
           java.io.IOException
Instantiate a GPS device on a given port and baud rate.

Parameters:
devProfile -
portName -
baud -
Throws:
gnu.io.NoSuchPortException - the port does not exist on this system.
java.io.IOException - the specified port is a parallel port.

GPS

public GPS(gnu.io.CommPortIdentifier portId,
           int baud)
    throws gnu.io.NoSuchPortException,
           java.io.IOException
Throws:
gnu.io.NoSuchPortException
java.io.IOException

GPS

protected GPS()
No-argument, do-nothing constructor for simulator subclass that will not use a port.

Method Detail

connect

public boolean connect()
                throws gnu.io.PortInUseException,
                       gnu.io.UnsupportedCommOperationException,
                       java.io.IOException,
                       java.util.TooManyListenersException
Connects to the GPS device based on the portName, baud, and device profile and activates the connection.

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

connected

public boolean connected()

disconnect

public void disconnect()
Deactivates the current GPS device and closes out the port.


serialEvent

public void serialEvent(gnu.io.SerialPortEvent event)
Specified by:
serialEvent in interface gnu.io.SerialPortEventListener

handleIncomingChars

protected void handleIncomingChars()
Parameters:
bytesRead -
Throws:
java.nio.charset.CharacterCodingException

addGPSDataListener

public void addGPSDataListener(GPSDataListener l)

removeGPSDataListener

public void removeGPSDataListener(GPSDataListener l)

getPortName

public java.lang.String getPortName()

getBaudRate

public int getBaudRate()
Gets the baud rate of the port. If the port is not specified (not connected), then returns -1.

Returns:
an integer representing the baud rate of the current port or -1 if not connected.