Interface ModbusClient

All Known Implementing Classes:
NettyModbusClient

public interface ModbusClient
API for a Modbus client application.
  • Method Details

    • getClientConfig

      ModbusClientConfig getClientConfig()
      Get the client configuration.
      Returns:
      the client configuration
    • start

      Future<?> start()
      Start the client.

      This method must be called before using the send(ModbusMessage) or sendAsync(ModbusMessage) methods. Calling this method on a client that has already been started is allowed, and will return the same result as first returned.

      Returns:
      a future that completes when the client is ready to be used
    • isStarted

      boolean isStarted()
      Test if the client has been started by a call to start() already.

      This will return true if start() has been called, until stop() is called.

      Returns:
      true if the client has been started (and not stopped)
    • stop

      void stop()
      Stop the client.

      This method shuts the client down, disconnecting it from whatever Modbus network it had been connected to. It can be started again by calling start(). Calling this method on a client that has already been stopped is allowed and will not result in any error.

      After calling this method isStarted() will return false.

    • isConnected

      boolean isConnected()
      Test if the client is started and connected to the Modbus network.

      Some clients may automatically reconnect to the network if the connection fails for any reason. After the connection has failed, and until it reconnects, this method will return false.

      Returns:
      true if the client is connected
    • send

      Send a request and receive a response, synchronously.
      Parameters:
      request - the request to send
      Returns:
      the response
    • sendAsync

      Future<ModbusMessage> sendAsync(ModbusMessage request)
      Send a request and receive a response, asynchronously.
      Parameters:
      request - the request to send
      Returns:
      the response future
    • setConnectionObserver

      void setConnectionObserver(ModbusClientConnectionObserver connectionObserver)
      Configure a connection observer.
      Parameters:
      connectionObserver - the observer to set, or null to clear