Class AbstractWordElement<E,T>

Type Parameters:
E - the subclass of myself
T - the target OpenemsType
All Implemented Interfaces:
ModbusElement<T>, ModbusRegisterElement<T>
Direct Known Subclasses:
SignedWordElement, UnsignedWordElement

public abstract class AbstractWordElement<E,T> extends AbstractModbusRegisterElement<E,T>
A WordElement has a size of one Modbus Registers or 16 bit.
  • Constructor Details

    • AbstractWordElement

      public AbstractWordElement(OpenemsType type, int startAddress)
  • Method Details

    • getLength

      public final int getLength()
      Description copied from interface: ModbusElement
      Number of Registers or Coils.
      Returns:
      the number of Registers or Coils
    • _setInputRegisters

      protected void _setInputRegisters(com.ghgande.j2mod.modbus.procimg.InputRegister... registers)
      Specified by:
      _setInputRegisters in class AbstractModbusRegisterElement<E,T>
    • fromByteBuffer

      protected abstract T fromByteBuffer(ByteBuffer buff)
      Converts a 2-byte ByteBuffer to the the current OpenemsType.
      Parameters:
      buff - the ByteBuffer
      Returns:
      an instance of the current OpenemsType
    • _setNextWriteValue

      public void _setNextWriteValue(Optional<T> valueOpt) throws OpenemsException
      Description copied from interface: ModbusElement
      Sets a value that should be written to the Modbus device.
      Parameters:
      valueOpt - the Optional value
      Throws:
      OpenemsException - on error
    • toByteBuffer

      protected abstract ByteBuffer toByteBuffer(ByteBuffer buff, Object value)
      Converts the current OpenemsType to a 2-byte ByteBuffer.
      Parameters:
      buff - the target ByteBuffer
      value - the value
      Returns:
      the ByteBuffer