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 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

      void connect() throws IOException
      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

      void configureOption1(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(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(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(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

      Get a list of all the options configured against this adapter.
      Returns:
      Array of option identifier strings
    • isOptionAdvanced

      boolean isOptionAdvanced(String option)
    • getOptionDisplayName

    • setOptionState

      void setOptionState(String option, String value)
      Set the value of an option.
      Parameters:
      option - the name string of the option
      value - 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

      boolean isOptionTypeText(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(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

      Get the system manufacturer's name.
      Returns:
      manufacturer's name
    • setManufacturer

      void setManufacturer(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

      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

      void setSystemPrefix(String systemPrefix) throws IllegalArgumentException
      Set the system prefix for this adapter.
      Parameters:
      systemPrefix - the new system prefix
      Throws:
      IllegalArgumentException - if another adapter has this system prefix
    • getSystemConnectionMemo

    • setSystemConnectionMemo

      Replace the existing SystemConnectionMemo with another one. Overriding methods should throw an IllegalAccessException if the overriding class requires a specific subclass of SystemConnectionMemo. A NullPointerException should be thrown if the parameter is null.
      Parameters:
      connectionMemo - the new connection memo
      Throws:
      IllegalArgumentException - if connectionMemo is the wrong subclass of SystemConnectionMemo
      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

      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

      Get the maximum interval between reconnection attempts.
      Returns:
      maximum interval in seconds.
    • 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.