Adding config file for sharing.
[iot2.git] / benchmarks / Java / Lifxtest / Lifxtest.java
1 package Lifxtest;
2
3 import iotruntime.slave.IoTSet;
4 import iotruntime.slave.IoTRelation;
5 import iotruntime.slave.IoTDeviceAddress;
6 import iotruntime.IoTUDP;
7
8 import java.io.IOException;
9 import java.net.*;
10 import iotcode.interfaces.LightBulbTest;
11 import iotcode.annotation.*;
12
13 import java.util.HashSet;
14 import java.util.Iterator;
15 import java.util.Set;
16 import java.util.Map;
17
18 import java.rmi.*;
19 import java.rmi.server.UnicastRemoteObject;
20
21 import iotcode.interfaces.LightBulbTest;
22
23 public class Lifxtest {
24
25         @config private IoTSet<LightBulbTest> lifx_light_bulb;
26
27         public void init() throws InterruptedException {
28
29                 for(LightBulbTest lifx : lifx_light_bulb.values()) {
30
31                         lifx.init();
32                         Thread.sleep(1000);
33
34                         for (int i = 0; i < 5; i++) {
35                                 lifx.turnOff();
36                                 System.out.println("Turning off!");
37                                 Thread.sleep(1000);
38                                 lifx.turnOn();
39                                 System.out.println("Turning on!");
40                                 Thread.sleep(1000);
41                         }
42
43
44                         for (int i = 2500; i < 9000; i += 100) {
45                                 System.out.println("Adjusting Temp: " + Integer.toString(i));
46                                 lifx.setTemperature(i);
47                                 Thread.sleep(100);
48                         }
49
50                         for (int i = 9000; i > 2500; i -= 100) {
51                                 System.out.println("Adjusting Temp: " + Integer.toString(i));
52                                 lifx.setTemperature(i);
53                                 Thread.sleep(100);
54                         }
55
56                         for (int i = 100; i > 0; i -= 10) {
57                                 System.out.println("Adjusting Brightness: " + Integer.toString(i));
58                                 lifx.setColor(lifx.getHue(), lifx.getSaturation(), i);
59                                 Thread.sleep(500);
60                         }
61
62                         for (int i = 0; i < 100; i += 10) {
63                                 System.out.println("Adjusting Brightness: " + Integer.toString(i));
64                                 lifx.setColor(lifx.getHue(), lifx.getSaturation(), i);
65                                 Thread.sleep(500);
66                         }
67                         lifx.turnOff();
68                 }
69         }
70 }