Class TimelineList<T>
java.lang.Object
com.inductiveautomation.ignition.common.util.TimelineList<T>
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
Timeline
A timeline list is a list of values that cover a span of time. There is only one timeline, and so values cannot
overlap. Items can be added with a start time, in which the end will be "forever", or a fixed range. In either case,
the start and end may be adjusted (or the value overwritten) by new values that get added.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclass
A time segment covers a span of time. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
void
Add the value at the given time, with a duration of forever.void
add
(TimelineList timelineList) void
add
(TimelineList<T>.TimeSegment timeSegment) boolean
covered
(long time) Returns whether the timeline contains a segment that covers the specified time.get
(long time) Returns the value for the specified time, or null if a value isn't defined.protected T
get
(long time, boolean allowClosest, boolean allowRollover) getClosest
(long time) Returns the value for the given time, or the next defined value.protected TimelineList<T>.TimeSegment
getSegment
(int pos) getSegment
(long time, boolean allowClosest) Returns the segment that contains the time.getSegment
(long time, boolean allowClosest, boolean allowRollover) Returns the segment that contains the time.protected int
indexOf
(long time, boolean allowRollover) Returns the index of the segment that covers the time, or comes next after the time.void
Merges together contiguous segments with the same value.long
nextEvent
(long time) Returns the next time that something interesting happens after the given time.long
nextEvent
(long time, boolean allowRollover) int
size()
void
sort()
toString()
-
Constructor Details
-
TimelineList
public TimelineList()
-
-
Method Details
-
size
public int size() -
sort
public void sort() -
indexOf
protected int indexOf(long time, boolean allowRollover) Returns the index of the segment that covers the time, or comes next after the time.- Parameters:
allowRollover
- if the time is beyond the last segment, and this parameter is true, the first index will be returned. Otherwise the last index of the list will be returned.- Returns:
- the index of the segment that covers the time, or comes next after the time.
-
getSegment
-
add
Add the value at the given time, with a duration of forever. Some care should be taken when using this function, because if values do not arrive in ascending time, previous entries will be overwritten. Because of this behavior, this function can also check the equality of values and avoid making extra segments, improving performance. -
add
-
add
-
add
-
covered
public boolean covered(long time) Returns whether the timeline contains a segment that covers the specified time. -
get
Returns the value for the specified time, or null if a value isn't defined. -
getClosest
Returns the value for the given time, or the next defined value. Returns null if there is no value specified at, or beyond, the given time. -
get
-
getSegment
Returns the segment that contains the time. If allowClosest is true, will return the next possible time, if a time segment doesn't cover the current time. -
getSegment
public TimelineList<T>.TimeSegment getSegment(long time, boolean allowClosest, boolean allowRollover) Returns the segment that contains the time. If allowClosest is true, will return the next possible time, if a time segment doesn't cover the current time. -
nextEvent
public long nextEvent(long time) Returns the next time that something interesting happens after the given time. That is, the current segment ends, the next one starts, etc. If nothing else happens, Long.Max is returned. -
nextEvent
public long nextEvent(long time, boolean allowRollover) -
toString
-
getSegments
-
mergeSegments
public void mergeSegments()Merges together contiguous segments with the same value. Used for composite user schedules.
-