Class ControllerApiBackendImpl
java.lang.Object
io.openems.edge.common.component.AbstractOpenemsComponent
io.openems.edge.controller.api.backend.ControllerApiBackendImpl
- All Implemented Interfaces:
OpenemsComponent
,ControllerApiBackend
,Controller
,org.osgi.service.event.EventHandler
public class ControllerApiBackendImpl
extends AbstractOpenemsComponent
implements ControllerApiBackend, Controller, OpenemsComponent, org.osgi.service.event.EventHandler
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.openems.edge.controller.api.Controller
Controller.ChannelId
Nested classes/interfaces inherited from interface io.openems.edge.controller.api.backend.api.ControllerApiBackend
ControllerApiBackend.ChannelId
Nested classes/interfaces inherited from interface io.openems.edge.common.component.OpenemsComponent
OpenemsComponent.ChannelId
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final ApiWorker
protected static final String
protected ComponentManager
protected io.openems.edge.controller.api.backend.Config
protected Cycle
protected BackendOnRequest
protected ResendHistoricDataWorker
protected final SendChannelValuesWorker
protected WebsocketClient
static final Key
<WebsocketClient> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
Handles @Deactivate of implementations.protected void
Execute a command using theScheduledExecutorService
.void
handleEvent
(org.osgi.service.event.Event event) boolean
Gets if the edge is currently connected to the backend.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.void
run()
Executes the Controller logic.scheduleWithFixedDelay
(Runnable command, long initialDelay, long delay, TimeUnit unit) Schedules a command using theScheduledExecutorService
.CompletableFuture
<? extends JsonrpcResponseSuccess> sendRequest
(User user, JsonrpcRequest request) Sends the request to the connected backend.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.controller.api.Controller
_setRunFailed, getRunFailed, getRunFailedChannel
Methods inherited from interface io.openems.edge.controller.api.backend.api.ControllerApiBackend
getApiWorkerLogChannel, getLastSuccessFulResendChannel, getUnableToSendChannel
Methods inherited from interface io.openems.edge.common.component.OpenemsComponent
_channel, _getChannelAs, alias, channel, channel, channels, debugLog, getComponentContext, getState, getStateChannel, hasFaults, id, isEnabled, serviceFactoryPid, servicePid
-
Field Details
-
COMPONENT_NAME
- See Also:
-
WEBSOCKET_CLIENT_KEY
-
sendChannelValuesWorker
-
apiWorker
-
componentManager
-
cycle
-
resendHistoricDataWorker
-
requestHandler
-
websocket
-
config
protected io.openems.edge.controller.api.backend.Config config
-
-
Constructor Details
-
ControllerApiBackendImpl
public ControllerApiBackendImpl()
-
-
Method Details
-
deactivate
protected void deactivate()Description copied from class:AbstractOpenemsComponent
Handles @Deactivate of implementations. Prints log output.- Overrides:
deactivate
in classAbstractOpenemsComponent
-
run
Description copied from interface:Controller
Executes the Controller logic.- Specified by:
run
in interfaceController
- Throws:
OpenemsError.OpenemsNamedException
- on error
-
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
-
handleEvent
public void handleEvent(org.osgi.service.event.Event event) - Specified by:
handleEvent
in interfaceorg.osgi.service.event.EventHandler
-
isConnected
public boolean isConnected()Description copied from interface:ControllerApiBackend
Gets if the edge is currently connected to the backend.- Specified by:
isConnected
in interfaceControllerApiBackend
- Returns:
- true if it is connected
-
execute
Execute a command using theScheduledExecutorService
.- Parameters:
command
- aRunnable
-
scheduleWithFixedDelay
public ScheduledFuture<?> scheduleWithFixedDelay(Runnable command, long initialDelay, long delay, TimeUnit unit) Schedules a command using theScheduledExecutorService
.- Parameters:
command
- aRunnable
initialDelay
- the initial delaydelay
- the delayunit
- theTimeUnit
- Returns:
- a
ScheduledFuture
, or null if Executor is shutting down
-
sendRequest
public CompletableFuture<? extends JsonrpcResponseSuccess> sendRequest(User user, JsonrpcRequest request) throws OpenemsError.OpenemsNamedException Description copied from interface:ControllerApiBackend
Sends the request to the connected backend.- Specified by:
sendRequest
in interfaceControllerApiBackend
- Parameters:
user
- the userrequest
- the request to send- Returns:
- the result future
- Throws:
OpenemsError.OpenemsNamedException
- on error
-