Package jmri.jmrix
Interface PortAdapter
-
- All Known Subinterfaces:
BiDiBPortController
,DCCppPortController
,NetworkPortAdapter
,SerialPortAdapter
,XNetPortController
- All Known Implementing Classes:
AbstractNetworkPortController
,AbstractPortController
,AbstractSerialPortController
,AbstractStreamPortController
,AcelaPortController
,AnymaDMX_UsbPortAdapter
,BiDiBNetworkPortController
,BiDiBOverTcpAdapter
,BiDiBSerialPortController
,BiDiBSimulatorAdapter
,CanisbSerialDriverAdapter
,CanUsbDriverAdapter
,CdBPortController
,Dcc4PcPortController
,DCCppAdapter
,DCCppEthernetAdapter
,DCCppNetworkPortController
,DCCppSerialPortController
,DCCppSimulatorAdapter
,DCCppSimulatorPortController
,DCCppStreamPortController
,DCCppTcpDriverAdapter
,DemoSerialPort
,EasyDccNetworkPortController
,EasyDccPortController
,EcosPortController
,EliteAdapter
,GcPortController
,GcSerialDriverAdapter
,IEEE802154PortController
,IntelliboxAdapter
,InternalAdapter
,IpocsPortController
,JMRIClientPortController
,LI100Adapter
,LI100fAdapter
,LI101Adapter
,LIUSBAdapter
,LIUSBEthernetAdapter
,LIUSBServerAdapter
,LnHexFilePort
,LnNetworkPortController
,LnPortController
,LnStreamPortController
,LnTcpDriverAdapter
,LocoBufferAdapter
,LocoBufferIIAdapter
,LocoBufferNGAdapter
,LocoBufferUsbAdapter
,LocoNetBluetoothAdapter
,LZV200Adapter
,MarklinPortController
,MergNetworkDriverAdapter
,MqttAdapter
,MrcPortController
,MS100Adapter
,Mx1Adapter
,Mx1PortController
,NceNetworkPortController
,NcePortController
,NetworkDriverAdapter
,NetworkDriverAdapter
,NetworkDriverAdapter
,NetworkDriverAdapter
,NetworkDriverAdapter
,NetworkDriverAdapter
,NetworkDriverAdapter
,NetworkDriverAdapter
,NetworkDriverAdapter
,Ph5DriverAdapter
,PiLccSerialDriverAdapter
,PiSprog3SerialDriverAdapter
,PiSprog3v2SerialDriverAdapter
,PiSprogNanoSerialDriverAdapter
,PiSprogOneCSSerialDriverAdapter
,PiSprogOneSerialDriverAdapter
,Port
,PortController
,PortController
,PR2Adapter
,PR3Adapter
,PR4Adapter
,QsiPortController
,RaspberryPiAdapter
,RfidNetworkPortController
,RfidPortController
,RfidStreamPortController
,SerialAdapter
,SerialDriverAdapter
,SerialDriverAdapter
,SerialDriverAdapter
,SerialDriverAdapter
,SerialDriverAdapter
,SerialDriverAdapter
,SerialDriverAdapter
,SerialDriverAdapter
,SerialDriverAdapter
,SerialDriverAdapter
,SerialDriverAdapter
,SerialDriverAdapter
,SerialDriverAdapter
,SerialDriverAdapter
,SerialDriverAdapter
,SerialDriverAdapter
,SerialDriverAdapter
,SerialDriverAdapter
,SerialDriverAdapter
,SerialDriverAdapter
,SerialDriverAdapter
,SerialDriverAdapter
,SerialDriverAdapter
,SerialDriverAdapter
,SerialDriverAdapter
,SerialDriverAdapter
,SerialDriverAdapter
,SerialDriverAdapter
,SerialDriverAdapter
,SerialDriverAdapter
,SerialDriverAdapter
,SerialNetworkPortAdapter
,SerialPortAdapter
,SerialPortController
,SerialPortController
,SerialPortController
,SerialPortController
,SerialPortController
,SerialPortController
,SimDriverAdapter
,SimulatorAdapter
,SimulatorAdapter
,SimulatorAdapter
,SimulatorAdapter
,SimulatorAdapter
,SimulatorAdapter
,SimulatorAdapter
,SimulatorAdapter
,SimulatorAdapter
,SimulatorAdapter
,SimulatorAdapter
,SimulatorAdapter
,SpecificDriverAdapter
,SpecificDriverAdapter
,SpecificDriverAdapter
,SpecificDriverAdapter
,SpeedoPortController
,Sprog3PlusSerialDriverAdapter
,SprogCSSerialDriverAdapter
,SprogCSStreamPortController
,SprogNanoSerialDriverAdapter
,SprogPortController
,SRCPPortController
,TamsPortController
,UhlenbrockAdapter
,UsbDcs210PlusAdapter
,UsbDcs240Adapter
,UsbDcs240PlusAdapter
,UsbDcs52Adapter
,UsbDriverAdapter
,UsbPortAdapter
,UsbUhlenbrock63120Adapter
,XBeeAdapter
,XBeeIOStream
,XNetNetworkPortController
,XNetSerialPortController
,XNetSimulatorAdapter
,XNetSimulatorPortController
,XNetStreamPortController
,XnTcpAdapter
,XpaPortController
,Z21Adapter
,Z21LnStreamPortController
,Z21SimulatorAdapter
,Z21XNetStreamPortController
,ZTC611Adapter
,ZTC640Adapter
public interface PortAdapter
Enables basic setup of a interface for a jmrix implementation.This is the basic interface. Subclasses provide extensions for specific connection types (network, serial, etc).
For historical reasons, this provides both four specific options (option1 to option4) plus a more flexible interface based on a String array. The more flexible interface is the preferred one for new work, but the 1-4 form hasn't been deprecated yet.
General design documentation is available on the Structure of External System Connections page.
- Since:
- 2.3.1
- See Also:
SerialConfigException
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
configure()
Configure all of the other jmrix widgets needed to work with this adapter.void
configureOption1(java.lang.String value)
Set the first port option.void
configureOption2(java.lang.String value)
Set the second port option.void
configureOption3(java.lang.String value)
Set the third port option.void
configureOption4(java.lang.String value)
Set the fourth port option.void
connect()
Open the connection.void
dispose()
This is called when a connection is to be disposed.java.lang.String
getCurrentPortName()
boolean
getDisabled()
Return the disabled state of the adapter.java.io.DataInputStream
getInputStream()
Get the InputStream from the port.java.lang.String
getManufacturer()
Get the system manufacturer's name.java.lang.String
getOption1Name()
java.lang.String
getOption2Name()
java.lang.String
getOption3Name()
java.lang.String
getOption4Name()
java.lang.String[]
getOptionChoices(java.lang.String option)
Get a list of the various choices allowed with an given option.java.lang.String
getOptionDisplayName(java.lang.String option)
java.lang.String[]
getOptions()
Get a list of all the options configured against this adapter.java.lang.String
getOptionState(java.lang.String option)
Get the string value of a specific option.java.io.DataOutputStream
getOutputStream()
Get the outputStream to the port.int
getReconnectMaxAttempts()
Get the maximum number of reconnection attempts which should be made.int
getReconnectMaxInterval()
Get the maximum interval between reconnection attempts.SystemConnectionMemo
getSystemConnectionMemo()
java.lang.String
getSystemPrefix()
Get the system prefix for this adapter.java.lang.String
getUserName()
Get the user name for this adapter.boolean
isDirty()
Determine if configuration needs to be written to disk.boolean
isOptionAdvanced(java.lang.String option)
boolean
isOptionTypePassword(java.lang.String option)
Should this option be represented by a password fieldboolean
isOptionTypeText(java.lang.String option)
Should this option be represented by a text field (as opposed to a JCombobox)boolean
isRestartRequired()
Determine if application needs to be restarted for configuration changes to be applied.void
recover()
This is called when a connection is initially lost.void
setDisabled(boolean disabled)
Set whether the connection is disabled.void
setManufacturer(java.lang.String Manufacturer)
Set the system manufacturer's name.void
setOptionState(java.lang.String option, java.lang.String value)
Set the value of an option.void
setReconnectMaxAttempts(int maxAttempts)
Set the maximum number of reconnection attemptsvoid
setReconnectMaxInterval(int maxInterval)
Set the maximum interval between reconnection attempts.void
setSystemConnectionMemo(SystemConnectionMemo connectionMemo)
Replace the existing SystemConnectionMemo with another one.void
setSystemPrefix(java.lang.String systemPrefix)
Set the system prefix for this adapter.void
setUserName(java.lang.String userName)
Set the user name for this adapter.boolean
status()
Query the status of this connection.
-
-
-
Method Detail
-
configure
void configure()
Configure all of the other jmrix widgets needed to work with this adapter.
-
status
boolean status()
Query the status of this connection. This is a question of configuration, not transient hardware status.- Returns:
- true if OK, at least as far as known
-
connect
void connect() throws java.io.IOException
Open the connection.- Throws:
java.io.IOException
- if unable to connect
-
getCurrentPortName
java.lang.String getCurrentPortName()
-
getInputStream
java.io.DataInputStream getInputStream()
Get the InputStream from the port.- Returns:
- the InputStream from the port
-
getOutputStream
java.io.DataOutputStream getOutputStream()
Get the outputStream to the port.- Returns:
- the outputStream to the port
-
getOption1Name
java.lang.String getOption1Name()
-
getOption2Name
java.lang.String getOption2Name()
-
getOption3Name
java.lang.String getOption3Name()
-
getOption4Name
java.lang.String getOption4Name()
-
configureOption1
void configureOption1(java.lang.String value)
Set the first port option. Only to be used after construction, but before the openPort call.- Parameters:
value
- to set the option to
-
configureOption2
void configureOption2(java.lang.String value)
Set the second port option. Only to be used after construction, but before the openPort call.- Parameters:
value
- to set the option to
-
configureOption3
void configureOption3(java.lang.String value)
Set the third port option. Only to be used after construction, but before the openPort call.- Parameters:
value
- to set the option to
-
configureOption4
void configureOption4(java.lang.String value)
Set the fourth port option. Only to be used after construction, but before the openPort call.- Parameters:
value
- to set the option to
-
getOptions
java.lang.String[] getOptions()
Get a list of all the options configured against this adapter.- Returns:
- Array of option identifier strings
-
isOptionAdvanced
boolean isOptionAdvanced(java.lang.String option)
-
getOptionDisplayName
java.lang.String getOptionDisplayName(java.lang.String option)
-
setOptionState
void setOptionState(java.lang.String option, java.lang.String value)
Set the value of an option.- Parameters:
option
- the name string of the optionvalue
- the string value to set the option to
-
getOptionState
java.lang.String getOptionState(java.lang.String option)
Get the string value of a specific option.- Parameters:
option
- the name of the option to query- Returns:
- the option value
-
getOptionChoices
java.lang.String[] getOptionChoices(java.lang.String option)
Get a list of the various choices allowed with an given option.- Parameters:
option
- the name of the option to query- Returns:
- list of valid values for the option
-
isOptionTypeText
boolean isOptionTypeText(java.lang.String option)
Should this option be represented by a text field (as opposed to a JCombobox)- Parameters:
option
- Name of the option to check- Returns:
- true for text representation preferred
-
isOptionTypePassword
boolean isOptionTypePassword(java.lang.String option)
Should this option be represented by a password field- Parameters:
option
- Name of the option to check- Returns:
- true for text representation preferred
-
getManufacturer
java.lang.String getManufacturer()
Get the system manufacturer's name.- Returns:
- manufacturer's name
-
setManufacturer
void setManufacturer(java.lang.String Manufacturer)
Set the system manufacturer's name.- Parameters:
Manufacturer
- the manufacturer's name
-
getDisabled
boolean getDisabled()
Return the disabled state of the adapter.- Returns:
- true if disabled
-
setDisabled
void setDisabled(boolean disabled)
Set whether the connection is disabled.- Parameters:
disabled
- When true, disables operation
-
getUserName
java.lang.String getUserName()
Get the user name for this adapter.- Returns:
- the username or null
-
setUserName
void setUserName(java.lang.String userName) throws java.lang.IllegalArgumentException
Set the user name for this adapter.- Parameters:
userName
- the new user name- Throws:
java.lang.IllegalArgumentException
- if another adapter has this user name
-
getSystemPrefix
java.lang.String getSystemPrefix()
Get the system prefix for this adapter.- Returns:
- the system prefix or null
-
setSystemPrefix
void setSystemPrefix(java.lang.String systemPrefix) throws java.lang.IllegalArgumentException
Set the system prefix for this adapter.- Parameters:
systemPrefix
- the new system prefix- Throws:
java.lang.IllegalArgumentException
- if another adapter has this system prefix
-
getSystemConnectionMemo
SystemConnectionMemo getSystemConnectionMemo()
-
setSystemConnectionMemo
void setSystemConnectionMemo(SystemConnectionMemo connectionMemo) throws java.lang.IllegalArgumentException
Replace the existing SystemConnectionMemo with another one. Overriding methods should throw anIllegalAccessException
if the overriding class requires a specific subclass of SystemConnectionMemo. ANullPointerException
should be thrown if the parameter is null.- Parameters:
connectionMemo
- the new connection memo- Throws:
java.lang.IllegalArgumentException
- if connectionMemo is the wrong subclass of SystemConnectionMemojava.lang.NullPointerException
- if connectionMemo is null
-
dispose
void dispose()
This is called when a connection is to be disposed.
-
recover
void recover()
This is called when a connection is initially lost.
-
isDirty
boolean isDirty()
Determine if configuration needs to be written to disk.- Returns:
- true if configuration needs to be saved, false otherwise
-
isRestartRequired
boolean isRestartRequired()
Determine if application needs to be restarted for configuration changes to be applied.- Returns:
- true if application needs to restart, false otherwise
-
setReconnectMaxInterval
void setReconnectMaxInterval(int maxInterval)
Set the maximum interval between reconnection attempts.- Parameters:
maxInterval
- in seconds.
-
setReconnectMaxAttempts
void setReconnectMaxAttempts(int maxAttempts)
Set the maximum number of reconnection attempts. -1 will set an infinite number of attempts.- Parameters:
maxAttempts
- total maximum reconnection attempts.
-
getReconnectMaxInterval
int getReconnectMaxInterval()
Get the maximum interval between reconnection attempts.- Returns:
- maximum interval in seconds.
-
getReconnectMaxAttempts
int getReconnectMaxAttempts()
Get the maximum number of reconnection attempts which should be made. A value of -1 means no maximum value, i.e. infinite attempts.- Returns:
- total number of attempts which should be made.
-
-