Class AbstractOpenemsComponent

java.lang.Object
io.openems.edge.common.component.AbstractOpenemsComponent
All Implemented Interfaces:
OpenemsComponent
Direct Known Subclasses:
AbstractCsvDatasource, AbstractDummyElectricityMeter, AbstractDummyOpenemsComponent, AbstractFixStateOfCharge, AbstractGenericManagedEss, AbstractManagedEvcsComponent, AbstractModbusBridge, AbstractModbusTcpApi, AbstractOpenemsMbusComponent, AbstractOpenemsModbusComponent, AbstractPredictor, AbstractRestApi, AppManagerImpl, BoschBpts5HybridCoreImpl, BoschBpts5HybridEssImpl, BoschBpts5HybridMeterImpl, BoschBpts5HybridPvImpl, BridgeMbusImpl, BridgeOnewireImpl, ComponentManagerImpl, ControllerApiBackendImpl, ControllerApiMqttImpl, ControllerApiWebsocketImpl, ControllerAsymmetricBalancingCosPhiImpl, ControllerAsymmetricFixReactivePowerImpl, ControllerAsymmetricPeakShavingImpl, ControllerAsymmetricPhaseRectificationImpl, ControllerChannelThresholdImpl, ControllerChpSocImpl, ControllerDebugDetailedLogImpl, ControllerDebugLogImpl, ControllerEssAcIslandImpl, ControllerEssActivePowerVoltageCharacteristicImpl, ControllerEssBalancingImpl, ControllerEssBalancingScheduleImpl, ControllerEssCycleImpl, ControllerEssDelayChargeImpl, ControllerEssDelayedSellToGridImpl, ControllerEssEmergencyCapacityReserveImpl, ControllerEssFixActivePowerImpl, ControllerEssFixReactivePowerImpl, ControllerEssGridOptimizedChargeImpl, ControllerEssHybridSurplusFeedToGridImpl, ControllerEssLimitActivePowerImpl, ControllerEssLimitTotalDischargeImpl, ControllerEssLinearPowerBandImpl, ControllerEssMinimumDischargePowerImpl, ControllerEssPeakShavingImpl, ControllerEssRandomPowerImpl, ControllerEssReactivePowerVoltageCharacteristicImpl, ControllerEssSellToGridLimitImpl, ControllerEssStandbyImpl, ControllerEssTimeslotPeakshavingImpl, ControllerEvcsFixActivePowerImpl, ControllerEvcsImpl, ControllerGenericJsonLogicImpl, ControllerHighLoadTimeslotImpl, ControllerIoAlarmImpl, ControllerIoAnalogImpl, ControllerIoChannelSingleThresholdImpl, ControllerIoFixDigitalOutputImpl, ControllerIoHeatingElementImpl, ControllerIoHeatPumpSgReadyImpl, ControllerMrFundamentalFrequencyImpl, ControllerMrSetBalancingImpl, ControllerPvInverterFixPowerLimitImpl, ControllerPvInverterSellToGridLimitImpl, CycleImpl, EssClusterImpl, EssFeneconBydContainerWatchdogControllerImpl, EssGridcon, EssPowerImpl, EvcsClusterPeakShavingImpl, EvcsOcppServer, EvcsPowerComponent, GoodWeChargerTwoStringImpl, HostImpl, IoGpioImpl, IoOffGridSwitchImpl, IoRevolutionPiDigitalIoImpl, IoShelly25Impl, IoShelly3EmImpl, IoShellyPlugImpl, KacoBlueplanetHybrid10ChargerImpl, KacoBlueplanetHybrid10CoreImpl, KacoBlueplanetHybrid10EssImpl, KacoBlueplanetHybrid10GridMeterImpl, KacoBlueplanetHybrid10PvInverterImpl, KostalPikoChargerImpl, KostalPikoCoreImpl, KostalPikoEssImpl, KostalPikoGridMeterImpl, MetaImpl, MeterDiscovergyImpl, MeterGridconImpl, MeterVirtualAddImpl, OneWireThermometerImpl, PredictorManagerImpl, PvInverterClusterImpl, SchedulerAllAlphabeticallyImpl, SchedulerDailyImpl, SchedulerFixedOrderImpl, SimulatorAppImpl, SimulatorBatteryImpl, SimulatorEssAsymmetricReactingImpl, SimulatorEssSinglePhaseReactingImpl, SimulatorEssSymmetricReactingImpl, SimulatorGridMeterActingImpl, SimulatorGridMeterReactingImpl, SimulatorIoDigitalInputOutputImpl, SimulatorModbusImpl, SimulatorNrcMeterActingImpl, SimulatorProductionMeterActingImpl, SimulatorPvInverterImpl, SimulatorThermometerImpl, SimulatorTimedataImpl, SumImpl, TeslaPowerwall2BatteryImpl, TeslaPowerwall2CoreImpl, TimedataInfluxDbImpl, TimedataRrd4jImpl, TimeOfUseTariffAwattarImpl, TimeOfUseTariffControllerImpl, TimeOfUseTariffCorrentlyImpl, TimeOfUseTariffTibberImpl, TouEntsoeImpl, VirtualSubtractMeterImpl

public abstract class AbstractOpenemsComponent extends Object implements OpenemsComponent
This is the default implementation of the OpenemsComponent interface.
invalid reference
#activate(ComponentContext, String, boolean)
and deactivate() methods should be called by the corresponding methods in the OSGi component.
  • Constructor Details

    • AbstractOpenemsComponent

      protected AbstractOpenemsComponent(ChannelId[] firstInitialChannelIds, ChannelId[]... furtherInitialChannelIds)
      Default constructor for AbstractOpenemsComponent.

      Automatically initializes (i.e. creates Channel instances for each given OpenemsComponent.ChannelId using the Channel-Doc.

      It is important to list all Channel-ID enums of all inherited OpenEMS-Natures, i.e. for every OpenEMS Java interface you are implementing, you need to list the interface' ChannelID-enum here like Interface.ChannelId.values().

      Use as follows:

       public YourPhantasticOpenemsComponent() {
              super(//
                              OpenemsComponent.ChannelId.values(), //
                              YourPhantasticOpenemsComponent.ChannelId.values());
       }
       

      Note: the separation in firstInitialChannelIds and furtherInitialChannelIds is only there to enforce that calling the constructor cannot be forgotten. This way it needs to be called with at least one parameter - which is always at least "OpenemsComponent.ChannelId.values()". Just use it as if it was:

       AbstractOpenemsComponent(ChannelId[]... channelIds)
       
      Parameters:
      firstInitialChannelIds - the Channel-IDs to initialize.
      furtherInitialChannelIds - the Channel-IDs to initialize.
  • Method Details

    • activate

      protected void activate(String id)
    • activate

      protected void activate(org.osgi.service.component.ComponentContext context, String id, String alias, boolean enabled) throws IllegalArgumentException
      Handles @Activate of implementations. Prints log output.
      Parameters:
      context - the OSGi ComponentContext
      id - the unique OpenEMS Component ID
      alias - Human-readable name of this Component. Typically 'config.alias()'. Defaults to 'id' if empty
      enabled - is the Component enabled?
      Throws:
      IllegalArgumentException - if 'id' is null
    • modified

      protected void modified(org.osgi.service.component.ComponentContext context, String id, String alias, boolean enabled) throws IllegalArgumentException
      Handles @Modified of implementations.
      Parameters:
      context - the OSGi ComponentContext
      id - the unique OpenEMS Component ID
      alias - Human-readable name of this Component. Typically 'config.alias()'. Defaults to 'id' if empty
      enabled - is the Component enabled?
      Throws:
      IllegalArgumentException - if 'id' is null
    • deactivate

      protected void deactivate()
      Handles @Deactivate of implementations. Prints log output.
    • isEnabled

      public boolean isEnabled()
      Description copied from interface: OpenemsComponent
      Returns whether this component is enabled.
      Specified by:
      isEnabled in interface OpenemsComponent
      Returns:
      true if the component is enabled
    • getComponentContext

      public org.osgi.service.component.ComponentContext getComponentContext()
      Description copied from interface: OpenemsComponent
      Returns the ComponentContext.
      Specified by:
      getComponentContext in interface OpenemsComponent
      Returns:
      the OSGi ComponentContext
    • addChannel

      protected Channel<?> addChannel(ChannelId channelId)
      Initializes the given Channel-ID.
      • Creates an object instance from Channel-Doc
      • Registers the Channel
      Parameters:
      channelId - the given Channel-ID
      Returns:
      the newly created Channel
    • addChannels

      protected void addChannels(ChannelId[] initialChannelIds)
      Initializes the given Channel-IDs.
      • Creates object instances from Channel-Doc
      • Registers the Channels
      Parameters:
      initialChannelIds - the given Channel-IDs
    • addChannels

      protected void addChannels(ChannelId[][] initialChannelIds)
      Initializes the given Channel-IDs.
      • Creates object instances from Channel-Doc
      • Registers the Channels
      Parameters:
      initialChannelIds - the given Channel-IDs
    • id

      public String id()
      Description copied from interface: OpenemsComponent
      Returns a unique ID for this OpenEMS component.
      Specified by:
      id in interface OpenemsComponent
      Returns:
      the unique ID
    • alias

      public String alias()
      Description copied from interface: OpenemsComponent
      Returns a human-readable name of this Component..
      Specified by:
      alias in interface OpenemsComponent
      Returns:
      the human-readable name
    • _channel

      @Deprecated public Channel<?> _channel(String channelName)
      Deprecated.
      Description copied from interface: OpenemsComponent
      Returns an undefined Channel defined by its ChannelId string representation.

      Note: It is preferred to use the typed channel()-method, that's why it is marked as @Deprecated.

      Specified by:
      _channel in interface OpenemsComponent
      Parameters:
      channelName - the Channel-ID as a string
      Returns:
      the Channel or null
    • removeChannel

      protected void removeChannel(Channel<?> channel)
      Removes a Channel from this Component.
      Parameters:
      channel - the Channel
    • channels

      public Collection<Channel<?>> channels()
      Description copied from interface: OpenemsComponent
      Returns all Channels.
      Specified by:
      channels in interface OpenemsComponent
      Returns:
      a Collection of Channels
    • logDebug

      protected void logDebug(org.slf4j.Logger log, String message)
      Log a debug message including the Component ID.
      Parameters:
      log - the Logger instance
      message - the message
    • logInfo

      protected void logInfo(org.slf4j.Logger log, String message)
      Log an info message including the Component ID.
      Parameters:
      log - the Logger instance
      message - the message
    • logWarn

      protected void logWarn(org.slf4j.Logger log, String message)
      Log a warn message including the Component ID.
      Parameters:
      log - the Logger instance
      message - the message
    • logError

      protected void logError(org.slf4j.Logger log, String message)
      Log an error message including the Component ID.
      Parameters:
      log - the Logger instance
      message - the message