wonderly.jeaprs.aprs.packet
Class APRSGps

java.lang.Object
  |
  +--wonderly.jeaprs.aprs.packet.APRSData
        |
        +--wonderly.jeaprs.aprs.packet.APRSGps
All Implemented Interfaces:
APRSEventDataProcessor, APRSPositionData, java.io.Serializable

public class APRSGps
extends APRSData
implements APRSPositionData

This class holds data from NMEA sentences. It currently understands $GPRMC and $GPGGA sentences.

Version:
1.0
Author:
Gregg Wonderly - The information contained in this document is Copyright 2001-2003, Gregg Wonderly, all rights reserved.
See Also:
Serialized Form

Field Summary
static int TYPE_GPGGA
          Not supported for output, but works for input
static int TYPE_GPRMC
           
 
Fields inherited from class wonderly.jeaprs.aprs.packet.APRSData
altIcons, data, hasOverlaya, hasOverlayn, icon, overlay, packetType
 
Constructor Summary
APRSGps(wonderly.jeaprs.ByteString data)
          Construct and parse NEMA data
APRSGps(wonderly.jeaprs.ByteString data, byte table, byte sym)
          Construct and parse data passed and specify a symbol table/overlay and icon
 
Method Summary
 byte[] formatReportData()
          Get the Information packet form of this packet.
 long getAltitude()
           
 boolean getAltitudePresent()
           
 int getCourse()
           
 boolean getCoursePresent()
           
 java.lang.String getCourseSpeed()
           
 java.lang.String getData()
          Returns the raw NMEA data string
 long getLatHundredthsSeconds()
           
 java.lang.String getLatHundredthsSecondsString()
          Returns the latitude specified as a string compliant with APRS formats
 long getLonHundredthsSeconds()
           
 java.lang.String getLonHundredthsSecondsString()
          Returns the longitude specified as a string compliant with APRS formats
 int getMagVariation()
           
 char getMagVariationDirection()
           
 wonderly.jeaprs.ByteString getMessage()
           
 wonderly.jeaprs.ByteString getName()
           
 int getSatCount()
           
 boolean getSatsPresent()
           
 int getSpeedInHundredthsMPH()
           
 boolean getSpeedPresent()
           
 int getType()
           
 boolean isValid()
          When the data is invalid the entire sentence is still processed.
static java.lang.String lonHundredthsSecondsToString(long lon)
           
 void processData(wonderly.jeaprs.aprs.packet.APRSPacket pkt, wonderly.jeaprs.aprs.packet.APRSEventListener obj)
          Distributes this packet to the passed listener via APRSEventListener.gps().
 void processGPGGA(java.lang.String line)
          Process a GPGGA packet, populating this object
 void processGPRMC(java.lang.String line)
          Process a GPRMC packet, populating this object.
 void setAltitude(int altitude)
          Sets the altitude for the data
 void setAltitudePresent(boolean how)
          Set whether altitude is present in the data
 void setCourse(int course)
          Sets the course data
 void setCoursePresent(boolean how)
          Sets whether the course is present
 void setData(java.lang.String pktData)
          Set the raw NMEA string data
 void setLatHundredthsSeconds(long latVal)
          Sets the latitude seconds of arc for the location
 void setLonHundredthsSeconds(long lonVal)
          Sets the longitude seconds of arc for the location
 void setMagVariation(int var)
           
 void setMagVariationDirection(char dir)
           
 void setSatCount(int cnt)
          Set the count of satellites found
 void setSatsPresent(boolean how)
          Sets whether or not satellite count was/is present in the data
 void setSpeedInHundredthsMPH(int speed)
          Sets the speed data
 void setSpeedPresent(boolean how)
          Set whether the speed is present in the data
 void setTimeDate(int hour, int min, int sec, int day, int mon, int year)
           
 void setType(int type)
           
 void setValid(boolean val)
          Set whether the data is valid or not
 java.lang.String toString()
           
 
Methods inherited from class wonderly.jeaprs.aprs.packet.APRSData
addOtherAPRSData, ambiguousDistance, calcIconFrom, fixedToString, formatTime, getGridInfo, getIcon, getLatHundredthsSecondsToString, getLatHundrethsSecondsParts, getLatSecondsToString, getLonHundredthsSecondsToString, getLonHundrethsSecondsParts, getLonSecondsToString, getOtherAPRSData, getOverlayIndex, getPrintable, isAltIcon, isGridOnly, isNum, isOverlayAlpha, isOverlayNumeric, latHundredthsSecondsAsString, latLonParts, latSecondsAsString, log, lonHundredthsSecondsAsString, lonSecondsAsString, main, numToString, numToString, numToString, parseLat, parseLon, parseTime, sendPacket, toNum, zeroPad, zeroPad, zFill
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface wonderly.jeaprs.aprs.packet.APRSPositionData
getGridInfo, getIcon, getLatHundredthsSecondsToString, getLonHundredthsSecondsToString, getOverlayIndex, isAltIcon, isGridOnly, isOverlayAlpha, isOverlayNumeric
 

Field Detail

TYPE_GPRMC

public static final int TYPE_GPRMC
See Also:
Constant Field Values

TYPE_GPGGA

public static final int TYPE_GPGGA
Not supported for output, but works for input

See Also:
Constant Field Values
Constructor Detail

APRSGps

public APRSGps(wonderly.jeaprs.ByteString data,
               byte table,
               byte sym)
Construct and parse data passed and specify a symbol table/overlay and icon


APRSGps

public APRSGps(wonderly.jeaprs.ByteString data)
Construct and parse NEMA data

Method Detail

getName

public wonderly.jeaprs.ByteString getName()
Specified by:
getName in interface APRSPositionData

setType

public void setType(int type)
Parameters:
type - one of the TYPE_* values defined in this class

getType

public int getType()
Returns:
one of the TYPE_* values defined in this class

setSatsPresent

public void setSatsPresent(boolean how)
Sets whether or not satellite count was/is present in the data


getSatsPresent

public boolean getSatsPresent()
Returns:
true if $GPGGA was parsed and sat count found

getSatCount

public int getSatCount()
Returns:
count of satellites heard as indicated in the $GPGGA sentence

setSatCount

public void setSatCount(int cnt)
Set the count of satellites found


setCoursePresent

public void setCoursePresent(boolean how)
Sets whether the course is present


getCoursePresent

public boolean getCoursePresent()
Returns:
true if $GPRMC was found and course set

setSpeedPresent

public void setSpeedPresent(boolean how)
Set whether the speed is present in the data


getSpeedPresent

public boolean getSpeedPresent()
Returns:
true if $GPRMC was found and speed set

setAltitudePresent

public void setAltitudePresent(boolean how)
Set whether altitude is present in the data


getAltitudePresent

public boolean getAltitudePresent()
Returns:
true if $GPGGA was found and altitude set

getCourseSpeed

public java.lang.String getCourseSpeed()
Returns:
the course and speed specification or an empty string if not present. The format is course@speedmph.

getAltitude

public long getAltitude()
Returns:
the altitude as specified in the data
See Also:
getAltitudePresent()

setAltitude

public void setAltitude(int altitude)
Sets the altitude for the data


getMessage

public wonderly.jeaprs.ByteString getMessage()
Specified by:
getMessage in interface APRSPositionData
Returns:
null, no message is supported

getLonHundredthsSeconds

public long getLonHundredthsSeconds()
Specified by:
getLonHundredthsSeconds in interface APRSPositionData

getLatHundredthsSeconds

public long getLatHundredthsSeconds()
Specified by:
getLatHundredthsSeconds in interface APRSPositionData

getLatHundredthsSecondsString

public java.lang.String getLatHundredthsSecondsString()
Returns the latitude specified as a string compliant with APRS formats


setLonHundredthsSeconds

public void setLonHundredthsSeconds(long lonVal)
Sets the longitude seconds of arc for the location


setLatHundredthsSeconds

public void setLatHundredthsSeconds(long latVal)
Sets the latitude seconds of arc for the location


getLonHundredthsSecondsString

public java.lang.String getLonHundredthsSecondsString()
Returns the longitude specified as a string compliant with APRS formats


lonHundredthsSecondsToString

public static java.lang.String lonHundredthsSecondsToString(long lon)

getCourse

public int getCourse()
Specified by:
getCourse in interface APRSPositionData
Returns:
the course specified in the data.
See Also:
getCoursePresent()

setCourse

public void setCourse(int course)
Sets the course data


getSpeedInHundredthsMPH

public int getSpeedInHundredthsMPH()
Specified by:
getSpeedInHundredthsMPH in interface APRSPositionData
Returns:
speed in hundredths of miles per hour. i.e. specified GPRMC speed * 115

setSpeedInHundredthsMPH

public void setSpeedInHundredthsMPH(int speed)
Sets the speed data

Parameters:
speed - speed in 100ths mph. 6543 is 65.43mph

isValid

public boolean isValid()
When the data is invalid the entire sentence is still processed. This method tells whether to believe the data or not.

Returns:
true if NMEA sentence was valid, false if not.

setValid

public void setValid(boolean val)
Set whether the data is valid or not


getData

public java.lang.String getData()
Returns the raw NMEA data string


setMagVariation

public void setMagVariation(int var)

getMagVariation

public int getMagVariation()

getMagVariationDirection

public char getMagVariationDirection()
Returns:
'W' or 'E' for variation

setMagVariationDirection

public void setMagVariationDirection(char dir)

setData

public void setData(java.lang.String pktData)
Set the raw NMEA string data


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

setTimeDate

public void setTimeDate(int hour,
                        int min,
                        int sec,
                        int day,
                        int mon,
                        int year)

formatReportData

public byte[] formatReportData()
                        throws InvalidPacketConfigurationException
Get the Information packet form of this packet. This returns whatever was set with setData.

Specified by:
formatReportData in class APRSData
Throws:
InvalidPacketConfigurationException - if the packet data is not completely established so that the packet can be formatted correctly.

processData

public void processData(wonderly.jeaprs.aprs.packet.APRSPacket pkt,
                        wonderly.jeaprs.aprs.packet.APRSEventListener obj)
Distributes this packet to the passed listener via APRSEventListener.gps().

Specified by:
processData in interface APRSEventDataProcessor
Overrides:
processData in class APRSData
See Also:
APRSPosition.processData(APRSPacket,APRSEventListener)

processGPRMC

public void processGPRMC(java.lang.String line)
Process a GPRMC packet, populating this object.
$GPRMC,022037,A,3606.6417,N,09604.2496,W,0.000,0.0,180800,4.9,E*69


processGPGGA

public void processGPGGA(java.lang.String line)
Process a GPGGA packet, populating this object
$GPGGA,012405,3609.617,N,09432.294,W,1,06,2.4,367.4,M,-28.0,M,,*7C