Package io.openems.edge.simulator.app
Class SimulatorAppImpl
java.lang.Object
io.openems.edge.common.component.AbstractOpenemsComponent
io.openems.edge.simulator.app.SimulatorAppImpl
- All Implemented Interfaces:
CommonTimedataService
,ClockProvider
,OpenemsComponent
,JsonApi
,SimulatorApp
,SimulatorDatasource
,Timedata
,org.osgi.service.event.EventHandler
public class SimulatorAppImpl
extends AbstractOpenemsComponent
implements SimulatorApp, SimulatorDatasource, ClockProvider, OpenemsComponent, JsonApi, org.osgi.service.event.EventHandler, Timedata
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.openems.edge.common.component.OpenemsComponent
OpenemsComponent.ChannelId
Nested classes/interfaces inherited from interface io.openems.edge.simulator.app.SimulatorApp
SimulatorApp.ChannelId
Nested classes/interfaces inherited from interface io.openems.edge.timedata.api.Timedata
Timedata.ChannelId
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
Handles @Deactivate of implementations.getClock()
Gets the Clock - real or mocked likeTimeLeapClock
.getKeys()
Gets the available keys.getLatestValue
(ChannelAddress channelAddress) Gets the latest known value for the givenChannelAddress
.getResendTimeranges
(ChannelAddress notSendChannel, long lastResendTimestamp) Gets theTimeranges
to data which got not send.int
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) CompletableFuture
<? extends JsonrpcResponseSuccess> handleJsonrpcRequest
(User user, JsonrpcRequest request) Handles a JSON-RPC Request.SortedMap
<ZonedDateTime, SortedMap<ChannelAddress, com.google.gson.JsonElement>> queryHistoricData
(String edgeId, ZonedDateTime fromDate, ZonedDateTime toDate, Set<ChannelAddress> channels, Resolution resolution) Queries historic data.SortedMap
<ChannelAddress, com.google.gson.JsonElement> queryHistoricEnergy
(String edgeId, ZonedDateTime fromDate, ZonedDateTime toDate, Set<ChannelAddress> channels) Queries historic energy.SortedMap
<ZonedDateTime, SortedMap<ChannelAddress, com.google.gson.JsonElement>> queryHistoricEnergyPerPeriod
(String edgeId, ZonedDateTime fromDate, ZonedDateTime toDate, Set<ChannelAddress> channels, Resolution resolution) Queries historic energy per period.SortedMap
<Long, SortedMap<ChannelAddress, com.google.gson.JsonElement>> queryResendData
(ZonedDateTime fromDate, ZonedDateTime toDate, Set<ChannelAddress> channels) Queries data to resend.Methods inherited from class io.openems.edge.common.component.AbstractOpenemsComponent
_channel, activate, activate, addChannel, addChannels, addChannels, alias, channels, getComponentContext, id, isEnabled, logDebug, logError, logInfo, logWarn, 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.common.timedata.CommonTimedataService
handleQueryHistoricTimeseriesExportXlxsRequest, queryHistoricData
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
-
SINGLETON_SERVICE_PID
- See Also:
-
SINGLETON_COMPONENT_ID
- See Also:
-
-
Constructor Details
-
SimulatorAppImpl
public SimulatorAppImpl()
-
-
Method Details
-
deactivate
protected void deactivate()Description copied from class:AbstractOpenemsComponent
Handles @Deactivate of implementations. Prints log output.- Overrides:
deactivate
in classAbstractOpenemsComponent
-
handleJsonrpcRequest
public CompletableFuture<? extends 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
-
handleEvent
public void handleEvent(org.osgi.service.event.Event event) - Specified by:
handleEvent
in interfaceorg.osgi.service.event.EventHandler
-
getClock
Description copied from interface:ClockProvider
Gets the Clock - real or mocked likeTimeLeapClock
.- Specified by:
getClock
in interfaceClockProvider
- Returns:
- the
Clock
-
getKeys
Description copied from interface:SimulatorDatasource
Gets the available keys.- Specified by:
getKeys
in interfaceSimulatorDatasource
- Returns:
- the Channel-Id
-
getTimeDelta
public int getTimeDelta()Description copied from interface:SimulatorDatasource
Returns the delta between two values in seconds.- Specified by:
getTimeDelta
in interfaceSimulatorDatasource
- Returns:
- the delta in seconds
-
getValue
Description copied from interface:SimulatorDatasource
Gets the value for the given key (channelId) in the given type.- Specified by:
getValue
in interfaceSimulatorDatasource
- Type Parameters:
T
- the type- Parameters:
type
- the expected typechannelAddress
- the Channel-Address- Returns:
- the value, possibly null
-
queryHistoricData
public SortedMap<ZonedDateTime,SortedMap<ChannelAddress, queryHistoricDatacom.google.gson.JsonElement>> (String edgeId, ZonedDateTime fromDate, ZonedDateTime toDate, Set<ChannelAddress> channels, Resolution resolution) throws OpenemsError.OpenemsNamedException Description copied from interface:CommonTimedataService
Queries historic data.- Specified by:
queryHistoricData
in interfaceCommonTimedataService
- Parameters:
edgeId
- the Edge-ID; or null query allfromDate
- the From-DatetoDate
- the To-Datechannels
- the Channelsresolution
- theResolution
- Returns:
- the query result; possibly null
- Throws:
OpenemsError.OpenemsNamedException
-
queryHistoricEnergy
public SortedMap<ChannelAddress,com.google.gson.JsonElement> queryHistoricEnergy(String edgeId, ZonedDateTime fromDate, ZonedDateTime toDate, Set<ChannelAddress> channels) throws OpenemsError.OpenemsNamedException Description copied from interface:CommonTimedataService
Queries historic energy.- Specified by:
queryHistoricEnergy
in interfaceCommonTimedataService
- Parameters:
edgeId
- the Edge-ID; or null query allfromDate
- the From-DatetoDate
- the To-Datechannels
- the Channels- Returns:
- the query result; possibly null
- Throws:
OpenemsError.OpenemsNamedException
-
queryHistoricEnergyPerPeriod
public SortedMap<ZonedDateTime,SortedMap<ChannelAddress, queryHistoricEnergyPerPeriodcom.google.gson.JsonElement>> (String edgeId, ZonedDateTime fromDate, ZonedDateTime toDate, Set<ChannelAddress> channels, Resolution resolution) throws OpenemsError.OpenemsNamedException Description copied from interface:CommonTimedataService
Queries historic energy per period.This is for use-cases where you want to get the energy for each period (with
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.- Specified by:
queryHistoricEnergyPerPeriod
in interfaceCommonTimedataService
- Parameters:
edgeId
- the Edge-ID; or null query allfromDate
- the From-DatetoDate
- the To-Datechannels
- the Channelsresolution
- theResolution
- Returns:
- the query result; possibly null
- Throws:
OpenemsError.OpenemsNamedException
-
queryResendData
public SortedMap<Long,SortedMap<ChannelAddress, queryResendDatacom.google.gson.JsonElement>> (ZonedDateTime fromDate, ZonedDateTime toDate, Set<ChannelAddress> channels) throws OpenemsError.OpenemsNamedException Description copied from interface:Timedata
Queries data to resend.- Specified by:
queryResendData
in interfaceTimedata
- Parameters:
fromDate
- the start datetoDate
- the end datechannels
- the channels to resend- Returns:
- the query result; possibly null
- Throws:
OpenemsError.OpenemsNamedException
- on error
-
getResendTimeranges
public Timeranges getResendTimeranges(ChannelAddress notSendChannel, long lastResendTimestamp) throws OpenemsError.OpenemsNamedException Description copied from interface:Timedata
Gets theTimeranges
to data which got not send. The not send data gets determined with the notSendChannel and the lastResendTimestamp.- Specified by:
getResendTimeranges
in interfaceTimedata
- Parameters:
notSendChannel
- the channel with the timestamps where the data got not sendlastResendTimestamp
- the timestamp of the last resend; negativ if there is no lastResendTimestamp- Returns:
- the
Timeranges
- Throws:
OpenemsError.OpenemsNamedException
- on error
-
getLatestValue
Description copied from interface:Timedata
Gets the latest known value for the givenChannelAddress
.- Specified by:
getLatestValue
in interfaceTimedata
- Parameters:
channelAddress
- the ChannelAddress to be queried- Returns:
- the latest known value or Empty
-