Prechádzať zdrojové kódy

Adds updated Devices to Scenario

Andreas T. Meyer-Berg 3 rokov pred
rodič
commit
05a24c937a

+ 1 - 1
src/main/java/de/tu_darmstadt/tk/SmartHomeNetworkSim/core/RoomStatus.java

@@ -16,7 +16,7 @@ public class RoomStatus implements Schedulable {
 	/**
 	 * Average temperature of the room
 	 */
-	private float temperature = 21f;
+	private float temperature = 19;
 	
 	@Override
 	public long getEventTime() {

+ 28 - 16
src/main/java/de/tu_darmstadt/tk/SmartHomeNetworkSim/view/menuBar/MenuBarNetworkExamples.java

@@ -26,11 +26,16 @@ import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.PacketSniffer;
 import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.Port;
 import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.PrecisionLink;
 import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.Protocol;
+import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.RoomStatus;
 import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.SmartDevice;
 import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.devices.BoolCollectorDevice;
 import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.devices.BoolSensorDevice;
 import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.devices.FloatCollectorDevice;
 import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.devices.FloatSensorDevice;
+import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.devices.SmartLight;
+import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.devices.SmartLightSensor;
+import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.devices.SmartTemperatureProducer;
+import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.devices.SmartTemperatureSensor;
 import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.distributionHandler.NormalDistributionHandler;
 import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.protocols.MQTT_protocol;
 import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.simpleImplementation.CountingMetric;
@@ -796,7 +801,7 @@ public class MenuBarNetworkExamples extends JMenu{
 		/*
 		 * Main networking devices 
 		 */
-		SmartDevice smartHub = networkController.createSmartDevice("SmartHub", 500, 500, 50);
+		SmartDevice smartHub = networkController.createSmartDevice("SmartHub", 400, 400, 50);
 		
 		/*
 		 * Links/Networks
@@ -823,20 +828,26 @@ public class MenuBarNetworkExamples extends JMenu{
 		networkController.addDeviceToConnectionAndProtocol(pBroker, mqtt, 0);
 		networkController.addConnection(mqtt);
 		
+		/**
+		 * Room
+		 */
+		String roomName = "Bedroom";
+		RoomStatus room = new RoomStatus();
+		room.setTemperature(19f);
 		/*
 		 * Add some MQTT Devices
 		 */
 		
-		String roomName = "Bedroom";
 		/**
 		 * Room Thermostat
 		 */
-		FloatSensorDevice floatSensor = new FloatSensorDevice(roomName + " Thermostat");
+		SmartTemperatureSensor floatSensor = new SmartTemperatureSensor(roomName + " Thermostat", room);
 		floatSensor.setFSinfoName("home/" + roomName + "/sensorTemp");
 		networkController.addLinkToDevice(zigbee, floatSensor);
-		networkController.moveSmartDevice(floatSensor, 300, 500, 50);
-		floatSensor.setFSmin(15.0f);
-		floatSensor.setFSmax(32.0f);
+		networkController.moveSmartDevice(floatSensor, 300, 300, 50);
+		floatSensor.setFSmin(19.0f);
+		floatSensor.setFSmax(21.0f);
+		floatSensor.setFSval(19.0f);
 		networkController.addSmartDevice(floatSensor);
 		Port pFloatSensor = new Port(floatSensor, (short)1883, 15000);
 		pFloatSensor.setTriggerHandler(new NormalDistributionHandler(15000, 500));
@@ -845,14 +856,15 @@ public class MenuBarNetworkExamples extends JMenu{
 		networkController.addDeviceToConnectionAndProtocol(pFloatSensor, mqtt,1);
 		
 		/*
-		 * Add Heater
+		 * Add Heater (every second update)
 		 */
-		FloatSensorDevice heaterDevice = new FloatSensorDevice(roomName + "Heater");
+		SmartTemperatureProducer heaterDevice = new SmartTemperatureProducer(roomName + " Heater", room, 1000);
 		heaterDevice.setFSinfoName("home/" + roomName + "/heaterTemp");
 		networkController.addLinkToDevice(zigbee, heaterDevice);
-		networkController.moveSmartDevice(heaterDevice, 100, 600, 50);
-		heaterDevice.setFSmin(-6.0f);
-		heaterDevice.setFSmax(-4.0f);
+		networkController.moveSmartDevice(heaterDevice, 300, 500, 50);
+		heaterDevice.setFSmin(19.0f);
+		heaterDevice.setFSmax(21.0f);
+		heaterDevice.setFSval(19.0f);
 		networkController.addSmartDevice(heaterDevice);
 		Port pHeaterDevice = new Port(heaterDevice, (short)1883, 15000);
 		pHeaterDevice.setStatus(Port.SENDING);
@@ -862,12 +874,12 @@ public class MenuBarNetworkExamples extends JMenu{
 		
 		
 		/*
-		 * Add some kitchen lights
+		 * Add a light
 		 */
-		BoolSensorDevice smartLight = new BoolSensorDevice(roomName + "Light");
+		SmartLight smartLight = new SmartLight(roomName + " Light", room);
 		smartLight.setBSinfoName("home/" + roomName + "/light");
 		networkController.addLinkToDevice(zigbee, smartLight);
-		networkController.moveSmartDevice(smartLight, 250, 400, 50);
+		networkController.moveSmartDevice(smartLight, 500, 500, 50);
 		networkController.addSmartDevice(smartLight);
 		Port pSmartLight = new Port(smartLight, (short)1883, 15000);
 		pSmartLight.setTriggerHandler(new NormalDistributionHandler(15000, 500));
@@ -878,10 +890,10 @@ public class MenuBarNetworkExamples extends JMenu{
 		/*
 		 * Add light Sensor
 		 */
-		BoolSensorDevice lightSensor = new BoolSensorDevice(roomName + "Light");
+		SmartLightSensor lightSensor = new SmartLightSensor(roomName + " LightSensor", room, 10000);
 		lightSensor.setBSinfoName("home/" + roomName + "/light");
 		networkController.addLinkToDevice(zigbee, lightSensor);
-		networkController.moveSmartDevice(lightSensor, 750, 400, 50);
+		networkController.moveSmartDevice(lightSensor, 500, 300, 50);
 		networkController.addSmartDevice(lightSensor);
 		Port pLightSensor = new Port(lightSensor, (short)1883, 15000);
 		pLightSensor.setTriggerHandler(new NormalDistributionHandler(15000, 500));