|
@@ -16,6 +16,7 @@ import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.devices.BoolCollector;
|
|
|
import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.devices.BoolSensor;
|
|
|
import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.devices.FloatCollector;
|
|
|
import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.devices.FloatSensor;
|
|
|
+import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.devices.SensorLabel;
|
|
|
import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.protocols.packets.MQTT_packet;
|
|
|
import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.protocols.packets.MQTTpublishPacket;
|
|
|
import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.scheduler.AbstractEvent;
|
|
@@ -260,6 +261,11 @@ public class MQTT_protocol implements Protocol {
|
|
|
* Value which should be published
|
|
|
*/
|
|
|
String newValue = null;
|
|
|
+ /**
|
|
|
+ * Value of the connected Sensor (as label)
|
|
|
+ */
|
|
|
+ String newSensorValue = null;
|
|
|
+
|
|
|
boolean isBoolean = false;
|
|
|
/**
|
|
|
* True if value anomaly (value = -1)
|
|
@@ -286,6 +292,12 @@ public class MQTT_protocol implements Protocol {
|
|
|
isBoolean = true;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ if(device instanceof SensorLabel) {
|
|
|
+ newSensorValue = ((SensorLabel)device).getSensorLabel();
|
|
|
+ }else {
|
|
|
+ newSensorValue=newValue;
|
|
|
+ }
|
|
|
|
|
|
if (newTopic != null) {
|
|
|
/**
|
|
@@ -293,9 +305,9 @@ public class MQTT_protocol implements Protocol {
|
|
|
*/
|
|
|
Packet pubPacket = null;
|
|
|
if(isBoolean) {
|
|
|
- pubPacket = new MQTTpublishPacket(timestep, port, broker, newTopic, Boolean.parseBoolean(newValue));
|
|
|
+ pubPacket = new MQTTpublishPacket(timestep, port, broker, newTopic, Boolean.parseBoolean(newValue), Boolean.parseBoolean(newSensorValue));
|
|
|
}else {
|
|
|
- pubPacket = new MQTTpublishPacket(timestep, port, broker, newTopic, Float.parseFloat(newValue));
|
|
|
+ pubPacket = new MQTTpublishPacket(timestep, port, broker, newTopic, Float.parseFloat(newValue), Float.parseFloat(newSensorValue));
|
|
|
}
|
|
|
if(valueAnomaly) {
|
|
|
pubPacket.setLabel((short) 1);
|
|
@@ -333,9 +345,9 @@ public class MQTT_protocol implements Protocol {
|
|
|
* Packet Broker -> Subscriber
|
|
|
*/
|
|
|
if(isBoolean) {
|
|
|
- pubPacket = new MQTTpublishPacket(timestep, broker, p, newTopic, Boolean.parseBoolean(newValue));
|
|
|
+ pubPacket = new MQTTpublishPacket(timestep, broker, p, newTopic, Boolean.parseBoolean(newValue), Boolean.parseBoolean(newSensorValue));
|
|
|
}else {
|
|
|
- pubPacket = new MQTTpublishPacket(timestep, broker, p, newTopic, Float.parseFloat(newValue));
|
|
|
+ pubPacket = new MQTTpublishPacket(timestep, broker, p, newTopic, Float.parseFloat(newValue), Float.parseFloat(newSensorValue));
|
|
|
}
|
|
|
if(valueAnomaly) {
|
|
|
pubPacket.setLabel((short) 1);
|
|
@@ -394,9 +406,9 @@ public class MQTT_protocol implements Protocol {
|
|
|
timestep += broker.getResponseTime();
|
|
|
|
|
|
if(isBoolean) {
|
|
|
- pubPacket = new MQTTpublishPacket(timestep, broker, p, newTopic, Boolean.parseBoolean(newValue));
|
|
|
+ pubPacket = new MQTTpublishPacket(timestep, broker, p, newTopic, Boolean.parseBoolean(newValue), Boolean.parseBoolean(newSensorValue));
|
|
|
}else {
|
|
|
- pubPacket = new MQTTpublishPacket(timestep, broker, p, newTopic, Float.parseFloat(newValue));
|
|
|
+ pubPacket = new MQTTpublishPacket(timestep, broker, p, newTopic, Float.parseFloat(newValue), Float.parseFloat(newSensorValue));
|
|
|
}
|
|
|
if(valueAnomaly) {
|
|
|
pubPacket.setLabel((short) 1);
|