Interface ModbusElement<T>

All Known Subinterfaces:
ModbusCoilElement, ModbusReadElement<T>, ModbusRegisterElement<T>, ModbusWriteElement<T>
All Known Implementing Classes:
AbstractDoubleWordElement, AbstractModbusElement, AbstractModbusRegisterElement, AbstractQuadrupleWordElement, AbstractWordElement, BitsWordElement, CoilElement, DummyCoilElement, DummyRegisterElement, FloatDoublewordElement, FloatQuadruplewordElement, SignedDoublewordElement, SignedQuadruplewordElement, SignedWordElement, StringWordElement, UnsignedDoublewordElement, UnsignedQuadruplewordElement, UnsignedWordElement

public interface ModbusElement<T>
A ModbusElement represents one or more registers or coils in an AbstractTask.
  • Method Details

    • getStartAddress

      int getStartAddress()
      Gets the start address of this Modbus element.
      Returns:
      the start address
    • getLength

      int getLength()
      Number of Registers or Coils.
      Returns:
      the number of Registers or Coils
    • setModbusTask

      void setModbusTask(AbstractTask abstractTask)
      Set the AbstractTask, where this Element belongs to.

      This is called by the AbstractTask constructor.

      Parameters:
      abstractTask - the AbstractTask
    • isIgnored

      boolean isIgnored()
      Whether this Element should be ignored (= DummyElement).
      Returns:
      true for ignored elements
    • getType

      OpenemsType getType()
      Gets the type of this Register, e.g. INTEGER, BOOLEAN,..
      Returns:
      the OpenemsType
    • _setNextWriteValue

      void _setNextWriteValue(Optional<T> valueOpt) throws OpenemsException, IllegalArgumentException
      Sets a value that should be written to the Modbus device.
      Parameters:
      valueOpt - the Optional value
      Throws:
      OpenemsException - on error
      IllegalArgumentException - on error
    • onSetNextWrite

      void onSetNextWrite(Consumer<Optional<T>> callback)
      Add an onSetNextWrite callback. It is called when a 'next write value' was set.
      Parameters:
      callback - the callback
    • invalidate

      boolean invalidate(AbstractModbusBridge bridge)
      Invalidates the Channel in case it could not be read from the Modbus device, i.e. sets the value to 'UNDEFINED'/null. Applies the 'invalidateElementsAfterReadErrors' config setting of the bridge.
      Parameters:
      bridge - the AbstractModbusBridge
      Returns:
      true if Channel was invalidated
    • deactivate

      void deactivate()
      This is called on deactivate of the Modbus-Bridge. It can be used to clear any references like listeners.