jmri.jmrix
Class AbstractNetworkPortController

Show UML class diagram
java.lang.Object
  extended by jmri.jmrix.AbstractPortController
      extended by jmri.jmrix.AbstractNetworkPortController
All Implemented Interfaces:
NetworkPortAdapter, PortAdapter
Direct Known Subclasses:
EasyDccNetworkPortController, EcosPortController, JMRIClientPortController, LnNetworkPortController, MarklinPortController, NceNetworkPortController, NetworkDriverAdapter, SRCPPortController, XNetNetworkPortController

public abstract class AbstractNetworkPortController
extends AbstractPortController
implements NetworkPortAdapter

Enables basic setup of a network client interface for a jmrix implementation.

See Also:
NetworkConfigException

Nested Class Summary
(package private)  class AbstractNetworkPortController.reconnectwait
           
 
Nested classes/interfaces inherited from class jmri.jmrix.AbstractPortController
AbstractPortController.Option
 
Field Summary
protected static org.slf4j.Logger log
           
protected  String m_HostName
           
protected  int m_port
           
protected  Socket socketConn
           
 
Fields inherited from class jmri.jmrix.AbstractPortController
allowConnectionRecovery, mDisabled, mManufacturer, opened, option1Name, option2Name, option3Name, option4Name, options, reconnectinterval, retryAttempts
 
Constructor Summary
AbstractNetworkPortController()
           
 
Method Summary
 void connect()
          Open the connection
 void connect(String host, int port)
          Connects to the end device using a hostname/ip address and port
 void dispose()
           
 String getCurrentPortName()
          Returns the connection name for the network connection in the format of ip_address:port
 String getHostName()
           
 DataInputStream getInputStream()
           
 DataOutputStream getOutputStream()
           
 int getPort()
           
 SystemConnectionMemo getSystemConnectionMemo()
           
 void reconnect()
          Attempts to reconnect to a failed Server
 void recover()
          This is called when a connection is initially lost.
protected  void resetupConnection()
          Customizable method to deal with resetting a system connection after a sucessful recovery of a connection.
 void setDisabled(boolean disabled)
          Sets whether the connection is disabled
 void setHostName(String s)
          Remember the associated host name
 void setPort(int p)
          Remeber the associated port number
 void setPort(String p)
          Remember the associated port name
 boolean status()
          Query the status of this connection.
 
Methods inherited from class jmri.jmrix.AbstractPortController
configureOption1, configureOption2, configureOption3, configureOption4, getDisabled, getManufacturer, getOption1Name, getOption2Name, getOption3Name, getOption4Name, getOptionChoices, getOptionDisplayName, getOptions, getOptionState, isOptionAdvanced, safeSleep, setClosed, setManufacturer, setOpened, setOptionState
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface jmri.jmrix.NetworkPortAdapter
configure
 
Methods inherited from interface jmri.jmrix.PortAdapter
configureOption1, configureOption2, configureOption3, configureOption4, getDisabled, getManufacturer, getOption1Name, getOption2Name, getOption3Name, getOption4Name, getOptionChoices, getOptionDisplayName, getOptions, getOptionState, isOptionAdvanced, setManufacturer, setOptionState
 

Field Detail

m_HostName

protected String m_HostName

m_port

protected int m_port

socketConn

protected Socket socketConn

log

protected static final org.slf4j.Logger log
Constructor Detail

AbstractNetworkPortController

public AbstractNetworkPortController()
Method Detail

connect

public void connect(String host,
                    int port)
             throws Exception
Description copied from interface: NetworkPortAdapter
Connects to the end device using a hostname/ip address and port

Specified by:
connect in interface NetworkPortAdapter
Throws:
Exception

connect

public void connect()
             throws Exception
Description copied from interface: PortAdapter
Open the connection

Specified by:
connect in interface PortAdapter
Throws:
Exception

status

public boolean status()
Query the status of this connection. If all OK, at least as far as is known, return true

Specified by:
status in interface NetworkPortAdapter
Specified by:
status in interface PortAdapter
Overrides:
status in class AbstractPortController

setHostName

public void setHostName(String s)
Remember the associated host name

Specified by:
setHostName in interface NetworkPortAdapter
Parameters:
s -

getHostName

public String getHostName()
Specified by:
getHostName in interface NetworkPortAdapter

setPort

public void setPort(int p)
Remeber the associated port number

Specified by:
setPort in interface NetworkPortAdapter
Parameters:
p -

setPort

public void setPort(String p)
Description copied from interface: NetworkPortAdapter
Remember the associated port name

Specified by:
setPort in interface NetworkPortAdapter

getPort

public int getPort()
Specified by:
getPort in interface NetworkPortAdapter

getCurrentPortName

public String getCurrentPortName()
Returns the connection name for the network connection in the format of ip_address:port

Specified by:
getCurrentPortName in interface NetworkPortAdapter
Specified by:
getCurrentPortName in interface PortAdapter
Specified by:
getCurrentPortName in class AbstractPortController
Returns:
ip_address:port

getInputStream

public DataInputStream getInputStream()
Specified by:
getInputStream in interface PortAdapter
Specified by:
getInputStream in class AbstractPortController

getOutputStream

public DataOutputStream getOutputStream()
Specified by:
getOutputStream in interface PortAdapter
Specified by:
getOutputStream in class AbstractPortController

getSystemConnectionMemo

public SystemConnectionMemo getSystemConnectionMemo()
Specified by:
getSystemConnectionMemo in interface PortAdapter
Specified by:
getSystemConnectionMemo in class AbstractPortController

setDisabled

public void setDisabled(boolean disabled)
Description copied from interface: PortAdapter
Sets whether the connection is disabled

Specified by:
setDisabled in interface PortAdapter
Specified by:
setDisabled in class AbstractPortController

dispose

public void dispose()
Specified by:
dispose in interface PortAdapter

recover

public void recover()
This is called when a connection is initially lost. It closes the client side socket connection, resets the open flag and attempts a reconnection.

Specified by:
recover in interface PortAdapter
Specified by:
recover in class AbstractPortController

reconnect

public void reconnect()
Attempts to reconnect to a failed Server


resetupConnection

protected void resetupConnection()
Customizable method to deal with resetting a system connection after a sucessful recovery of a connection.



Copyright © 1997-2013 JMRI Community.
JMRI, DecoderPro, PanelPro, SoundPro, DispatcherPro and associated logos are our trademarks.

Additional information on copyright, trademarks and licenses is linked here.
Site hosted by: Get JMRI Model Railroad Interface at SourceForge.net. Fast, secure and Free Open Source software downloads