Class AbstractDoc<T>

java.lang.Object
io.openems.edge.common.channel.internal.AbstractDoc<T>
All Implemented Interfaces:
Doc
Direct Known Subclasses:
EnumDoc, OpenemsTypeDoc

public abstract class AbstractDoc<T> extends Object implements Doc
Provides static meta information for a Channel using Builder pattern.
  • Constructor Details

    • AbstractDoc

      protected AbstractDoc(OpenemsType type)
  • Method Details

    • self

      protected abstract AbstractDoc<T> self()
      Gets an instance of the correct subclass of myself.
      Returns:
      myself
    • getType

      public OpenemsType getType()
      Description copied from interface: Doc
      Gets the OpenemsType.
      Specified by:
      getType in interface Doc
      Returns:
      the OpenemsType
    • accessMode

      public AbstractDoc<T> accessMode(AccessMode accessMode)
      Sets the AccessMode for the Channel.

      This is validated on construction of the Channel by AbstractReadChannel

      Parameters:
      accessMode - the AccessMode
      Returns:
      myself
    • getAccessMode

      public AccessMode getAccessMode()
      Description copied from interface: Doc
      Gets the 'Access-Mode' information.
      Specified by:
      getAccessMode in interface Doc
      Returns:
      the AccessMode
    • persistencePriority

      public AbstractDoc<T> persistencePriority(PersistencePriority persistencePriority)
      Sets the PersistencePriority. Defaults to PersistencePriority.VERY_LOW.

      This parameter may be used by persistence services to decide, if the Channel should be persisted to the hard disk.

      Parameters:
      persistencePriority - the PersistencePriority
      Returns:
      myself
    • getPersistencePriority

      public PersistencePriority getPersistencePriority()
      Description copied from interface: Doc
      Gets the Persistence Priority. Defaults to VERY_LOW.

      This parameter may be used by persistence services to decide, if the Channel should be persisted to the hard disk.

      Specified by:
      getPersistencePriority in interface Doc
      Returns:
      the PersistencePriority
    • initialValue

      public AbstractDoc<T> initialValue(T initialValue)
      Initial-Value. Default: none
      Parameters:
      initialValue - the initial value
      Returns:
      myself
    • getInitialValue

      public T getInitialValue()
      Gets the initial value.
      Returns:
      the initial value
    • text

      public AbstractDoc<T> text(String text)
      Description copied from interface: Doc
      Sets the descriptive text. Defaults to an empty string.
      Specified by:
      text in interface Doc
      Parameters:
      text - the text
      Returns:
      myself
    • getText

      public String getText()
      Description copied from interface: Doc
      Gets the descriptive text. Defaults to empty String.
      Specified by:
      getText in interface Doc
      Returns:
      the text
    • getUnit

      public Unit getUnit()
      Description copied from interface: Doc
      Gets the Unit. Defaults to NONE.
      Specified by:
      getUnit in interface Doc
      Returns:
      the unit
    • debug

      public AbstractDoc<T> debug()
      Activates the more verbose debug mode.
      Returns:
      myself
    • isDebug

      public boolean isDebug()
      Description copied from interface: Doc
      Is the more verbose debug mode activated?.
      Specified by:
      isDebug in interface Doc
      Returns:
      true for debug mode
    • onInit

      public AbstractDoc<T> onInit(Consumer<Channel<T>> callback)
      Provides a callback on initialization of the actual Channel.
      Parameters:
      callback - the method to call on initialization
      Returns:
      myself
    • onChannelChange

      public <COMPONENT extends OpenemsComponent> AbstractDoc<T> onChannelChange(Consumer<COMPONENT> callback)
      Provides a callback on Channel onChange event.

      This is a convenience method to react on a Channel.onChange(BiConsumer) event

      Type Parameters:
      COMPONENT - the type of the OpenemsComponent
      Parameters:
      callback - the callback method
      Returns:
      myself
    • onChannelChange

      public <COMPONENT extends OpenemsComponent> AbstractDoc<T> onChannelChange(BiConsumer<COMPONENT,Value<T>> callback)
      Provides a callback on Channel onChange event.

      This is a convenience method to react on a Channel.onChange(BiConsumer) event

      Type Parameters:
      COMPONENT - the type of the OpenemsComponent
      Parameters:
      callback - the callback method; value is the new value after change
      Returns:
      myself
    • onChannelUpdate

      public <COMPONENT extends OpenemsComponent> AbstractDoc<T> onChannelUpdate(BiConsumer<COMPONENT,Value<T>> callback)
      Provides a callback on Channel onUpdate event.

      This is a convenience method to react on a Channel.onUpdate(Consumer) event

      Type Parameters:
      COMPONENT - the type of the OpenemsComponent
      Parameters:
      callback - the callback method
      Returns:
      myself
    • onChannelSetNextValue

      public <COMPONENT extends OpenemsComponent> AbstractDoc<T> onChannelSetNextValue(BiConsumer<COMPONENT,Value<T>> callback)
      Provides a callback on Channel setNextValue event.

      This is a convenience method to react on a Channel.onSetNextValue(Consumer) event

      Type Parameters:
      COMPONENT - the type of the OpenemsComponent
      Parameters:
      callback - the callback method; value is the new value after change
      Returns:
      myself
    • onChannelSetNextWrite

      public <COMPONENT extends OpenemsComponent> AbstractDoc<T> onChannelSetNextWrite(ThrowingBiConsumer<COMPONENT,T,OpenemsError.OpenemsNamedException> callback)
      Provides a callback on Channel setNextWriteValue event.

      This is a convenience method to react on a WriteChannel.onSetNextWrite(ThrowingConsumer) event

      Type Parameters:
      COMPONENT - the type of the OpenemsComponent
      Parameters:
      callback - the callback method; value can be null
      Returns:
      myself
    • onChannelSetNextWriteMirrorToDebugChannel

      public AbstractDoc<T> onChannelSetNextWriteMirrorToDebugChannel(ChannelId targetChannelId)
      Registers a Mirror-To-Debug-Channel on Channel setNextWriteValue event.

      After calling this method, on every setNextWriteValue event, the 'nextWriteValue' will be mirrored to the 'targetChannelId' of the same Component.

      Parameters:
      targetChannelId - the target Channel-ID of the same component
      Returns:
      myself
    • getOnInitCallbacks

      protected List<Consumer<Channel<T>>> getOnInitCallbacks()
      Gets the callbacks for initialization of the actual Channel.
      Returns:
      a list of callbacks
    • createChannelInstance

      public abstract <C extends Channel<?>> C createChannelInstance(OpenemsComponent component, ChannelId channelId)
      Creates an instance of Channel for the given Channel-ID using its Channel-AbstractDoc.
      Specified by:
      createChannelInstance in interface Doc
      Type Parameters:
      C - the Channel type
      Parameters:
      component - the OpenemsComponent
      channelId - the ChannelId
      Returns:
      the Channel