Class ComponentManagerImpl
- All Implemented Interfaces:
ClockProvider
,ComponentManager
,OpenemsComponent
,JsonApi
,org.osgi.service.cm.ConfigurationListener
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.openems.edge.common.component.ComponentManager
ComponentManager.ChannelId
Nested classes/interfaces inherited from interface io.openems.edge.common.component.OpenemsComponent
OpenemsComponent.ChannelId
-
Field Summary
Modifier and TypeFieldDescriptionprotected org.osgi.framework.BundleContext
protected org.osgi.service.cm.ConfigurationAdmin
protected org.osgi.service.event.EventAdmin
protected org.osgi.service.metatype.MetaTypeService
protected org.osgi.service.component.runtime.ServiceComponentRuntime
Fields inherited from interface io.openems.edge.common.component.ComponentManager
SINGLETON_COMPONENT_ID, SINGLETON_SERVICE_PID
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
configurationEvent
(org.osgi.service.cm.ConfigurationEvent event) protected void
Handles @Deactivate of implementations.debugLog()
Gets some output that is suitable for a continuous Debug log.Gets all OpenEMS-Components.getClock()
Gets the OpenEMS Clock - either the real system clock or a mocked clock for simulations.<T extends OpenemsComponent>
TgetComponent
(String componentId) Gets a OpenEMS-Component by its Component-ID.Gets the complete configuration of this OpenEMS Edge.Gets all enabled OpenEMS-Components.<T extends OpenemsComponent>
List<T> getEnabledComponentsOfType
(Class<T> clazz) Gets all enabled OpenEMS-Components of the given Type.protected org.osgi.service.cm.Configuration
getExistingConfigForId
(String componentId) Gets the ConfigAdmin Configuration for the OpenEMS Component with the given Component-ID.<T extends OpenemsComponent>
TgetPossiblyDisabledComponent
(String componentId) Gets a OpenEMS-Component by its Component-ID.protected CompletableFuture
<JsonrpcResponseSuccess> handleChannelExportXlsxRequest
(User user, ChannelExportXlsxRequest request) Handles aChannelExportXlsxRequest
.handleCreateComponentConfigRequest
(User user, CreateComponentConfigRequest request) Handles aCreateComponentConfigRequest
.handleDeleteComponentConfigRequest
(User user, DeleteComponentConfigRequest request) Handles aDeleteComponentConfigRequest
.handleJsonrpcRequest
(User user, JsonrpcRequest request) Handles a JSON-RPC Request.handleUpdateComponentConfigRequest
(User user, UpdateComponentConfigRequest request) Handles aUpdateComponentConfigRequest
.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.Methods inherited from class io.openems.edge.common.component.AbstractOpenemsComponent
_channel, activate, activate, addChannel, addChannels, addChannels, alias, channels, getComponentContext, id, isEnabled, logDebug, modified, removeChannel
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.ComponentManager
_setConfigNotActivated, _setDefaultConfigurationFailed, _setDuplicatedComponentId, _setWasOutOfMemory, getChannel, getConfigNotActivated, getConfigNotActivatedChannel, getDefaultConfigurationFailed, getDefaultConfigurationFailedChannel, getDuplicatedComponentId, getDuplicatedComponentIdChannel, getWasOutOfMemory, getWasOutOfMemoryChannel
Methods inherited from interface io.openems.edge.common.component.OpenemsComponent
_channel, _getChannelAs, alias, channel, channel, channels, getComponentContext, getState, getStateChannel, hasFaults, id, isEnabled, serviceFactoryPid, servicePid
-
Field Details
-
bundleContext
protected org.osgi.framework.BundleContext bundleContext -
metaTypeService
protected org.osgi.service.metatype.MetaTypeService metaTypeService -
cm
protected org.osgi.service.cm.ConfigurationAdmin cm -
eventAdmin
protected org.osgi.service.event.EventAdmin eventAdmin -
serviceComponentRuntime
protected org.osgi.service.component.runtime.ServiceComponentRuntime serviceComponentRuntime
-
-
Constructor Details
-
ComponentManagerImpl
public ComponentManagerImpl()
-
-
Method Details
-
deactivate
protected void deactivate()Description copied from class:AbstractOpenemsComponent
Handles @Deactivate of implementations. Prints log output.- Overrides:
deactivate
in classAbstractOpenemsComponent
-
getEnabledComponents
Description copied from interface:ComponentManager
Gets all enabled OpenEMS-Components.Be aware that via this method usage of the Component service is not tracked by the bundle's use count (See
BundleContext.getService(org.osgi.framework.ServiceReference)
). Make sure to use the references as shortly as possible.- Specified by:
getEnabledComponents
in interfaceComponentManager
- Returns:
- a List of OpenEMS-Components
-
getEnabledComponentsOfType
Description copied from interface:ComponentManager
Gets all enabled OpenEMS-Components of the given Type.Be aware that via this method usage of the Component service is not tracked by the bundle's use count (See
BundleContext.getService(org.osgi.framework.ServiceReference)
). Make sure to use the references as shortly as possible.- Specified by:
getEnabledComponentsOfType
in interfaceComponentManager
- Type Parameters:
T
- the given Type, subclass ofOpenemsComponent
- Parameters:
clazz
- the given Type, subclass ofOpenemsComponent
- Returns:
- a List of OpenEMS-Components
-
getAllComponents
Description copied from interface:ComponentManager
Gets all OpenEMS-Components.Be aware that via this method usage of the Component service is not tracked by the bundle's use count (See
BundleContext.getService(org.osgi.framework.ServiceReference)
). Make sure to use the references as shortly as possible.- Specified by:
getAllComponents
in interfaceComponentManager
- Returns:
- a List of OpenEMS-Components
-
getComponent
public <T extends OpenemsComponent> T getComponent(String componentId) throws OpenemsError.OpenemsNamedException Description copied from interface:ComponentManager
Gets a OpenEMS-Component by its Component-ID. The Component is guaranteed to be enabled.Be aware that via this method usage of the Component service is not tracked by the bundle's use count (See
BundleContext.getService(org.osgi.framework.ServiceReference)
). Make sure to use the references as shortly as possible.- Specified by:
getComponent
in interfaceComponentManager
- Type Parameters:
T
- the typed Component- Parameters:
componentId
- the Component-ID (e.g. "_sum")- Returns:
- the OpenEMS-Component
- Throws:
OpenemsError.OpenemsNamedException
- if the Component was not found
-
getPossiblyDisabledComponent
public <T extends OpenemsComponent> T getPossiblyDisabledComponent(String componentId) throws OpenemsError.OpenemsNamedException Description copied from interface:ComponentManager
Gets a OpenEMS-Component by its Component-ID. Be careful, that the Component might not be 'enabled'. If in doubt, useComponentManager.getComponent(String)
instead.Be aware that via this method usage of the Component service is not tracked by the bundle's use count (See
BundleContext.getService(org.osgi.framework.ServiceReference)
). Make sure to use the references as shortly as possible.- Specified by:
getPossiblyDisabledComponent
in interfaceComponentManager
- Type Parameters:
T
- the typed Component- Parameters:
componentId
- the Component-ID (e.g. "_sum")- Returns:
- the OpenEMS-Component
- Throws:
OpenemsError.OpenemsNamedException
- if the Component was not found
-
debugLog
Description copied from interface:OpenemsComponent
Gets some output that is suitable for a continuous Debug log. Returns 'null' by default which causes no output.- Specified by:
debugLog
in interfaceOpenemsComponent
- Returns:
- the debug log output
-
logInfo
Description copied from class:AbstractOpenemsComponent
Log an info message including the Component ID.- Overrides:
logInfo
in classAbstractOpenemsComponent
- Parameters:
log
- the Logger instancemessage
- the message
-
logWarn
Description copied from class:AbstractOpenemsComponent
Log a warn message including the Component ID.- Overrides:
logWarn
in classAbstractOpenemsComponent
- Parameters:
log
- the Logger instancemessage
- the message
-
logError
Description copied from class:AbstractOpenemsComponent
Log an error message including the Component ID.- Overrides:
logError
in classAbstractOpenemsComponent
- Parameters:
log
- the Logger instancemessage
- the message
-
handleJsonrpcRequest
public CompletableFuture<JsonrpcResponseSuccess> handleJsonrpcRequest(User user, JsonrpcRequest request) throws OpenemsError.OpenemsNamedException Description copied from interface:JsonApi
Handles a JSON-RPC Request.- Specified by:
handleJsonrpcRequest
in interfaceJsonApi
- Parameters:
user
- the authenticatedUser
request
- the JSON-RPC Request- Returns:
- a Future JSON-RPC Success Response; null response results in a OpenemsError.JSONRPC_UNHANDLED_METHOD
- Throws:
OpenemsError.OpenemsNamedException
- on error
-
handleCreateComponentConfigRequest
public CompletableFuture<JsonrpcResponseSuccess> handleCreateComponentConfigRequest(User user, CreateComponentConfigRequest request) throws OpenemsError.OpenemsNamedException Handles aCreateComponentConfigRequest
.- Parameters:
user
- theUser
request
- theCreateComponentConfigRequest
- Returns:
- the Future JSON-RPC Response
- Throws:
OpenemsError.OpenemsNamedException
- on error
-
handleUpdateComponentConfigRequest
public CompletableFuture<JsonrpcResponseSuccess> handleUpdateComponentConfigRequest(User user, UpdateComponentConfigRequest request) throws OpenemsError.OpenemsNamedException Handles aUpdateComponentConfigRequest
.- Parameters:
user
- theUser
request
- theUpdateComponentConfigRequest
- Returns:
- the Future JSON-RPC Response
- Throws:
OpenemsError.OpenemsNamedException
- on error
-
handleDeleteComponentConfigRequest
public CompletableFuture<JsonrpcResponseSuccess> handleDeleteComponentConfigRequest(User user, DeleteComponentConfigRequest request) throws OpenemsError.OpenemsNamedException Handles aDeleteComponentConfigRequest
.- Parameters:
user
- theUser
request
- theDeleteComponentConfigRequest
- Returns:
- the Future JSON-RPC Response
- Throws:
OpenemsError.OpenemsNamedException
- on error
-
handleChannelExportXlsxRequest
protected CompletableFuture<JsonrpcResponseSuccess> handleChannelExportXlsxRequest(User user, ChannelExportXlsxRequest request) throws OpenemsError.OpenemsNamedException Handles aChannelExportXlsxRequest
.- Parameters:
user
- theUser
request
- theChannelExportXlsxRequest
- Returns:
- the Future JSON-RPC Response
- Throws:
OpenemsError.OpenemsNamedException
- on error
-
getExistingConfigForId
protected org.osgi.service.cm.Configuration getExistingConfigForId(String componentId) throws OpenemsError.OpenemsNamedException Gets the ConfigAdmin Configuration for the OpenEMS Component with the given Component-ID.- Parameters:
componentId
- the Component-ID- Returns:
- the Configuration
- Throws:
OpenemsError.OpenemsNamedException
- on error
-
getEdgeConfig
Description copied from interface:ComponentManager
Gets the complete configuration of this OpenEMS Edge.Internally updates the cache if necessary and publishes a CONFIG_UPDATE event on update.
- Specified by:
getEdgeConfig
in interfaceComponentManager
- Returns:
- the
EdgeConfig
object
-
configurationEvent
public void configurationEvent(org.osgi.service.cm.ConfigurationEvent event) - Specified by:
configurationEvent
in interfaceorg.osgi.service.cm.ConfigurationListener
-
getClock
Description copied from interface:ComponentManager
Gets the OpenEMS Clock - either the real system clock or a mocked clock for simulations.- Specified by:
getClock
in interfaceClockProvider
- Specified by:
getClock
in interfaceComponentManager
- Returns:
- the Clock
-