|
@@ -7,6 +7,8 @@ import java.util.Iterator;
|
|
|
import java.util.LinkedList;
|
|
|
import java.util.Random;
|
|
|
|
|
|
+import org.hamcrest.core.IsAnything;
|
|
|
+
|
|
|
import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.Packet;
|
|
|
import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.Port;
|
|
|
import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.Protocol;
|
|
@@ -168,7 +170,7 @@ public class MQTT_protocol implements Protocol {
|
|
|
* Topic which should be subscribed to
|
|
|
*/
|
|
|
String newTopic = null;
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* Check if FloatCollector & not subscribed
|
|
|
*/
|
|
@@ -261,7 +263,10 @@ public class MQTT_protocol implements Protocol {
|
|
|
*/
|
|
|
String newValue = null;
|
|
|
boolean isBoolean = false;
|
|
|
-
|
|
|
+ /**
|
|
|
+ * True if value anomaly (value = -1)
|
|
|
+ */
|
|
|
+ boolean valueAnomaly = (device.getLabel()==(short)-1);
|
|
|
/**
|
|
|
* Check if FloatSensor
|
|
|
*/
|
|
@@ -294,6 +299,9 @@ public class MQTT_protocol implements Protocol {
|
|
|
}else {
|
|
|
pubPacket = new MQTTpublishPacket(timestep, port, broker, newTopic, Float.parseFloat(newValue));
|
|
|
}
|
|
|
+ if(valueAnomaly) {
|
|
|
+ pubPacket.setLabel((short) 1);
|
|
|
+ }
|
|
|
/**
|
|
|
* Send Packet
|
|
|
*/
|
|
@@ -331,6 +339,9 @@ public class MQTT_protocol implements Protocol {
|
|
|
}else {
|
|
|
pubPacket = new MQTTpublishPacket(timestep, broker, p, newTopic, Float.parseFloat(newValue));
|
|
|
}
|
|
|
+ if(valueAnomaly) {
|
|
|
+ pubPacket.setLabel((short) 1);
|
|
|
+ }
|
|
|
returnPackets.add(pubPacket);
|
|
|
if (p.getStatus() != Port.CLOSED && delayBrokerToSub != Long.MAX_VALUE) {
|
|
|
returnPackets.add(
|
|
@@ -389,6 +400,9 @@ public class MQTT_protocol implements Protocol {
|
|
|
}else {
|
|
|
pubPacket = new MQTTpublishPacket(timestep, broker, p, newTopic, Float.parseFloat(newValue));
|
|
|
}
|
|
|
+ if(valueAnomaly) {
|
|
|
+ pubPacket.setLabel((short) 1);
|
|
|
+ }
|
|
|
returnPackets.add(pubPacket);
|
|
|
if (p.getStatus() != Port.CLOSED && delayBrokerToSub != Long.MAX_VALUE) {
|
|
|
returnPackets.add(
|