Adding more directory structure to generated files by compiler, also script to copy...
[iot2.git] / others / tutorial / benchmarks / application / SmartLights / SmartLights.java
1 package SmartLights;
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 public class Lifxtest {
22
23         @config private IoTSet<LightBulbTest> lightbulbs;
24         @config private IoTSet<RoomSmart> rooms;
25         @config private IoTRelation<RoomSmart,LightBulbTest> rooms2lightbulbs;
26
27         public void init() throws InterruptedException {
28
29                 // Iterate over RoomSmart set
30                 for(RoomSmart rm : rooms.values()) {
31
32                         System.out.println("Get room: " + rm.getRoomID());
33                         // Iterate over LightBulbTest set
34                         for(LightBulbTest lb : rooms2lightbulbs.get(rm)) {
35
36                                 lb.init();
37                                 Thread.sleep(1000);
38
39                                 for (int i = 0; i < 5; i++) {
40                                         lb.turnOff();
41                                         System.out.println("Turning off!");
42                                         Thread.sleep(1000);
43                                         lb.turnOn();
44                                         System.out.println("Turning on!");
45                                         Thread.sleep(1000);
46                                 }
47
48                                 lb.turnOff();
49                         }
50                 }
51         }
52 }