1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- package de.tu_darmstadt.tk.SmartHomeNetworkSim.core.protocols.packets;
- import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.Port;
- /**
- * MQTT Publish Packet
- *
- *
- * @author Andreas T. Meyer-Berg
- */
- public class MQTTpublishPacket extends MQTT_packet {
- /**
- * Topic of the Publish Packet
- */
- private String topic = "";
- /**
- * Value of the packet
- */
- private float value = 0;
- private float sensorValue = 0;
- /**
- * True if boolean
- */
- private boolean isBoolean = false;
-
- /**
- * MQTT Publish Packet
- * @param timestamp time it is send
- * @param source source port
- * @param destination destination port
- * @param topic topic of the message
- * @param value value of the message
- */
- public MQTTpublishPacket(long timestamp, Port source, Port destination, String topic, float value, float sensorValue) {
- super(MQTT_packet.PUBLISH, timestamp, source, destination);
- this.setTopic(topic);
- this.setValue(value);
- this.sensorValue = sensorValue;
- setBoolean(false);
- this.message = topic + ":"+ value;
- }
-
- /**
- * MQTT Publish Packet
- * @param timestamp time it is send
- * @param source source port
- * @param destination destination port
- * @param topic topic of the message
- * @param value value of the message
- */
- public MQTTpublishPacket(long timestamp, Port source, Port destination, String topic, boolean value, boolean sensorValue) {
- super(MQTT_packet.PUBLISH, timestamp, source, destination);
- this.setTopic(topic);
- this.setValue(value ? 1 : 0);
- setBoolean(true);
- this.sensorValue = sensorValue ? 1 : 0;
- this.message = "Topic:"+topic + ":"+ value;
- }
- public boolean isBoolean() {
- return isBoolean;
- }
- public void setBoolean(boolean isBoolean) {
- this.isBoolean = isBoolean;
- }
- public float getValue() {
- return value;
- }
- public void setValue(float value) {
- this.value = value;
- }
- public String getTopic() {
- return topic;
- }
- public void setTopic(String topic) {
- this.topic = topic;
- }
- public float getSensorValue() {
- return sensorValue;
- }
-
- public void setSensorValue(float sensorValue) {
- this.sensorValue = sensorValue;
- }
- }
|