4 class LightsController {
6 public static void main(String[] args) throws Exception {
10 byte[] bulbMacAdd1 = new byte[8];
11 bulbMacAdd1[0] = (byte)0xD0;
12 bulbMacAdd1[1] = (byte)0x73;
13 bulbMacAdd1[2] = (byte)0xD5;
14 bulbMacAdd1[3] = (byte)0x11;
15 bulbMacAdd1[4] = (byte)0x42;
16 bulbMacAdd1[5] = (byte)0xE5;
17 bulbMacAdd1[6] = (byte)0x00;
18 bulbMacAdd1[7] = (byte)0x00;
20 IoTDeviceAddress devAddr1 = new IoTDeviceAddress("192.168.2.216", 56700, 56700, false, false);
21 IoTUDP udp1 = new IoTUDP(devAddr1);
22 LightBulb bulb1 = new LifxLightBulb(udp1, bulbMacAdd1);
26 byte[] bulbMacAdd2 = new byte[8];
27 bulbMacAdd2[0] = (byte)0xD0;
28 bulbMacAdd2[1] = (byte)0x73;
29 bulbMacAdd2[2] = (byte)0xD5;
30 bulbMacAdd2[3] = (byte)0x12;
31 bulbMacAdd2[4] = (byte)0x8E;
32 bulbMacAdd2[5] = (byte)0x30;
33 bulbMacAdd2[6] = (byte)0x00;
34 bulbMacAdd2[7] = (byte)0x00;
36 IoTDeviceAddress devAddr2 = new IoTDeviceAddress("192.168.2.126", 56701, 56700, false, false);
37 IoTUDP udp2 = new IoTUDP(devAddr2);
38 LightBulb bulb2 = new LifxLightBulb(udp2, bulbMacAdd2);
42 byte[] bulbMacAdd3 = new byte[8];
43 bulbMacAdd3[0] = (byte)0xD0;
44 bulbMacAdd3[1] = (byte)0x73;
45 bulbMacAdd3[2] = (byte)0xD5;
46 bulbMacAdd3[3] = (byte)0x02;
47 bulbMacAdd3[4] = (byte)0x41;
48 bulbMacAdd3[5] = (byte)0xDA;
49 bulbMacAdd3[6] = (byte)0x00;
50 bulbMacAdd3[7] = (byte)0x00;
52 IoTDeviceAddress devAddr3 = new IoTDeviceAddress("192.168.2.232", 56702, 56700, false, false);
53 IoTUDP udp3 = new IoTUDP(devAddr3);
54 LightBulb bulb3 = new LifxLightBulb(udp3, bulbMacAdd3);
57 List<LightBulb> bulbs = new ArrayList<LightBulb>();
67 IoTString ia1 = new IoTString(a1);
68 IoTString ia2 = new IoTString(a2);
69 IoTString ia3 = new IoTString(a3);
72 List<IoTString> keys = new ArrayList<IoTString>();
79 IoTString iValueA = new IoTString(valueA);
82 String pingTimerKey = "bulbController";
83 IoTString ipingTimerKey = new IoTString(pingTimerKey);
87 System.out.println("Starting System");
93 t1 = new Table("http://dc-6.calit2.uci.edu/test.iotcloud/", "reallysecret", 321, 6000);
94 t1.addLocalCommunication(1000, "192.168.2.50", 6001);
100 for (int i = 0; i < 3; i++) {
101 bulbs.get(i).setColor(0, 100, 100);
107 for (int i = 0; i < 3; i++) {
108 bulbs.get(i).turnOff();
112 for (int i = 0; i < 3; i++) {
113 bulbs.get(i).turnOn();
122 // Table t2 = new Table("http://dc-6.calit2.uci.edu/test.iotcloud/", "reallysecret", 400, -1);
130 System.out.println("Loop");
132 String pingTimer = Long.toString(System.currentTimeMillis());
133 IoTString ipingTimer = new IoTString(pingTimer);
136 t1.startTransaction();
137 t1.addKV(ipingTimerKey, ipingTimer);
138 t1.commitTransaction();
141 // t2.startTransaction();
142 // t2.addKV(ipingTimerKey, ipingTimer);
143 // t2.commitTransaction();
151 for (int i = 0; i < 3; i++) {
152 IoTString testValA1 = t1.getCommitted(keys.get(i));
153 if ((testValA1 != null) && (testValA1.equals(iValueA) == true)) {
154 bulbs.get(i).turnOn();
156 bulbs.get(i).turnOff();
165 for (int i = 0; i < 3; i++) {
166 bulbs.get(i).setColor(0, 100, 100);
172 for (int i = 0; i < 3; i++) {
173 bulbs.get(i).turnOff();
177 for (int i = 0; i < 3; i++) {
178 bulbs.get(i).turnOn();