Package net.solarnetwork.node.io.modbus
Interface ModbusNetwork
- All Superinterfaces:
net.solarnetwork.service.Identifiable
- All Known Implementing Classes:
AbstractModbusNetwork
public interface ModbusNetwork
extends net.solarnetwork.service.Identifiable
High level Modbus API.
This API aims to simplify accessing Modbus capable devices without having any direct dependency on any specific Modbus implementation.
- Since:
- 2.0
- Version:
- 2.0
- Author:
- matt
-
Field Summary
Fields inherited from interface net.solarnetwork.service.Identifiable
GROUP_UID_PROPERTY, UID_PROPERTY -
Method Summary
Modifier and TypeMethodDescriptioncreateConnection(int unitId) Create a connection to a specific Modbus device.<T> TperformAction(int unitId, ModbusConnectionAction<T> action) Perform some action that requires aModbusConnection, returning the result.Methods inherited from interface net.solarnetwork.service.Identifiable
getDisplayName, getGroupUid, getUid
-
Method Details
-
performAction
Perform some action that requires aModbusConnection, returning the result.The
ModbusConnectionAction.doWithConnection(ModbusConnection)method will be called and the result returned by this method. TheModbusConnectionpassed will already be opened, and it will be closed automatically after the action is complete.- Type Parameters:
T- the result type- Parameters:
unitId- the Modbus unit ID to addressaction- the callback whose result to return- Returns:
- the result of calling
ModbusConnectionAction.doWithConnection(ModbusConnection) - Throws:
IOException- if any IO error occurs
-
createConnection
Create a connection to a specific Modbus device. The returned connection will not be opened and must be closed when finished being used.- Parameters:
unitId- the Modbus unit ID to connect with- Returns:
- a new connection
-