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:
-
Method Summary
Modifier and TypeMethodDescriptionvoidConfigure all of the other jmrix widgets needed to work with this adapter.voidconfigureOption1(String value) Set the first port option.voidconfigureOption2(String value) Set the second port option.voidconfigureOption3(String value) Set the third port option.voidconfigureOption4(String value) Set the fourth port option.voidconnect()Open the connection.voiddispose()This is called when a connection is to be disposed.booleanReturn the disabled state of the adapter.Get the InputStream from the port.Get the system manufacturer's name.String[]getOptionChoices(String option) Get a list of the various choices allowed with an given option.getOptionDisplayName(String option) String[]Get a list of all the options configured against this adapter.getOptionState(String option) Get the string value of a specific option.Get the outputStream to the port.intGet the maximum number of reconnection attempts which should be made.intGet the maximum interval between reconnection attempts.Get the system prefix for this adapter.Get the user name for this adapter.booleanisDirty()Determine if configuration needs to be written to disk.booleanisOptionAdvanced(String option) booleanisOptionTypePassword(String option) Should this option be represented by a password fieldbooleanisOptionTypeText(String option) Should this option be represented by a text field (as opposed to a JCombobox)booleanDetermine 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(String Manufacturer) Set the system manufacturer's name.voidsetOptionState(String option, 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(String systemPrefix) Set the system prefix for this adapter.voidsetUserName(String userName) Set the user name for this adapter.booleanstatus()Query the status of this connection.
-
Method Details
-
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
Open the connection.- Throws:
IOException- if unable to connect
-
getCurrentPortName
-
getInputStream
Get the InputStream from the port.- Returns:
- the InputStream from the port
-
getOutputStream
Get the outputStream to the port.- Returns:
- the outputStream to the port
-
getOption1Name
-
getOption2Name
-
getOption3Name
-
getOption4Name
-
configureOption1
Set the first port option. Only to be used after construction, but before the openPort call.- Parameters:
value- to set the option to
-
configureOption2
Set the second port option. Only to be used after construction, but before the openPort call.- Parameters:
value- to set the option to
-
configureOption3
Set the third port option. Only to be used after construction, but before the openPort call.- Parameters:
value- to set the option to
-
configureOption4
Set the fourth port option. Only to be used after construction, but before the openPort call.- Parameters:
value- to set the option to
-
getOptions
String[] getOptions()Get a list of all the options configured against this adapter.- Returns:
- Array of option identifier strings
-
isOptionAdvanced
-
getOptionDisplayName
-
setOptionState
Set the value of an option.- Parameters:
option- the name string of the optionvalue- the string value to set the option to
-
getOptionState
Get the string value of a specific option.- Parameters:
option- the name of the option to query- Returns:
- the option value
-
getOptionChoices
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
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
Should this option be represented by a password field- Parameters:
option- Name of the option to check- Returns:
- true for text representation preferred
-
getManufacturer
Get the system manufacturer's name.- Returns:
- manufacturer's name
-
setManufacturer
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
Set whether the connection is disabled.- Parameters:
disabled- When true, disables operation
-
getUserName
Get the user name for this adapter.- Returns:
- the username or null
-
setUserName
Set the user name for this adapter.- Parameters:
userName- the new user name- Throws:
IllegalArgumentException- if another adapter has this user name
-
getSystemPrefix
Get the system prefix for this adapter.- Returns:
- the system prefix or null
-
setSystemPrefix
Set the system prefix for this adapter.- Parameters:
systemPrefix- the new system prefix- Throws:
IllegalArgumentException- if another adapter has this system prefix
-
getSystemConnectionMemo
-
setSystemConnectionMemo
void setSystemConnectionMemo(@Nonnull SystemConnectionMemo connectionMemo) throws 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:
IllegalArgumentException- if connectionMemo is the wrong subclass of SystemConnectionMemoNullPointerException- 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
Set the maximum interval between reconnection attempts.- Parameters:
maxInterval- in seconds.
-
setReconnectMaxAttempts
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.
-