jwo.landserf.process.gps
Class GPS

java.lang.Object
  extended byjwo.landserf.process.gps.GPS
Direct Known Subclasses:
GarminGPS

public abstract class GPS
extends Object

Abstract base class that represents the functionality of a generic GPS unit.

Version:
2.2, 10th July, 2004.
Author:
Jo Wood, based on the design by Henrik Sorensen (haas@itu.dk).

Field Summary
protected  Vector gpsListeners
          List of objects registered as listeners to this GPS.
protected  Vector routeListeners
          List of objects registered as listeners for route data from the GPS.
protected  Vector trackListeners
          List of objects registered as listeners for track data from the GPS.
protected  Vector transferListeners
          List of objects registered as listeners for data transfers from the GPS.
protected  Vector waypointListeners
          List of objects registered as listeners for waypoint data from the GPS.
 
Constructor Summary
protected GPS()
          Initialises the generic GPS object.
 
Method Summary
 void addGPSlistener(GPSListener gpsListener)
          Adds the specified GPSListener to those that will receive data from the GPS.
 void addRouteListener(GPSRouteListener routeListener)
          Adds the specified RouteListener to those that will receive data from the GPS.
 void addTrackListener(GPSTrackListener trackListener)
          Adds the specified TrackListener to those that will receive data from the GPS.
 void addWaypointListener(GPSWaypointListener waypointListener)
          Adds the specified WaypointListener to those that will receive data from the GPS.
protected  void fireDateData(GPSDate date)
          Notifies listeners of a new GPS date.
protected  void firePositionData(Position position)
          Notifies listeners of a new GPS position.
 void fireRouteData(GPSRoute route)
          Notifies listeners of the given route.
protected  void fireTimeData(GPSTime time)
          Notifies listeners of a new GPS time.
 void fireTrackData(GPSTrack track)
          Notifies listeners of the given track.
 void fireTransferComplete(int commandID)
          Notifies listeners of the end of a stream of data.
 void fireTransferStart(int numItems)
          Notifies listeners of the beginning of a stream of data.
 void fireWaypointData(GPSWaypoint waypoint)
          Notifies listeners of the given waypoint.
abstract  String getDescription()
          Should ask for a descriptive string from the GPS.
abstract  String getShortDescription()
          Should ask for a short descriptive string from the GPS.
 void removeGPSListener(GPSListener gpsListener)
          Removes the given GPS listener from the list of GPS listeners.
 void removeRouteListener(GPSRouteListener routeListener)
          Removes the given route listener from the list of route listeners.
 void removeTrackListener(GPSTrackListener trackListener)
          Removes the given track listener from the list of track listeners.
protected  void removeTransferListener(GPSTransferListener transferListener)
          Removes the given transfer listener from the list of transfer listeners.
 void removeWaypointListener(GPSWaypointListener waypointListener)
          Removes the given waypoint listener from the list of waypoint listeners.
abstract  void requestDate()
          Should ask for the date from the GPS.
abstract  void requestPosition()
          Should ask for the current position from the GPS.
abstract  void requestRoutes()
          Should ask the GPS to transmit all the routes in its memory.
abstract  void requestTime()
          Should ask for the time from the GPS.
abstract  void requestTracks()
          Should ask the GPS to transmit all the tracks in its memory.
abstract  void requestWaypoints()
          Should ask the GPS to transmit all the waypoints in its memory.
abstract  void sendWaypoints(Vector gpsWaypoints)
          Should send the given collection of GPSWaypoints to the GPS.
abstract  void setAutoTransmit(boolean transmit)
          Should ask the GPS to either start or stop transmitting data periodically.
abstract  void shutdown(boolean turnOff)
          Should stop communication with GPS.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

gpsListeners

protected Vector gpsListeners
List of objects registered as listeners to this GPS.


waypointListeners

protected Vector waypointListeners
List of objects registered as listeners for waypoint data from the GPS.


trackListeners

protected Vector trackListeners
List of objects registered as listeners for track data from the GPS.


routeListeners

protected Vector routeListeners
List of objects registered as listeners for route data from the GPS.


transferListeners

protected Vector transferListeners
List of objects registered as listeners for data transfers from the GPS. A listener can't be directly added to this list, but will instead be added when it registers for some other data that is being transmitted in transfer groups.

Constructor Detail

GPS

protected GPS()
Initialises the generic GPS object.

Method Detail

addGPSlistener

public void addGPSlistener(GPSListener gpsListener)
Adds the specified GPSListener to those that will receive data from the GPS.

Parameters:
gpsListener - Object receiving GPS information.

addWaypointListener

public void addWaypointListener(GPSWaypointListener waypointListener)
Adds the specified WaypointListener to those that will receive data from the GPS.

Parameters:
waypointListener - Object receiving GPS waypoint information.

addTrackListener

public void addTrackListener(GPSTrackListener trackListener)
Adds the specified TrackListener to those that will receive data from the GPS.

Parameters:
trackListener - Object receiving GPS track information.

addRouteListener

public void addRouteListener(GPSRouteListener routeListener)
Adds the specified RouteListener to those that will receive data from the GPS.

Parameters:
routeListener - Object receiving GPS route information.

removeWaypointListener

public void removeWaypointListener(GPSWaypointListener waypointListener)
Removes the given waypoint listener from the list of waypoint listeners.

Parameters:
waypointListener - Listener to remove.

removeTrackListener

public void removeTrackListener(GPSTrackListener trackListener)
Removes the given track listener from the list of track listeners.

Parameters:
trackListener - Listener to remove.

removeRouteListener

public void removeRouteListener(GPSRouteListener routeListener)
Removes the given route listener from the list of route listeners.

Parameters:
routeListener - Listener to remove.

removeGPSListener

public void removeGPSListener(GPSListener gpsListener)
Removes the given GPS listener from the list of GPS listeners.

Parameters:
gpsListener - Listener to remove.

removeTransferListener

protected void removeTransferListener(GPSTransferListener transferListener)
Removes the given transfer listener from the list of transfer listeners.

Parameters:
transferListener - Listener to remove.

fireTransferStart

public void fireTransferStart(int numItems)
Notifies listeners of the beginning of a stream of data. Tells listeners of the number of data units in the transfer.

Parameters:
numItems - Number of data units in the transfer.

fireWaypointData

public void fireWaypointData(GPSWaypoint waypoint)
Notifies listeners of the given waypoint.

Parameters:
waypoint - Waypoint passed to listeners

fireTrackData

public void fireTrackData(GPSTrack track)
Notifies listeners of the given track.

Parameters:
track - Track passed to listeners

fireRouteData

public void fireRouteData(GPSRoute route)
Notifies listeners of the given route.

Parameters:
route - Route passed to listeners

fireTransferComplete

public void fireTransferComplete(int commandID)
Notifies listeners of the end of a stream of data.

Parameters:
commandID - ID of command that has been completed.

firePositionData

protected void firePositionData(Position position)
Notifies listeners of a new GPS position.

Parameters:
position - Point location passed to listeners

fireDateData

protected void fireDateData(GPSDate date)
Notifies listeners of a new GPS date.

Parameters:
date - GPS date passed to listeners

fireTimeData

protected void fireTimeData(GPSTime time)
Notifies listeners of a new GPS time.

Parameters:
time - GPS time passed to listeners

requestPosition

public abstract void requestPosition()
Should ask for the current position from the GPS. Data should be returned to all listeners through the GPSlistener interface.


requestTime

public abstract void requestTime()
Should ask for the time from the GPS. Data should be returned to all listeners through the GPSlistener interface.


requestDate

public abstract void requestDate()
Should ask for the date from the GPS. Data should be returned to all listeners through the GPSListener interface.


getDescription

public abstract String getDescription()
Should ask for a descriptive string from the GPS. Should be formatted for human reading. The string should be constructed by every GPS implementation upon startup.

Returns:
Description of the GPS unit. For example, vendor, make, software version.

getShortDescription

public abstract String getShortDescription()
Should ask for a short descriptive string from the GPS. Should be formatted for human reading. The string should be constructed by every GPS implementation upon startup.

Returns:
Short description of the GPS unit. For example, vendor and make.

requestWaypoints

public abstract void requestWaypoints()
Should ask the GPS to transmit all the waypoints in its memory. The result should be returned through the GPSWaypointListener interface.

Throws:
FeatureNotSupportException - if it isn't possible to do this on the GPS.

requestTracks

public abstract void requestTracks()
Should ask the GPS to transmit all the tracks in its memory. The result should be returned through the GPSTrackListener interface.

Throws:
FeatureNotSupportException - if it isn't possible to do this on the GPS.

requestRoutes

public abstract void requestRoutes()
Should ask the GPS to transmit all the routes in its memory. The result should be returned through the GPSRouteListener and GPSWaypoint interfaces.


sendWaypoints

public abstract void sendWaypoints(Vector gpsWaypoints)
Should send the given collection of GPSWaypoints to the GPS.

Parameters:
gpsWaypoints - Collection of waypoints. Each item in the collection should be a GPSWaypoint object.

setAutoTransmit

public abstract void setAutoTransmit(boolean transmit)
Should ask the GPS to either start or stop transmitting data periodically. The data should be the that which is accessible through the GPSListener interface.

Parameters:
transmit - Start transmitting if true, otherwise stop transmitting.
Throws:
FeatureNotSupportedException - if it isn't possible to do this on the GPS.

shutdown

public abstract void shutdown(boolean turnOff)
Should stop communication with GPS. This method should be called before quitting any application. If turnOff is true, will attempt to turn off the GPS unit remotely.

Parameters:
turnOff - Turn of GPS unit if true, otherwise just stop listening.
Throws:
FeatureNotSupportedException - if turnOff is true, but the GPS unit doesn't support remote shutdown.


Copyright Jo Wood, 1996-2005, last modified, 11th March, 2005