public interface ModbusClient
| Modifier and Type | Method and Description |
|---|---|
ModbusClientConfig |
getClientConfig()
Get the client configuration.
|
boolean |
isConnected()
Test if the client is started and connected to the Modbus network.
|
boolean |
isStarted()
Test if the client has been started by a call to
start()
already. |
ModbusMessage |
send(ModbusMessage request)
Send a request and receive a response, synchronously.
|
CompletableFuture<ModbusMessage> |
sendAsync(ModbusMessage request)
Send a request and receive a response, asynchronously.
|
void |
setConnectionObserver(ModbusClientConnectionObserver connectionObserver)
Configure a connection observer.
|
CompletableFuture<?> |
start()
Start the client.
|
CompletableFuture<?> |
stop()
Stop the client.
|
ModbusClientConfig getClientConfig()
CompletableFuture<?> start()
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.
boolean isStarted()
start()
already.
This will return true if start() has been called,
until stop() is called.
CompletableFuture<?> stop()
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.
boolean isConnected()
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.
ModbusMessage send(ModbusMessage request)
request - the request to sendModbusTimeoutException - if a timeout occurs waiting for the responseModbusException - if an error occursCompletableFuture<ModbusMessage> sendAsync(ModbusMessage request)
request - the request to sendvoid setConnectionObserver(ModbusClientConnectionObserver connectionObserver)
connectionObserver - the observer to set, or null to clear