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, SensorLabel { long eventTime = 0; 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); } @Override public String getSensorLabel() { return "" + getBSval(); } }