jwo.landserf.process.gps.garmin
Class GarminGPS

java.lang.Object
  extended byjwo.landserf.process.gps.GPS
      extended byjwo.landserf.process.gps.garmin.GarminGPS
All Implemented Interfaces:
Runnable

public class GarminGPS
extends GPS
implements Runnable

Handles the link with a Garmin GPS unit (e.g. etrex, Geko, StreetPilot).

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

Field Summary
protected  boolean active
           
protected  StringBuffer description
           
protected  Vector garminListeners
           
protected  StringBuffer shortDescription
           
 
Fields inherited from class jwo.landserf.process.gps.GPS
gpsListeners, routeListeners, trackListeners, transferListeners, waypointListeners
 
Constructor Summary
GarminGPS(BufferedInputStream i, BufferedOutputStream o)
          Creates a link with a Garmin GPS.
 
Method Summary
 void addGarminListener(GarminListener listener)
          Adds the given GarminListener to receive all packets sent from the GPS.
protected  void distribute(GarminPacket packet)
          Identifies the type of packet received, and distributes it to the correct listeners.
protected  void fireGarminPacket(GarminPacket packet)
          Transmits the given packet to all registered GarminListeners
 String getDescription()
          Returns a description of the Garmin GPS indicating the software version and the protocols supported.
 String getShortDescription()
          Returns a short description of the Garmin GPS indicating the make and software version used.
 void removeGarminListener(GarminListener listener)
          Removes the specified GarminListener from the list of listeners.
 void requestDate()
          Makes a request for the date from the GPS.
 void requestPosition()
          Makes a request for the position to be sent from the GPS.
 void requestRoutes()
          Asks the GPS to transmit all the routes in its memory.
 void requestTime()
          Makes a request for the time from the GPS.
 void requestTracks()
          Asks the GPS to transmit all the tracks in its memory.
 void requestWaypoints()
          Asks the GPS to transmit all the waypoints in its memory.
 void run()
          Starts listening for input from the GPS as a threaded process.
 void sendWaypoints(Vector gpsWaypoints)
          Sends the given collection of GPSWaypoints to the GPS.
 void setAutoTransmit(boolean transmit)
          Asks the GPS to either start or stop transmitting data periodically.
 void shutdown(boolean turnOff)
          Stops communication with GPS.
 
Methods inherited from class jwo.landserf.process.gps.GPS
addGPSlistener, addRouteListener, addTrackListener, addWaypointListener, fireDateData, firePositionData, fireRouteData, fireTimeData, fireTrackData, fireTransferComplete, fireTransferStart, fireWaypointData, removeGPSListener, removeRouteListener, removeTrackListener, removeTransferListener, removeWaypointListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

description

protected StringBuffer description

shortDescription

protected StringBuffer shortDescription

active

protected boolean active

garminListeners

protected Vector garminListeners
Constructor Detail

GarminGPS

public GarminGPS(BufferedInputStream i,
                 BufferedOutputStream o)
Creates a link with a Garmin GPS. Can listen to and send packets to the GPS connected via the given input and output streams.

Parameters:
i - Input stream connecting to GPS.
o - Output stream connecting to GPS.
Method Detail

addGarminListener

public void addGarminListener(GarminListener listener)
Adds the given GarminListener to receive all packets sent from the GPS.

Parameters:
listener - Listener to add to those that will be broadcast.

removeGarminListener

public void removeGarminListener(GarminListener listener)
Removes the specified GarminListener from the list of listeners.

Parameters:
listener - Listener to remove.

fireGarminPacket

protected void fireGarminPacket(GarminPacket packet)
Transmits the given packet to all registered GarminListeners

Parameters:
packet - Packet to transmit.

run

public void run()
Starts listening for input from the GPS as a threaded process.

Specified by:
run in interface Runnable

distribute

protected void distribute(GarminPacket packet)
Identifies the type of packet received, and distributes it to the correct listeners.

Parameters:
packet - Packet recieved.

requestPosition

public void requestPosition()
Makes a request for the position to be sent from the GPS. Data will be returned to all listeners through the GPSListener interface.

Specified by:
requestPosition in class GPS

requestTime

public void requestTime()
Makes a request for the time from the GPS. Data should be returned to all listeners through the GPSListener interface.

Specified by:
requestTime in class GPS

requestDate

public void requestDate()
Makes a request for the date from the GPS. Data should be returned to all listeners through the GPSListener interface.

Specified by:
requestDate in class GPS

requestWaypoints

public void requestWaypoints()
Asks the GPS to transmit all the waypoints in its memory. The result will be returned through the GPSWaypointListener interface.

Specified by:
requestWaypoints in class GPS

requestTracks

public void requestTracks()
Asks the GPS to transmit all the tracks in its memory. The result will be returned through the GPSTrackListener interface.

Specified by:
requestTracks in class GPS

requestRoutes

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

Specified by:
requestRoutes in class GPS

sendWaypoints

public void sendWaypoints(Vector gpsWaypoints)
Sends the given collection of GPSWaypoints to the GPS.

Specified by:
sendWaypoints in class GPS
Parameters:
gpsWaypoints - Collection of waypoints. Each item in the collection should be a WaypointDataPacket object.

setAutoTransmit

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

Specified by:
setAutoTransmit in class GPS
Parameters:
transmit - Start transmitting if true, otherwise stop transmitting.

shutdown

public void shutdown(boolean turnOff)
Stops 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.

Specified by:
shutdown in class GPS
Parameters:
turnOff - Turn of GPS unit if true, otherwise just stop listening.

getDescription

public String getDescription()
Returns a description of the Garmin GPS indicating the software version and the protocols supported.

Specified by:
getDescription in class GPS
Returns:
Description of the Garmin GPS provided by the device.

getShortDescription

public String getShortDescription()
Returns a short description of the Garmin GPS indicating the make and software version used.

Specified by:
getShortDescription in class GPS
Returns:
Description of the Garmin GPS provided by the device.


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