wonderly.jeaprs.aprs.packet
Class APRSData

java.lang.Object
  |
  +--wonderly.jeaprs.aprs.packet.APRSData
All Implemented Interfaces:
APRSEventDataProcessor, java.io.Serializable
Direct Known Subclasses:
APRSGps, APRSLocationInfo, APRSMessage, APRSObject, APRSPosition, APRSQuery, APRSShelter, APRSStation, APRSTelemetry, APRSThirdParty, APRSUserDefined, APRSWeather

public abstract class APRSData
extends java.lang.Object
implements APRSEventDataProcessor, java.io.Serializable

This class is the base class for all APRS data objects. The APRSData objects hold all of the information pertaining to specific APRS packet types. The APRSPacket object contains just the 4 basic pieces of information about an APRS packet.

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
protected  boolean altIcons
          Whether or not the icon is in the alt icons group
protected  java.util.Vector data
          The extra APRSData objects extracted from a packet.
protected  boolean hasOverlaya
          True if there is an alpha character overlay.
protected  boolean hasOverlayn
          True if there is a numeric character overlay.
protected  int icon
          The icon index number computed by calcIconFrom()
protected  int overlay
          The overlay character/numeric offset.
protected  char packetType
          The character used as the first character in this packet
 
Constructor Summary
APRSData()
           
 
Method Summary
 void addOtherAPRSData(wonderly.jeaprs.aprs.packet.APRSData dt)
          Adds extra APRSData to this object.
static int ambiguousDistance(wonderly.jeaprs.ByteString val)
          Returns the distance ambiguity of the passed lat/long string representation based on where the space characters start.
 void calcIconFrom(byte tab, byte sym)
          Calculates all the associated icon information based on the specified symbol table and icon character.
protected static java.lang.String fixedToString(long val, int sz)
          zero fill of fixed point value from the MathFP package.
abstract  byte[] formatReportData()
          This method must be implemented by the various packet types to construct the APRS packet data that follows the PATH in a UI frame.
static java.lang.String formatTime(long time)
           
 wonderly.jeaprs.ByteString getGridInfo()
           
 int getIcon()
          Returns the icon number, from 0 to 127, associated with this packet.
 java.lang.String getLatHundredthsSecondsToString(long lat)
           
static int[] getLatHundrethsSecondsParts(long val)
           
 java.lang.String getLatSecondsToString(long lat)
           
 java.lang.String getLonHundredthsSecondsToString(long lon)
           
static int[] getLonHundrethsSecondsParts(long val)
           
 java.lang.String getLonSecondsToString(long lon)
           
 java.util.Vector getOtherAPRSData()
          Returns the Vector of extra APRS data associated with this object.
 int getOverlayIndex()
          Returns a value from 0 through 9 if the icon has a numeric character overlay, or a value from 0 through 25 if the icon has an alpha character overlay.
 java.lang.String getPrintable()
          Returns a printable/readable version of the packet.
 boolean isAltIcon()
          Returns true if the icon specification refers to the alternate icon set, false if it refers to the primary icon set.
 boolean isGridOnly()
           
protected  boolean isNum(wonderly.jeaprs.ByteString str)
           
 boolean isOverlayAlpha()
          Returns true if the icon has an alpha character overlay
 boolean isOverlayNumeric()
          Returns true if the icon has a numeric character overlay
static java.lang.String latHundredthsSecondsAsString(long lat)
           
static int[] latLonParts(wonderly.jeaprs.ByteString val)
           
static java.lang.String latSecondsAsString(long lat)
           
protected  void log(java.lang.String str)
           
static java.lang.String lonHundredthsSecondsAsString(long lon)
           
static java.lang.String lonSecondsAsString(long lon)
           
static void main(java.lang.String[] arg)
           
protected static java.lang.String numToString(int val)
          Default padding of numeric to zero filled 3 char string
protected static java.lang.String numToString(int val, int sz)
          zero fill of numeric string to indicated length
protected static java.lang.String numToString(long val, int sz)
          zero fill of numeric string to indicated length
static long parseLat(wonderly.jeaprs.ByteString slat)
          Parses a latitude specification and turns it into a decimal number without regard to the intermixing of degrees and minutes.
static long parseLon(wonderly.jeaprs.ByteString slon)
          Parses a longitude specification and turns it into a decimal number without regard to the intermixing of degrees and minutes.
static long parseTime(wonderly.jeaprs.ByteString str)
          parses the passed APRS timestring and converts it into a Java time value that is relative to 1/1/70 00:00 GMT.
 void processData(wonderly.jeaprs.aprs.packet.APRSPacket pkt, wonderly.jeaprs.aprs.packet.APRSEventListener context)
          This method needs to be called for any APRS packet that could produce multiple APRS data objects.
 void sendPacket(wonderly.jeaprs.io.aprs.APRSOutput os)
          This method must be implemented by all APRSData subclasses.
protected static int toNum(wonderly.jeaprs.ByteString str)
          replaces space chars in str with 0 and then coverts str to an integer
protected  java.lang.String zeroPad(int d)
           
protected  java.lang.String zeroPad(int d, int cnt)
           
protected static java.lang.String zFill(int v, int sz)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

data

protected java.util.Vector data
The extra APRSData objects extracted from a packet. Status packets can can include maidenhead position data, weather etc. Other packets have similar capabilities. When an APRSData packet is processed, it may be necesary to use the getOtherAPRSData() method to get a reference to the extra data that was in the primary packet.


icon

protected int icon
The icon index number computed by calcIconFrom()


overlay

protected int overlay
The overlay character/numeric offset.

See Also:
hasOverlaya, hasOverlayn

altIcons

protected boolean altIcons
Whether or not the icon is in the alt icons group


hasOverlaya

protected boolean hasOverlaya
True if there is an alpha character overlay. overlay is then the value to add to 'A' to get the overlay character. i.e. it has a value from 0 to 25.


hasOverlayn

protected boolean hasOverlayn
True if there is a numeric character overlay. overlay is then the value to add to '0' to get the overlay character. i.e. it has a value from 0 to 9.


packetType

protected char packetType
The character used as the first character in this packet

Constructor Detail

APRSData

public APRSData()
Method Detail

sendPacket

public void sendPacket(wonderly.jeaprs.io.aprs.APRSOutput os)
                throws java.io.IOException
This method must be implemented by all APRSData subclasses. This method must assemble a packet, and then use os to write that data to the passed APRSOutput reference.

Throws:
java.io.IOException - if an output error occurs.

getGridInfo

public wonderly.jeaprs.ByteString getGridInfo()

isGridOnly

public boolean isGridOnly()

getIcon

public int getIcon()
Returns the icon number, from 0 to 127, associated with this packet. The value, -1, is returned if no icon has been provided in the packet, or the packet parser did not recognize the notations in the packet indicating the icon.

See Also:
isOverlayAlpha(), isOverlayNumeric(), getOverlayIndex(), isAltIcon()

isOverlayAlpha

public boolean isOverlayAlpha()
Returns true if the icon has an alpha character overlay


isOverlayNumeric

public boolean isOverlayNumeric()
Returns true if the icon has a numeric character overlay


getOverlayIndex

public int getOverlayIndex()
Returns a value from 0 through 9 if the icon has a numeric character overlay, or a value from 0 through 25 if the icon has an alpha character overlay. If getIcon() returns -1, the value returned here is undefined

See Also:
getIcon()

isAltIcon

public boolean isAltIcon()
Returns true if the icon specification refers to the alternate icon set, false if it refers to the primary icon set.


getPrintable

public java.lang.String getPrintable()
Returns a printable/readable version of the packet. This default implementation uses the Object.toString() methods return value.


addOtherAPRSData

public void addOtherAPRSData(wonderly.jeaprs.aprs.packet.APRSData dt)
Adds extra APRSData to this object.

See Also:
getOtherAPRSData(), data

log

protected void log(java.lang.String str)

getOtherAPRSData

public java.util.Vector getOtherAPRSData()
Returns the Vector of extra APRS data associated with this object. Vector.size() will be 0 if there is no extra data.


zeroPad

protected java.lang.String zeroPad(int d)

zeroPad

protected java.lang.String zeroPad(int d,
                                   int cnt)

latHundredthsSecondsAsString

public static java.lang.String latHundredthsSecondsAsString(long lat)

lonHundredthsSecondsAsString

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

latSecondsAsString

public static java.lang.String latSecondsAsString(long lat)

lonSecondsAsString

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

getLatHundredthsSecondsToString

public java.lang.String getLatHundredthsSecondsToString(long lat)

getLonHundredthsSecondsToString

public java.lang.String getLonHundredthsSecondsToString(long lon)

getLatSecondsToString

public java.lang.String getLatSecondsToString(long lat)

getLonSecondsToString

public java.lang.String getLonSecondsToString(long lon)

zFill

protected static java.lang.String zFill(int v,
                                        int sz)

parseTime

public static long parseTime(wonderly.jeaprs.ByteString str)
parses the passed APRS timestring and converts it into a Java time value that is relative to 1/1/70 00:00 GMT.


formatTime

public static java.lang.String formatTime(long time)

main

public static void main(java.lang.String[] arg)

ambiguousDistance

public static int ambiguousDistance(wonderly.jeaprs.ByteString val)
Returns the distance ambiguity of the passed lat/long string representation based on where the space characters start. The value returned is one of 0, 1, 10 or 100.


parseLat

public static long parseLat(wonderly.jeaprs.ByteString slat)
Parses a latitude specification and turns it into a decimal number without regard to the intermixing of degrees and minutes. I.e. if the value was 3604.23N, this method returns the number 3604.23, not a number based on minutes or degrees or seconds. North results in positive numbers. South results in negative numbers


latLonParts

public static int[] latLonParts(wonderly.jeaprs.ByteString val)

getLatHundrethsSecondsParts

public static int[] getLatHundrethsSecondsParts(long val)

getLonHundrethsSecondsParts

public static int[] getLonHundrethsSecondsParts(long val)

parseLon

public static long parseLon(wonderly.jeaprs.ByteString slon)
Parses a longitude specification and turns it into a decimal number without regard to the intermixing of degrees and minutes. I.e. if the value was 09625.82W, this method returns the number -9625.82, not a number based on minutes or degrees or seconds. West results in negative numbers. East results in positive numbers.


calcIconFrom

public void calcIconFrom(byte tab,
                         byte sym)
Calculates all the associated icon information based on the specified symbol table and icon character. If tab is 0, it is ignored.

See Also:
getIcon()

isNum

protected boolean isNum(wonderly.jeaprs.ByteString str)
Returns:
true if all chars in str are numeric

toNum

protected static int toNum(wonderly.jeaprs.ByteString str)
replaces space chars in str with 0 and then coverts str to an integer


numToString

protected static java.lang.String numToString(int val)
Default padding of numeric to zero filled 3 char string


numToString

protected static java.lang.String numToString(int val,
                                              int sz)
zero fill of numeric string to indicated length

Parameters:
val - the value
sz - the needed length of the string, zero filled to this

numToString

protected static java.lang.String numToString(long val,
                                              int sz)
zero fill of numeric string to indicated length

Parameters:
val - the value
sz - the needed length of the string, zero filled to this

fixedToString

protected static java.lang.String fixedToString(long val,
                                                int sz)
zero fill of fixed point value from the MathFP package.

Parameters:
val - the value
sz - the needed length of the string, zero filled to this

formatReportData

public abstract byte[] formatReportData()
                                 throws InvalidPacketConfigurationException
This method must be implemented by the various packet types to construct the APRS packet data that follows the PATH in a UI frame. Thus, if a status packet was to be sent out, this method should return something such as ">My status".getBytes().

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 context)
This method needs to be called for any APRS packet that could produce multiple APRS data objects.

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