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,MarklinSimDriverAdapter,MergNetworkDriverAdapter,MqttAdapter,MrcPortController,MS100Adapter,Mx1Adapter,Mx1PortController,NceNetworkPortController,NcePortController,NetBiDiBAdapter,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,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,TcpDriverAdapter,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 voidconfigure()Configure all of the other jmrix widgets needed to work with this adapter.voidconfigureOption1(java.lang.String value)Set the first port option.voidconfigureOption2(java.lang.String value)Set the second port option.voidconfigureOption3(java.lang.String value)Set the third port option.voidconfigureOption4(java.lang.String value)Set the fourth port option.voidconnect()Open the connection.voiddispose()This is called when a connection is to be disposed.java.lang.StringgetCurrentPortName()booleangetDisabled()Return the disabled state of the adapter.java.io.DataInputStreamgetInputStream()Get the InputStream from the port.java.lang.StringgetManufacturer()Get the system manufacturer's name.java.lang.StringgetOption1Name()java.lang.StringgetOption2Name()java.lang.StringgetOption3Name()java.lang.StringgetOption4Name()java.lang.String[]getOptionChoices(java.lang.String option)Get a list of the various choices allowed with an given option.java.lang.StringgetOptionDisplayName(java.lang.String option)java.lang.String[]getOptions()Get a list of all the options configured against this adapter.java.lang.StringgetOptionState(java.lang.String option)Get the string value of a specific option.java.io.DataOutputStreamgetOutputStream()Get the outputStream to the port.intgetReconnectMaxAttempts()Get the maximum number of reconnection attempts which should be made.intgetReconnectMaxInterval()Get the maximum interval between reconnection attempts.SystemConnectionMemogetSystemConnectionMemo()java.lang.StringgetSystemPrefix()Get the system prefix for this adapter.java.lang.StringgetUserName()Get the user name for this adapter.booleanisDirty()Determine if configuration needs to be written to disk.booleanisOptionAdvanced(java.lang.String option)booleanisOptionTypePassword(java.lang.String option)Should this option be represented by a password fieldbooleanisOptionTypeText(java.lang.String option)Should this option be represented by a text field (as opposed to a JCombobox)booleanisRestartRequired()Determine if application needs to be restarted for configuration changes to be applied.voidrecover()This is called when a connection is initially lost.voidsetDisabled(boolean disabled)Set whether the connection is disabled.voidsetManufacturer(java.lang.String Manufacturer)Set the system manufacturer's name.voidsetOptionState(java.lang.String option, java.lang.String value)Set the value of an option.voidsetReconnectMaxAttempts(int maxAttempts)Set the maximum number of reconnection attemptsvoidsetReconnectMaxInterval(int maxInterval)Set the maximum interval between reconnection attempts.voidsetSystemConnectionMemo(SystemConnectionMemo connectionMemo)Replace the existing SystemConnectionMemo with another one.voidsetSystemPrefix(java.lang.String systemPrefix)Set the system prefix for this adapter.voidsetUserName(java.lang.String userName)Set the user name for this adapter.booleanstatus()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(@Nonnull SystemConnectionMemo connectionMemo) throws java.lang.IllegalArgumentException
Replace the existing SystemConnectionMemo with another one. Overriding methods should throw anIllegalAccessExceptionif the overriding class requires a specific subclass of SystemConnectionMemo. ANullPointerExceptionshould 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.
-
-