Package io.openems.edge.timedata.api
Class Timeranges
java.lang.Object
io.openems.edge.timedata.api.Timeranges
Bundle class of multiple
Timeranges.Timerange
. Used to get the timeranges to
resend data from.
All Timeranges.Timerange
inside a Timeranges
are separated by the
MAX_CONCAT_TIME
. When inserting a new timestamp the
timestamp gets inserted to the nearest Timeranges.Timerange
or if the nearest
one is more than the MAX_CONCAT_TIME
away a new
Timeranges.Timerange
gets inserted in the current Timeranges
.
Usage example:
final var timeranges = timedata.getResendTimeranges([CHANNEL_ADDRESS], [LAST_RESEND_TIMESTAMP]); for (var timerange : timeranges.maxDataInTime([MAX_RESEND_TIMESPAN_SECONDS])) { final var from = timerange.getMinTimestamp(); final var to = timerange.getMaxTimestamp(); ...fetch resend data ...send data }
- See Also:
-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescriptionprotected static final long
protected static final Comparator
<Timeranges.Timerange> -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionGets theTimeranges
in ascending order.void
insert
(long timestamp) Inserts a timestamp in seconds into thisTimeranges
.maxDataInTime
(long maxTimerange) Creates anIterable
which iterates over newTimeranges
where the max size of oneTimeranges.Timerange
is the given maxTimerange.withBuffer
(long beforeBuffer, long afterBuffer) Creates a newTimeranges
with the given buffers before and after everyTimeranges.Timerange
.
-
Field Details
-
MAX_CONCAT_TIME
protected static final long MAX_CONCAT_TIME- See Also:
-
TIMERANGE_COMPARATOR
-
-
Constructor Details
-
Timeranges
public Timeranges()
-
-
Method Details
-
insert
public void insert(long timestamp) Inserts a timestamp in seconds into thisTimeranges
.- Parameters:
timestamp
- the timestamp to inserts in seconds
-
getTimerangeAscending
Gets theTimeranges
in ascending order.- Returns:
- a list of the
Timeranges
-
withBuffer
Creates a newTimeranges
with the given buffers before and after everyTimeranges.Timerange
.- Parameters:
beforeBuffer
- the buffer before everyTimeranges.Timerange
afterBuffer
- the buffer after everyTimeranges.Timerange
- Returns:
- the new
Timeranges
with the buffer
-
maxDataInTime
Creates anIterable
which iterates over newTimeranges
where the max size of oneTimeranges.Timerange
is the given maxTimerange.- Parameters:
maxTimerange
- the maximal timerange of oneTimeranges.Timerange
in seconds- Returns:
- a new
Iterable
-