Checking in new files for phone app and testing local control/communication.
[iotcloud.git] / version2 / src / java / light_fan_embed_benchmark_2bulbs / LocalControl.java
1 import iotcloud.*;
2 import java.util.*;
3
4 class LocalControl {
5
6     public static void main(String[] args) throws Exception {
7
8                 String a = "bulb";
9                 IoTString ia = new IoTString(a);
10
11         String valueA = "on";
12         IoTString iValueA = new IoTString(valueA);
13
14         String valueB = "off";
15         IoTString iValueB = new IoTString(valueB);
16
17         System.out.println("Starting System");
18         int counter = 0;
19
20
21         Table t1 = null;
22         try {
23             t1 = new Table("http://dc-6.calit2.uci.edu/test.iotcloud/", "reallysecret", 399, 7000);
24             t1.addLocalCommunication(400, "192.168.1.192", 6000);
25             System.out.println("Rebuilding!");
26             t1.rebuild();
27  
28             while (true) {
29                 t1.update();
30                                 //IoTString testValA1 = t1.getCommitted(ia);
31                                 t1.startTransaction();
32                                 t1.addKV(ia, iValueA);
33                                 t1.commitTransaction();
34                                 t1.update();
35                 Thread.sleep(1000);
36                 System.out.println("Turning on");
37
38                 t1.update();
39                                 //IoTString testValA1 = t1.getCommitted(ia);
40                                 t1.startTransaction();
41                                 t1.addKV(ia, iValueB);
42                                 t1.commitTransaction();
43                                 t1.update();
44                 Thread.sleep(1000);
45                 System.out.println("Turning off");
46             } 
47        } catch (Error e) {
48
49             e.printStackTrace();
50
51         }
52     }
53 }