Class 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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ModbusUtils

        public ModbusUtils()
    • 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 - the ModbusProtocol, that is linked with a BridgeModbus
        element - the AbstractModbusElement
        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 the ModbusProtocol object
      • convert

        public static java.lang.Short convert​(int value,
                                              int upperBytes)
        Converts upper/lower bytes to Short.
        Parameters:
        value - the int value
        upperBytes - 1 = upper two bytes, 0 = lower two bytes
        Returns:
        the Short