Package jmri.jmrix.lenz.liusbserver
Class LIUSBServerAdapter
- java.lang.Object
-
- jmri.jmrix.AbstractPortController
-
- jmri.jmrix.AbstractNetworkPortController
-
- jmri.jmrix.lenz.XNetNetworkPortController
-
- jmri.jmrix.lenz.liusbserver.LIUSBServerAdapter
-
- All Implemented Interfaces:
XNetPortController
,NetworkPortAdapter
,PortAdapter
public class LIUSBServerAdapter extends XNetNetworkPortController
Provide access to XpressNet via a the Lenz LIUSB Server. NOTES: The LIUSB server binds only to localhost (127.0.0.1) on TCP ports 5550 and 5551. Port 5550 is used for general communication. Port 5551 is used for broadcast messages only. The LIUSB Server disconnects both ports if there is 60 seconds of inactivity on the port. The LIUSB Server disconnects port 5550 if another device puts the system into service mode.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class jmri.jmrix.AbstractPortController
AbstractPortController.Option
-
-
Field Summary
Fields Modifier and Type Field Description (package private) static int
BROADCAST_TCP_PORT
(package private) static int
COMMUNICATION_TCP_PORT
(package private) static java.lang.String
DEFAULT_IP_ADDRESS
-
Fields inherited from class jmri.jmrix.AbstractNetworkPortController
connTimeout, m_HostName, m_port, socketConn
-
Fields inherited from class jmri.jmrix.AbstractPortController
allowConnectionRecovery, manufacturerName, opened, option1Name, option2Name, option3Name, option4Name, options, reconnectinterval, reconnectMaxAttempts, reconnectMaxInterval
-
-
Constructor Summary
Constructors Constructor Description LIUSBServerAdapter()
-
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 LIUSB Server interface.void
connect()
Open the connection.java.io.DataInputStream
getInputStream()
Get the InputStream from the port.java.io.DataOutputStream
getOutputStream()
Get the outputStream to the port.boolean
okToSend()
Can the port accept additional characters?void
recover()
This is called when a connection is initially lost.protected void
resetupConnection()
Customizable method to deal with resetting a system connection after a successful recovery of a connection.boolean
status()
Check that this object is ready to operate.-
Methods inherited from class jmri.jmrix.lenz.XNetNetworkPortController
dispose, getSystemConnectionMemo, hasTimeSlot, setOutputBufferEmpty, setTimeSlot
-
Methods inherited from class jmri.jmrix.AbstractNetworkPortController
autoConfigure, closeConnection, connect, getAdvertisementName, getConnectionTimeout, getCurrentPortName, getHostAddress, getHostName, getMdnsConfigure, getPort, getServiceType, reconnectFromLoop, setAdvertisementName, setConnectionTimeout, setHostAddress, setHostName, setMdnsConfigure, setPort, setPort, setServiceType
-
Methods inherited from class jmri.jmrix.AbstractPortController
configureOption1, configureOption2, configureOption3, configureOption4, getDisabled, getManufacturer, getOption1Name, getOption2Name, getOption3Name, getOption4Name, getOptionChoices, getOptionDisplayName, getOptions, getOptionState, getReconnectMaxAttempts, getReconnectMaxInterval, getSystemPrefix, getUserName, isDirty, isOptionAdvanced, isOptionTypePassword, isOptionTypeText, isRestartRequired, purgeStream, reconnect, 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
configureOption1, configureOption2, configureOption3, configureOption4, getDisabled, getManufacturer, getOption1Name, getOption2Name, getOption3Name, getOption4Name, getOptionChoices, getOptionDisplayName, getOptions, getOptionState, getReconnectMaxAttempts, getReconnectMaxInterval, getSystemPrefix, getUserName, isDirty, isOptionAdvanced, isOptionTypePassword, isOptionTypeText, isRestartRequired, setDisabled, setManufacturer, setOptionState, setReconnectMaxAttempts, setReconnectMaxInterval, setSystemConnectionMemo, setSystemPrefix, setUserName
-
-
-
-
Field Detail
-
COMMUNICATION_TCP_PORT
static final int COMMUNICATION_TCP_PORT
- See Also:
- Constant Field Values
-
BROADCAST_TCP_PORT
static final int BROADCAST_TCP_PORT
- See Also:
- Constant Field Values
-
DEFAULT_IP_ADDRESS
static final java.lang.String DEFAULT_IP_ADDRESS
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
LIUSBServerAdapter
public LIUSBServerAdapter()
-
-
Method Detail
-
connect
public void connect() throws java.io.IOException
Description copied from interface:PortAdapter
Open the connection.- Specified by:
connect
in interfacePortAdapter
- Overrides:
connect
in classAbstractNetworkPortController
- Throws:
java.io.IOException
- if unable to connect
-
okToSend
public boolean okToSend()
Can the port accept additional characters? return true if the port is opened.- Specified by:
okToSend
in interfaceXNetPortController
- Overrides:
okToSend
in classXNetNetworkPortController
- Returns:
- true if OK to send, else false.
-
getInputStream
public java.io.DataInputStream getInputStream()
Description copied from class:AbstractNetworkPortController
Get the InputStream from the port.- Specified by:
getInputStream
in interfacePortAdapter
- Overrides:
getInputStream
in classAbstractNetworkPortController
- Returns:
- the InputStream from the port
-
getOutputStream
public java.io.DataOutputStream getOutputStream()
Description copied from class:AbstractNetworkPortController
Get the outputStream to the port.- Specified by:
getOutputStream
in interfacePortAdapter
- Overrides:
getOutputStream
in classAbstractNetworkPortController
- Returns:
- the outputStream to the port
-
status
public boolean status()
Description copied from class:XNetNetworkPortController
Check that this object is ready to operate. This is a question of configuration, not transient hardware status.- Specified by:
status
in interfaceNetworkPortAdapter
- Specified by:
status
in interfacePortAdapter
- Specified by:
status
in interfaceXNetPortController
- Specified by:
status
in classXNetNetworkPortController
- Returns:
- true if OK, at least as far as known
-
configure
public void configure()
Set up all of the other objects to operate with a LIUSB Server interface.
-
recover
public void recover()
This is called when a connection is initially lost. For this connection, it calls the default recovery method for both of the internal adapters.- Specified by:
recover
in interfacePortAdapter
- Overrides:
recover
in classAbstractPortController
-
resetupConnection
protected void resetupConnection()
Customizable method to deal with resetting a system connection after a successful recovery of a connection.- Overrides:
resetupConnection
in classXNetNetworkPortController
-
-