Interface ModbusCommunicationInterface
- All Superinterfaces:
- AutoCloseable
Interface for interacting with a particular modbus slave.
 When no further communication is expected with the slave, close the interface so that any underlying resources can be
 freed.
 Close unregisters all the regular polls registered with registerRegularPoll. When endpoint's last
 communication interface is closed, the connection is closed as well, no matter the what EndpointPoolConfiguration
 says.
- Author:
- Sami Salonen - Initial contribution
- 
Method SummaryModifier and TypeMethodDescriptionvoidclose()Close this communication interface and try to free all resources associated with it Upon close, all polling tasks registered by this instance are unregistered.Get endpoint associated with this communication interfaceregisterRegularPoll(ModbusReadRequestBlueprint request, long pollPeriodMillis, long initialDelayMillis, ModbusReadCallback resultCallback, ModbusFailureCallback<ModbusReadRequestBlueprint> failureCallback) Register regularly polled task.Future<?> submitOneTimePoll(ModbusReadRequestBlueprint request, ModbusReadCallback resultCallback, ModbusFailureCallback<ModbusReadRequestBlueprint> failureCallback) Submit one-time poll task.Future<?> submitOneTimeWrite(ModbusWriteRequestBlueprint request, ModbusWriteCallback resultCallback, ModbusFailureCallback<ModbusWriteRequestBlueprint> failureCallback) Submit one-time write task.booleanUnregister regularly polled task If this communication interface is closed already, the method returns immediately with false return value
- 
Method Details- 
getEndpointModbusSlaveEndpoint getEndpoint()Get endpoint associated with this communication interface- Returns:
- modbus slave endpoint
 
- 
submitOneTimePollFuture<?> submitOneTimePoll(ModbusReadRequestBlueprint request, ModbusReadCallback resultCallback, ModbusFailureCallback<ModbusReadRequestBlueprint> failureCallback) Submit one-time poll task. The method returns immediately, and the execution of the poll task will happen in background.- Parameters:
- request- request to send
- resultCallback- callback to call with data
- failureCallback- callback to call in case of failure
- Returns:
- future representing the polled task
- Throws:
- IllegalStateException- when this communication has been closed already
 
- 
registerRegularPollPollTask registerRegularPoll(ModbusReadRequestBlueprint request, long pollPeriodMillis, long initialDelayMillis, ModbusReadCallback resultCallback, ModbusFailureCallback<ModbusReadRequestBlueprint> failureCallback) Register regularly polled task. The method returns immediately, and the execution of the poll task will happen in the background. One can register only one regular poll task for triplet of (endpoint, request, callback).- Parameters:
- request- request to send
- pollPeriodMillis- poll interval, in milliseconds
- initialDelayMillis- initial delay before starting polling, in milliseconds
- resultCallback- callback to call with data
- failureCallback- callback to call in case of failure
- Returns:
- poll task representing the regular poll
- Throws:
- IllegalStateException- when this communication has been closed already
 
- 
unregisterRegularPollUnregister regularly polled task If this communication interface is closed already, the method returns immediately with false return value- Parameters:
- task- poll task to unregister
- Returns:
- whether poll task was unregistered. Poll task is not unregistered in case of unexpected errors or in the case where the poll task is not registered in the first place
 
- 
submitOneTimeWriteFuture<?> submitOneTimeWrite(ModbusWriteRequestBlueprint request, ModbusWriteCallback resultCallback, ModbusFailureCallback<ModbusWriteRequestBlueprint> failureCallback) Submit one-time write task. The method returns immediately, and the execution of the task will happen in background.- Parameters:
- request- request to send
- resultCallback- callback to call with response
- failureCallback- callback to call in case of failure
- Returns:
- future representing the task
- Throws:
- IllegalStateException- when this communication has been closed already
 
- 
closeClose this communication interface and try to free all resources associated with it Upon close, all polling tasks registered by this instance are unregistered. In addition, connections are closed eagerly if this was the last connection interface pointing to the endpoint. After close, the communication interface cannot be used to communicate with the device.- Specified by:
- closein interface- AutoCloseable
- Throws:
- Exception
 
 
-