Package jmri.jmrix
Class AbstractNetworkPortController
java.lang.Object
jmri.jmrix.AbstractPortController
jmri.jmrix.AbstractNetworkPortController
- All Implemented Interfaces:
NetworkPortAdapter,PortAdapter
- Direct Known Subclasses:
BiDiBNetworkPortController,DCCppNetworkPortController,EasyDccNetworkPortController,EcosPortController,JMRIClientPortController,LnNetworkPortController,MarklinPortController,MqttAdapter,NceNetworkPortController,NetworkDriverAdapter,RfidNetworkPortController,SerialNetworkPortAdapter,SRCPPortController,XNetNetworkPortController,Z21Adapter
public abstract class AbstractNetworkPortController
extends AbstractPortController
implements NetworkPortAdapter
Enables basic setup of a network client interface for a jmrix implementation.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class jmri.jmrix.AbstractPortController
AbstractPortController.Option -
Field Summary
FieldsFields inherited from class jmri.jmrix.AbstractPortController
allowConnectionRecovery, manufacturerName, opened, option1Name, option2Name, option3Name, option4Name, options, reconnectinterval, reconnectMaxAttempts, reconnectMaxInterval -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractNetworkPortController(SystemConnectionMemo connectionMemo) -
Method Summary
Modifier and TypeMethodDescriptionvoidprotected voidAbstract class for controllers to close the connection.voidconnect()Open the connection.voidConnects to the end device using a hostname/ip address and portprotected intReturn the connection name for the network connection in the format of ip_address:portprotected StringGet the InputStream from the port.booleanGet the outputStream to the port.intgetPort()protected voidreconnectFromLoop(int retryNum) Abstract class for ports to attempt a single re-connection attempt.protected voidCustomizable method to deal with resetting a system connection after a successful recovery of a connection.voidsetAdvertisementName(String AdName) protected voidsetConnectionTimeout(int t) protected voidRemember the associated IP Address This is used internally for mDNS configuration.voidRemember the associated host name.voidsetMdnsConfigure(boolean autoconfig) voidsetPort(int p) Remember the associated port number.voidRemember the associated port name.voidsetServiceType(String ServiceType) Methods inherited from class jmri.jmrix.AbstractPortController
configureOption1, configureOption2, configureOption3, configureOption4, dispose, getDisabled, getManufacturer, getOption1Name, getOption2Name, getOption3Name, getOption4Name, getOptionChoices, getOptionDisplayName, getOptions, getOptionState, getReconnectMaxAttempts, getReconnectMaxInterval, getSystemConnectionMemo, getSystemPrefix, getUserName, isDirty, isOptionAdvanced, isOptionTypePassword, isOptionTypeText, isRestartRequired, purgeStream, reconnect, recover, safeSleep, setClosed, setDisabled, setManufacturer, setOpened, setOptionState, setReconnectMaxAttempts, setReconnectMaxInterval, setSystemConnectionMemo, setSystemPrefix, setUserName, statusMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface jmri.jmrix.NetworkPortAdapter
configure, statusMethods inherited from interface jmri.jmrix.PortAdapter
configureOption1, configureOption2, configureOption3, configureOption4, dispose, getDisabled, getManufacturer, getOption1Name, getOption2Name, getOption3Name, getOption4Name, getOptionChoices, getOptionDisplayName, getOptions, getOptionState, getReconnectMaxAttempts, getReconnectMaxInterval, getSystemConnectionMemo, getSystemPrefix, getUserName, isDirty, isOptionAdvanced, isOptionTypePassword, isOptionTypeText, isRestartRequired, recover, setDisabled, setManufacturer, setOptionState, setReconnectMaxAttempts, setReconnectMaxInterval, setSystemConnectionMemo, setSystemPrefix, setUserName
-
Field Details
-
m_HostName
-
m_port
-
socketConn
-
connTimeout
-
-
Constructor Details
-
AbstractNetworkPortController
-
-
Method Details
-
connect
Description copied from interface:NetworkPortAdapterConnects to the end device using a hostname/ip address and port- Specified by:
connectin interfaceNetworkPortAdapter- Parameters:
host- hostname / ip address.port- network port.- Throws:
IOException- on connection error.
-
connect
Description copied from interface:PortAdapterOpen the connection.- Specified by:
connectin interfacePortAdapter- Throws:
IOException- if unable to connect
-
setHostName
Remember the associated host name.- Specified by:
setHostNamein interfaceNetworkPortAdapter- Parameters:
s- the host name; if empty will use MDNS to get host name
-
getHostName
- Specified by:
getHostNamein interfaceNetworkPortAdapter
-
setHostAddress
Remember the associated IP Address This is used internally for mDNS configuration. Public access to the IP address is through the hostname field.- Parameters:
s- the address; if empty, will use the host name
-
getHostAddress
-
setPort
Remember the associated port number.- Specified by:
setPortin interfaceNetworkPortAdapter- Parameters:
p- the port
-
setPort
Description copied from interface:NetworkPortAdapterRemember the associated port name.- Specified by:
setPortin interfaceNetworkPortAdapter- Parameters:
p- port name.
-
getPort
- Specified by:
getPortin interfaceNetworkPortAdapter
-
getCurrentPortName
Return the connection name for the network connection in the format of ip_address:port- Specified by:
getCurrentPortNamein interfaceNetworkPortAdapter- Specified by:
getCurrentPortNamein interfacePortAdapter- Specified by:
getCurrentPortNamein classAbstractPortController- Returns:
- ip_address:port
-
setMdnsConfigure
- Specified by:
setMdnsConfigurein interfaceNetworkPortAdapter
-
getMdnsConfigure
- Specified by:
getMdnsConfigurein interfaceNetworkPortAdapter
-
autoConfigure
- Specified by:
autoConfigurein interfaceNetworkPortAdapter
-
setAdvertisementName
- Specified by:
setAdvertisementNamein interfaceNetworkPortAdapter
-
getAdvertisementName
- Specified by:
getAdvertisementNamein interfaceNetworkPortAdapter
-
setServiceType
- Specified by:
setServiceTypein interfaceNetworkPortAdapter
-
getServiceType
- Specified by:
getServiceTypein interfaceNetworkPortAdapter
-
getInputStream
Get the InputStream from the port.- Specified by:
getInputStreamin interfacePortAdapter- Specified by:
getInputStreamin classAbstractPortController- Returns:
- the InputStream from the port
-
getOutputStream
Get the outputStream to the port.- Specified by:
getOutputStreamin interfacePortAdapter- Specified by:
getOutputStreamin classAbstractPortController- Returns:
- the outputStream to the port
-
closeConnection
Abstract class for controllers to close the connection. Called prior to any re-connection attempts.- Overrides:
closeConnectionin classAbstractPortController
-
resetupConnection
Customizable method to deal with resetting a system connection after a successful recovery of a connection.- Overrides:
resetupConnectionin classAbstractPortController
-
reconnectFromLoop
Abstract class for ports to attempt a single re-connection attempt. Called from within main reconnect thread.- Overrides:
reconnectFromLoopin classAbstractPortController- Parameters:
retryNum- Reconnection attempt number.
-
setConnectionTimeout
-
getConnectionTimeout
-