Class GPSDistributor

java.lang.Object
org.ka2ddo.yaac.gps.GPSDistributor

public class GPSDistributor extends Object
This class collects GPS data from GPS data sources and accumulates current position data for use by other parts of the application. It also allows collecting GPS data from remote GPS's (such as relayed over unlicensed ISM links from an amateur rocket) for display and reporting.
Author:
Andrew Pavlin, KA2DDO
  • Method Details

    • getInstance

      public static GPSDistributor getInstance()
      Get a nonshareable instance of GPSDistributor.
      Returns:
      GPSDistributor instance
    • getLogFormat

      public static GpsLogMode getLogFormat()
      Get the log file format that will be used for logging GPS position sentences (assuming logging is turned on).
      Returns:
      GpsLogMode used for logging
    • setLogFormat

      public static void setLogFormat(GpsLogMode logFormat)
      Set the log file format that will be used for logging GPS position sentences (assuming logging is turned on). Note that a change in log format while logging is in progress will cause the old format file to be closed and the new format file to be opened or created.
      Parameters:
      logFormat - GpsLogMode used for logging
    • parseNMEA0183DataLine

      public Object parseNMEA0183DataLine(String line, PortConnector connector, boolean isLocal, String source)
      Parse an NMEA-0183 standard data sentence into GPS data structure values. The received sentence will also be forwarded to all registered GpsRawNMEA0183Listeners.
      Parameters:
      line - String line to parse
      connector - PortConnector that received the sentence
      isLocal - boolean true if this is from this station's own GPS, not from some other station
      source - callsign of source of remote GPS
      Returns:
      populated data structure if valid sentence parsed, or null if parse failed or DeLorme TripMate was trying to be initialized
    • extractGpsdJsonInfo

      public Object extractGpsdJsonInfo(Map<String,Object> jsonMsg, boolean isLocal, String source)
      Decode a JSON message from GPSD and update the appropriate GPS state objects.
      Parameters:
      jsonMsg - Map<String,Object> as returned by Json.decodeJSON()
      isLocal - boolean true if this is for the GPS local to this station (not a remote GPS)
      source - String name of source, used for identifying specific remote GPS ports
      Returns:
      local GPS data structure filled in by the message, or null if not parseable
      See Also:
    • parseGpsdJsonLine

      public Object parseGpsdJsonLine(Map<String,Object> jsonMsg, GpsFix fix, SatelliteCatalog satCatalog)
      Decode a JSON message from GPSD and update the appropriate GPS state objects.
      Parameters:
      jsonMsg - Map<String,Object> as returned by Json.decodeJSON()
      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
      Returns:
      local GPS data structure filled in by the message, or null if not parseable or not a GPSD structure
      See Also:
    • addGpsDataListener

      public static void addGpsDataListener(GpsDataListener l)
      Register to be informed when local GPS position data is updated.
      Parameters:
      l - GpsDataListener to call when the GPS data is updated
    • removeGpsDataListener

      public static void removeGpsDataListener(GpsDataListener l)
      Stop being informed when GPS data is updated.
      Parameters:
      l - GpsDataListener to unregister
    • isGpsDataListener

      public static boolean isGpsDataListener(GpsDataListener l)
      Test if specified listener is currently registered to be informed when local GPS position data is updated.
      Parameters:
      l - GpsDataListener to test for registration
      Returns:
      boolean true if specified listener is currently registered to receive GPS events
    • addGpsRawNMEA0183Listener

      public static void addGpsRawNMEA0183Listener(GpsRawNMEA0183Listener l)
      Register to be informed when raw NMEA-0183 data is received.
      Parameters:
      l - GpsRawNMEA0183Listener to call when raw NMEA-0183 data is received
    • removeGpsRawNMEA0183Listener

      public static void removeGpsRawNMEA0183Listener(GpsRawNMEA0183Listener l)
      Stop being informed when raw NMEA-0183 data is received.
      Parameters:
      l - GpsRawNMEA0183Listener to unregister
    • isGpsRawNMEA0183Listener

      public static boolean isGpsRawNMEA0183Listener(GpsRawNMEA0183Listener l)
      Test if specified listener is currently registered to be informed when local GPS position data is updated.
      Parameters:
      l - GpsRawNMEA0183Listener to test for registration
      Returns:
      boolean true if specified listener is currently registered to receive raw NMEA-0183 sentences
    • getCurrentFix

      public static GpsFix getCurrentFix()
      get the current GPS fix information of the local station.
      Returns:
      the active GpsFix object
    • getNamedSources

      public static String[] getNamedSources()
      Get the names for the currently known named remote GPS receivers.
      Returns:
      array of String names for remote GPS receivers
    • getNamedGpsFix

      public static GpsFix getNamedGpsFix(String name)
      Get the current GPS fix information for the named source. This cannot return the local GPS source for this station, but is intended for remote GPS sources connected to this YAAC by distance links.
      Parameters:
      name - String name of source
      Returns:
      GpsFix if data has been received for the specified name, or null if no data for the name
    • getLocalSpeedKnots

      public static float getLocalSpeedKnots()
      Return the current movement speed of the local station in knots (nautical miles per hour).
      Returns:
      speed in knots
    • getLocalBearingDegN

      public static float getLocalBearingDegN(int stepBack)
      Returns the current direction of motion in degrees relative to True North.
      Parameters:
      stepBack - number of position samples to use to get direction (larger numbers average out motion more)
      Returns:
      movement bearing in degrees from True North
    • getSatCatalog

      public static SatelliteCatalog getSatCatalog()
      Get the current state of the GPS satellite constellation. Note this information may be empty if the GPS receiver does not report $GPGSA or $GPGSV records.
      Returns:
      the SatelliteCatalog object containing the currently visible satellites
    • getNamedSatCatalog

      public static SatelliteCatalog getNamedSatCatalog(String name)
      Get the current GPS satellite catalog for the named source. This cannot return the local GPS source for this station, but is intended for remote GPS sources connected to this YAAC by distance links.
      Parameters:
      name - String name of source
      Returns:
      SatelliteCatalog if data has been received for the specified name, or null if no data for the name
    • getShortTermHistory

      public static ArrayList<GpsFix> getShortTermHistory()
      Get a copy of the recent position history of this station.
      Returns:
      ArrayList containing GpsFix objects for the last 5 minutes
    • appendToGpsLog

      public static void appendToGpsLog(String logMsg)
      Append the specified log message to the current GPS log file (if logging is running).
      Parameters:
      logMsg - String to log in GPS log