Package org.ka2ddo.yaac.gps
Class GPSDistributor
java.lang.Object
org.ka2ddo.yaac.gps.GPSDistributor
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 Summary
Modifier and TypeMethodDescriptionstatic void
Register to be informed when local GPS position data is updated.static void
Register to be informed when raw NMEA-0183 data is received.static void
appendToGpsLog
(String logMsg) Append the specified log message to the current GPS log file (if logging is running).extractGpsdJsonInfo
(Map<String, Object> jsonMsg, boolean isLocal, String source) Decode a JSON message from GPSD and update the appropriate GPS state objects.static GpsFix
get the current GPS fix information of the local station.static GPSDistributor
Get a nonshareable instance of GPSDistributor.static float
getLocalBearingDegN
(int stepBack) Returns the current direction of motion in degrees relative to True North.static float
Return the current movement speed of the local station in knots (nautical miles per hour).static GpsLogMode
Get the log file format that will be used for logging GPS position sentences (assuming logging is turned on).static GpsFix
getNamedGpsFix
(String name) Get the current GPS fix information for the named source.static SatelliteCatalog
getNamedSatCatalog
(String name) Get the current GPS satellite catalog for the named source.static String[]
Get the names for the currently known named remote GPS receivers.static SatelliteCatalog
Get the current state of the GPS satellite constellation.Get a copy of the recent position history of this station.static boolean
Test if specified listener is currently registered to be informed when local GPS position data is updated.static boolean
Test if specified listener is currently registered to be informed when local GPS position data is updated.parseGpsdJsonLine
(Map<String, Object> jsonMsg, GpsFix fix, SatelliteCatalog satCatalog) Decode a JSON message from GPSD and update the appropriate GPS state objects.parseNMEA0183DataLine
(String line, PortConnector connector, boolean isLocal, String source) Parse an NMEA-0183 standard data sentence into GPS data structure values.static void
Stop being informed when GPS data is updated.static void
Stop being informed when raw NMEA-0183 data is received.static void
setLogFormat
(GpsLogMode logFormat) Set the log file format that will be used for logging GPS position sentences (assuming logging is turned on).
-
Method Details
-
getInstance
Get a nonshareable instance of GPSDistributor.- Returns:
- GPSDistributor instance
-
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
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 registeredGpsRawNMEA0183Listener
s.- Parameters:
line
- String line to parseconnector
- PortConnector that received the sentenceisLocal
- boolean true if this is from this station's own GPS, not from some other stationsource
- 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
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 allocatedsatCatalog
- 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
Register to be informed when local GPS position data is updated.- Parameters:
l
- GpsDataListener to call when the GPS data is updated
-
removeGpsDataListener
Stop being informed when GPS data is updated.- Parameters:
l
- GpsDataListener to unregister
-
isGpsDataListener
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
Register to be informed when raw NMEA-0183 data is received.- Parameters:
l
- GpsRawNMEA0183Listener to call when raw NMEA-0183 data is received
-
removeGpsRawNMEA0183Listener
Stop being informed when raw NMEA-0183 data is received.- Parameters:
l
- GpsRawNMEA0183Listener to unregister
-
isGpsRawNMEA0183Listener
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
get the current GPS fix information of the local station.- Returns:
- the active GpsFix object
-
getNamedSources
Get the names for the currently known named remote GPS receivers.- Returns:
- array of String names for remote GPS receivers
-
getNamedGpsFix
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
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
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
Get a copy of the recent position history of this station.- Returns:
- ArrayList containing GpsFix objects for the last 5 minutes
-
appendToGpsLog
Append the specified log message to the current GPS log file (if logging is running).- Parameters:
logMsg
- String to log in GPS log
-