jmri.jmrix.lenz.xnetsimulator
Class XNetSimulatorAdapter

java.lang.Object
  extended by jmri.jmrix.AbstractPortController
      extended by jmri.jmrix.AbstractSerialPortController
          extended by jmri.jmrix.lenz.XNetSimulatorPortController
              extended by jmri.jmrix.lenz.xnetsimulator.XNetSimulatorAdapter
All Implemented Interfaces:
Runnable, XNetPortController, PortAdapter, SerialPortAdapter

public class XNetSimulatorAdapter
extends XNetSimulatorPortController
implements Runnable

Provide access to a simulated XPressNet system. Currently, the XNetSimulator reacts to commands sent from the user interface with messages an appropriate reply message. NOTE: Most XPressNet commands are still unsupported in this implementation. Normally controlled by the lenz.XNetSimulator.XNetSimulatorFrame class. NOTE: Some material in this file was modified from other portions of the support infrastructure.

Author:
Paul Bender, Copyright (C) 2009-2010

Field Summary
 
Fields inherited from class jmri.jmrix.lenz.XNetSimulatorPortController
adaptermemo
 
Fields inherited from class jmri.jmrix.AbstractSerialPortController
mBaudRate, mPort
 
Fields inherited from class jmri.jmrix.AbstractPortController
mDisabled, mManufacturer, mOpt1, mOpt2, opened
 
Constructor Summary
XNetSimulatorAdapter()
           
 
Method Summary
 void configure()
          set up all of the other objects to operate with a XNetSimulator connected to this port
 DataInputStream getInputStream()
           
 DataOutputStream getOutputStream()
           
static XNetSimulatorAdapter instance()
          Deprecated. 
 boolean okToSend()
          Can the port accept additional characters?
 String openPort(String portName, String appName)
          Open a specified port.
protected  byte readByteProtected(DataInputStream istream)
          Read a single byte, protecting against various timeouts, etc.
 void run()
           
 void setOutputBufferEmpty(boolean s)
          we need a way to say if the output buffer is empty or full this should only be set to false by external processes
 boolean status()
          Check that this object is ready to operate.
 String[] validBaudRates()
          Get an array of valid baud rates.
 
Methods inherited from class jmri.jmrix.lenz.XNetSimulatorPortController
dispose, getSystemConnectionMemo
 
Methods inherited from class jmri.jmrix.AbstractSerialPortController
configureBaudRate, currentBaudNumber, getCurrentBaudRate, getCurrentPortName, getPortNames, handlePortBusy, handlePortNotFound, setDisabled, setPort, validBaudNumber
 
Methods inherited from class jmri.jmrix.AbstractPortController
configureOption1, configureOption2, getCurrentOption1Setting, getCurrentOption2Setting, getDisabled, getManufacturer, option1Name, option2Name, setManufacturer, validOption1, 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.PortAdapter
configureOption1, configureOption2, getCurrentOption1Setting, getCurrentOption2Setting, getCurrentPortName, getDisabled, getManufacturer, option1Name, option2Name, setDisabled, setManufacturer, validOption1, validOption2
 
Methods inherited from interface jmri.jmrix.SerialPortAdapter
configureOption1, configureOption2, getCurrentOption1Setting, getCurrentOption2Setting, getManufacturer, option1Name, option2Name, setManufacturer, validOption1, validOption2
 

Constructor Detail

XNetSimulatorAdapter

public XNetSimulatorAdapter()
Method Detail

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)
we need a way to say if the output buffer is empty or full this should only be set to false by external processes

Specified by:
setOutputBufferEmpty in interface XNetPortController
Specified by:
setOutputBufferEmpty in class XNetSimulatorPortController

okToSend

public boolean okToSend()
Can the port accept additional characters? The state of CTS determines this, as there seems to be no way to check the number of queued bytes and buffer length. This might go false for short intervals, but it might also stick off if something goes wrong.

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

configure

public void configure()
set up all of the other objects to operate with a XNetSimulator connected to this port

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 XNetSimulatorPortController

getOutputStream

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

status

public boolean status()
Description copied from class: XNetSimulatorPortController
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 PortAdapter
Specified by:
status in interface SerialPortAdapter
Specified by:
status in class XNetSimulatorPortController

validBaudRates

public String[] validBaudRates()
Get an array of valid baud rates. This is currently just a message saying its fixed

Specified by:
validBaudRates in interface SerialPortAdapter

instance

@Deprecated
public static XNetSimulatorAdapter instance()
Deprecated. 


run

public void run()
Specified by:
run in interface Runnable

readByteProtected

protected byte readByteProtected(DataInputStream istream)
                          throws IOException
Read a single byte, protecting against various timeouts, etc.

When a gnu.io port is set to have a receive timeout (via the enableReceiveTimeout() method), some will return zero bytes or an EOFException at the end of the timeout. In that case, the read should be repeated to get the next real character.

Throws:
IOException


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