jmri.jmrix.lenz.xntcp
Class XnTcpAdapter

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

public class XnTcpAdapter
extends XNetPortController
implements SerialPortAdapter

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

Author:
Giorgio Terdina Copyright (C) 2008, 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
protected  String outName
           
protected  XnTcpAdapter.OutputTcpStream outTcpStream
           
 
Fields inherited from class jmri.jmrix.lenz.XNetPortController
validOption2
 
Fields inherited from class jmri.jmrix.AbstractPortController
mBaudRate, mOpt1, mOpt2, mPort
 
Constructor Summary
XnTcpAdapter()
           
 
Method Summary
 void configure()
          set up all of the other objects to operate with a XnTcp interface
 String getCurrentBaudRate()
           
 DataInputStream getInputStream()
           
 DataOutputStream getOutputStream()
           
 Vector<String> getPortNames()
          Provide a vector of valid port names, each a String.
static XnTcpAdapter instance()
           
 boolean okToSend()
          Can the port accept additional characters?
 String openPort(String portName, String appName)
          Open a specified port.
 String option1Name()
          XnTcp comunication options (used only with manual configuration) Option 1 is used to specify the IP address
 String option2Name()
          Option 2 is used to specify the port number
 void setOutputBufferEmpty(boolean s)
          We need a way to say if the output buffer is empty or not
 boolean status()
          Check that this object is ready to operate.
 String[] validBaudRates()
          Local method to do specific configuration
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.XNetPortController
validOption2
 
Methods inherited from class jmri.jmrix.AbstractPortController
configureBaudRate, configureOption1, configureOption2, currentBaudNumber, getCurrentOption1Setting, getCurrentOption2Setting, getCurrentPortName, handlePortBusy, handlePortNotFound, reloadDriver, setPort, validBaudNumber, validOption1
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface jmri.jmrix.SerialPortAdapter
configureBaudRate, configureOption1, configureOption2, getCurrentOption1Setting, getCurrentOption2Setting, getCurrentPortName, handlePortBusy, setPort, validOption1, validOption2
 

Field Detail

outTcpStream

protected XnTcpAdapter.OutputTcpStream outTcpStream

outName

protected String outName
Constructor Detail

XnTcpAdapter

public XnTcpAdapter()
Method Detail

getPortNames

public Vector<String> getPortNames()
Description copied from interface: SerialPortAdapter
Provide a vector of valid port names, each a String.

Specified by:
getPortNames in interface SerialPortAdapter
Overrides:
getPortNames in class AbstractPortController

openPort

public String openPort(String portName,
                       String appName)
Description copied from interface: SerialPortAdapter
Open a specified port. The appname argument is to be provided to the underlying OS during startup so that it can show on status displays, etc

Specified by:
openPort in interface SerialPortAdapter

setOutputBufferEmpty

public void setOutputBufferEmpty(boolean s)
Description copied from class: XNetPortController
We need a way to say if the output buffer is empty or not

Specified by:
setOutputBufferEmpty in class XNetPortController

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 class XNetPortController

configure

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

Specified by:
configure in interface PortAdapter
Specified by:
configure in interface SerialPortAdapter

getInputStream

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

getOutputStream

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

status

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

Specified by:
status in interface PortAdapter
Specified by:
status in interface SerialPortAdapter
Specified by:
status in class XNetPortController

validBaudRates

public String[] validBaudRates()
Local method to do specific configuration

Specified by:
validBaudRates in interface SerialPortAdapter

getCurrentBaudRate

public String getCurrentBaudRate()
Specified by:
getCurrentBaudRate in interface SerialPortAdapter
Overrides:
getCurrentBaudRate in class AbstractPortController

option1Name

public String option1Name()
XnTcp comunication options (used only with manual configuration) Option 1 is used to specify the IP address

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

option2Name

public String option2Name()
Option 2 is used to specify the port number

Specified by:
option2Name in interface PortAdapter
Specified by:
option2Name in interface SerialPortAdapter
Overrides:
option2Name in class XNetPortController

instance

public static XnTcpAdapter instance()


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