Browse Source

Removes Collectors on Network Reset

Andreas T. Meyer-Berg 5 years ago
parent
commit
106291915d

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

@@ -46,8 +46,8 @@ public class Controller {
 		this.model = model;
 		settingsController = new SettingsController(this.model, this);
 		importController = new ImportController(this.model, this);
-		networkController = new NetworkController(this.model, this);
 		simulationController = new SimulationController(this.model, this);
+		networkController = new NetworkController(this.model, this);
 	}
 	
 	/**

+ 14 - 0
src/main/java/de/tu_darmstadt/tk/SmartHomeNetworkSim/control/NetworkController.java

@@ -34,6 +34,10 @@ public class NetworkController {
 	 * NetworkTreeSettings Controller
 	 */
 	private NetworkTreeSettingsController networkTreeSettings;
+	/**
+	 * Packet Capture Controller
+	 */
+	private PacketCaptureController captureController;
 	/**
 	 * Creates a new NetworkController, which may manipulate the given model and use the controller
 	 * @param model Model which can be manipulated
@@ -43,6 +47,7 @@ public class NetworkController {
 		this.model = model;
 		this.controller = controller;
 		networkTreeSettings = controller.getSettingsController().getNetworkTreeSettingsController();
+		captureController = controller.getSimulationController().getPacketCaptureController();
 	}
 
 	/**
@@ -538,6 +543,15 @@ public class NetworkController {
 		for(Link l: model.getConnectionNetworks())
 			deleteLink(l);
 		linksToDelete.clear();
+		
+		/**
+		 * Delete Collectors
+		 */
+		LinkedList<PacketCollector> collectors = new LinkedList<PacketCollector>(captureController.getPacketCollectors());
+		for(PacketCollector p:collectors){
+			captureController.removePacketCollector(p);
+		}
+		
 		/**
 		 * Update the GUI
 		 */