|
@@ -0,0 +1,42 @@
|
|
|
|
+package de.tu_darmstadt.tk.SmartHomeNetworkSim.core.devices;
|
|
|
|
+
|
|
|
|
+import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.RoomStatus;
|
|
|
|
+import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.SimulationManager;
|
|
|
|
+import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.scheduler.Schedulable;
|
|
|
|
+
|
|
|
|
+public class SmartLightSensor extends BoolSensorDevice implements Schedulable {
|
|
|
|
+
|
|
|
|
+ long eventTime = -1000;
|
|
|
|
+ long updateInterval = 10000;
|
|
|
|
+ RoomStatus roomStatus;
|
|
|
|
+
|
|
|
|
+ public SmartLightSensor(String name, RoomStatus roomStatus, long updateInterval) {
|
|
|
|
+ super(name);
|
|
|
|
+ this.roomStatus = roomStatus;
|
|
|
|
+ this.updateInterval = updateInterval;
|
|
|
|
+ SimulationManager.scheduleEvent(this);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ @Override
|
|
|
|
+ public long getEventTime() {
|
|
|
|
+ return eventTime;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void simulateTimeStep(long startTime, long duration) {
|
|
|
|
+ /**
|
|
|
|
+ * Do nothing
|
|
|
|
+ */
|
|
|
|
+ }
|
|
|
|
+ @Override
|
|
|
|
+ public void simulateEvent(long time) {
|
|
|
|
+ /*
|
|
|
|
+ * get Light Status
|
|
|
|
+ */
|
|
|
|
+ this.setBSval(roomStatus.isLightOn());
|
|
|
|
+ eventTime = time + updateInterval;
|
|
|
|
+ SimulationManager.scheduleEvent(this);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+}
|