Class 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
OpenemsComponent
interface.
invalid reference
#activate(ComponentContext, String, boolean)
deactivate()
methods should be called by the corresponding methods
in the OSGi component.-
Nested Class Summary
Nested classes/interfaces inherited from interface io.openems.edge.common.component.OpenemsComponent
OpenemsComponent.ChannelId
-
Constructor Summary
ModifierConstructorDescriptionprotected
AbstractOpenemsComponent
(ChannelId[] firstInitialChannelIds, ChannelId[]... furtherInitialChannelIds) Default constructor for AbstractOpenemsComponent. -
Method Summary
Modifier and TypeMethodDescriptionChannel
<?> Deprecated.protected void
protected void
activate
(org.osgi.service.component.ComponentContext context, String id, String alias, boolean enabled) Handles @Activate of implementations.protected Channel
<?> addChannel
(ChannelId channelId) Initializes the given Channel-ID.protected void
addChannels
(ChannelId[] initialChannelIds) Initializes the given Channel-IDs.protected void
addChannels
(ChannelId[][] initialChannelIds) Initializes the given Channel-IDs.alias()
Returns a human-readable name of this Component..Collection
<Channel<?>> channels()
Returns all Channels.protected void
Handles @Deactivate of implementations.org.osgi.service.component.ComponentContext
Returns the ComponentContext.id()
Returns a unique ID for this OpenEMS component.boolean
Returns whether this component is enabled.protected void
Log a debug message including the Component ID.protected void
Log an error message including the Component ID.protected void
Log an info message including the Component ID.protected void
Log a warn message including the Component ID.protected void
modified
(org.osgi.service.component.ComponentContext context, String id, String alias, boolean enabled) Handles @Modified of implementations.protected void
removeChannel
(Channel<?> channel) Removes a Channel from this Component.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.openems.edge.common.component.OpenemsComponent
_getChannelAs, channel, channel, debugLog, getState, getStateChannel, hasFaults, serviceFactoryPid, servicePid
-
Constructor Details
-
AbstractOpenemsComponent
protected AbstractOpenemsComponent(ChannelId[] firstInitialChannelIds, ChannelId[]... furtherInitialChannelIds) Default constructor for AbstractOpenemsComponent.Automatically initializes (i.e. creates
Channel
instances for each givenOpenemsComponent.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
-
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 ComponentContextid
- the unique OpenEMS Component IDalias
- Human-readable name of this Component. Typically 'config.alias()'. Defaults to 'id' if emptyenabled
- 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 ComponentContextid
- the unique OpenEMS Component IDalias
- Human-readable name of this Component. Typically 'config.alias()'. Defaults to 'id' if emptyenabled
- 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 interfaceOpenemsComponent
- 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 interfaceOpenemsComponent
- Returns:
- the OSGi ComponentContext
-
addChannel
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
Initializes the given Channel-IDs.- Creates object instances from Channel-Doc
- Registers the Channels
- Parameters:
initialChannelIds
- the given Channel-IDs
-
addChannels
Initializes the given Channel-IDs.- Creates object instances from Channel-Doc
- Registers the Channels
- Parameters:
initialChannelIds
- the given Channel-IDs
-
id
Description copied from interface:OpenemsComponent
Returns a unique ID for this OpenEMS component.- Specified by:
id
in interfaceOpenemsComponent
- Returns:
- the unique ID
-
alias
Description copied from interface:OpenemsComponent
Returns a human-readable name of this Component..- Specified by:
alias
in interfaceOpenemsComponent
- Returns:
- the human-readable name
-
_channel
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 interfaceOpenemsComponent
- Parameters:
channelName
- the Channel-ID as a string- Returns:
- the Channel or null
-
removeChannel
Removes a Channel from this Component.- Parameters:
channel
- the Channel
-
channels
Description copied from interface:OpenemsComponent
Returns all Channels.- Specified by:
channels
in interfaceOpenemsComponent
- Returns:
- a Collection of Channels
-
logDebug
Log a debug message including the Component ID.- Parameters:
log
- the Logger instancemessage
- the message
-
logInfo
Log an info message including the Component ID.- Parameters:
log
- the Logger instancemessage
- the message
-
logWarn
Log a warn message including the Component ID.- Parameters:
log
- the Logger instancemessage
- the message
-
logError
Log an error message including the Component ID.- Parameters:
log
- the Logger instancemessage
- the message
-