Class GPSParser

java.lang.Object
org.ka2ddo.gps.GPSParser
All Implemented Interfaces:
DebugCtl.DbgListener

public class GPSParser extends Object implements DebugCtl.DbgListener
This singleton functor class collects GPS data from GPS data sources and accumulates current position data for use by other parts of the application.
Author:
Andrew Pavlin, KA2DDO
  • Method Details

    • setDebug

      public void setDebug(String categoryName, boolean setting)
      Specify if a specific category of debug messages should be printed out.
      Specified by:
      setDebug in interface DebugCtl.DbgListener
      Parameters:
      categoryName - String name of category to enable debug logging for
      setting - boolean true or false to enable or disable debugging this category
    • parseNMEA0183DataLine

      public static Object parseNMEA0183DataLine(String line, GpsFix fix, SatelliteCatalog satCatalog, String source)
      Parse an NMEA-0183 standard data sentence into GPS data structure values.
      Parameters:
      line - String line to parse
      fix - GpsFix data structure to populate, or null if a new one should be allocated
      satCatalog - SatelliteCatalog data structure to populate, or null if a new one should be allocated
      source - callsign of source (used only for error messages)
      Returns:
      populated data structure if valid sentence parsed, "ASTRAL" if the sentence was a DeLorme TripMate trying to initialize, or null if parse failed
    • registerSentenceParser

      public static boolean registerSentenceParser(String sentenceName, GPSSentenceParser parser)
      Register a parser for a particular NMEA-0183 sentence.
      Parameters:
      sentenceName - String sentence name, starting with the '$' character and ending just before the delimiting comma; if multiple constellations are to be supported by a parser, the same parser must be registered for each variant, i.e., $GPTXT and $GATXT.
      parser - GPSSentenceParser instance to call for the specified sentence name
      Returns:
      whatever value the parser chooses to return
    • unregisterSentenceParser

      public static boolean unregisterSentenceParser(String sentenceName)
      Unregister a parser for a particular NMEA-0183 sentence.
      Parameters:
      sentenceName - String sentence name, starting with the '$' character and ending just before the delimiting comma; if multiple constellations are to be supported by a parser, the same parser must be registered for each variant, i.e., $GPTXT and $GATXT.
      Returns:
      whatever value the parser chooses to return
    • split

      protected static String[] split(String line, char separator)
      This is a more optimized version of String.split() that doesn't require compiling and evaluating regular expression patterns to do it, thereby saving chunks of transient heap (and probably some CPU time as well).
      Parameters:
      line - the String to split at occurrences of the separator
      separator - the char delimiting substrings of the line
      Returns:
      array of Strings split at the various points the separator appears