Class GcSerialDriverAdapter
- java.lang.Object
-
- jmri.jmrix.AbstractPortController
-
- jmri.jmrix.AbstractSerialPortController
-
- jmri.jmrix.can.adapters.gridconnect.GcPortController
-
- jmri.jmrix.can.adapters.gridconnect.GcSerialDriverAdapter
-
- All Implemented Interfaces:
PortAdapter
,SerialPortAdapter
- Direct Known Subclasses:
CanisbSerialDriverAdapter
,PiSprog3SerialDriverAdapter
,SerialDriverAdapter
,SerialDriverAdapter
,SerialDriverAdapter
,SerialDriverAdapter
,Sprog3PlusSerialDriverAdapter
public class GcSerialDriverAdapter extends GcPortController
Implements SerialPortAdapter for the GridConnect protocol.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class jmri.jmrix.AbstractPortController
AbstractPortController.Option
-
-
Field Summary
Fields Modifier and Type Field Description protected purejavacomm.SerialPort
activeSerialPort
protected int
flowControl
(package private) java.io.InputStream
serialStream
-
Fields inherited from class jmri.jmrix.AbstractSerialPortController
mBaudRate, mPort
-
Fields inherited from class jmri.jmrix.AbstractPortController
allowConnectionRecovery, manufacturerName, opened, option1Name, option2Name, option3Name, option4Name, options, reconnectinterval, reconnectMaxAttempts, reconnectMaxInterval
-
-
Constructor Summary
Constructors Constructor Description GcSerialDriverAdapter()
Creates a new CAN GridConnect Network Driver Adapter.GcSerialDriverAdapter(java.lang.String prefix)
Creates a new CAN GridConnect Network Driver Adapter.GcSerialDriverAdapter(java.lang.String prefix, int flow)
Creates a new CAN GridConnect Network Driver Adapter.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
closeConnection()
Abstract class for controllers to close the connection.void
configure()
Set up all of the other objects to operate with a CAN RS adapter connected to this port.int
defaultBaudIndex()
Get the index of the default port speed for this adapter from the validSpeeds and validRates arrays.java.io.DataInputStream
getInputStream()
Base class methods for the PortController interface.java.io.DataOutputStream
getOutputStream()
Get the outputStream to the port.protected GcTrafficController
makeGcTrafficController()
Make a new GC Traffic Controller.java.lang.String
openPort(java.lang.String portName, java.lang.String appName)
Open a specified port.protected void
resetupConnection()
Re-setup the connection.int[]
validBaudNumbers()
Get an array of valid baud rates.java.lang.String[]
validBaudRates()
Get an array of valid baud rate strings; used to display valid options in Connections Preferences.-
Methods inherited from class jmri.jmrix.can.adapters.gridconnect.GcPortController
getSystemConnectionMemo
-
Methods inherited from class jmri.jmrix.AbstractSerialPortController
configureBaudRate, configureBaudRateFromIndex, configureBaudRateFromNumber, configureLeadsAndFlowControl, configureLeadsAndFlowControl, connect, currentBaudNumber, getCurrentBaudIndex, getCurrentBaudNumber, getCurrentBaudRate, getCurrentPortName, getPortNames, handlePortBusy, handlePortNotFound, reconnectFromLoop, setPort, setPortEventLogging
-
Methods inherited from class jmri.jmrix.AbstractPortController
configureOption1, configureOption2, configureOption3, configureOption4, dispose, getDisabled, getManufacturer, getOption1Name, getOption2Name, getOption3Name, getOption4Name, getOptionChoices, getOptionDisplayName, getOptions, getOptionState, getReconnectMaxAttempts, getReconnectMaxInterval, getSystemPrefix, getUserName, isDirty, isOptionAdvanced, isOptionTypePassword, isOptionTypeText, isRestartRequired, purgeStream, reconnect, recover, safeSleep, setClosed, setDisabled, setManufacturer, setOpened, setOptionState, setReconnectMaxAttempts, setReconnectMaxInterval, setSystemConnectionMemo, setSystemPrefix, setUserName, status
-
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
dispose, getDisabled, getOption1Name, getOption2Name, getOption3Name, getOption4Name, getOptionChoices, getOptionDisplayName, getOptions, getOptionState, getReconnectMaxAttempts, getReconnectMaxInterval, getSystemPrefix, getUserName, isDirty, isOptionAdvanced, isOptionTypePassword, isOptionTypeText, isRestartRequired, recover, setDisabled, setOptionState, setReconnectMaxAttempts, setReconnectMaxInterval, setSystemConnectionMemo, setSystemPrefix, setUserName
-
Methods inherited from interface jmri.jmrix.SerialPortAdapter
configureOption1, configureOption2, configureOption3, configureOption4, getManufacturer, setManufacturer, status
-
-
-
-
Field Detail
-
activeSerialPort
protected purejavacomm.SerialPort activeSerialPort
-
flowControl
protected int flowControl
-
serialStream
java.io.InputStream serialStream
-
-
Constructor Detail
-
GcSerialDriverAdapter
public GcSerialDriverAdapter()
Creates a new CAN GridConnect Network Driver Adapter.
-
GcSerialDriverAdapter
public GcSerialDriverAdapter(java.lang.String prefix)
Creates a new CAN GridConnect Network Driver Adapter.Allows for default systemPrefix other than "M".
- Parameters:
prefix
- System Prefix.
-
GcSerialDriverAdapter
public GcSerialDriverAdapter(java.lang.String prefix, int flow)
Creates a new CAN GridConnect Network Driver Adapter.Allows for default systemPrefix other than "M".
- Parameters:
prefix
- System Prefix.flow
- flow control.
-
-
Method Detail
-
openPort
public java.lang.String openPort(java.lang.String portName, java.lang.String appName)
Open a specified port.- Parameters:
portName
- name tu use for this portappName
- provided to the underlying OS during startup so that it can show on status displays, etc.- Returns:
- null indicates OK return, else error message.
-
configure
public void configure()
Set up all of the other objects to operate with a CAN RS adapter connected to this port. Configure all of the other jmrix widgets needed to work with this adapter.
-
resetupConnection
protected void resetupConnection()
Re-setup the connection. Called when the physical connection has reconnected and can be linked to this connection. Each port adapter should handle this and it should be abstract. Reconnects to Traffic Controller. Updates connection status.- Overrides:
resetupConnection
in classAbstractSerialPortController
-
closeConnection
protected void closeConnection()
Abstract class for controllers to close the connection. Called prior to any re-connection attempts. Each serial port adapter should handle this and it should be abstract. Closes serial streams.- Overrides:
closeConnection
in classAbstractSerialPortController
-
makeGcTrafficController
protected GcTrafficController makeGcTrafficController()
Make a new GC Traffic Controller.- Returns:
- new GridConnect Traffic Controller.
-
getInputStream
public java.io.DataInputStream getInputStream()
Base class methods for the PortController interface. Get the InputStream to the port. Get the InputStream from the port.- Specified by:
getInputStream
in interfacePortAdapter
- Specified by:
getInputStream
in classGcPortController
- Returns:
- the InputStream from the port
-
getOutputStream
public java.io.DataOutputStream getOutputStream()
Get the outputStream to the port. Get the outputStream to the port.- Specified by:
getOutputStream
in interfacePortAdapter
- Specified by:
getOutputStream
in classGcPortController
- Returns:
- the outputStream to the port
-
validBaudRates
public java.lang.String[] validBaudRates()
Get an array of valid baud rate strings; used to display valid options in Connections Preferences.- Specified by:
validBaudRates
in interfaceSerialPortAdapter
- Overrides:
validBaudRates
in classAbstractSerialPortController
- Returns:
- array of localized valid baud rates
-
validBaudNumbers
public int[] validBaudNumbers()
Get an array of valid baud rates.- Specified by:
validBaudNumbers
in interfaceSerialPortAdapter
- Overrides:
validBaudNumbers
in classAbstractSerialPortController
- Returns:
- valid baud rates
-
defaultBaudIndex
public int defaultBaudIndex()
Get the index of the default port speed for this adapter from the validSpeeds and validRates arrays.- Specified by:
defaultBaudIndex
in interfaceSerialPortAdapter
- Overrides:
defaultBaudIndex
in classAbstractSerialPortController
- Returns:
- -1 to indicate not supported, unless overridden in adapter
-
-