Package jmri.jmrix.bidib.serialdriver
Class SerialDriverAdapter
java.lang.Object
jmri.jmrix.AbstractPortController
jmri.jmrix.AbstractSerialPortController
jmri.jmrix.bidib.BiDiBSerialPortController
jmri.jmrix.bidib.serialdriver.SerialDriverAdapter
- All Implemented Interfaces:
BiDiBPortController,PortAdapter,SerialPortAdapter
Implements SerialPortAdapter for the BiDiB system.
This connects an BiDiB device via a serial com port.
-
Nested Class Summary
Nested classes/interfaces inherited from class jmri.jmrix.AbstractSerialPortController
AbstractSerialPortController.Blocking, AbstractSerialPortController.FlowControlNested classes/interfaces inherited from class jmri.jmrix.AbstractPortController
AbstractPortController.Option -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Stringprotected Longprotected Stringprotected booleanprotected String[]protected int[]Fields inherited from class jmri.jmrix.bidib.BiDiBSerialPortController
bidib, contextFields inherited from class jmri.jmrix.AbstractSerialPortController
currentSerialPort, mBaudRate, mPortFields inherited from class jmri.jmrix.AbstractPortController
allowConnectionRecovery, manufacturerName, opened, option1Name, option2Name, option3Name, option4Name, options, reconnectinterval, reconnectMaxAttempts, reconnectMaxInterval -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionInternal method to check if the given port is a BiDiB connection and returns the unique ID of the root node.voidSet up all of the other objects to operate with an BiDiB command station connected to this port.findPortbyUniqueID(Long requid) Internal method to find a port, possibly with already created BiDiB objectstatic StringgetCanonicalPortName(String portName) Get the canonical port name from the underlying operating system.Get the InputStream from the port.getKownPortName(Long reqUid) Check if the port name of a given UID already exists in the cache.Get the outputStream to the port.Get a list of available port namesGet the filter string for port names to scan when autoScan is onGet the physical port name used with jbidibcstatic StringgetRealPortName(String portName) Static function to get the port name in the format which is used by jbidibcGet the root node unique IDbooleanGet the AutoScan statusThis methods is called from serial connection config and creates the BiDiB object from jbidibc and opens it.voidregisterAllListeners(org.bidib.jbidibc.messages.ConnectionListener connectionListener, Set<org.bidib.jbidibc.core.NodeListener> nodeListeners, Set<org.bidib.jbidibc.core.MessageListener> messageListeners, Set<org.bidib.jbidibc.core.node.listener.TransferListener> transferListeners) Register all Listeners to the specific BiDiB Object.voidsetPortNameFilter(String filter) Set the port name filtervoidsetRootNodeUid(Long uid) Set the root node unique IDvoidsetUseAutoScan(boolean flag) Set the AutoScan statusbooleanstatus()Query the status of this connection.int[]Get an array of valid baud rate numbers; used to store/load adapter speed option.String[]Get an array of valid baud rate strings; used to display valid options in Connections Preferences.Methods inherited from class jmri.jmrix.bidib.BiDiBSerialPortController
getContext, getSystemConnectionMemoMethods inherited from class jmri.jmrix.AbstractSerialPortController
activatePort, activatePort, activatePort, closeConnection, closeSerialPort, configureBaudRate, configureBaudRateFromIndex, configureBaudRateFromNumber, configureLeads, configureLeadsAndFlowControl, configureLeadsAndFlowControl, connect, currentBaudNumber, defaultBaudIndex, getActualPortNames, getCurrentBaudIndex, getCurrentBaudNumber, getCurrentBaudRate, getCurrentPortName, getFlowControl, getPortSettingsString, handlePortBusy, handlePortNotFound, handlePortNotFound, isPortOpen, replacePortWithFakePort, reportPortStatus, resetupConnection, setBaudRate, setComPortTimeouts, setDataListener, setFlowControl, setPortMethods 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, reconnectFromLoop, recover, safeSleep, setClosed, setDisabled, setManufacturer, setOpened, setOptionState, setReconnectMaxAttempts, setReconnectMaxInterval, setSystemConnectionMemo, setSystemPrefix, setUserNameMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface jmri.jmrix.PortAdapter
connect, 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, setUserNameMethods inherited from interface jmri.jmrix.SerialPortAdapter
configureOption1, configureOption2, configureOption3, configureOption4, getManufacturer, getPortNames, setManufacturer
-
Field Details
-
portNameFilter
-
rootNodeUid
-
useAutoScan
-
validSpeeds
-
validSpeedValues
-
selectedSpeed
-
-
Constructor Details
-
SerialDriverAdapter
public SerialDriverAdapter()
-
-
Method Details
-
getPortNameFilter
Get the filter string for port names to scan when autoScan is on- Returns:
- port name filter as a string (wildcard is allowed at the end)
-
setPortNameFilter
Set the port name filter- Parameters:
filter- filter string
-
getRootNodeUid
Get the root node unique ID- Returns:
- UID as Long
-
setRootNodeUid
Set the root node unique ID- Parameters:
uid- Unique ID as Long
-
getUseAutoScan
Get the AutoScan status- Returns:
- true of autoScan is on, false if not
-
setUseAutoScan
Set the AutoScan status- Parameters:
flag- true of ON is requested
-
getRealPortName
Get the physical port name used with jbidibc Get the port name in the format which is used by jbidibc- Specified by:
getRealPortNamein interfaceBiDiBPortController- Overrides:
getRealPortNamein classBiDiBSerialPortController- Returns:
- real port name
-
getCanonicalPortName
Get the canonical port name from the underlying operating system. For a symbolic link, the real path is returned.- Parameters:
portName- human-readable name- Returns:
- canonical path
-
getRealPortName
Static function to get the port name in the format which is used by jbidibc- Parameters:
portName- displayed port name- Returns:
- real port name
-
openPort
This methods is called from serial connection config and creates the BiDiB object from jbidibc and opens it. The connectPort method of the traffic controller is called for generic initialisation.- Parameters:
portName- port name from XMLappName- not used- Returns:
- error string to be displayed by JMRI. null of no error
-
configure
Set up all of the other objects to operate with an BiDiB command station connected to this port. -
registerAllListeners
public void registerAllListeners(org.bidib.jbidibc.messages.ConnectionListener connectionListener, Set<org.bidib.jbidibc.core.NodeListener> nodeListeners, Set<org.bidib.jbidibc.core.MessageListener> messageListeners, Set<org.bidib.jbidibc.core.node.listener.TransferListener> transferListeners) Register all Listeners to the specific BiDiB Object. We need this here since the BidibInterface does not provide this method.- Specified by:
registerAllListenersin interfaceBiDiBPortController- Specified by:
registerAllListenersin classBiDiBSerialPortController- Parameters:
connectionListener- where to addnodeListeners- listeners to addmessageListeners- listeners to addtransferListeners- listeners to add
-
getPortIdentifiers
Get a list of available port names- Returns:
- list of portnames
-
findPortbyUniqueID
Internal method to find a port, possibly with already created BiDiB object- Parameters:
requid- requested unique ID of the root node- Returns:
- port name as String
-
checkPort
Internal method to check if the given port is a BiDiB connection and returns the unique ID of the root node. Return the UID from cache if we already know the UID. // * @param bidib a BiDiB object from jbidibc- Parameters:
portName- port name to check- Returns:
- unique ID of the root node
-
getKownPortName
Check if the port name of a given UID already exists in the cache.- Parameters:
reqUid- requested UID- Returns:
- port name or null if not found in cache
-
getInputStream
Description copied from class:AbstractPortControllerGet the InputStream from the port.- Specified by:
getInputStreamin interfacePortAdapter- Overrides:
getInputStreamin classAbstractSerialPortController- Returns:
- the InputStream from the port
-
getOutputStream
Description copied from class:AbstractPortControllerGet the outputStream to the port.- Specified by:
getOutputStreamin interfacePortAdapter- Overrides:
getOutputStreamin classAbstractSerialPortController- Returns:
- the outputStream to the port
-
status
Query the status of this connection. This is a question of configuration, not transient hardware status.- Specified by:
statusin interfacePortAdapter- Specified by:
statusin interfaceSerialPortAdapter- Overrides:
statusin classAbstractPortController- Returns:
- true if OK, at least as far as known
-
validBaudRates
Get an array of valid baud rate strings; used to display valid options in Connections Preferences.- Specified by:
validBaudRatesin interfaceSerialPortAdapter- Overrides:
validBaudRatesin classAbstractSerialPortController- Returns:
- array of I18N display strings of port speed settings valid for this serial adapter,
must match order and values from
SerialPortAdapter.validBaudNumbers()
-
validBaudNumbers
Get an array of valid baud rate numbers; used to store/load adapter speed option.- Specified by:
validBaudNumbersin interfaceSerialPortAdapter- Overrides:
validBaudNumbersin classAbstractSerialPortController- Returns:
- integer array of speeds, must match order and values from
SerialPortAdapter.validBaudRates()
-