Class ModbusUtils
- java.lang.Object
-
- io.openems.edge.bridge.modbus.api.ModbusUtils
-
public class ModbusUtils extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description ModbusUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.Short
convert(int value, int upperBytes)
Converts upper/lower bytes to Short.static <T> java.util.concurrent.CompletableFuture<T>
readELementOnce(ModbusProtocol modbusProtocol, AbstractModbusElement<T> element, boolean tryAgainOnError)
Reads given Element once from Modbus.
-
-
-
Method Detail
-
readELementOnce
public static <T> java.util.concurrent.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
-
convert
public static java.lang.Short convert(int value, int upperBytes)
Converts upper/lower bytes to Short.- Parameters:
value
- the int valueupperBytes
- 1 = upper two bytes, 0 = lower two bytes- Returns:
- the Short
-
-