Interface ModbusClient
- All Known Implementing Classes:
NettyModbusClient
-
Method Summary
Modifier and TypeMethodDescriptionbooleanTest if the client is started and connected to the Modbus network.booleanTest if the client has been started by a call tostart()already.send(ModbusMessage request) Send a request and receive a response, synchronously.sendAsync(ModbusMessage request) Send a request and receive a response, asynchronously.voidsetConnectionObserver(ModbusClientConnectionObserver connectionObserver) Configure a connection observer.Future<?>start()Start the client.voidstop()Stop the client.
-
Method Details
-
start
Future<?> start()Start the client.This method must be called before using the
send(ModbusMessage)orsendAsync(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 tostart()already.This will return true if
start()has been called, untilstop()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
Send a request and receive a response, asynchronously.- Parameters:
request- the request to send- Returns:
- the response future
-
setConnectionObserver
Configure a connection observer.- Parameters:
connectionObserver- the observer to set, or null to clear
-