Interface Channel<T>

    • Field Detail

      • NO_OF_PAST_VALUES

        static final int NO_OF_PAST_VALUES
        Holds the number of past values for this Channel that are kept in the 'pastValues' variable.
        See Also:
        Constant Field Values
    • Method Detail

      • channelId

        ChannelId channelId()
        Gets the ChannelId of this Channel.
        Returns:
      • channelDoc

        default Doc channelDoc()
        Gets the ChannelDoc of this Channel.
        Returns:
      • getComponent

        OpenemsComponent getComponent()
        Gets the OpenemsComponent this Channel belongs to.
        Returns:
      • address

        ChannelAddress address()
        Gets the address of this Channel.
        Returns:
      • nextProcessImage

        void nextProcessImage()
        Switches to the next process image, i.e. copies the "next"-value into "current"-value.
      • getType

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

        default void setNextValue​(java.lang.Object value)
        Updates the 'next value' of Channel.
        Parameters:
        value - the 'next value'. It is going to be the 'value' after the next ProcessImage gets activated.
      • getNextValue

        Value<T> getNextValue()
        Gets the 'next value'.

        Note that usually you should prefer the value() method.

        Returns:
        the 'next value'
      • removeOnSetNextValueCallback

        void removeOnSetNextValueCallback​(java.util.function.Consumer<?> callback)
        Removes an onSetNextValue callback.
        Parameters:
        callback - the callback Consumer
        See Also:
        onSetNextValue(Consumer)
      • _setNextValue

        @Deprecated
        void _setNextValue​(T value)
        Deprecated.
        Internal method. Do not call directly.
        Parameters:
        value - the 'next value'
      • value

        Value<T> value()
                throws java.lang.IllegalArgumentException
        Gets the currently active value, wrapped in a @{link Value}.
        Throws:
        java.lang.IllegalArgumentException - if value cannot be access, e.g. because the Channel is Write-Only.
      • getPastValues

        CircularTreeMap<java.time.LocalDateTime,​Value<T>> getPastValues()
        Gets the past values for this Channel.
        Returns:
        a map of recording time and historic value at that time
      • onUpdate

        java.util.function.Consumer<Value<T>> onUpdate​(java.util.function.Consumer<Value<T>> callback)
        Add an onUpdate callback. It is called, after the active value was updated by nextProcessImage().
      • removeOnUpdateCallback

        void removeOnUpdateCallback​(java.util.function.Consumer<Value<?>> callback)
        Removes an onUpdate callback.
        Parameters:
        callback - the callback Consumer
        See Also:
        onUpdate(Consumer)
      • onChange

        java.util.function.BiConsumer<Value<T>,​Value<T>> onChange​(java.util.function.BiConsumer<Value<T>,​Value<T>> callback)
        Add an onChange callback. It is called, after a new, different active value was set by nextProcessImage().
        Parameters:
        callback - old value and new value
      • removeOnChangeCallback

        void removeOnChangeCallback​(java.util.function.BiConsumer<?,​?> callback)
        Removes an onChange callback.
        Parameters:
        callback - the callback BiConsumer
        See Also:
        onChange(BiConsumer)
      • deactivate

        void deactivate()
        Deactivates the Channel and makes sure all callbacks are released for garbe collection to avoid memory-leaks.
      • setMetaInfo

        <META_INFO> void setMetaInfo​(META_INFO metaInfo)
                              throws java.lang.IllegalArgumentException
        Sets an object that holds meta information about the Channel, e.g. a read source or write target of this Channel, like a Modbus Register or REST-Api endpoint address. Defaults to null.
        Type Parameters:
        META_INFO - the type of the meta info
        Parameters:
        metaInfo - the meta info object
        Throws:
        java.lang.IllegalArgumentException - if there is already a different meta-info registered with the Channel
      • getMetaInfo

        <META_INFO> META_INFO getMetaInfo()
        Gets the meta information object. Defaults to null.
        Type Parameters:
        META_INFO - the type of the meta info attachment
        Returns:
        the meta info object