Completing Tomoyo policies for all 4 benchmarks
[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                         //Thread thread = new Thread(new Runnable() {
31                         //      public void run() {
32                                         lifx.init();
33                         //      }
34                         //});
35                         //thread.start();
36                         Thread.sleep(1000);
37
38                         for (int i = 0; i < 5; i++) {
39                                 lifx.turnOff();
40                                 System.out.println("Turning off!");
41                                 Thread.sleep(1000);
42                                 lifx.turnOn();
43                                 System.out.println("Turning on!");
44                                 Thread.sleep(1000);
45                         }
46
47                         for (int i = 2500; i < 9000; i += 100) {
48                                 System.out.println("Adjusting Temp: " + Integer.toString(i));
49                                 lifx.setTemperature(i);
50                                 Thread.sleep(100);
51                         }
52
53                         for (int i = 9000; i > 2500; i -= 100) {
54                                 System.out.println("Adjusting Temp: " + Integer.toString(i));
55                                 lifx.setTemperature(i);
56                                 Thread.sleep(100);
57                         }
58
59                         for (int i = 100; i > 0; i -= 10) {
60                                 System.out.println("Adjusting Brightness: " + Integer.toString(i));
61                                 lifx.setColor(lifx.getHue(), lifx.getSaturation(), i);
62                                 Thread.sleep(500);
63                         }
64
65                         for (int i = 0; i < 100; i += 10) {
66                                 System.out.println("Adjusting Brightness: " + Integer.toString(i));
67                                 lifx.setColor(lifx.getHue(), lifx.getSaturation(), i);
68                                 Thread.sleep(500);
69                         }
70
71                         //thread.join();
72                 }
73         }
74 }