edits
[iotcloud.git] / version2 / src / java / light_fan_benchmark / WemoController.java
1 import iotcloud.*;
2
3 class WemoController {
4     public static void main(String[] args) throws Exception {
5
6         Table t1 = new Table("http://dc-6.calit2.uci.edu/test.iotcloud/", "reallysecret", 351, -1);
7         t1.rebuild();
8
9
10         String a = "fan";
11         IoTString ia = new IoTString(a);
12         t1.createNewKey(ia, 351);
13
14
15
16         IoTDeviceAddress devAddr = new IoTDeviceAddress("192.168.1.5", 49153, 49153, false, false);
17         Wemo wemo = new Wemo(devAddr);
18
19
20
21         String valueA = "on";
22         IoTString iValueA = new IoTString(valueA);
23
24         System.out.println("Starting System");
25
26         while (true) {
27             t1.update();
28             Thread.sleep(1000);
29
30             IoTString testValA1 = t1.getCommitted(ia);
31             if ((testValA1 != null) && (testValA1.equals(iValueA) == true)) {
32                 wemo.turnOn();
33             } else {
34                 wemo.turnOff();
35             }
36         }
37     }
38 }