-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathContinStat.java
More file actions
47 lines (42 loc) · 847 Bytes
/
ContinStat.java
File metadata and controls
47 lines (42 loc) · 847 Bytes
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
39
40
41
42
43
44
45
46
47
public class ContinStat
{
private float start;
private float area;
private float prevValue;
private float prevTime;
private float max;
private float min;
public ContinStat(float value, float present)
{
start = present;
area = 0;
prevValue = value;
prevTime = present;
max = (float)-3.4E+38;
min = (float)3.4E+38;
}
public float getContinAve(float present)
{
area += (present - prevTime)*prevValue;
prevTime = present;
return area/(present - start);
}
public float getContinMax()
{
return max;
}
public float getContinMin()
{
return min;
}
public void recordContin(float value, float present)
{
area += (present - prevTime)*prevValue;
if (value > max)
max = value;
if (value < min)
min = value;
prevValue = value;
prevTime = present;
}
}