Package jmri.jmrix.bidib.simulator
Class BiDiBSimulatorAdapter
- java.lang.Object
-
- jmri.jmrix.AbstractPortController
-
- jmri.jmrix.AbstractSerialPortController
-
- jmri.jmrix.bidib.BiDiBSerialPortController
-
- jmri.jmrix.bidib.simulator.BiDiBSimulatorAdapter
-
- All Implemented Interfaces:
BiDiBPortController
,PortAdapter
,SerialPortAdapter
public class BiDiBSimulatorAdapter extends BiDiBSerialPortController
Provide access to a simulated BiDiB system.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class jmri.jmrix.AbstractSerialPortController
AbstractSerialPortController.Blocking, AbstractSerialPortController.FlowControl
-
Nested classes/interfaces inherited from class jmri.jmrix.AbstractPortController
AbstractPortController.Option
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.String
absoluteSimulationFile
protected java.lang.String
loadedSimulationFilename
protected java.lang.String
simulationFile
-
Fields inherited from class jmri.jmrix.bidib.BiDiBSerialPortController
bidib, context
-
Fields inherited from class jmri.jmrix.AbstractSerialPortController
currentSerialPort, 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 BiDiBSimulatorAdapter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
configure()
Set up all of the other objects to operate with a BiDiBSimulator connected to this portjava.lang.String
getCurrentPortName()
Overridden in simulator adapter classes to return "";java.io.DataInputStream
getInputStream()
Get the InputStream from the port.java.io.DataOutputStream
getOutputStream()
Get the outputStream to the port.java.lang.String
getRealPortName()
Get the physical port name used with jbidibcjava.lang.String
getSimulationFile()
boolean
isDirty()
Determine if configuration needs to be written to disk.boolean
isRestartRequired()
Determine if application needs to be restarted for configuration changes to be applied.java.lang.String
openPort(java.lang.String fileName, java.lang.String appName)
Here we do not really open something.void
registerAllListeners(org.bidib.jbidibc.messages.ConnectionListener connectionListener, java.util.Set<org.bidib.jbidibc.core.NodeListener> nodeListeners, java.util.Set<org.bidib.jbidibc.core.MessageListener> messageListeners, java.util.Set<org.bidib.jbidibc.core.node.listener.TransferListener> transferListeners)
Register all Listeners to the specific BiDiB Object.void
setSimulationFile(java.lang.String f)
boolean
status()
Query the status of this connection.-
Methods inherited from class jmri.jmrix.bidib.BiDiBSerialPortController
getContext, getSystemConnectionMemo
-
Methods inherited from class jmri.jmrix.AbstractSerialPortController
activatePort, activatePort, activatePort, closeConnection, closeSerialPort, configureBaudRate, configureBaudRateFromIndex, configureBaudRateFromNumber, configureLeads, configureLeadsAndFlowControl, configureLeadsAndFlowControl, connect, currentBaudNumber, defaultBaudIndex, getActualPortNames, getCurrentBaudIndex, getCurrentBaudNumber, getCurrentBaudRate, getFlowControl, getPortSettingsString, handlePortBusy, handlePortNotFound, handlePortNotFound, isPortOpen, replacePortWithFakePort, reportPortStatus, resetupConnection, setBaudRate, setComPortTimeouts, setDataListener, setFlowControl, setPort, validBaudNumbers, validBaudRates
-
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, isOptionAdvanced, isOptionTypePassword, isOptionTypeText, purgeStream, reconnect, reconnectFromLoop, recover, safeSleep, setClosed, setDisabled, setManufacturer, setOpened, setOptionState, setReconnectMaxAttempts, setReconnectMaxInterval, setSystemConnectionMemo, setSystemPrefix, setUserName
-
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
connect, dispose, getDisabled, getOption1Name, getOption2Name, getOption3Name, getOption4Name, getOptionChoices, getOptionDisplayName, getOptions, getOptionState, getReconnectMaxAttempts, getReconnectMaxInterval, getSystemPrefix, getUserName, isOptionAdvanced, isOptionTypePassword, isOptionTypeText, recover, setDisabled, setOptionState, setReconnectMaxAttempts, setReconnectMaxInterval, setSystemConnectionMemo, setSystemPrefix, setUserName
-
Methods inherited from interface jmri.jmrix.SerialPortAdapter
configureOption1, configureOption2, configureOption3, configureOption4, getManufacturer, getPortNames, setManufacturer
-
-
-
-
Field Detail
-
simulationFile
protected java.lang.String simulationFile
-
loadedSimulationFilename
protected java.lang.String loadedSimulationFilename
-
absoluteSimulationFile
protected java.lang.String absoluteSimulationFile
-
-
Constructor Detail
-
BiDiBSimulatorAdapter
public BiDiBSimulatorAdapter()
-
-
Method Detail
-
getSimulationFile
public java.lang.String getSimulationFile()
-
setSimulationFile
public void setSimulationFile(java.lang.String f)
-
isDirty
public boolean isDirty()
Description copied from interface:PortAdapter
Determine if configuration needs to be written to disk.- Specified by:
isDirty
in interfacePortAdapter
- Overrides:
isDirty
in classAbstractPortController
- Returns:
- true if configuration needs to be saved, false otherwise
-
isRestartRequired
public boolean isRestartRequired()
Description copied from interface:PortAdapter
Determine if application needs to be restarted for configuration changes to be applied.- Specified by:
isRestartRequired
in interfacePortAdapter
- Overrides:
isRestartRequired
in classAbstractPortController
- Returns:
- true if application needs to restart, false otherwise
-
getCurrentPortName
public java.lang.String getCurrentPortName()
Overridden in simulator adapter classes to return "";- Specified by:
getCurrentPortName
in interfacePortAdapter
- Specified by:
getCurrentPortName
in interfaceSerialPortAdapter
- Overrides:
getCurrentPortName
in classAbstractSerialPortController
-
getRealPortName
public java.lang.String getRealPortName()
Get the physical port name used with jbidibc Get the "port name" in the format which is used by jbidibc - this is absolute path to the simulation XML file- Specified by:
getRealPortName
in interfaceBiDiBPortController
- Overrides:
getRealPortName
in classBiDiBSerialPortController
- Returns:
- real port name
-
openPort
public java.lang.String openPort(java.lang.String fileName, java.lang.String appName)
Here we do not really open something.- Parameters:
fileName
- name of simulation fileappName
- not used- Returns:
- error string, null if no error
-
configure
public void configure()
Set up all of the other objects to operate with a BiDiBSimulator connected to this port
-
registerAllListeners
public void registerAllListeners(org.bidib.jbidibc.messages.ConnectionListener connectionListener, java.util.Set<org.bidib.jbidibc.core.NodeListener> nodeListeners, java.util.Set<org.bidib.jbidibc.core.MessageListener> messageListeners, java.util.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:
registerAllListeners
in interfaceBiDiBPortController
- Specified by:
registerAllListeners
in classBiDiBSerialPortController
- Parameters:
connectionListener
- where to addnodeListeners
- listeners to addmessageListeners
- listeners to addtransferListeners
- listeners to add
-
getInputStream
public java.io.DataInputStream getInputStream()
Get the InputStream from the port.- Specified by:
getInputStream
in interfacePortAdapter
- Overrides:
getInputStream
in classAbstractSerialPortController
- Returns:
- the InputStream from the port
-
getOutputStream
public java.io.DataOutputStream getOutputStream()
Get the outputStream to the port.- Specified by:
getOutputStream
in interfacePortAdapter
- Overrides:
getOutputStream
in classAbstractSerialPortController
- Returns:
- the outputStream to the port
-
status
public boolean status()
Query the status of this connection. This is a question of configuration, not transient hardware status.- Specified by:
status
in interfacePortAdapter
- Specified by:
status
in interfaceSerialPortAdapter
- Overrides:
status
in classAbstractPortController
- Returns:
- true if OK, at least as far as known
-
-