jaron.flightgear
Class FlightGearSender

java.lang.Object
  extended by java.lang.Thread
      extended by jaron.flightgear.FlightGearSender
All Implemented Interfaces:
java.lang.Runnable

public class FlightGearSender
extends java.lang.Thread

The FlightGearSender class provides a TCP/IP connection to the FlightGear flight simulator (FG) via the FG generic input interface.
FlightGearSender runs as a thread an by instantiating it tries to connect to FG (with port 5556 and ip address "127.0.0.1" by default).
Be aware that running FG and a Java application that uses the FlightGearSender needs a computer with sufficient performance. The consequence of a lack of performance is, that some of the data sent to 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.0
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 java.lang.String DEFAULT_IP
          The default IP address that is used for the outgoing connection.
static int DEFAULT_PORT
          The default port that is used for the outgoing connection.
static float DEFAULT_UPDATE_FREQUENCY
          The default update frequency of the FlightGearSender is 3.0f Hz.
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
FlightGearSender()
          Creates a new FlightGearSender and starts a Thread that tries to connect to FlightGear.
FlightGearSender(java.lang.String ip)
          Creates a new FlightGearSender and starts a Thread that tries to connect to FlightGear.
FlightGearSender(java.lang.String ip, int port)
          Creates a new FlightGearSender and starts a Thread that tries to connect to FlightGear.
 
Method Summary
 Signal getAileron()
          Returns a Signal object that provides access to the aileron data.
 Signal getElevator()
          Returns a Signal object that provides access to the elevator data.
 Signal getRudder()
          Returns a Signal object that provides access to the rudder data.
 Signal getThrottle()
          Returns a Signal object that provides access to the throttle data.
 void run()
           
 void setDebug(java.lang.Boolean debug)
          Sets the debugging flag which determines if the debugging informations should be printed to the console.
 void setUpdateFrequency(float updateFrequency)
          Sets the update frequency for the FlightGearSender.
 void shutDown()
          Shuts this sender down.
 
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 FlightGearSender is 3.0f Hz.

See Also:
Constant Field Values

DEFAULT_PORT

public static final int DEFAULT_PORT
The default port that is used for the outgoing connection. At the moment this is port 5556 but this cold change in the future.

See Also:
Constant Field Values

DEFAULT_IP

public static final java.lang.String DEFAULT_IP
The default IP address that is used for the outgoing connection. This is the local address "127.0.0.1".

See Also:
Constant Field Values
Constructor Detail

FlightGearSender

public FlightGearSender(java.lang.String ip,
                        int port)
Creates a new FlightGearSender and starts a Thread that tries to connect to FlightGear.

Parameters:
ip - the IP address of the FlightGear application
port - the port of the FlightGear application

FlightGearSender

public FlightGearSender(java.lang.String ip)
Creates a new FlightGearSender and starts a Thread that tries to connect to FlightGear. It tries to connect to the default port DEFAULT_PORT.

Parameters:
ip - the IP address of the FlightGear application
See Also:
DEFAULT_PORT

FlightGearSender

public FlightGearSender()
Creates a new FlightGearSender and starts a Thread that tries to connect to FlightGear. It tries to connect to the default IP adres DEFAULT_IP and the default port DEFAULT_PORT.

See Also:
DEFAULT_PORT, DEFAULT_IP
Method Detail

getAileron

public Signal getAileron()
Returns a Signal object that provides access to the aileron data. Usually the signal is linked to another signal via the EventListener mechanism. Like that the aileron data is for example sent from a joystick to FlightGear.
The signal value sent to FG ranges form -1 to + 1.

Returns:
the aileron signal

getElevator

public Signal getElevator()
Returns a Signal object that provides access to the elevator data. Usually the signal is linked to another signal via the EventListener mechanism. Like that the elevator data is for example sent from a joystick to FlightGear.
The signal value sent to FG ranges form -1 to + 1.

Returns:
the elevator signal

getRudder

public Signal getRudder()
Returns a Signal object that provides access to the rudder data. Usually the signal is linked to another signal via the EventListener mechanism. Like that the rudder data is for example sent from a joystick to FlightGear.
The signal value sent to FG ranges form -1 to + 1.

Returns:
the rudder signal

getThrottle

public Signal getThrottle()
Returns a Signal object that provides access to the throttle data. Usually the signal is linked to another signal via the EventListener mechanism. Like that the throttle data is for example sent from a joystick to FlightGear.
The signal value sent to FG ranges form 0 to + 1.

Returns:
the throttle signal

setDebug

public void setDebug(java.lang.Boolean debug)
Sets the debugging flag which determines if the debugging informations should be printed to the console. This is for debugging purpose only.

Parameters:
debug - set to true if additional debugging information should be printed

setUpdateFrequency

public void setUpdateFrequency(float updateFrequency)
Sets the update frequency for the FlightGearSender. The default update frequency is set to 3.0fHz.

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()
Shuts this sender down.