Package org.ka2ddo.yaac.io
Class PortManager
java.lang.Object
org.ka2ddo.yaac.io.PortManager
- Direct Known Subclasses:
Transmitter
This singleton class manages the PortConnectors opened by YAAC.
- Author:
- Andrew Pavlin, KA2DDO
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
Register a listener to be informed when PortConnectors are created or deleted.static void
Register a listener to be informed when PortConnectors are opened or closed.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.static void
Service method for PortConnectors to call when they are closed, so PortStatusListeners can be notified of the status change.static void
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
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
Service method for PortConnectors to call when they are opened, so PortStatusListeners can be notified of the status change.static void
Service method for PortConnectors to call when their capabilities change, so PortExtendedStatusListeners can be notified of the status change.static String
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 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.static int
Find the next port number that is not currently in use.static ArrayList<PortConnector>
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 all the requested capabilities.static TuneIfc
Get the current implementation of the TuneIfc.static void
Unregister a PortMgmtListener; it will no longer be informed when ports are created or deleted.static void
Unregister a PortStatusListener; it will no longer be informed when ports are opened or closed.static void
setSuggestedLocalCallsign
(String suggestedLocalCallsign) Set the suggested callsign for the ports.static void
setTuneIfc
(TuneIfc tuneIfc) Set the implementation that can provide the TuneIfc service for the TUNE button on the radio view pane.
-
Method Details
-
getPortList
Get all the currently defined PortConnectors, whether or not they are open.- Returns:
- ArrayList of PortConnectors
-
getPreferredConnector
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
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
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
Register a listener to be informed when PortConnectors are opened or closed.- Parameters:
l
- PortStatusListener instance to register
-
removePortStatusListener
Unregister a PortStatusListener; it will no longer be informed when ports are opened or closed.- Parameters:
l
- PortStatusListener to unregister
-
firePortOpened
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
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
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
Register a listener to be informed when PortConnectors are created or deleted.- Parameters:
l
- PortMgmtListener instance to register
-
removePortMgmtListener
Unregister a PortMgmtListener; it will no longer be informed when ports are created or deleted.- Parameters:
l
- PortMgmtListener to unregister
-
firePortCreated
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
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
Set the suggested callsign for the ports. Used by the configuration wizard to hint when ports are created.- Parameters:
suggestedLocalCallsign
- suggested port callsign
-
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
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 inPortConfig.generatePrefsString()
format
-
getTuneIfc
Get the current implementation of the TuneIfc.- Returns:
- current implementation, or null if no implementation.
-
setTuneIfc
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
-