faa.tg.adsb
Class AdsbMgr

java.lang.Object
  extended by faa.tg.adsb.AdsbMgr
All Implemented Interfaces:
SimDataListener, OptionallyLoaded

public class AdsbMgr
extends java.lang.Object
implements SimDataListener, OptionallyLoaded

 AdsbMgr manages the transmission of ADS-B (Automatic Dependent
 Surveillance--Broadcast) datalink messages from simulated aircraft,
 containing aircraft state information, to listeners that register to
 receive it. If an aircraft is received that is ADS-B equipped and it has
 been long enough since the last ADS-B message was sent (per message type),
 then an ADS-B message is created for it and sent to the registered
 listeners. 

This will act as a Singleton in nearly all cases, because the standard usage will be to use the TransmittedSimData's address and port (i.e., SimMessageCenter.MULTICAST_ADDR and SimMessageCenter.SIM_DATA_PORT) with the Scenario's base port offset.

AdsBMsgs can be sent to TransmittedSimDataListeners and Broadcasters. See the source: AdsbMgr.java

Version:
$Id: AdsbMgr.java,v 3.6 2008/12/31 23:45:08 lykensj Exp $
Author:
Dana N. Whicker, TGF/Titan Corp, Mar 2 2004

Field Summary
private static java.util.ArrayList<java.lang.String> acids
           
static java.lang.String ADS_B_EQUIP_CODES
          Contains the characters that designate ADS-B equipment: the aircraft type will be checked for an equipment code field (..."/#") to see if the equipment code is one of the characters in this string.
private  java.util.ArrayList<Broadcaster> adsbBroadcasters
          Broadcasters registered to be sent ADS-B state information.
private  java.util.ArrayList<SimDataListener> adsbListeners
          SimDataListeners registered to be sent ADS-B state information.
private static java.util.HashMap<java.lang.String,AdsbMgr> adsbMgrInstanceHash
          The AdsbMgr objects created so far: indexed by "addr:port".
private  Time adsbModeStatusDelay
          The delay between ADS-B state broadcasts.
private  Time adsbStateVectorDelay
          The delay between ADS-B state broadcasts.
private  Time adsbVelocityDelay
          The delay between ADS-B air referenced velocity broadcasts.
static java.lang.String CVS_VERSION_ID
          The CVS Version ID
private static int FIRST_PARTICIPANT_ADDR
           
private  java.util.HashMap<java.lang.String,Time> lastModeStatusTransmit
           
private  java.util.HashMap<java.lang.String,SimulationTime> lastStateVectorTransmit
           
private  java.util.HashMap<java.lang.String,SimulationTime> lastVelocityDelayTransmit
           
private  SimDataTransmitter simDataSource
          Source of TransmittedSimData to get AircraftInfo from.
 
Constructor Summary
private AdsbMgr()
          Constructs a new AdsbMgr, creates a new SimDataTransmitter to listen for aircraft data on.
private AdsbMgr(SimDataTransmitter simDataSource)
          Constructs an AdsbMgr getting aircraft data from a previously created SimDataTransmitter.
  AdsbMgr(UdpMulticaster mcaster)
          Constructs a new AdsbMgr that adds a specified broadcaster so that an AdsbMgr that immediately starts sending messages to a multicast InetAddress can be started by an OptionalClasses.xml entry.
 
Method Summary
 void addBroadcaster(Broadcaster listener)
          Adds Broadcaster to list of those that receive AdsBState objects.
 void addListener(SimDataListener listener)
          Adds SimDataListener to list of those that receive AdsBState objects.
protected static byte[] convertIntToParticipantAddress(int pAddrInt)
          Converts integer back to the ADS-B participant address (first byte is ignored).
static int convertParticipantAddressToInt(byte[] pAddr)
          Converts an ADS-B participant address to a integer for convenience.
private  void fireAdsBMsg(AdsbMsg adsbMsg)
          Sends an ADS-B message to all registered listeners.
static java.lang.String getAcid(byte[] pAddr)
          Returns the ACID for the aircraft that corresponds to the specified 24-bit (3 byte) ADS-B participant address; or "NONE" if the aircraft address is 0.
 Time getAdsbModeStatusDelay()
          Gets the interval to send the AdsbModeStatus messages at.
 Time getAdsbStateVectorDelay()
          Gets the interval to send the AdsbVector messages at.
 Time getAdsbVelocityDelay()
          Gets the interval to send the AdsbAirRefVelocity messages at.
static AdsbMgr getInstance(PortOffset portOffset)
          Returns an AdsbMgr associated with a SimDataTransmitter for the given port offset using the standard simulation address and port.
static AdsbMgr getInstance(SimDataTransmitter sdSource)
          Returns an AdsbMgr associated with the given SimDataTransmitter.
static AdsbMgr getInstance(java.lang.String addr, Port port)
          Returns an AdsbMgr associated with a SimDataTransmitter for the given address and port.
static byte[] getParticipantAddr(java.lang.String acid)
          Returns the 24-bit ADS-B participant address for the ACID as a 3-byte array.
 SimDataTransmitter getSimDataSource()
           
 void handleObject(TransmittedSimData simData)
          Needed to implement SimDataListener: if the object received is AircraftInformation and it is appropriate to send the aircraft's ADS-B state information, then the AdsbState is both sent to the SimDataListeners registered and sent out as a DatagramPacket using the broadcaster that was specified.
static void main(java.lang.String[] args)
          Starts an independent AdsbMgr sending ADS-B messages to a UdpMulticaster at a specified address and port number; usage options are provided when no parameters are specified.
 void removeBroadcaster(Broadcaster listener)
          Removes a Broadcaster from list of receivers of AdsBState objects.
 void removeListener(SimDataListener listener)
          Removes a SimDataListener from list of receivers of AdsBState objects.
 void setAdsbModeStatusDelay(Time adsbModeStatusDelay)
          Sets the interval to send the AdsbModeStatus messages at.
 void setAdsbStateVectorDelay(Time adsbStateVectorDelay)
          Sets the interval to send the AdsbVector messages at.
 void setAdsbVelocityDelay(Time adsbVelocityDelay)
          Sets the interval to send the AdsbAirRefVelocity messages at.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CVS_VERSION_ID

public static final java.lang.String CVS_VERSION_ID
The CVS Version ID

See Also:
Constant Field Values

ADS_B_EQUIP_CODES

public static final java.lang.String ADS_B_EQUIP_CODES
Contains the characters that designate ADS-B equipment: the aircraft type will be checked for an equipment code field (..."/#") to see if the equipment code is one of the characters in this string.

See Also:
Constant Field Values

adsbModeStatusDelay

private Time adsbModeStatusDelay
The delay between ADS-B state broadcasts.


adsbStateVectorDelay

private Time adsbStateVectorDelay
The delay between ADS-B state broadcasts.


adsbVelocityDelay

private Time adsbVelocityDelay
The delay between ADS-B air referenced velocity broadcasts.


FIRST_PARTICIPANT_ADDR

private static final int FIRST_PARTICIPANT_ADDR
See Also:
Constant Field Values

acids

private static java.util.ArrayList<java.lang.String> acids

lastModeStatusTransmit

private java.util.HashMap<java.lang.String,Time> lastModeStatusTransmit

lastStateVectorTransmit

private java.util.HashMap<java.lang.String,SimulationTime> lastStateVectorTransmit

lastVelocityDelayTransmit

private java.util.HashMap<java.lang.String,SimulationTime> lastVelocityDelayTransmit

simDataSource

private SimDataTransmitter simDataSource
Source of TransmittedSimData to get AircraftInfo from.


adsbBroadcasters

private java.util.ArrayList<Broadcaster> adsbBroadcasters
Broadcasters registered to be sent ADS-B state information.


adsbListeners

private java.util.ArrayList<SimDataListener> adsbListeners
SimDataListeners registered to be sent ADS-B state information.


adsbMgrInstanceHash

private static java.util.HashMap<java.lang.String,AdsbMgr> adsbMgrInstanceHash
The AdsbMgr objects created so far: indexed by "addr:port".

Constructor Detail

AdsbMgr

public AdsbMgr(UdpMulticaster mcaster)
Constructs a new AdsbMgr that adds a specified broadcaster so that an AdsbMgr that immediately starts sending messages to a multicast InetAddress can be started by an OptionalClasses.xml entry. NOTE: individual constructors would be needed for any other subclasses of Broadcaster to allow optional loading of the subclass, since reflect package does not recognize superclasses when trying to find constructors. (paraphrase of bethl)

Parameters:
mcaster - A UDP multicaster to send ADS-B state packets to.
Throws:
java.lang.NullPointerException - If port parameter is null.

AdsbMgr

private AdsbMgr()
Constructs a new AdsbMgr, creates a new SimDataTransmitter to listen for aircraft data on.


AdsbMgr

private AdsbMgr(SimDataTransmitter simDataSource)
Constructs an AdsbMgr getting aircraft data from a previously created SimDataTransmitter.

Parameters:
simDataSource - Transmitter sending TGF aircraft data packets.
Method Detail

convertParticipantAddressToInt

public static int convertParticipantAddressToInt(byte[] pAddr)
                                          throws java.lang.IllegalArgumentException
Converts an ADS-B participant address to a integer for convenience.

Parameters:
pAddr - A 3-byte ADS-B participant address identifying an aircraft.
Returns:
Returns an int containing the participant address in its final three bytes (preceded by 0x00).
Throws:
java.lang.IllegalArgumentException - If parameter array is not 3 bytes.

convertIntToParticipantAddress

protected static byte[] convertIntToParticipantAddress(int pAddrInt)
Converts integer back to the ADS-B participant address (first byte is ignored).

Parameters:
pAddrInt - An integer containing the participant address in its final three bytes.
Returns:
Returns 3-byte ADS-B participant address identifying an ac.

getAcid

public static java.lang.String getAcid(byte[] pAddr)
Returns the ACID for the aircraft that corresponds to the specified 24-bit (3 byte) ADS-B participant address; or "NONE" if the aircraft address is 0.
 NOTE: the participant address must have been generated by an
       AdsbMgr from the same Java VM or this method will
       return an invalid aircraft ID or throw an IllegalArgumentException.
 

Parameters:
pAddr - The participant address identifying an aircraft.
Returns:
Returns ACID of the aircraft (as a String) that the participant address IDs.
Throws:
java.lang.IllegalArgumentException - Participant addr array is not 3 bytes.
java.lang.IndexOutOfBoundsException - Invalid participant address with no corresponding aircraft.

getParticipantAddr

public static byte[] getParticipantAddr(java.lang.String acid)
Returns the 24-bit ADS-B participant address for the ACID as a 3-byte array. NOTE: this does not return an ICAO Mode S ID, since it does not seem necessary to calculate it.

Parameters:
acid - The aircraft to get the participant address for.
Returns:
Returns the participant address identifier.

getInstance

public static AdsbMgr getInstance(PortOffset portOffset)
Returns an AdsbMgr associated with a SimDataTransmitter for the given port offset using the standard simulation address and port. Creates a new AdsbMgr if this manager has no AdsbMgr for the "address:port" of this SimDataTransmitter; otherwise, returns a previously created AdsbMgr with a SimDataTransmitter matching the "address:port".

Parameters:
portOffset - The port offset to connect to the server on.
Returns:
Returns a AdsbMgr with an equivalent SimDataTransmitter.

getInstance

public static AdsbMgr getInstance(java.lang.String addr,
                                  Port port)
Returns an AdsbMgr associated with a SimDataTransmitter for the given address and port. Creates a new AdsbMgr if this manager has no AdsbMgr for the "address:port" of this SimDataTransmitter; otherwise, returns a previously created AdsbMgr with a SimDataTransmitter matching the "address:port".

Parameters:
addr - Multicast address to receive data packets from.
port - The port to connect to the server on.
Returns:
Returns a AdsbMgr with an equivalent SimDataTransmitter.

getInstance

public static AdsbMgr getInstance(SimDataTransmitter sdSource)
Returns an AdsbMgr associated with the given SimDataTransmitter. Creates a new AdsbMgr if this manager has no AdsbMgr for the "address:port" of this SimDataTransmitter; otherwise, returns a previously created AdsbMgr with its own SimDataTransmitter matching the "address:port".

Parameters:
sdSource - SimDataTransmitter sending TGF aircraft data packets.
Returns:
Returns a AdsbMgr with an equivalent SimDataTransmitter.

getSimDataSource

public SimDataTransmitter getSimDataSource()
Returns:
Returns the simDataSource so it can be reused.

addListener

public void addListener(SimDataListener listener)
Adds SimDataListener to list of those that receive AdsBState objects.

Parameters:
listener - Listener registering for ADS-B state information.

removeListener

public void removeListener(SimDataListener listener)
Removes a SimDataListener from list of receivers of AdsBState objects.

Parameters:
listener - Listener to stop receiving ADS-B state information.

addBroadcaster

public void addBroadcaster(Broadcaster listener)
Adds Broadcaster to list of those that receive AdsBState objects.

Parameters:
listener - Broadcaster registering for ADS-B state information.

removeBroadcaster

public void removeBroadcaster(Broadcaster listener)
Removes a Broadcaster from list of receivers of AdsBState objects.

Parameters:
listener - Broadcaster to stop receiving ADS-B state information.

getAdsbModeStatusDelay

public Time getAdsbModeStatusDelay()
Gets the interval to send the AdsbModeStatus messages at.


setAdsbModeStatusDelay

public void setAdsbModeStatusDelay(Time adsbModeStatusDelay)
Sets the interval to send the AdsbModeStatus messages at.


getAdsbStateVectorDelay

public Time getAdsbStateVectorDelay()
Gets the interval to send the AdsbVector messages at.


setAdsbStateVectorDelay

public void setAdsbStateVectorDelay(Time adsbStateVectorDelay)
Sets the interval to send the AdsbVector messages at.


getAdsbVelocityDelay

public Time getAdsbVelocityDelay()
Gets the interval to send the AdsbAirRefVelocity messages at.


setAdsbVelocityDelay

public void setAdsbVelocityDelay(Time adsbVelocityDelay)
Sets the interval to send the AdsbAirRefVelocity messages at.


fireAdsBMsg

private void fireAdsBMsg(AdsbMsg adsbMsg)
Sends an ADS-B message to all registered listeners.

Parameters:
adsbMsg - ADS-B information to be sent.

handleObject

public void handleObject(TransmittedSimData simData)
Needed to implement SimDataListener: if the object received is AircraftInformation and it is appropriate to send the aircraft's ADS-B state information, then the AdsbState is both sent to the SimDataListeners registered and sent out as a DatagramPacket using the broadcaster that was specified.

Specified by:
handleObject in interface SimDataListener
Parameters:
simData - The TransmittedSimData received.

main

public static void main(java.lang.String[] args)
Starts an independent AdsbMgr sending ADS-B messages to a UdpMulticaster at a specified address and port number; usage options are provided when no parameters are specified.

Calls AdsbMgr.getInstance().