jmri.jmrix.lenz.xntcp
Class XnTcpAdapter

java.lang.Object
  extended by jmri.jmrix.AbstractPortController
      extended by jmri.jmrix.AbstractNetworkPortController
          extended by jmri.jmrix.lenz.XNetNetworkPortController
              extended by jmri.jmrix.lenz.xntcp.XnTcpAdapter
All Implemented Interfaces:
XNetPortController, NetworkPortAdapter, PortAdapter

public class XnTcpAdapter
extends XNetNetworkPortController
implements XNetPortController

Provide access to XPressNet via a XnTcp interface attached on the Ethernet port.

Author:
Giorgio Terdina Copyright (C) 2008-2011, based on LI100 adapter by Bob Jacobsen, Copyright (C) 2002, Portions by Paul Bender, Copyright (C) 2003

Nested Class Summary
 class XnTcpAdapter.OutputTcpStream
           
 
Field Summary
 
Fields inherited from class jmri.jmrix.lenz.XNetNetworkPortController
adaptermemo, checkBuffer, validOption2
 
Fields inherited from class jmri.jmrix.AbstractNetworkPortController
m_HostName, m_port, socketConn
 
Fields inherited from class jmri.jmrix.AbstractPortController
mDisabled, mManufacturer, mOpt1, mOpt2, opened
 
Constructor Summary
XnTcpAdapter()
           
 
Method Summary
 void configure()
          set up all of the other objects to operate with a XnTcp interface
 void connect()
           
 DataInputStream getInputStream()
           
 Vector<String> getInterfaceNames()
           
 DataOutputStream getOutputStream()
           
 boolean okToSend()
          Can the port accept additional characters?
 String option1Name()
          Get a String that says what Option 1 represents May be an empty string, but will not be null
 boolean status()
          Check that this object is ready to operate.
 String[] validOption1()
          Get an array of valid values for "option 1"; used to display valid options.
protected  void xnTcpError()
          If an error occurs, either in the input or output thread, the display of a message is queued in the SWING thread.
protected  void xnTcpSetPendingPackets(int s)
          TCP/IP stack and the XnTcp interface provide enough buffering to avoid overrun.
 
Methods inherited from class jmri.jmrix.lenz.XNetNetworkPortController
dispose, getCurrentOption2Setting, getSystemConnectionMemo, setOutputBufferEmpty
 
Methods inherited from class jmri.jmrix.AbstractNetworkPortController
connect, getCurrentPortName, getHostName, getPort, setDisabled, setHostName, setPort, setPort
 
Methods inherited from class jmri.jmrix.AbstractPortController
configureOption1, configureOption2, getCurrentOption1Setting, getDisabled, getManufacturer, option2Name, setManufacturer, validOption2
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface jmri.jmrix.lenz.XNetPortController
setOutputBufferEmpty
 
Methods inherited from interface jmri.jmrix.PortAdapter
configureOption1, configureOption2, dispose, getCurrentOption1Setting, getCurrentOption2Setting, getCurrentPortName, getDisabled, getManufacturer, getSystemConnectionMemo, option2Name, setDisabled, setManufacturer, validOption2
 
Methods inherited from interface jmri.jmrix.NetworkPortAdapter
configureOption1, configureOption2, getCurrentOption1Setting, option2Name, validOption2
 

Constructor Detail

XnTcpAdapter

public XnTcpAdapter()
Method Detail

option1Name

public String option1Name()
Get a String that says what Option 1 represents May be an empty string, but will not be null

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

validOption1

public String[] validOption1()
Get an array of valid values for "option 1"; used to display valid options. May not be null, but may have zero entries

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

getInterfaceNames

public Vector<String> getInterfaceNames()

connect

public void connect()
             throws Exception
Specified by:
connect in interface NetworkPortAdapter
Overrides:
connect in class AbstractNetworkPortController
Throws:
Exception

xnTcpSetPendingPackets

protected void xnTcpSetPendingPackets(int s)
TCP/IP stack and the XnTcp interface provide enough buffering to avoid overrun. However, queueing commands faster than they can be processed should in general be avoided. To this purpose, a counter is incremented each time a packet is queued and decremented when a reply from the interface is received. When the counter reaches the pre-defined maximum (e.g. 15) queuing of commands is blocked. Owing to broadcasts from the command station, the number of commands received can actually be higher than that of commands sent, but this fact simply implies that we may have a higher number of pending commands for a while, without any negative consequence (the maximum is however arbitrary).


xnTcpError

protected void xnTcpError()
If an error occurs, either in the input or output thread, the display of a message is queued in the SWING thread. Since the input and output streams are not connected any more and the input and output threads will soon exit, user must save possible changes, quit, fix the problem and then restart JMRI.


okToSend

public boolean okToSend()
Can the port accept additional characters? There is no CTS signal available. We only limit the number of commands queued in TCP/IP stack

Specified by:
okToSend in interface XNetPortController
Specified by:
okToSend in class XNetNetworkPortController

configure

public void configure()
set up all of the other objects to operate with a XnTcp interface

Specified by:
configure in interface NetworkPortAdapter
Specified by:
configure in interface PortAdapter

getInputStream

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

getOutputStream

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

status

public boolean status()
Description copied from class: XNetNetworkPortController
Check that this object is ready to operate. This is a question of configuration, not transient hardware status.

Specified by:
status in interface XNetPortController
Specified by:
status in interface NetworkPortAdapter
Specified by:
status in interface PortAdapter
Specified by:
status in class XNetNetworkPortController


Copyright © 1997 - 2011 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