Class ModbusRegisterArray

java.lang.Object
org.openhab.core.io.transport.modbus.ModbusRegisterArray

@NonNullByDefault public class ModbusRegisterArray extends Object
Immutable ModbusRegisterArray implementation
Author:
Sami Salonen - Initial contribution
  • Constructor Summary

    Constructors
    Constructor
    Description
    ModbusRegisterArray(byte... bytes)
     
    ModbusRegisterArray(int... registerValues)
    Construct plain ModbusRegisterArray array from register values
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    equals(@Nullable Object obj)
     
    byte[]
    Return bytes representing the registers Index 0: hi-byte of 1st register Index 1: low-byte of 1st register Index 3: hi-byte of 2nd register Index 4: low-byte of 2nd register ...
    int
    getRegister(int i)
    Get register index i as unsigned integer
    int
     
    int
    Get number of registers stored in this instance
    Get register data as a hex string For example, 04 45 00 00
     

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • ModbusRegisterArray

      public ModbusRegisterArray(byte... bytes)
    • ModbusRegisterArray

      public ModbusRegisterArray(int... registerValues)
      Construct plain ModbusRegisterArray array from register values
      Parameters:
      registerValues - register values, each int corresponding to one register
  • Method Details

    • getRegister

      public int getRegister(int i)
      Get register index i as unsigned integer
      Parameters:
      i - register index
      Returns:
      register value interpreted as unsigned integer (big-endian byte ordering)
    • getBytes

      public byte[] getBytes()
      Return bytes representing the registers Index 0: hi-byte of 1st register Index 1: low-byte of 1st register Index 3: hi-byte of 2nd register Index 4: low-byte of 2nd register ...
      Returns:
      set of bytes
    • size

      public int size()
      Get number of registers stored in this instance
      Returns:
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • toHexString

      public String toHexString()
      Get register data as a hex string For example, 04 45 00 00
      Returns:
      string representing the bytes of the register array
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(@Nullable Object obj)
      Overrides:
      equals in class Object