Class PortManager

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

public class PortManager extends Object
This singleton class manages the PortConnectors opened by YAAC.
Author:
Andrew Pavlin, KA2DDO
  • Method Details

    • getPortList

      public static 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 all the requested capabilities.
      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:
    • getMatchingConnector

      public static PortConnector getMatchingConnector(int capMask)
      Get the first PortConnector defined in the location station which has all the requested capabilities, regardless of whether it is currently open.
      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:
    • 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:
    • 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:
    • firePortStatusChanged

      public static void firePortStatusChanged(PortConnector p)
      Service method for PortConnectors to call when their capabilities change, so PortExtendedStatusListeners 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:
    • 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:
    • 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:
    • setSuggestedLocalCallsign

      public static void setSuggestedLocalCallsign(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 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
    • createPortIfNonexistent

      public static void createPortIfNonexistent(String portParams)
      Check the existing ports to see if a port matching the specified parameter string exists, and create a new one if a match is not found.
      Parameters:
      portParams - String of port parameters in PortConfig.generatePrefsString() format
    • getTuneIfc

      public static TuneIfc getTuneIfc()
      Get the current implementation of the TuneIfc.
      Returns:
      current implementation, or null if no implementation.
    • setTuneIfc

      public static void setTuneIfc(TuneIfc tuneIfc)
      Set the implementation that can provide the TuneIfc service for the TUNE button on the radio view pane.
      Parameters:
      tuneIfc - TuneIfc implementation to use, or null to disable tuning ability