Changes
[iotcloud.git] / version2 / src / java / light_fan_embed_benchmark / Sensor.java
1 import iotcloud.*;
2 import java.util.*;
3 import java.lang.*;
4 import java.io.*;
5
6 class Sensor {
7     public static void main(String[] args) throws Exception {
8
9
10         long pstart = System.currentTimeMillis();
11
12
13         Table t1 = new Table("http://dc-6.calit2.uci.edu/test.iotcloud/", "reallysecret", 361, -1);
14
15         try {
16             Thread.sleep(5000);
17         } catch (Exception e) {
18
19         }
20
21         long start = System.currentTimeMillis();
22         t1.rebuild();
23
24
25         System.out.println("Sleeping......");
26
27         try {
28             Thread.sleep(10000);
29         } catch (Exception e) {
30
31         }
32
33         System.out.println("Pulling......");
34         long stop1 = System.currentTimeMillis();
35
36
37
38
39
40         System.out.println(stop1 - pstart);
41         t1.update();
42
43
44
45
46         Runtime runTime = Runtime.getRuntime();
47         // Process proc = runTime.exec("/opt/vc/bin/vcgencmd measure_temp | tr -d 'temp=' |  tr -d \"'C\"");
48         Process proc = runTime.exec("/opt/vc/bin/vcgencmd measure_temp");
49         BufferedReader reader = new BufferedReader(new InputStreamReader(proc.getInputStream()));
50         String line = null;
51         String dat = "";
52         while ((line = reader.readLine()) != null) {
53             System.out.println(line);
54             dat = line;
55         }
56         reader.close();
57
58
59
60         // String pingTimer = Long.toString(System.currentTimeMillis());
61         // IoTString ipingTimer = new IoTString(pingTimer);
62
63
64
65         String a1 = "bulb1";
66         IoTString ia1 = new IoTString(a1);
67
68
69
70         IoTString senDat = new IoTString(dat);
71
72         t1.update();
73         t1.startTransaction();
74         t1.addKV(ia1, senDat);
75         t1.commitTransaction();
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90         long stop2 = System.currentTimeMillis();
91
92         System.out.println("Done......");
93         System.out.println(stop1 - start);
94         System.out.println(stop2 - stop1);
95
96         // t1.startTransaction();
97         // t1.addKV(ipingTimerKey, ipingTimer);
98         // t1.addKV(ia1, senDat);
99         // t1.commitTransaction();
100
101
102
103
104
105         // String pingTimerKey = "sensorController";
106         // IoTString ipingTimerKey = new IoTString(pingTimerKey);
107
108         // String a1 = "sensor";
109         // IoTString ia1 = new IoTString(a1);
110
111
112         // System.out.println("Starting System");
113
114
115
116
117         // while (true) {
118         //     try {
119
120
121
122         //         // Runtime runTime = Runtime.getRuntime();
123         //         // // Process proc = runTime.exec("/opt/vc/bin/vcgencmd measure_temp | tr -d 'temp=' |  tr -d \"'C\"");
124         //         // Process proc = runTime.exec("/opt/vc/bin/vcgencmd measure_temp");
125         //         // BufferedReader reader = new BufferedReader(new InputStreamReader(proc.getInputStream()));
126         //         // String line = null;
127         //         // String dat = "";
128         //         // while ((line = reader.readLine()) != null) {
129         //         //     System.out.println(line);
130         //         //     dat = line;
131         //         // }
132         //         // reader.close();
133
134
135
136         //         // String pingTimer = Long.toString(System.currentTimeMillis());
137         //         // IoTString ipingTimer = new IoTString(pingTimer);
138
139
140         //         IoTString senDat = new IoTString(dat);
141
142         //         t1.update();
143         //         t1.startTransaction();
144         //         t1.addKV(ipingTimerKey, ipingTimer);
145         //         t1.addKV(ia1, senDat);
146         //         t1.commitTransaction();
147
148
149
150
151
152
153
154         //         Thread.sleep(5000);
155
156         //     } catch (Error e) {
157         //         e.printStackTrace();
158
159         //         Runtime runTime = Runtime.getRuntime();
160         //         runTime.exec("gpio mode 4 out");
161
162
163         //         while (true) {
164         //             runTime.exec("gpio write 4 1");
165         //             Thread.sleep(500);
166         //             runTime.exec("gpio write 4 0");
167         //             Thread.sleep(500);
168         //         }
169         //     }
170         // }
171     }
172 }