jaron.autopilot
Class FlightGearGpsReceiver

java.lang.Object
  extended by java.lang.Thread
      extended by jaron.autopilot.FlightGearGpsReceiver
All Implemented Interfaces:
java.lang.Runnable

public class FlightGearGpsReceiver
extends java.lang.Thread

The FlightGearGpsReceiver class provides a TCP/IP connection to the FlightGear flight simulator (FG) via the FG NMEA output interface.
FlightGearGpsReceiver runs as a thread and by instantiating it waits for the incoming connection from FG (at port 5557 by default).
The instantiating has to be done before FG starts up, or else FG reports a connection error and terminates.
Be aware that running FG and a Java application that uses the FlightGearGpsReceiver needs a computer with sufficient performance. The consequence of a lack of performance is, that some of the data sent by FG could be lost because of timing issues. In this case you could run FG and the Java application on two different machines via a network connection.

Since:
1.2
Version:
1.2
Author:
jarontec gmail com

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
static int DEFAULT_PORT
          The default port that is used for the incoming connection.
static float DEFAULT_UPDATE_FREQUENCY
          The default update frequency of the FlightGearGpsReceiver is set to 5.0f Hz.
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
FlightGearGpsReceiver()
          Creates a new FlightGearGpsReceiver and starts a Thread that listens for incoming connections.
FlightGearGpsReceiver(int port)
          Creates a new FlightGearGpsReceiver and starts a Thread that listens for incoming connections.
 
Method Summary
 void addTrackpointListener(TrackpointListener listener)
          Adds a listener to the EventListener mechanism.
 Signal getAltitudeAbsolute()
          Returns the absolute altitude signal which is used for the event handling mechanism.
 Signal getCourseOverGround()
          Returns the course over ground signal which is used for the event handling mechanism.
 Signal getLatitude()
          Returns the latitude signal which is used for the event handling mechanism.
 Signal getLongitude()
          Returns the longitude signal which is used for the event handling mechanism.
 Signal getSatellites()
          Returns the satellite signal (number of satellites) which is used for the event handling mechanism.
 Signal getSpeedOverGround()
          Returns the speed over ground signal which is used for the event handling mechanism.
 void run()
           
 void setUpdateFrequency(float updateFrequency)
          Sets the update frequency for the FlightGearGpsReceiver.
 void shutDown()
          Disconnects the FlightGear client.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_UPDATE_FREQUENCY

public static final float DEFAULT_UPDATE_FREQUENCY
The default update frequency of the FlightGearGpsReceiver is set to 5.0f Hz.

See Also:
Constant Field Values

DEFAULT_PORT

public static final int DEFAULT_PORT
The default port that is used for the incoming connection. At the moment this is port 5557 but this could change in the future.

See Also:
Constant Field Values
Constructor Detail

FlightGearGpsReceiver

public FlightGearGpsReceiver(int port)
Creates a new FlightGearGpsReceiver and starts a Thread that listens for incoming connections.

Parameters:
port - the port the receiver listens to

FlightGearGpsReceiver

public FlightGearGpsReceiver()
Creates a new FlightGearGpsReceiver and starts a Thread that listens for incoming connections. It listens on the default port DEFAULT_PORT.

See Also:
DEFAULT_PORT
Method Detail

addTrackpointListener

public void addTrackpointListener(TrackpointListener listener)
Adds a listener to the EventListener mechanism. So whenever a trackpoint is added to the trackpath, the listener will be informed about that event.

Parameters:
listener - the listener to be added

getLatitude

public Signal getLatitude()
Returns the latitude signal which is used for the event handling mechanism.

Returns:
the latitude signal
See Also:
Signal

getLongitude

public Signal getLongitude()
Returns the longitude signal which is used for the event handling mechanism.

Returns:
the longitude signal
See Also:
Signal

getCourseOverGround

public Signal getCourseOverGround()
Returns the course over ground signal which is used for the event handling mechanism.

Returns:
the course over ground signal
See Also:
Signal

getSpeedOverGround

public Signal getSpeedOverGround()
Returns the speed over ground signal which is used for the event handling mechanism.

Returns:
the speed over ground signal
See Also:
Signal

getAltitudeAbsolute

public Signal getAltitudeAbsolute()
Returns the absolute altitude signal which is used for the event handling mechanism.

Returns:
the absolute altitude signal
See Also:
Signal

getSatellites

public Signal getSatellites()
Returns the satellite signal (number of satellites) which is used for the event handling mechanism.

Returns:
the number of satellite signal
See Also:
Signal

setUpdateFrequency

public void setUpdateFrequency(float updateFrequency)
Sets the update frequency for the FlightGearGpsReceiver. The default update frequency is set to 5.0f Hz.

Parameters:
updateFrequency - the new frequency in Hz

run

public void run()
Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread

shutDown

public void shutDown()
Disconnects the FlightGear client.