jmri.jmrix
Class AbstractSerialPortController

java.lang.Object
  extended by jmri.jmrix.AbstractPortController
      extended by jmri.jmrix.AbstractSerialPortController
All Implemented Interfaces:
PortAdapter, SerialPortAdapter
Direct Known Subclasses:
AbstractNetworkPortAdapter, AcelaPortController, EasyDccPortController, GcPortController, InternalAdapter, LnPortController, MrcPortController, Mx1PortController, NcePortController, NetworkDriverAdapter, Port, PortController, PortController, QsiPortController, RfidPortController, SerialAdapter, SerialPortController, SerialPortController, SerialPortController, SerialPortController, SerialPortController, SerialPortController, SerialPortController, SerialSensorAdapter, SpeedoPortController, SprogPortController, XNetSerialPortController, XNetSimulatorPortController, XpaPortController

public abstract class AbstractSerialPortController
extends AbstractPortController
implements SerialPortAdapter

Provide an abstract base for *PortController classes.

This is complicated by the lack of multiple inheritance. SerialPortAdapter is an Interface, and its implementing classes also inherit from various PortController types. But we want some common behaviours for those, so we put them here.

Author:
Bob Jacobsen Copyright (C) 2001, 2002
See Also:
SerialPortAdapter

Field Summary
protected static Logger log
           
protected  String mBaudRate
           
protected  String mPort
           
 
Fields inherited from class jmri.jmrix.AbstractPortController
mDisabled, mManufacturer, mOpt1, mOpt2, opened
 
Constructor Summary
AbstractSerialPortController()
           
 
Method Summary
 void configureBaudRate(String rate)
          Set the baud rate.
 int currentBaudNumber(String currentBaudRate)
          Convert a baud rate string to a number.
 void dispose()
           
 String getCurrentBaudRate()
           
 String getCurrentPortName()
           
 Vector<String> getPortNames()
          Provide a vector of valid port names, each a String.
 SystemConnectionMemo getSystemConnectionMemo()
           
 String handlePortBusy(PortInUseException p, String portName, Logger log)
          Standard error handling for port-busy case
 String handlePortNotFound(NoSuchPortException p, String portName, Logger log)
          Standard error handling for port-not-found case
 void setDisabled(boolean disabled)
          Sets whether the connection is disabled
 void setPort(String port)
          Remember the associated port name
 int[] validBaudNumber()
          Get an array of valid baud rates as integers.
 
Methods inherited from class jmri.jmrix.AbstractPortController
configureOption1, configureOption2, getCurrentOption1Setting, getCurrentOption2Setting, getDisabled, getInputStream, getManufacturer, getOutputStream, option1Name, option2Name, setManufacturer, status, 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.SerialPortAdapter
configure, configureOption1, configureOption2, getCurrentOption1Setting, getCurrentOption2Setting, getManufacturer, openPort, option1Name, option2Name, setManufacturer, status, validBaudRates, validOption1, validOption2
 
Methods inherited from interface jmri.jmrix.PortAdapter
getDisabled, getInputStream, getOutputStream
 

Field Detail

mPort

protected String mPort

mBaudRate

protected String mBaudRate

log

protected static final Logger log
Constructor Detail

AbstractSerialPortController

public AbstractSerialPortController()
Method Detail

handlePortBusy

public String handlePortBusy(PortInUseException p,
                             String portName,
                             Logger log)
Standard error handling for port-busy case

Specified by:
handlePortBusy in interface SerialPortAdapter
See Also:
AbstractSerialPortController

handlePortNotFound

public String handlePortNotFound(NoSuchPortException p,
                                 String portName,
                                 Logger log)
Standard error handling for port-not-found case


setPort

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

Specified by:
setPort in interface SerialPortAdapter

getCurrentPortName

public String getCurrentPortName()
Specified by:
getCurrentPortName in interface PortAdapter
Specified by:
getCurrentPortName in interface SerialPortAdapter
Specified by:
getCurrentPortName in class AbstractPortController

configureBaudRate

public void configureBaudRate(String rate)
Set the baud rate. This records it for later.

Specified by:
configureBaudRate in interface SerialPortAdapter

getCurrentBaudRate

public String getCurrentBaudRate()
Specified by:
getCurrentBaudRate in interface SerialPortAdapter

validBaudNumber

public int[] validBaudNumber()
Get an array of valid baud rates as integers. This allows subclasses to change the arrays of speeds. This method need not be reimplemented unless the subclass is using currentBaudNumber, which requires it.


currentBaudNumber

public int currentBaudNumber(String currentBaudRate)
Convert a baud rate string to a number. Uses the validBaudNumber and validBaudRates methods to do this.

Returns:
-1 if no match (configuration system should prevent this)

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

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


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