Class ApiWorker
java.lang.Object
io.openems.edge.controller.api.common.ApiWorker
Takes care of continuously writing channels till a timeout. This class is
used in all Api-Controllers.
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addValue
(WriteChannel<?> channel, WriteObject writeObject) Adds a value to the write-pipeline.handleSetChannelValueRequest
(ComponentManager componentManager, User user, SetChannelValueRequest request) Adds a value via JSON-RPCSetChannelValueRequest
.void
run()
Sets the channels.void
setLogChannel
(StringReadChannel logChannel) Sets the Channel that should be used to log debug information about writes to channels.void
setTimeoutSeconds
(int timeoutSeconds) Sets the timeout in seconds.
-
Field Details
-
DEFAULT_TIMEOUT_SECONDS
public static final int DEFAULT_TIMEOUT_SECONDS- See Also:
-
-
Constructor Details
-
ApiWorker
-
-
Method Details
-
setLogChannel
Sets the Channel that should be used to log debug information about writes to channels.- Parameters:
logChannel
- aStringReadChannel
-
addValue
Adds a value to the write-pipeline. The values are then set in the next execution ofrun()
, until the timeout is reached.- Parameters:
channel
- theWriteChannel
writeObject
- theWriteObject
-
handleSetChannelValueRequest
public CompletableFuture<JsonrpcResponseSuccess> handleSetChannelValueRequest(ComponentManager componentManager, User user, SetChannelValueRequest request) throws IllegalArgumentException, OpenemsError.OpenemsNamedException Adds a value via JSON-RPCSetChannelValueRequest
.- Parameters:
componentManager
- theComponentManager
user
- the authenticatedUser
request
- the Request- Returns:
- success
- Throws:
OpenemsError.OpenemsNamedException
- on errorIllegalArgumentException
- on error
-
setTimeoutSeconds
public void setTimeoutSeconds(int timeoutSeconds) Sets the timeout in seconds. Default is 60, which means that for 60 seconds in each cycle a value is rewritten to the WriteChannel. If set to '0', timeout is deactivated.- Parameters:
timeoutSeconds
- the timeout for this ApiWorker
-
run
Sets the channels. This method is called by the run() method of the Controller- Throws:
OpenemsError.OpenemsNamedException
- on error
-