Package io.openems.edge.timedata.rrd4j
Class Rrd4jReadHandler
java.lang.Object
io.openems.edge.timedata.rrd4j.Rrd4jReadHandler
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected static List
<org.rrd4j.core.Archive> getArchivesSortedByArcStep
(org.rrd4j.core.RrdDb db) Gets a list of the archives from the given database, sorted by their arc step size ascending.getLatestValue
(String rrdDbId, ChannelAddress channelAddress) Gets the latest known value for the givenChannelAddress
.getResendTimeranges
(String rrdDbId, ChannelAddress notSendChannel, long lastResendTimestamp, boolean debugMode) Gets theTimeranges
to data which got not send.SortedMap
<ZonedDateTime, SortedMap<ChannelAddress, com.google.gson.JsonElement>> queryHistoricData
(String rrdDbId, ZonedDateTime fromDate, ZonedDateTime toDate, Set<ChannelAddress> channels, Resolution resolution, boolean debugMode) Queries historic data.SortedMap
<ChannelAddress, com.google.gson.JsonElement> queryHistoricEnergy
(String rrdDbId, ZonedDateTime fromDate, ZonedDateTime toDate, Set<ChannelAddress> channels, boolean debugMode) Queries historic energy.SortedMap
<ZonedDateTime, SortedMap<ChannelAddress, com.google.gson.JsonElement>> queryHistoricEnergyPerPeriod
(String rrdDbId, ZonedDateTime fromDate, ZonedDateTime toDate, Set<ChannelAddress> channels, Resolution resolution, boolean debugMode) Queries historic energy per period.SortedMap
<Long, SortedMap<ChannelAddress, com.google.gson.JsonElement>> queryResendData
(String rrdDbId, ZonedDateTime fromDate, ZonedDateTime toDate, Set<ChannelAddress> channels, boolean debugMode) Queries data to resend.
-
Constructor Details
-
Rrd4jReadHandler
public Rrd4jReadHandler()
-
-
Method Details
-
getArchivesSortedByArcStep
protected static List<org.rrd4j.core.Archive> getArchivesSortedByArcStep(org.rrd4j.core.RrdDb db) throws IOException Gets a list of the archives from the given database, sorted by their arc step size ascending. The step size can be obtained withArchive.getArcStep()
.- Parameters:
db
- the archives of which database- Returns:
- a sorted list of the archives
- Throws:
IOException
- Thrown in case of I/O error.
-
getResendTimeranges
public Timeranges getResendTimeranges(String rrdDbId, ChannelAddress notSendChannel, long lastResendTimestamp, boolean debugMode) throws OpenemsError.OpenemsNamedException Gets theTimeranges
to data which got not send. The not send data gets determined with the notSendChannel and the lastResendTimestamp.- Parameters:
rrdDbId
- the id of the rrdbnotSendChannel
- the channel with the timestamps where the data got not sendlastResendTimestamp
- the timstamp of the last resenddebugMode
- if debugMode is active- Returns:
- the
Timeranges
- Throws:
OpenemsError.OpenemsNamedException
- on error
-
queryResendData
public SortedMap<Long,SortedMap<ChannelAddress, queryResendDatacom.google.gson.JsonElement>> (String rrdDbId, ZonedDateTime fromDate, ZonedDateTime toDate, Set<ChannelAddress> channels, boolean debugMode) throws OpenemsError.OpenemsNamedException Queries data to resend.- Parameters:
rrdDbId
- the id of the rrdbfromDate
- the start datetoDate
- the end datechannels
- the channels to resenddebugMode
- if debugMode is active- Returns:
- the query result; possibly null
- Throws:
OpenemsError.OpenemsNamedException
- on error
-
queryHistoricData
public SortedMap<ZonedDateTime,SortedMap<ChannelAddress, queryHistoricDatacom.google.gson.JsonElement>> (String rrdDbId, ZonedDateTime fromDate, ZonedDateTime toDate, Set<ChannelAddress> channels, Resolution resolution, boolean debugMode) throws OpenemsError.OpenemsNamedException Queries historic data.- Parameters:
rrdDbId
- the id of the rrdbfromDate
- the From-DatetoDate
- the To-Datechannels
- the Channelsresolution
- theResolution
debugMode
- if debugMode is active- Returns:
- the query result; possibly null
- Throws:
OpenemsError.OpenemsNamedException
-
queryHistoricEnergy
public SortedMap<ChannelAddress,com.google.gson.JsonElement> queryHistoricEnergy(String rrdDbId, ZonedDateTime fromDate, ZonedDateTime toDate, Set<ChannelAddress> channels, boolean debugMode) throws OpenemsError.OpenemsNamedException Queries historic energy.- Parameters:
rrdDbId
- the id of the rrdbfromDate
- the From-DatetoDate
- the To-Datechannels
- the ChannelsdebugMode
- if debugMode is active- Returns:
- the query result; possibly null
- Throws:
OpenemsError.OpenemsNamedException
-
queryHistoricEnergyPerPeriod
public SortedMap<ZonedDateTime,SortedMap<ChannelAddress, queryHistoricEnergyPerPeriodcom.google.gson.JsonElement>> (String rrdDbId, ZonedDateTime fromDate, ZonedDateTime toDate, Set<ChannelAddress> channels, Resolution resolution, boolean debugMode) throws OpenemsError.OpenemsNamedException 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.- Parameters:
rrdDbId
- the id of the rrdbfromDate
- the From-DatetoDate
- the To-Datechannels
- the Channelsresolution
- theResolution
debugMode
- if debugMode is active- Returns:
- the query result; possibly null
- Throws:
OpenemsError.OpenemsNamedException
-
getLatestValue
public CompletableFuture<Optional<Object>> getLatestValue(String rrdDbId, ChannelAddress channelAddress) Gets the latest known value for the givenChannelAddress
.- Parameters:
rrdDbId
- the id of the rrdbchannelAddress
- the ChannelAddress to be queried- Returns:
- the latest known value or Empty
-