Class ModbusUtils
java.lang.Object
io.openems.edge.bridge.modbus.api.ModbusUtils
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Short
convert
(int value, int upperBytes) Converts upper/lower bytes to Short.static <T> CompletableFuture<T>
readELementOnce
(ModbusProtocol modbusProtocol, AbstractModbusElement<T> element, boolean tryAgainOnError) Reads given Element once from Modbus.static <T> CompletableFuture<List<T>>
readELementsOnce
(ModbusProtocol modbusProtocol, AbstractModbusElement<T>[] elements, boolean tryAgainOnError) Reads given Elements once from Modbus.
-
Constructor Details
-
ModbusUtils
public ModbusUtils()
-
-
Method Details
-
readELementOnce
public static <T> CompletableFuture<T> readELementOnce(ModbusProtocol modbusProtocol, AbstractModbusElement<T> element, boolean tryAgainOnError) throws OpenemsException Reads given Element once from Modbus.- Type Parameters:
T
- the Type of the element- Parameters:
modbusProtocol
- theModbusProtocol
, that is linked with aBridgeModbus
element
- theAbstractModbusElement
tryAgainOnError
- if true, tries to read till it receives a value; if false, stops after first try and possibly return null- Returns:
- a future value, e.g. a Integer or null (if tryAgainOnError is false)
- Throws:
OpenemsException
- on error with theModbusProtocol
object
-
readELementsOnce
public static <T> CompletableFuture<List<T>> readELementsOnce(ModbusProtocol modbusProtocol, AbstractModbusElement<T>[] elements, boolean tryAgainOnError) throws OpenemsException Reads given Elements once from Modbus.- Type Parameters:
T
- the Type of the elements- Parameters:
modbusProtocol
- theModbusProtocol
, that is linked with aBridgeModbus
elements
- theAbstractModbusElement
stryAgainOnError
- if true, tries to read till it receives a value on first register; if false, stops after first try and possibly return null- Returns:
- a future array of values, e.g. Integer[] or null (if tryAgainOnError is false). If an array is returned, it is guaranteed to have the same length as `elements`
- Throws:
OpenemsException
- on error with theModbusProtocol
object
-
convert
Converts upper/lower bytes to Short.- Parameters:
value
- the int valueupperBytes
- 1 = upper two bytes, 0 = lower two bytes- Returns:
- the Short
-