Class AbstractModbusElement<T>

    • Field Detail

      • onSetNextWriteCallbacks

        protected final java.util.List<java.util.function.Consumer<java.util.Optional<T>>> onSetNextWriteCallbacks
    • Constructor Detail

      • AbstractModbusElement

        public AbstractModbusElement​(OpenemsType type,
                                     int startAddress)
      • AbstractModbusElement

        public AbstractModbusElement​(OpenemsType type,
                                     int startAddress,
                                     boolean isIgnored)
    • Method Detail

      • onSetNextWrite

        public final void onSetNextWrite​(java.util.function.Consumer<java.util.Optional<T>> callback)
        Description copied from interface: ModbusElement
        Add an onSetNextWrite callback. It is called when a 'next write value' was set.
        Specified by:
        onSetNextWrite in interface ModbusElement<T>
        Parameters:
        callback - the callback
      • getType

        public OpenemsType getType()
        Description copied from interface: ModbusElement
        Gets the type of this Register, e.g. INTEGER, BOOLEAN,..
        Specified by:
        getType in interface ModbusElement<T>
        Returns:
        the OpenemsType
      • onUpdateCallback

        public AbstractModbusElement<T> onUpdateCallback​(java.util.function.Consumer<T> onUpdateCallback)
        The onUpdateCallback is called on reception of a new value.

        Be aware, that this is the original, untouched value. ChannelToElementConverters are not applied here yet!

        Parameters:
        onUpdateCallback - the Callback
        Returns:
        myself
      • getStartAddress

        public int getStartAddress()
        Description copied from interface: ModbusElement
        Gets the start address of this Modbus element.
        Specified by:
        getStartAddress in interface ModbusElement<T>
        Returns:
        the start address
      • isIgnored

        public boolean isIgnored()
        Description copied from interface: ModbusElement
        Whether this Element should be ignored (= DummyElement).
        Specified by:
        isIgnored in interface ModbusElement<T>
        Returns:
        true for ignored elements
      • setValue

        protected void setValue​(T value)
      • invalidate

        public boolean invalidate​(AbstractModbusBridge bridge)
        Description copied from interface: ModbusElement
        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.
        Specified by:
        invalidate in interface ModbusElement<T>
        Parameters:
        bridge - the AbstractModbusBridge
        Returns:
        true if Channel was invalidated
      • isDebug

        protected boolean isDebug()
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • deactivate

        public void deactivate()
        Description copied from interface: ModbusElement
        This is called on deactivate of the Modbus-Bridge. It can be used to clear any references like listeners.
        Specified by:
        deactivate in interface ModbusElement<T>