Adding more directory structure to generated files by compiler, also script to copy...
[iot2.git] / others / tutorial / benchmarks / application / SmartLights / SmartLights.java
diff --git a/others/tutorial/benchmarks/application/SmartLights/SmartLights.java b/others/tutorial/benchmarks/application/SmartLights/SmartLights.java
new file mode 100644 (file)
index 0000000..2a4eca0
--- /dev/null
@@ -0,0 +1,52 @@
+package SmartLights;
+
+import iotruntime.slave.IoTSet;
+import iotruntime.slave.IoTRelation;
+import iotruntime.slave.IoTDeviceAddress;
+import iotruntime.IoTUDP;
+
+import java.io.IOException;
+import java.net.*;
+import iotcode.interfaces.LightBulbTest;
+import iotcode.annotation.*;
+
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+import java.util.Map;
+
+import java.rmi.*;
+import java.rmi.server.UnicastRemoteObject;
+
+public class Lifxtest {
+
+       @config private IoTSet<LightBulbTest> lightbulbs;
+       @config private IoTSet<RoomSmart> rooms;
+       @config private IoTRelation<RoomSmart,LightBulbTest> rooms2lightbulbs;
+
+       public void init() throws InterruptedException {
+
+               // Iterate over RoomSmart set
+               for(RoomSmart rm : rooms.values()) {
+
+                       System.out.println("Get room: " + rm.getRoomID());
+                       // Iterate over LightBulbTest set
+                       for(LightBulbTest lb : rooms2lightbulbs.get(rm)) {
+
+                               lb.init();
+                               Thread.sleep(1000);
+
+                               for (int i = 0; i < 5; i++) {
+                                       lb.turnOff();
+                                       System.out.println("Turning off!");
+                                       Thread.sleep(1000);
+                                       lb.turnOn();
+                                       System.out.println("Turning on!");
+                                       Thread.sleep(1000);
+                               }
+
+                               lb.turnOff();
+                       }
+               }
+       }
+}