lejos.gps
Class SimpleGPS

java.lang.Object
  extended by java.lang.Thread
      extended by lejos.gps.SimpleGPS
All Implemented Interfaces:
Runnable
Direct Known Subclasses:
GPS

public class SimpleGPS
extends Thread

This class manages data received from a GPS Device. SimpleGPS Class manages the following NMEA Sentences which supply location, heading, and speed data: GPGGA (location data) GPVTG (heading and speed data)

Author:
BB

Field Summary
 int errors
           
protected  GGASentence ggaSentence
           
protected static Vector listeners
           
protected  VTGSentence vtgSentence
           
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
SimpleGPS(InputStream in)
          The constructor.
 
Method Summary
static void addListener(GPSListener listener)
          add a listener to manage events with GPS
 void close()
          Method used to close connection.
 float getAltitude()
          The altitude above mean sea level
 float getCourse()
          Get the course heading of the GPS unit.
 int getFixMode()
          Fix quality: 0 = invalid 1 = GPS fix (SPS) 2 = DGPS fix 3 = PPS fix 4 = Real Time Kinematic 5 = Float RTK 6 = estimated (dead reckoning) (2.3 feature) 7 = Manual input mode 8 = Simulation mode
 int getFixType()
          3D fix - values include: 1 = no fix 2 = 2D fix 3 = 3D fix
 float getHDOP()
          Get the Horizontal Dilution of Precision (HDOP).
 double getLatitude()
          Get Latitude
 char getLatitudeDirection()
          Get Latitude Direction
 double getLongitude()
          Get Longitude
 char getLongitudeDirection()
          Get Longitude Direction
 float getPDOP()
          Get the 3D Position Dilution of Precision (PDOP).
 int[] getPRN()
          Get an Array of Pseudo-Random Noise codes (PRN).
 int getSatellitesTracked()
          Returns the number of satellites being tracked to determine the coordinates.
 String getSelectionType()
          Selection type of 2D or 3D fix 'M' = manual 'A' = automatic
 float getSpeed()
          Get speed in kilometers per hour
 int getTimeStamp()
          Get the last time stamp from the satellite for GGA sentence.
 float getVDOP()
          Get the Vertical Dilution of Precision (VDOP).
protected static void notifyListeners(NMEASentence sen)
           
static void removeListener(GPSListener listener)
          Remove a listener
 void run()
          Keeps reading sentences from GPS receiver stream and extracting data.
protected  void sentenceChooser(String token, String s)
          Internal helper method to aid in the subclass architecture.
 
Methods inherited from class java.lang.Thread
currentThread, getPriority, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, setDaemon, setPriority, sleep, start, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

errors

public int errors

ggaSentence

protected GGASentence ggaSentence

vtgSentence

protected VTGSentence vtgSentence

listeners

protected static Vector listeners
Constructor Detail

SimpleGPS

public SimpleGPS(InputStream in)
The constructor. It needs an InputStream

Parameters:
in - An input stream from the GPS receiver
Method Detail

getLatitude

public double getLatitude()
Get Latitude

Returns:
the latitude

getLatitudeDirection

public char getLatitudeDirection()
Get Latitude Direction

Returns:
the latitude direction

getLongitude

public double getLongitude()
Get Longitude

Returns:
the longitude

getLongitudeDirection

public char getLongitudeDirection()
Get Longitude Direction

Returns:
the longitude direction

getAltitude

public float getAltitude()
The altitude above mean sea level

Returns:
Meters above sea level e.g. 545.4

getSatellitesTracked

public int getSatellitesTracked()
Returns the number of satellites being tracked to determine the coordinates.

Returns:
Number of satellites e.g. 8

getFixMode

public int getFixMode()
Fix quality:
  • 0 = invalid
  • 1 = GPS fix (SPS)
  • 2 = DGPS fix
  • 3 = PPS fix
  • 4 = Real Time Kinematic
  • 5 = Float RTK
  • 6 = estimated (dead reckoning) (2.3 feature)
  • 7 = Manual input mode
  • 8 = Simulation mode

    Returns:
    the fix quality

  • getTimeStamp

    public int getTimeStamp()
    Get the last time stamp from the satellite for GGA sentence.

    Returns:
    Time as a UTC integer. 123459 = 12:34:59 UTC

    getSpeed

    public float getSpeed()
    Get speed in kilometers per hour

    Returns:
    the speed in kilometers per hour

    getCourse

    public float getCourse()
    Get the course heading of the GPS unit.

    Returns:
    course (0.0 to 360.0)

    getSelectionType

    public String getSelectionType()
    Selection type of 2D or 3D fix
  • 'M' = manual
  • 'A' = automatic

    Returns:
    selection type - either 'A' or 'M'

  • getFixType

    public int getFixType()
    3D fix - values include:
  • 1 = no fix
  • 2 = 2D fix
  • 3 = 3D fix

    Returns:
    fix type (1 to 3)

  • getPRN

    public int[] getPRN()
    Get an Array of Pseudo-Random Noise codes (PRN). You can look up a list of GPS satellites by this number at: http://en.wikipedia.org/wiki/List_of_GPS_satellite_launches Note: This number might be similar or identical to SVN.

    Returns:
    array of PRNs

    getPDOP

    public float getPDOP()
    Get the 3D Position Dilution of Precision (PDOP). When visible GPS satellites are close together in the sky, the geometry is said to be weak and the DOP value is high; when far apart, the geometry is strong and the DOP value is low. Thus a low DOP value represents a better GPS positional accuracy due to the wider angular separation between the satellites used to calculate a GPS unit's position. Other factors that can increase the effective DOP are obstructions such as nearby mountains or buildings.

    Returns:
    The PDOP (PDOP * 6 meters = the error to expect in meters) -1 means PDOP is unavailable from the GPS.

    getHDOP

    public float getHDOP()
    Get the Horizontal Dilution of Precision (HDOP). When visible GPS satellites are close together in the sky, the geometry is said to be weak and the DOP value is high; when far apart, the geometry is strong and the DOP value is low. Thus a low DOP value represents a better GPS positional accuracy due to the wider angular separation between the satellites used to calculate a GPS unit's position. Other factors that can increase the effective DOP are obstructions such as nearby mountains or buildings.

    Returns:
    the HDOP (HDOP * 6 meters = the error to expect in meters) -1 means HDOP is unavailable from the GPS.

    getVDOP

    public float getVDOP()
    Get the Vertical Dilution of Precision (VDOP). When visible GPS satellites are close together in the sky, the geometry is said to be weak and the DOP value is high; when far apart, the geometry is strong and the DOP value is low. Thus a low DOP value represents a better GPS positional accuracy due to the wider angular separation between the satellites used to calculate a GPS unit's position. Other factors that can increase the effective DOP are obstructions such as nearby mountains or buildings.

    Returns:
    the VDOP (VDOP * 6 meters = the error to expect in meters) -1 means VDOP is unavailable from the GPS.

    close

    public void close()
               throws IOException
    Method used to close connection. There is no real need to call this method. Included in case programmer wants absolutely clean exit.

    Throws:
    IOException

    run

    public void run()
    Keeps reading sentences from GPS receiver stream and extracting data. This is a daemon thread so when program ends it won't keep running.

    Specified by:
    run in interface Runnable
    Overrides:
    run in class Thread

    sentenceChooser

    protected void sentenceChooser(String token,
                                   String s)
    Internal helper method to aid in the subclass architecture. Overwritten by subclass.

    Parameters:
    token -
    s -

    notifyListeners

    protected static void notifyListeners(NMEASentence sen)

    addListener

    public static void addListener(GPSListener listener)
    add a listener to manage events with GPS

    Parameters:
    listener -

    removeListener

    public static void removeListener(GPSListener listener)
    Remove a listener

    Parameters:
    listener -