Prechádzať zdrojové kódy

Fixes missing Java-doc comments and improves some comments

* JavaDoc can be generated by "gradlew javadoc"
Andreas T. Meyer-Berg 5 rokov pred
rodič
commit
b3cd1b8fa9

+ 3 - 1
src/main/java/de/tu_darmstadt/tk/SmartHomeNetworkSim/Main.java

@@ -41,7 +41,6 @@ public class Main {
 	 * @param args will be ignored
 	 */
 	public static void main(String[] args) {
-		
 		m = new Model();
 		c = new Controller(m);
 	    v = new MainFrame(m, c);
@@ -50,6 +49,9 @@ public class Main {
 	    sim.simulateTimeIntervall(0, 1000);
 	}
 	
+	/**
+	 * Initializes a basic test Network, which contains a few SmartDevices, one Link and one Connection
+	 */
 	public static void initializeTest(){
 		SmartDevice A = null, B = null, C = null;
 		for(int i = 0; i<5; i++){

+ 88 - 60
src/main/java/de/tu_darmstadt/tk/SmartHomeNetworkSim/control/Controller.java

@@ -16,6 +16,13 @@ public class Controller {
 	 */
 	Model model;
 
+	/**
+	 * Create a new Controller, which controls the given model and allows
+	 * manipulation of this model
+	 * 
+	 * @param model
+	 *            model, that should be controlled
+	 */
 	public Controller(Model model) {
 		this.model = model;
 	}
@@ -30,47 +37,45 @@ public class Controller {
 	 * @param y
 	 *            new y position
 	 * @param z
-	 *            new z postiion
+	 *            new z position
 	 */
 	public void moveSmartDevice(SmartDevice device, int x, int y, int z) {
-		for (SmartDevice d : model.getDevices()) {
-			if (d == device) {
-				d.setX(x);
-				d.setY(y);
-				d.setZ(z);
-			}
-		}
+		device.setX(x);
+		device.setY(y);
+		device.setZ(z);
+
 	}
 
 	/**
-	 * Sets the Dimension of the model
+	 * Changes the dimension of the model, without scaling the SmartDevice
+	 * positions
 	 * 
 	 * @param width
-	 *            the width to set
+	 *            the new width to set
 	 * @param height
-	 *            the height to set
+	 *            the new height to set
 	 * @param depth
-	 *            the depth to set
+	 *            the new depth to set
 	 */
 	public void setDimension(int width, int height, int depth) {
 		setDimension(width, height, depth, false);
 	}
 
 	/**
-	 * Sets the Dimension of the model and moves SmartDevices to new relative
-	 * positions
+	 * Changes the dimension of the model and moves SmartDevices to new relative
+	 * positions if {@code stretchModel} is true
 	 * 
 	 * @param width
-	 *            the width to set
+	 *            the new width to set
 	 * @param height
-	 *            the height to set
+	 *            the new height to set
 	 * @param depth
-	 *            the depth to set
-	 * @param true
-	 *            if smartDevice positions should be stretched
+	 *            the new depth to set
+	 * @param stretchModel
+	 *            true, if smartDevice positions should be stretched
 	 */
 	public void setDimension(int width, int height, int depth, boolean stretchModel) {
-		//Dont allow to small Models
+		// Don't allow to small Models
 		if (width < 400)
 			width = 400;
 		if (height < 400)
@@ -108,84 +113,107 @@ public class Controller {
 		model.setHeight(height);
 		model.setDepth(depth);
 	}
-	
+
 	/**
-	 * Calculates the new scaled position, which should radius < newPost < upperBound - radius
-	 * @param oldPosition previous Position that should be scaled
-	 * @param factor how much it is stretched/shrunk
-	 * @param upperBound upper Bound of the frame, which should not be exceeded
-	 * @return newPosition that was calculated
+	 * Calculates the new scaled position, which should be in Bounds:
+	 * {@code radius < newPosition <
+	 * (upperBound - radius)}
+	 * 
+	 * @param oldPosition
+	 *            previous position that should be scaled
+	 * @param factor
+	 *            how much it is stretched/shrunk
+	 * @param upperBound
+	 *            upper bound of the frame, which should not be exceeded
+	 * @return new position that was calculated
 	 */
-	private int scalePos(int oldPosition, double factor, int upperBound){
+	private int scalePos(int oldPosition, double factor, int upperBound) {
 		/**
 		 * New Position that should be validated and returned
 		 */
 		int newPosition = (int) Math.round(factor * oldPosition);
-		//Update if it moves out of the frame
-		if(newPosition<model.getDevice_visualization_radius())
+		// Update if it moves out of the frame
+		if (newPosition < model.getDevice_visualization_radius())
 			newPosition = model.getDevice_visualization_radius();
-		if(newPosition>=upperBound-model.getDevice_visualization_radius())
-			newPosition = upperBound-model.getDevice_visualization_radius();
-		
+		if (newPosition >= upperBound - model.getDevice_visualization_radius())
+			newPosition = upperBound - model.getDevice_visualization_radius();
+
 		return newPosition;
 	}
-	
+
 	/**
-	 * Adds SmartDevice to the Model
+	 * Adds SmartDevice to the Model and verifies that it is inside the model
+	 * bounds
+	 * 
 	 * @param sd
+	 *            SmartDevice which should be added to the model
 	 */
-	public void addSmartDevice(SmartDevice sd){
+	public void addSmartDevice(SmartDevice sd) {
+		if (model.getDevices().contains(sd))
+			return;
 		model.addDevices(sd);
-		//validate Position
+		// validate Position
 		sd.setX(scalePos(sd.getX(), 1.0, model.getWidth()));
 		sd.setY(scalePos(sd.getY(), 1.0, model.getHeight()));
 		sd.setZ(scalePos(sd.getZ(), 1.0, model.getDepth()));
 	}
-	
+
 	/**
-	 * Creates a new SmartDevice at the given Position
-	 * @param name name of the smartDevice
-	 * @param x_pos position on the x-Axis
-	 * @param y_pos position on the y-Axis
-	 * @param z_pos position on the z-Axis
+	 * Creates a new SmartDevice at the given Position. The Device is moved
+	 * into the model bounds, if the position is outside the bounds
+	 * 
+	 * @param name
+	 *            name of the smartDevice
+	 * @param x_pos
+	 *            position on the x-Axis
+	 * @param y_pos
+	 *            position on the y-Axis
+	 * @param z_pos
+	 *            position on the z-Axis
 	 */
-	public void createSmartDevice(String name, int x_pos, int y_pos, int z_pos){
+	public void createSmartDevice(String name, int x_pos, int y_pos, int z_pos) {
 		SmartDevice sd = new SmartDevice(name);
 		sd.setX(scalePos(x_pos, 1.0, model.getWidth()));
 		sd.setY(scalePos(y_pos, 1.0, model.getHeight()));
 		sd.setZ(scalePos(z_pos, 1.0, model.getDepth()));
 		model.addDevices(sd);
 	}
-	
+
 	/**
-	 * Deletes the given SmartDevice toDelete, removes it from its links and connections.
-	 * @param toDelete the SmartDevice to remove
+	 * Deletes the given SmartDevice toDelete, removes it from its links and
+	 * connections.
+	 * 
+	 * @param toDelete
+	 *            the SmartDevice to delete
 	 */
-	public void deleteSmartDevice(SmartDevice toDelete){
-		if(toDelete == null) return;
-		//Remove from Links
-		for(Link link:toDelete.getLinks())
+	public void deleteSmartDevice(SmartDevice toDelete) {
+		if (toDelete == null)
+			return;
+		// Remove from Links
+		for (Link link : toDelete.getLinks())
 			removeSmartDeviceFromLink(toDelete, link);
-		
-		//Delete Connections
-		for(Connection c: toDelete.getConnections()){
+
+		// Delete Connections
+		for (Connection c : toDelete.getConnections()) {
 			c.removeSmartDevice(toDelete);
-			if(c.getSource()==null){
+			if (c.getSource() == null) {
 				model.addTerminatingConnections(c);
-				for(SmartDevice sd:c.getParticipants()){
-					if(sd!=null)sd.getConnections().remove(c);
+				for (SmartDevice sd : c.getParticipants()) {
+					if (sd != null)
+						sd.getConnections().remove(c);
 				}
 			}
 		}
 		model.getDevices().remove(toDelete);
 	}
-	
+
 	/**
 	 * Removes the SmartDevice from the given Link
-	 * @param toRemove
-	 * @param link
+	 * 
+	 * @param toRemove the Device that should be removed from the link
+	 * @param link the Link, which contains the SmartDevice
 	 */
-	public void removeSmartDeviceFromLink(SmartDevice toRemove, Link link){
+	public void removeSmartDeviceFromLink(SmartDevice toRemove, Link link) {
 		toRemove.removeLink(link);
 	}
 }

+ 1 - 1
src/main/java/de/tu_darmstadt/tk/SmartHomeNetworkSim/control/package-info.java

@@ -1,5 +1,5 @@
 /**
- * Control classes, APIs and Interfaces.
+ * Control classes, APIs and Interfaces for interaction with the {@link de.tu_darmstadt.tk.SmartHomeNetworkSim.core.Model} and {@link de.tu_darmstadt.tk.SmartHomeNetworkSim.core.SimulationManager}.
  * 
  * @author Andreas T. Meyer-Berg
  */

+ 21 - 14
src/main/java/de/tu_darmstadt/tk/SmartHomeNetworkSim/core/Connection.java

@@ -13,7 +13,7 @@ public interface Connection {
 	/**
 	 * Returns the Link, which the connection uses
 	 * 
-	 * @return
+	 * @return link this connection uses
 	 */
 	public Link getLink();
 
@@ -25,38 +25,45 @@ public interface Connection {
 	public SmartDevice getSource();
 
 	/**
-	 * Returns the SmartDevices that are Part of this Connection
+	 * Returns the SmartDevices that are part of this connection
 	 * 
-	 * @return SmartDevices participating in this Connection
+	 * @return SmartDevices participating in this connection
 	 */
 	public Collection<SmartDevice> getParticipants();
 
 	/**
 	 * Removes the SmartDevice from the Connection. Should create terminating
-	 * packages, that are returned on the next call of simulateTimeIntervall.
-	 * If the Connection will be fully closed, source should be set to null and
-	 * getTerminationPackages should return the lastPackages. If the connection still
-	 * continues, a new Device should become the source.
-	 * The Calling Method should remove the Connection in the SmartDevice and
-	 * add the Connection to Model.terminatedConnections(), if source was set to null.
+	 * packages, that are returned on the next call of simulateTimeIntervall. If
+	 * the Connection will be fully closed, source should be set to null and
+	 * getTerminationPackages should return the lastPackages. If the connection
+	 * still continues, a new Device should become the source. The Calling
+	 * Method should remove the Connection in the SmartDevice and add the
+	 * Connection to Model.terminatedConnections(), if source was set to null.
 	 * 
-	 * @param sd SmartDevice to Remove
+	 * @param sd
+	 *            SmartDevice to Remove
 	 */
 	public void removeSmartDevice(SmartDevice sd);
 
 	/**
-	 * Simulate Time Step
+	 * Simulates the next Simulation interval and returns the packets that were
+	 * sent during this interval.
 	 * 
 	 * @param startTime
+	 *            Time the simulation interval starts in
+	 *            System.currentTimeMillis() time
 	 * @param duration
-	 * @return packets that were sent
+	 *            Duration of the simulation interval in milliseconds
+	 * @return packets that were sent in this interval
 	 */
-	public Collection<Packet> simulateTimeIntervall(long startTime, long duration);
-	
+	public Collection<Packet> simulateTimeInterval(long startTime, long duration);
+
 	/**
 	 * Returns the Packets, created to terminate the connection
 	 * 
 	 * @param startTime
+	 *            Time the simulation interval starts in
+	 *            System.currentTimeMillis() time
 	 * @return packets that were sent
 	 */
 	public Collection<Packet> getTerminationPackages(long startTime);

+ 19 - 10
src/main/java/de/tu_darmstadt/tk/SmartHomeNetworkSim/core/Link.java

@@ -3,7 +3,8 @@ package de.tu_darmstadt.tk.SmartHomeNetworkSim.core;
 import java.util.Collection;
 
 /**
- * Physical Link medium for SmartDevices, which connects two or more devices and allows communication between them
+ * Physical Link medium for SmartDevices, which connects two or more devices and
+ * allows communication between them
  *
  * @author Andreas T. Meyer-Berg
  */
@@ -14,7 +15,8 @@ public interface Link {
 	public String getName();
 
 	/**
-	 * @param name the name to set
+	 * @param name
+	 *            the name to set
 	 */
 	public void setName(String name);
 
@@ -24,24 +26,31 @@ public interface Link {
 	public Collection<SmartDevice> getDevices();
 
 	/**
-	 * @param device the devices to add
+	 * @param device
+	 *            the devices to add
 	 */
 	public void addDevice(SmartDevice device);
-	
+
 	/**
-	 * @param device the devices to remove
+	 * @param device
+	 *            the devices to remove
 	 */
 	public void removeDevice(SmartDevice device);
-	
+
 	/**
-	 * Simulates an intervall starting at startTime for a given duration
-	 * @param startTime 
+	 * Simulates an interval starting at startTime for a given duration
+	 * 
+	 * @param startTime
+	 *            Time the simulation interval starts in
+	 *            System.currentTimeMillis() time
 	 * @param duration
+	 *            Duration of the simulation interval in milliseconds
 	 */
-	public void simulateTimeIntervall(long startTime, long duration);
-	
+	public void simulateTimeInterval(long startTime, long duration);
+
 	/**
 	 * Returns all packets which where sent during the last Simulation time step
+	 * 
 	 * @return packets, which were sent during the last time step
 	 */
 	public Collection<Packet> getPackets();

+ 2 - 2
src/main/java/de/tu_darmstadt/tk/SmartHomeNetworkSim/core/Packet.java

@@ -2,6 +2,7 @@ package de.tu_darmstadt.tk.SmartHomeNetworkSim.core;
 
 /**
  * Virtual network packet, that can be sent, collected, dumped and edited
+ * 
  * @author Andreas T. Meyer-Berg
  */
 public abstract class Packet {
@@ -11,14 +12,13 @@ public abstract class Packet {
 	 * @return Byte representation of the current packet
 	 */
 	public abstract Byte[] dumpBytes();
-	
 
 	/**
 	 * 
 	 * @return Textual Representation of the Package
 	 */
 	public abstract String getTextualRepresentation();
-	
+
 	/**
 	 * 
 	 * @return Textual Representation of the Package

+ 5 - 2
src/main/java/de/tu_darmstadt/tk/SmartHomeNetworkSim/core/PacketSniffer.java

@@ -11,13 +11,16 @@ public interface PacketSniffer {
 
 	/**
 	 * Add packets, that were sent
+	 * 
 	 * @param received
+	 *            the packets which were received
 	 */
 	public void addPackets(Collection<Packet> received);
-	
+
 	/**
 	 * Returns the Packets, that were sent.
-	 * @return
+	 * 
+	 * @return the packets the sniffer collected
 	 */
 	public Collection<Packet> getPackets();
 }

+ 11 - 11
src/main/java/de/tu_darmstadt/tk/SmartHomeNetworkSim/core/Protocol.java

@@ -11,11 +11,11 @@ import java.util.Collection;
 public interface Protocol {
 
 	/**
-	 * Generates the next Packet
+	 * Generates the next packet
 	 * 
 	 * @param timestep
-	 *            Time the package should be sent
-	 * @return next Packet
+	 *            Time the package should be sent, in System.currentTimeMillis
+	 * @return next Packet, which was sent
 	 */
 	public Packet generateNextPaket(long timestep);
 
@@ -28,17 +28,17 @@ public interface Protocol {
 	public int getNumberOfRoles();
 
 	/**
-	 * Returns the textual Representation of the different Roles. The Array
-	 * should contain {@codeNumberOfRoles} Strings. {@codeArray[role]} should be
-	 * a human-readable String representation of the Role at Position
+	 * Returns the textual representation of the different Roles. The Array
+	 * should contain {@code NumberOfRoles} Strings. {@code Array[role]} should be
+	 * a human-readable String representation of the Role at its position
 	 * {@code role}.
 	 * 
-	 * @return String Representations of the roles
+	 * @return String representations of the roles
 	 */
 	public String[] getRoles();
 
 	/**
-	 * Returns all SmartDevices of the given Role. Returns null, if the role
+	 * Returns all SmartDevices of the given Role. Returns {@code null}, if the role
 	 * number was invalid.
 	 * 
 	 * @param role
@@ -48,7 +48,7 @@ public interface Protocol {
 	public Collection<SmartDevice> getDevicesWithRole(int role);
 
 	/**
-	 * Adds a new smartDevice to the role, returns {@code true} if if was
+	 * Adds a new SmartDevice to the role, returns {@code true} if it was
 	 * assigned successfully, {@code false} if it wasn't. (Either invalid role
 	 * number or maximum number of devices for the role reached)
 	 * 
@@ -56,12 +56,12 @@ public interface Protocol {
 	 *            SmartDevice that should be assigned to the given role
 	 * @param role
 	 *            Position of the role in {@code getNumberOfRoles}
-	 * @return whether the Device was added
+	 * @return true, if the SmartDevice was added
 	 */
 	public boolean addDeviceOfRole(SmartDevice device, int role);
 
 	/**
-	 * Remove a device from the Protocol
+	 * Remove a SmartDevice from this protocol
 	 * 
 	 * @param device
 	 *            device that should be removed

+ 33 - 9
src/main/java/de/tu_darmstadt/tk/SmartHomeNetworkSim/core/SimpleConnection.java

@@ -1,22 +1,46 @@
 package de.tu_darmstadt.tk.SmartHomeNetworkSim.core;
 
-import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.LinkedList;
 
 public class SimpleConnection implements Connection {
 
-	SmartDevice source;
-	SmartDevice destination;
-	Link link;
-	Protocol p;
+	/**
+	 * SmartDevice which is the source of this connection
+	 */
+	private SmartDevice source;
+	/**
+	 * SmartDevice which is the destination of this connection
+	 */
+	private SmartDevice destination;
+	/**
+	 * Link which connects {@code source} and  {@code destination}
+	 */
+	private Link link;
+	/**
+	 * Protocol, which specifies the packet generation
+	 */
+	private Protocol p;
 	
 	//for Termination
-	ArrayList<Packet> terminatingPackets;
-	SmartDevice srcOfTermination;
-	SmartDevice other;
+	/**
+	 * SmartDevice which started the termination process
+	 */
+	private SmartDevice srcOfTermination;
+	/**
+	 * SmartDevice which responds in the termination process
+	 */
+	private SmartDevice other;
 	
+	/**
+	 * Creates a new connection between to SmartDevices on a given Link, which communicate with a protocol p
+	 * 
+	 * @param src SmartDevice which is the source of this connection
+	 * @param dest SmartDevice which is the destination of this connection
+	 * @param link Link which connects {@code src} and  {@code dest}
+	 * @param p Protocol, which specifies the packet generation
+	 */
 	public SimpleConnection(SmartDevice src, SmartDevice dest, Link link, Protocol p) {
 		source = src;
 		destination = dest;
@@ -29,7 +53,7 @@ public class SimpleConnection implements Connection {
 	}
 
 	@Override
-	public Collection<Packet> simulateTimeIntervall(long startTime, long duration) {
+	public Collection<Packet> simulateTimeInterval(long startTime, long duration) {
 		LinkedList<Packet> list = new LinkedList<Packet>();
 		for(long i = 0; i<duration; i+=100)
 			list.add(p.generateNextPaket(startTime+i));

+ 38 - 20
src/main/java/de/tu_darmstadt/tk/SmartHomeNetworkSim/core/SimpleLink.java

@@ -5,82 +5,100 @@ import java.util.LinkedList;
 import java.util.ArrayList;
 
 /**
- * Simple Implementation of {@link Link}, which allows connection of multiple devices
+ * Simple Implementation of {@link Link}, which allows connection of multiple
+ * devices
  *
  * @author Andreas T. Meyer-Berg
  */
 public class SimpleLink implements Link {
 
 	/**
-	 * name of the connection
+	 * Name of the connection
 	 */
 	private String name;
-	
+
 	/**
 	 * Devices connected by this Link
 	 */
 	private ArrayList<SmartDevice> devices;
 
+	/**
+	 * List of packages to store packages sent during simulation intervals, or
+	 * after termination
+	 */
 	private LinkedList<Packet> packets;
+
 	/**
 	 * Initializes a simple Link with name and an empty devices list.
+	 * 
 	 * @param name
+	 *            Name the Link should have
 	 */
-	public SimpleLink(String name){
+	public SimpleLink(String name) {
 		this.name = name;
 		this.devices = new ArrayList<SmartDevice>();
 		this.packets = new LinkedList<Packet>();
 	}
-	
-	
+
 	/**
-	 * @return the name
+	 * Returns the name of this Link
+	 * 
+	 * @return name of this Link
 	 */
 	public String getName() {
 		return name;
 	}
 
 	/**
-	 * @param name the name to set
+	 * Sets the name of this Link
+	 * 
+	 * @param name
+	 *            the name to set
 	 */
 	public void setName(String name) {
 		this.name = name;
 	}
 
 	/**
-	 * @return the devices
+	 * Returns the device that are part of this connection
+	 * 
+	 * @return the devices of this Link
 	 */
 	public Collection<SmartDevice> getDevices() {
 		return devices;
 	}
 
 	/**
-	 * @param device the devices to add
+	 * Adds the SmartDevice to this Link
+	 * 
+	 * @param device
+	 *            the devices to add
 	 */
 	public void addDevice(SmartDevice device) {
 		this.devices.add(device);
 	}
-	
+
 	/**
-	 * @param device the devices to remove
+	 * Remove SmartDevice from this Link
+	 * 
+	 * @param device
+	 *            the device to remove
 	 */
 	public void removeDevice(SmartDevice device) {
 		this.devices.remove(device);
 	}
 
-
 	@Override
-	public void simulateTimeIntervall(long startTime, long duration) {
+	public void simulateTimeInterval(long startTime, long duration) {
 		packets.clear();
-		for(SmartDevice sd: devices)
-			for(Connection c:sd.getConnections()){
-				//Simulate just if source and link match
-				if(c.getLink()==this && c.getSource() == sd)
-					packets.addAll(c.simulateTimeIntervall(startTime, duration));
+		for (SmartDevice sd : devices)
+			for (Connection c : sd.getConnections()) {
+				// Simulate just if source and link match
+				if (c.getLink() == this && c.getSource() == sd)
+					packets.addAll(c.simulateTimeInterval(startTime, duration));
 			}
 	}
 
-
 	@Override
 	public Collection<Packet> getPackets() {
 		return packets;

+ 30 - 11
src/main/java/de/tu_darmstadt/tk/SmartHomeNetworkSim/core/SimplePacket.java

@@ -1,7 +1,7 @@
 package de.tu_darmstadt.tk.SmartHomeNetworkSim.core;
 
 /**
- * Simple Dummy Packet for testing purposes
+ * Simple dummy packet for testing purposes
  *
  * @author Andreas T. Meyer-Berg
  */
@@ -10,22 +10,32 @@ public class SimplePacket extends Packet {
 	/**
 	 * Time the packet was sent
 	 */
-	long time;
+	private long time;
+
+	/**
+	 * Source of this packet
+	 */
+	private SmartDevice source;
+
 	/**
-	 * source and destination
+	 * Destination of this packet
 	 */
-	SmartDevice source, destination;
-	
+	private SmartDevice destination;
+
 	/**
 	 * Payload which was sent
 	 */
 	private String payload;
-	
+
 	/**
-	 * Creates a new dummy packet
+	 * Creates a new dummy packet without payload
+	 * 
 	 * @param time
+	 *            time the package was created in System.currentTimeMillis
 	 * @param source
+	 *            SmartDevice which sent this packet
 	 * @param destination
+	 *            SmartDevice which should receive this packet
 	 */
 	public SimplePacket(long time, SmartDevice source, SmartDevice destination) {
 		this.time = time;
@@ -33,12 +43,19 @@ public class SimplePacket extends Packet {
 		this.destination = destination;
 		this.payload = null;
 	}
-	
+
 	/**
-	 * Creates a new dummy packet
+	 * Creates a new dummy packet with a String as payload
+	 * 
 	 * @param time
+	 *            time the package was created in System.currentTimeMillis
 	 * @param source
+	 *            SmartDevice which sent this packet
 	 * @param destination
+	 *            SmartDevice which should receive this packet
+	 * @param payload
+	 *            String which represents the payload which is encapsulated by
+	 *            this packet
 	 */
 	public SimplePacket(long time, SmartDevice source, SmartDevice destination, String payload) {
 		this.time = time;
@@ -46,6 +63,7 @@ public class SimplePacket extends Packet {
 		this.destination = destination;
 		this.payload = payload;
 	}
+
 	@Override
 	public Byte[] dumpBytes() {
 		return this.dumpBytes();
@@ -53,12 +71,13 @@ public class SimplePacket extends Packet {
 
 	@Override
 	public String getTextualRepresentation() {
-		return "[SimplePacket:"+payload+" time-"+time+";source:"+source.getName()+";dest:"+destination.getName()+"]";
+		return "[SimplePacket:" + payload + " time-" + time + ";source:" + source.getName() + ";dest:"
+				+ destination.getName() + "]";
 	}
 
 	@Override
 	public String getPayload() {
-		return payload == null ? "":payload;
+		return payload == null ? "" : payload;
 	}
 
 }

+ 8 - 5
src/main/java/de/tu_darmstadt/tk/SmartHomeNetworkSim/core/SimulationManager.java

@@ -9,26 +9,29 @@ public class SimulationManager {
 	Model model;
 
 	/**
-	 * creates a new Simulationmanger
+	 * Creates a new Simulationmanager
 	 * 
-	 * @param model
+	 * @param model Model that should be simulated
 	 */
 	public SimulationManager(Model model) {
 		this.model = model;
 	}
 
 	/**
-	 * Simulates one time step
+	 * Simulates one time step at a given time fur a given duration
 	 * 
 	 * @param startTime
+	 *            Time the simulation interval starts in
+	 *            System.currentTimeMillis() time
 	 * @param duration
+	 *            Duration of the simulation interval in milliseconds
 	 */
 	public void simulateTimeIntervall(long startTime, long duration){
 		//Simulate all Links, and their connections
-		model.getConnectionNetworks().forEach(d -> d.simulateTimeIntervall(startTime, duration));
+		model.getConnectionNetworks().forEach(d -> d.simulateTimeInterval(startTime, duration));
 		//Simulate SmartDevices - if they need some logic
 		model.getDevices().forEach(d -> d.simulateTimeStep(startTime, duration));
-		//Store Packages/Export Packages etc. 
+		//Store Packages/Export Packages etc. (for debug purposes)
 		model.getConnectionNetworks().forEach(d->d.getPackets()
 				.forEach(p-> 
 				{

+ 58 - 24
src/main/java/de/tu_darmstadt/tk/SmartHomeNetworkSim/core/SmartDevice.java

@@ -4,8 +4,8 @@ import java.util.LinkedList;
 import java.util.List;
 
 /**
- * Model of an SmartDevice, which keeps track of its main attributes, like name
- * and links
+ * Model of an SmartDevice, which keeps track of its main attributes, like name,
+ * position, links and connections
  * 
  * @author Andreas T. Meyer-Berg
  */
@@ -15,12 +15,11 @@ public class SmartDevice {
 	 * Name of the Device
 	 */
 	private String name;
-
 	/**
 	 * Physical connections to other SmartDevices
 	 */
 	private List<Link> links;
-	
+
 	/**
 	 * Virtual Connections to other SmartDevices
 	 */
@@ -42,33 +41,39 @@ public class SmartDevice {
 	 * Position on the x-Axis
 	 */
 	private int x;
-	
+
 	/**
 	 * Positon on the y-Axis
 	 */
 	private int y;
-	
+
 	/**
 	 * Position on the z-Axis
 	 */
 	private int z;
-	
+
 	/**
-	 * @return the name
+	 * Returns the {@link SmartDevice#name}
+	 * 
+	 * @return {@link SmartDevice#name}
 	 */
 	public String getName() {
 		return name;
 	}
 
 	/**
+	 * Sets the {@link SmartDevice#name}
+	 * 
 	 * @param name
-	 *            the name to set
+	 *            the {@link SmartDevice#name} to set
 	 */
-	public void setoDeletetName(String name) {
+	public void setName(String name) {
 		this.name = name;
 	}
 
 	/**
+	 * Returns links of this device
+	 * 
 	 * @return the links of this device
 	 */
 	public List<Link> getLinks() {
@@ -76,74 +81,99 @@ public class SmartDevice {
 	}
 
 	/**
+	 * Adds a new link to this device
+	 * 
 	 * @param link
-	 *            the connection to add
+	 *            the link to add
 	 */
 	public void addLink(Link link) {
 		this.links.add(link);
 	}
-	
+
 	/**
 	 * Removes the link from this SmartDevice
+	 * 
 	 * @param link
+	 *            Link which should be removed
 	 */
-	public void removeLink(Link link){
-		if(link == null)return;
+	public void removeLink(Link link) {
+		if (link == null)
+			return;
 		links.remove(link);
 		link.removeDevice(this);
 	}
 
 	/**
-	 * @return the x
+	 * Returns the x-position
+	 * 
+	 * @return the x-position
 	 */
 	public int getX() {
 		return x;
 	}
 
 	/**
-	 * @param x the x to set
+	 * Sets the x-position
+	 * 
+	 * @param x
+	 *            the x-position to set
 	 */
 	public void setX(int x) {
-		this.x = x;	
+		this.x = x;
 	}
 
 	/**
-	 * @return the y
+	 * Returns the y-position
+	 * 
+	 * @return the y-position
 	 */
 	public int getY() {
 		return y;
 	}
 
 	/**
-	 * @param y the y to set
+	 * Sets the y-position
+	 * 
+	 * @param y
+	 *            the y-position to set
 	 */
 	public void setY(int y) {
 		this.y = y;
 	}
 
 	/**
-	 * @return the z
+	 * Returns the z-position
+	 * 
+	 * @return the z-position
 	 */
 	public int getZ() {
 		return z;
 	}
 
 	/**
-	 * @param z the z to set
+	 * Sets the z-position
+	 * 
+	 * @param z
+	 *            the z-position to set
 	 */
 	public void setZ(int z) {
 		this.z = z;
 	}
 
 	/**
-	 * @return the connections
+	 * Returns all connections of this device
+	 * 
+	 * @return the connections of this device
 	 */
 	public List<Connection> getConnections() {
 		return connections;
 	}
 
 	/**
-	 * @param connections the connections to set
+	 * Adds a connection to this device
+	 * 
+	 * @param connections
+	 *            the connection add
 	 */
 	public void addConnection(Connection connections) {
 		this.connections.add(connections);
@@ -151,11 +181,15 @@ public class SmartDevice {
 
 	/**
 	 * Simulates the next Timestep
+	 * 
 	 * @param startTime
+	 *            Time the simulation interval starts in
+	 *            System.currentTimeMillis() time
 	 * @param duration
+	 *            Duration of the simulation interval in milliseconds
 	 */
 	public void simulateTimeStep(long startTime, long duration) {
-		
+
 	}
 
 }

+ 5 - 4
src/main/java/de/tu_darmstadt/tk/SmartHomeNetworkSim/view/VisualisationInteractor.java

@@ -77,12 +77,13 @@ public class VisualisationInteractor implements MouseInputListener, MouseMotionL
 	 */
 	private SmartDevice clicked = null;
 
+	
 	/**
-	 * Creates a new VisualisationInteractor**
-	 * Finishes the drag operation, if a SmartDevice was dragged, repaint the panel and set dragged 
+	 * Creates a new VisualisationInteractor
 	 *
-	 * @param model
-	 * @param controller
+	 * @param model Model which is visualized
+	 * @param controller controller that is accessed
+	 * @param panel which should visualize the interactions
 	 */
 	public VisualisationInteractor(Model model, Controller controller, VisualisationPanel panel) {
 		//Initialize the values

+ 49 - 38
src/main/java/de/tu_darmstadt/tk/SmartHomeNetworkSim/view/VisualisationPanel.java

@@ -37,7 +37,7 @@ public class VisualisationPanel extends JPanel {
 	private int visualisationRadius = 17;
 
 	/**
-	 * Initializes the Visualisation Panel
+	 * Initializes the Visualization Panel
 	 * 
 	 * @param model
 	 *            Model to visualize
@@ -49,17 +49,18 @@ public class VisualisationPanel extends JPanel {
 
 		this.model = model;
 		this.control = control;
-		
+
 		this.interactor = new VisualisationInteractor(model, control, this);
 
 		this.addMouseMotionListener(interactor);
 		this.addMouseListener(interactor);
 	}
-	
+
 	/**
-	 * Performs further initializations, which have to be performed, after the model was made visible
+	 * Performs further initializations, which have to be performed, after the
+	 * model was made visible
 	 */
-	public void delayedInit(){
+	public void delayedInit() {
 		this.addComponentListener(new ComponentListener() {
 
 			@Override
@@ -81,22 +82,22 @@ public class VisualisationPanel extends JPanel {
 			}
 		});
 	}
-	
+
 	@Override
 	public void paint(Graphics g) {
 		// paint white background
 		g.setColor(Color.white);
 		g.fillRect(0, 0, this.getWidth(), this.getHeight());
-		
+
 		paintConnections(g);
-		
+
 		paintDevices(g);
 	}
 
 	/**
 	 * Paints the smart devices of the Model
 	 * 
-	 * @param g
+	 * @param g the Graphics object to visualize on
 	 */
 	public void paintDevices(Graphics g) {
 
@@ -109,73 +110,83 @@ public class VisualisationPanel extends JPanel {
 				y = interactor.dragged_y;
 			}
 			g.setColor(Color.WHITE);
-			g.fillOval(x - visualisationRadius, y - visualisationRadius, 2*visualisationRadius-1, 2*visualisationRadius-1);
+			g.fillOval(x - visualisationRadius, y - visualisationRadius, 2 * visualisationRadius - 1,
+					2 * visualisationRadius - 1);
 			g.setColor(Color.BLACK);
-			g.drawOval(x - visualisationRadius, y - visualisationRadius, 2*visualisationRadius-1, 2*visualisationRadius-1);
+			g.drawOval(x - visualisationRadius, y - visualisationRadius, 2 * visualisationRadius - 1,
+					2 * visualisationRadius - 1);
 			g.setColor(Color.BLUE);
-			g.drawOval(x - visualisationRadius+2, y - visualisationRadius+2, 2*visualisationRadius-5, 2*visualisationRadius-5);
+			g.drawOval(x - visualisationRadius + 2, y - visualisationRadius + 2, 2 * visualisationRadius - 5,
+					2 * visualisationRadius - 5);
 			g.setColor(Color.BLACK);
-			g.drawString(s.getName(), x - g.getFontMetrics().stringWidth(s.getName()) / 2, y + visualisationRadius+11);
+			g.drawString(s.getName(), x - g.getFontMetrics().stringWidth(s.getName()) / 2,
+					y + visualisationRadius + 11);
 		}
 	}
-	
+
 	/**
 	 * Paints the Connections
-	 * @param g
+	 * 
+	 * @param g the Graphics object to visualize on
 	 */
-	private void paintConnections(Graphics g){
+	private void paintConnections(Graphics g) {
 		g.setColor(Color.RED);
-		//For all Connections
+		// For all Connections
 		for (SmartDevice s : model.getDevices())
-			for(Connection c: s.getConnections()){
-				//Draw just once, if the device is the source
-				if(c.getSource() == s){
+			for (Connection c : s.getConnections()) {
+				// Draw just once, if the device is the source
+				if (c.getSource() == s) {
 					/**
 					 * All Devices that are part of the connection
 					 */
 					Collection<SmartDevice> d = c.getParticipants();
-					if(d.size() == 2){
-						
-						for(SmartDevice sd: d)
-							if(s!=sd){
-								//Check if dragged object
-								int s_x,s_y,sd_x,sd_y;
-								if(s == interactor.dragged){
+					if (d.size() == 2) {
+
+						for (SmartDevice sd : d)
+							if (s != sd) {
+								// Check if dragged object
+								int s_x, s_y, sd_x, sd_y;
+								if (s == interactor.dragged) {
 									s_x = interactor.dragged_x;
 									s_y = interactor.dragged_y;
-								}else{
+								} else {
 									s_x = s.getX();
 									s_y = s.getY();
 								}
-								if(sd == interactor.dragged){
+								if (sd == interactor.dragged) {
 									sd_x = interactor.dragged_x;
 									sd_y = interactor.dragged_y;
-								}else{
+								} else {
 									sd_x = sd.getX();
 									sd_y = sd.getY();
 								}
 								g.drawLine(s_x, s_y, sd_x, sd_y);
 							}
-					}else if(d.size() == 1){
-						
-					} else if(d.size() <= 0){
-						//Invalid Connection
-					}else{
-						//Draw MultiConnection
+					} else if (d.size() == 1) {
+
+					} else if (d.size() <= 0) {
+						// Invalid Connection
+					} else {
+						// Draw MultiConnection
 					}
 				}
 			}
 	}
 
 	/**
-	 * @return the visualisationRadius
+	 * Returns the visualization radius of SmartDevices
+	 * 
+	 * @return the visualitation radius of SmartDevices
 	 */
 	public int getVisualisationRadius() {
 		return visualisationRadius;
 	}
 
 	/**
-	 * @param visualisationRadius the visualisationRadius to set
+	 * Sets the visualization radius of smartDevices
+	 * 
+	 * @param visualisationRadius
+	 *            the visualization radius to set
 	 */
 	public void setVisualisationRadius(int visualisationRadius) {
 		this.visualisationRadius = visualisationRadius;

+ 1 - 1
src/main/java/de/tu_darmstadt/tk/SmartHomeNetworkSim/view/package-info.java

@@ -1,5 +1,5 @@
 /**
- * GUI for visualisation and interaction with the {@link de.tu_darmstadt.tk.smartHomeNetworkSim.Core}.
+ * GUI for visualization and interaction with the {@link de.tu_darmstadt.tk.SmartHomeNetworkSim.core.Model}.
  * 
  * @author Andreas T. Meyer-Berg
  */