public class SimulatorApp extends AbstractOpenemsComponent implements SimulatorDatasource, ClockProvider, OpenemsComponent, JsonApi, org.osgi.service.event.EventHandler, Timedata
Modifier and Type | Class and Description |
---|---|
static class |
SimulatorApp.ChannelId |
Constructor and Description |
---|
SimulatorApp() |
Modifier and Type | Method and Description |
---|---|
protected void |
deactivate()
Handles @Deactivate of implementations.
|
java.time.Clock |
getClock()
Gets the Clock - real or mocked like
TimeLeapClock . |
java.util.Set<java.lang.String> |
getKeys()
Gets the available keys.
|
java.util.concurrent.CompletableFuture<java.util.Optional<java.lang.Object>> |
getLatestValue(ChannelAddress channelAddress)
Gets the latest known value for the given
ChannelAddress . |
int |
getTimeDelta()
Returns the delta between two values in seconds.
|
<T> T |
getValue(OpenemsType type,
ChannelAddress channelAddress)
Gets the value for the given key (channelId) in the given type.
|
void |
handleEvent(org.osgi.service.event.Event event) |
java.util.concurrent.CompletableFuture<? extends JsonrpcResponseSuccess> |
handleJsonrpcRequest(User user,
JsonrpcRequest request)
Handles a JSON-RPC Request.
|
java.util.SortedMap<java.time.ZonedDateTime,java.util.SortedMap<ChannelAddress,com.google.gson.JsonElement>> |
queryHistoricData(java.lang.String edgeId,
java.time.ZonedDateTime fromDate,
java.time.ZonedDateTime toDate,
java.util.Set<ChannelAddress> channels,
int resolution)
Queries historic data.
|
java.util.SortedMap<ChannelAddress,com.google.gson.JsonElement> |
queryHistoricEnergy(java.lang.String edgeId,
java.time.ZonedDateTime fromDate,
java.time.ZonedDateTime toDate,
java.util.Set<ChannelAddress> channels)
Queries historic energy.
|
java.util.SortedMap<java.time.ZonedDateTime,java.util.SortedMap<ChannelAddress,com.google.gson.JsonElement>> |
queryHistoricEnergyPerPeriod(java.lang.String edgeId,
java.time.ZonedDateTime fromDate,
java.time.ZonedDateTime toDate,
java.util.Set<ChannelAddress> channels,
int resolution)
Queries historic energy per period.
|
_channel, activate, addChannel, addChannels, addChannels, alias, channels, getComponentContext, id, isEnabled, logDebug, logError, logInfo, logWarn, modified, removeChannel
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
calculateResolution, handleQueryHistoricTimeseriesExportXlxsRequest, queryHistoricData
_channel, _getChannelAs, alias, channel, channel, channels, debugLog, getComponentContext, getModbusSlaveNatureTable, getState, getStateChannel, hasFaults, id, isEnabled, logDebug, logError, logInfo, logWarn, serviceFactoryPid, servicePid, updateConfigurationProperty, updateReferenceFilter
protected void deactivate()
AbstractOpenemsComponent
deactivate
in class AbstractOpenemsComponent
public java.util.concurrent.CompletableFuture<? extends JsonrpcResponseSuccess> handleJsonrpcRequest(User user, JsonrpcRequest request) throws OpenemsError.OpenemsNamedException
JsonApi
handleJsonrpcRequest
in interface JsonApi
user
- the authenticated Userrequest
- the JSON-RPC RequestOpenemsError.OpenemsNamedException
- on errorpublic void handleEvent(org.osgi.service.event.Event event)
handleEvent
in interface org.osgi.service.event.EventHandler
public java.time.Clock getClock()
ClockProvider
TimeLeapClock
.getClock
in interface ClockProvider
Clock
public java.util.Set<java.lang.String> getKeys()
SimulatorDatasource
getKeys
in interface SimulatorDatasource
public int getTimeDelta()
SimulatorDatasource
getTimeDelta
in interface SimulatorDatasource
public <T> T getValue(OpenemsType type, ChannelAddress channelAddress)
SimulatorDatasource
getValue
in interface SimulatorDatasource
T
- the typetype
- the expected typechannelAddress
- the Channel-Addresspublic java.util.SortedMap<java.time.ZonedDateTime,java.util.SortedMap<ChannelAddress,com.google.gson.JsonElement>> queryHistoricData(java.lang.String edgeId, java.time.ZonedDateTime fromDate, java.time.ZonedDateTime toDate, java.util.Set<ChannelAddress> channels, int resolution) throws OpenemsError.OpenemsNamedException
CommonTimedataService
queryHistoricData
in interface CommonTimedataService
edgeId
- the Edge-ID; or null query allfromDate
- the From-DatetoDate
- the To-Datechannels
- the Channelsresolution
- the Resolution in secondsOpenemsError.OpenemsNamedException
public java.util.SortedMap<ChannelAddress,com.google.gson.JsonElement> queryHistoricEnergy(java.lang.String edgeId, java.time.ZonedDateTime fromDate, java.time.ZonedDateTime toDate, java.util.Set<ChannelAddress> channels) throws OpenemsError.OpenemsNamedException
CommonTimedataService
queryHistoricEnergy
in interface CommonTimedataService
edgeId
- the Edge-ID; or null query allfromDate
- the From-DatetoDate
- the To-Datechannels
- the ChannelsOpenemsError.OpenemsNamedException
public java.util.SortedMap<java.time.ZonedDateTime,java.util.SortedMap<ChannelAddress,com.google.gson.JsonElement>> queryHistoricEnergyPerPeriod(java.lang.String edgeId, java.time.ZonedDateTime fromDate, java.time.ZonedDateTime toDate, java.util.Set<ChannelAddress> channels, int resolution) throws OpenemsError.OpenemsNamedException
CommonTimedataService
This is for use-cases where you want to get the energy for each period (with length 'resolution') per Channel, e.g. to visualize energy in a histogram chart. For each period the energy is calculated by subtracting first value of the period from the last value of the period.
queryHistoricEnergyPerPeriod
in interface CommonTimedataService
edgeId
- the Edge-ID; or null query allfromDate
- the From-DatetoDate
- the To-Datechannels
- the Channelsresolution
- the Resolution in secondsOpenemsError.OpenemsNamedException
public java.util.concurrent.CompletableFuture<java.util.Optional<java.lang.Object>> getLatestValue(ChannelAddress channelAddress)
Timedata
ChannelAddress
.getLatestValue
in interface Timedata
channelAddress
- the ChannelAddress to be queried