-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTimeTail.df
38 lines (29 loc) · 1.02 KB
/
TimeTail.df
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
class TimeTail
// Utilities for obtaining sections of channel history.
function Span(string channelName, timeInterval)
private channelData = Evaluate(channelName)
private endTime = SysTime()
private startIndex = 0
while (startIndex < NumRows(channelData))
if (endTime - GetTime(channelData[startIndex]) > timeInterval)
break
else
startIndex++
endif
endwhile
return channelData[0, startIndex]
endfunction
function From(string channelName, startTime)
private channelData = Evaluate(channelName)
private startIndex = 0
while (startIndex < NumRows(channelData))
if (startTime >= GetTime(channelData[startIndex]))
break
else
startIndex++
endif
endwhile
return channelData[0, startIndex]
endfunction
endclass
global TimeTail = new(TimeTail)