org.ka2ddo.yaac.io
Class PortManager

java.lang.Object
  extended by org.ka2ddo.yaac.io.PortManager
Direct Known Subclasses:
Transmitter

public class PortManager
extends java.lang.Object

This class manages the PortConnectors opened by YAAC.


Constructor Summary
protected PortManager()
           
 
Method Summary
static void addPortMgmtListener(PortMgmtListener l)
          Register a listener to be informed when PortConnectors are created or deleted.
static void addPortStatusListener(PortStatusListener l)
          Register a listener to be informed when PortConnectors are opened or closed.
static void firePortClosed(PortConnector p)
          Service method for PortConnectors to call when they are closed, so PortStatusListeners can be notified of the status change.
static void firePortCreated(PortConnector p)
          Service method for PortConnectors to call when they are added to the operational configuration, so PortMgmtListeners can be notified of the status change.
static void firePortDeleted(PortConnector p)
          Service method for PortConnectors to call when they are removed from the operational configuration, so PortMgmtListeners can be notified of the status change.
static void firePortOpened(PortConnector p)
          Service method for PortConnectors to call when they are opened, so PortStatusListeners can be notified of the status change.
static java.lang.String getCallsign()
          Get the "best" callsign for this station, based on the callsigns associated with the open ports.
static PortConnector getConnector(PortConfig portConfig)
          Return the PortConnector associated with a specific PortConfig.
static int getNextAvailablePortNumber()
          Find the next port number that is not currently in use.
static java.util.ArrayList<PortConnector> getPortList()
          Get all the currently defined PortConnectors, whether or not they are open.
static PortConnector getPreferredConnector(int capMask)
          Get the first PortConnector defined in the location station which has the requested capability.
static void removePortMgmtListener(PortMgmtListener l)
          Unregister a PortMgmtListener; it will no longer be informed when ports are created or deleted.
static void removePortStatusListener(PortStatusListener l)
          Unregister a PortStatusListener; it will no longer be informed when ports are opened or closed.
static void setSuggestedLocalCallsign(java.lang.String suggestedLocalCallsign)
          Set the suggested callsign for the ports.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PortManager

protected PortManager()
Method Detail

getPortList

public static java.util.ArrayList<PortConnector> getPortList()
Get all the currently defined PortConnectors, whether or not they are open.

Returns:
ArrayList of PortConnectors

getPreferredConnector

public static PortConnector getPreferredConnector(int capMask)
Get the first PortConnector defined in the location station which has the requested capability.

Parameters:
capMask - int bitmask of capabilities to test for
Returns:
PortConnector with the specified capability, or null if no open PortConnector with the specified capabilities exist
See Also:
Connector.CAP_FULL_DUPLEX, Connector.CAP_GPS_DATA, Connector.CAP_IGATE, Connector.CAP_OPENTRAC, Connector.CAP_RCV_PACKET_DATA, Connector.CAP_RF, Connector.CAP_WAYPOINT_SENDER, Connector.CAP_WEATHER, Connector.CAP_XMT_PACKET_DATA

getConnector

public static PortConnector getConnector(PortConfig portConfig)
Return the PortConnector associated with a specific PortConfig.

Parameters:
portConfig - PortConfig of PortConnector to be located
Returns:
PortConnector matching the PortConfig, or null if no match

getNextAvailablePortNumber

public static int getNextAvailablePortNumber()
Find the next port number that is not currently in use.

Returns:
next available positive port number

addPortStatusListener

public static void addPortStatusListener(PortStatusListener l)
Register a listener to be informed when PortConnectors are opened or closed.

Parameters:
l - PortStatusListener instance to register

removePortStatusListener

public static void removePortStatusListener(PortStatusListener l)
Unregister a PortStatusListener; it will no longer be informed when ports are opened or closed.

Parameters:
l - PortStatusListener to unregister

firePortOpened

public static void firePortOpened(PortConnector p)
Service method for PortConnectors to call when they are opened, so PortStatusListeners can be notified of the status change. Note this deliberately does not use iterators, so it can't fail due to ConcurrentModificationExceptions.

Parameters:
p - PortConnector which has been opened
See Also:
PortConnector.configure(org.ka2ddo.yaac.io.PortConfig)

firePortClosed

public static void firePortClosed(PortConnector p)
Service method for PortConnectors to call when they are closed, so PortStatusListeners can be notified of the status change. Note this deliberately does not use iterators, so it can't fail due to ConcurrentModificationExceptions.

Parameters:
p - PortConnector which has been closed
See Also:
PortConnector.configure(org.ka2ddo.yaac.io.PortConfig), Connector.close()

addPortMgmtListener

public static void addPortMgmtListener(PortMgmtListener l)
Register a listener to be informed when PortConnectors are created or deleted.

Parameters:
l - PortMgmtListener instance to register

removePortMgmtListener

public static void removePortMgmtListener(PortMgmtListener l)
Unregister a PortMgmtListener; it will no longer be informed when ports are created or deleted.

Parameters:
l - PortMgmtListener to unregister

firePortCreated

public static void firePortCreated(PortConnector p)
Service method for PortConnectors to call when they are added to the operational configuration, so PortMgmtListeners can be notified of the status change. Note this deliberately does not use iterators, so it can't fail due to ConcurrentModificationExceptions.

Parameters:
p - PortConnector which has been added
See Also:
PortConnector.configure(org.ka2ddo.yaac.io.PortConfig), Connector.close()

firePortDeleted

public static void firePortDeleted(PortConnector p)
Service method for PortConnectors to call when they are removed from the operational configuration, so PortMgmtListeners can be notified of the status change. Note this deliberately does not use iterators, so it can't fail due to ConcurrentModificationExceptions.

Parameters:
p - PortConnector which has been removed
See Also:
PortConnector.configure(org.ka2ddo.yaac.io.PortConfig), Connector.close()

setSuggestedLocalCallsign

public static void setSuggestedLocalCallsign(java.lang.String suggestedLocalCallsign)
Set the suggested callsign for the ports. Used by the configuration wizard to hint when ports are created.

Parameters:
suggestedLocalCallsign - suggested port callsign

getCallsign

public static java.lang.String getCallsign()
Get the "best" callsign for this station, based on the callsigns associated with the open ports.

Returns:
callsign String, or null if nothing available