Class ModbusRegisterArray


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

      • 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 Detail

      • 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:
      • 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