-
Notifications
You must be signed in to change notification settings - Fork 1
/
space.pde
56 lines (43 loc) · 1.14 KB
/
space.pde
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
48
49
50
51
52
53
54
55
import java.text.NumberFormat;
class Space extends SensorReading {
// final values
float total, free;
private Runtime runtime = Runtime.getRuntime();
public Space() {
super("space");
}
void init() {
}
void execute() {
File[] roots = File.listRoots();
/* For each filesystem root, print some info */
for (File root : roots) {
float gb = 1f/(1024*1024*1024);
total = root.getTotalSpace()*gb;
free = root.getFreeSpace()*gb;
}
send();
}
OscMessage createMessage(String adrPattern) {
OscMessage m = new OscMessage(adrPattern);
m.add(name);
m.add(total);
m.add(free);
return m;
}
void send() {
OscMessage m = createMessage("/data");
oscP5.send(m, serverLocation);
// this is important
readingDone = true;
}
SensorReading createFromMessage(OscMessage msg) {
Space sr = new Space();
sr.total = msg.get(1).floatValue();
sr.free = msg.get(2).floatValue();
return sr;
}
void print() {
println(name + " total space: "+total+" free space: "+free);
}
}