Class PortConnector
- Direct Known Subclasses:
AbstractGpsConnector
,ExternalMessageSourceConnector
,GpsdConnector
,SerialWeatherConnector
,TNCConnector
,WxnowTxtConnector
To support the dynamically plugin-built support for multiple port types, each non-abstract PortConnector subclass must define the following public static final fields:
- TYPE_NAME - a String specifying the internal type name of the class (stored in the
PortConfig.portType
field of PortConfig records) - CONFIG_GUI - a wildcarded fully-qualified String name of a Class which implements an editor for the configuration parameters for the PortConnector subclass
To support configuration transfer, the subclass must also define the following public static final fields:
- BLANK_FIELDS - a Set of the
PortConfig.Fields
enums for the fields that should not be copied for this port driver - REQ_FIELDS - a Map of the
PortConfig.Fields
enums for the fields that must be defined for this port driver, mapping toPortConfig.RequireHints
structures containing the ResourceBundle keys for their UI prompt strings if they are undefined
If a field is both required and blanked, the configuration import code will prompt for the missing field.
To support the -createport command-line option, a port type whose port editor class changes the defaults in the PortConfig.Cfg object for a new port should have those changes performed by a public static method named fillinConfigDefaults(PortConfig.Cfg) in the PortConnector subclass, so that the command-line port creation logic can fill in those defaults to deal with new port specifications that are not complete.
- Author:
- Andrew Pavlin, KA2DDO
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
This enum is used to select which sets of statistics should be returned.Nested classes/interfaces inherited from class org.ka2ddo.ax25.Connector
Connector.ConnectorType, Connector.PortStats
-
Field Summary
Modifier and TypeFieldDescriptionThe port type-specific configuration associated with this PortConnector.The port configuration associated with this PortConnector.Fields inherited from class org.ka2ddo.ax25.Connector
CAP_ADSB, CAP_FAST_RF_9600, CAP_FULL_DUPLEX, CAP_GPS_DATA, CAP_HF, CAP_IGATE, CAP_KENWOOD_CMD, CAP_OPENTRAC, CAP_RAW_AX25, CAP_RCV_PACKET_DATA, CAP_RF, CAP_SUBCLIENT, CAP_WAYPOINT_SENDER, CAP_WEATHER, CAP_XMT_PACKET_DATA, stats
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Register a listener for port transmission and/or reception events.abstract void
configure
(PortConfig cfg) Update the configuration of the connector to match the updated setup.static PortConnector
createPort
(PortConfig cfg) Instantiate a PortConnector object of the type specified in the configuration object.static void
Fill in the port-type-specific defaults for a port configuration.void
Report to interested listeners that the port has failed for some reason.void
fireReceiving
(boolean isReceiving) Report to interested listeners that the port has started or stopped receiving.protected void
fireTransmitting
(boolean isTransmitting) Report to interested listeners that the port has started or stopped transmitting.int
Get the bit transmission rate on this port.Get all the categories of statistics currently collected on this port.Get the current configuration object for this PortConnector.static Class<? extends PortConnector>
getPortConnectorClass
(String portTypeName) Get the class corresponding to a particular port type name.protected static Timer
Get the Timer for use by PortConnectors to handle inactivity tests.Get a particular category of statistics for this port.static Collection<Class<? extends PortConnector>>
Get all the concrete subclasses of PortConnector currently registered in YAAC for which instances can be created and configured.Get all the registered PortConnector names that should be displayed in the port configuration dialog as a port type.static void
registerPortConnectorType
(String typeName, Class<? extends PortConnector> pcClazz) Add a new subclass of PortConnector to the supported map of PortConnector types.void
Unregister a listener so it no longer is informed of transmission and reception events.void
setPortConfig
(PortConfig portConfig) Store the configuration associated with this PortConnector.Methods inherited from class org.ka2ddo.ax25.Connector
addFrameListener, close, finalize, fireConsumeFrame, fireConsumeFrame, getCallsign, getCapabilities, getStats, getType, hasCapability, isOpen, removeFrameListener
-
Field Details
-
portConfig
The port configuration associated with this PortConnector. -
currentCfg
The port type-specific configuration associated with this PortConnector.
-
-
Constructor Details
-
PortConnector
protected PortConnector()Create a PortConnector.
-
-
Method Details
-
getStats
Get a particular category of statistics for this port. Callers who only wish to read statistics should ensure the statistics category already exists by using thegetCollectedStatsTypes()
method, to prevent creation of spurious statistics with zero counts.- Parameters:
type
- PortStatsType to obtain- Returns:
- PortStats object for the category of statistics on this port.
-
getCollectedStatsTypes
Get all the categories of statistics currently collected on this port.- Returns:
- Set of PortStatsType enums in use for the port
-
getPortConnectorInactivityTimer
Get the Timer for use by PortConnectors to handle inactivity tests.- Returns:
- Timer dedicated to PortConnector timeout checks
-
registerPortConnectorType
public static void registerPortConnectorType(String typeName, Class<? extends PortConnector> pcClazz) Add a new subclass of PortConnector to the supported map of PortConnector types. Note that putting a new Class object with the same typeName will replace any existing driver for that type name.- Parameters:
typeName
- String name of PortConnector subclasspcClazz
- the Class object for instantiating objects of this type
-
portTypeNames
Get all the registered PortConnector names that should be displayed in the port configuration dialog as a port type.- Returns:
- Set of String names to be displayed as port driver types.
-
portConnectorClasses
Get all the concrete subclasses of PortConnector currently registered in YAAC for which instances can be created and configured.- Returns:
- Collection of subclasses of PortConnector
-
getPortConnectorClass
Get the class corresponding to a particular port type name.- Parameters:
portTypeName
- String name of port connector type- Returns:
- Class providing that port connector type, or null if no match
-
addPortEventListener
Register a listener for port transmission and/or reception events.- Parameters:
l
- PortEventListener to register
-
removePortEventListener
Unregister a listener so it no longer is informed of transmission and reception events.- Parameters:
l
- PortEventListener to unregister
-
fireTransmitting
protected void fireTransmitting(boolean isTransmitting) Report to interested listeners that the port has started or stopped transmitting.- Parameters:
isTransmitting
- boolean true if transmission has started, false if stopped
-
fireReceiving
public void fireReceiving(boolean isReceiving) Report to interested listeners that the port has started or stopped receiving.- Parameters:
isReceiving
- boolean true if reception has started, false if stopped
-
fireFailed
public void fireFailed()Report to interested listeners that the port has failed for some reason. -
fillinConfigDefaultsForType
public static void fillinConfigDefaultsForType(PortConfig cfg) throws UnknownServiceException, IOException Fill in the port-type-specific defaults for a port configuration.- Parameters:
cfg
- PortConfig whose default values are to be adjusted- Throws:
UnknownServiceException
- if the port type is unknownIOException
- if some other problem occurs trying to fill in the defaults
-
createPort
Instantiate a PortConnector object of the type specified in the configuration object.- Parameters:
cfg
- PortConfig object identifying what type of port to create- Returns:
- instantiated but not configured PortConnector subclass object
- Throws:
IOException
- if port could not be instantiatedUnknownServiceException
- if port type not recognized
-
configure
Update the configuration of the connector to match the updated setup.- Parameters:
cfg
- PortConfig defining new port settings- Throws:
IOException
- if interface changes could not be appliedIllegalArgumentException
- if type information is invalid for changing the settings of this PortConnector
-
getPortConfig
Get the current configuration object for this PortConnector. Note that the caller should not modify this data structure; if the port parameters are to be changed, the PortConnector should be closed and then configured with an updated PortConfig object.- Returns:
- PortConfig for this PortConnector (may return null for a non-configured port)
- See Also:
-
setPortConfig
Store the configuration associated with this PortConnector. The PortConfig is assumed to be of the correct type here, such that the current() method will return the appropriate type-specific configuration data.- Parameters:
portConfig
- PortConfig matching the PortConnector subclass's type
-
getBitRate
public int getBitRate()Get the bit transmission rate on this port. This abstract superclass does not know what the data rate is, and expects subclasses to override this method.- Returns:
- bit rate in bits per second (baud)
-