|
@@ -62,12 +62,12 @@ public class SimulationManager extends Observable {
|
|
/**
|
|
/**
|
|
* PacketCollectionManager which manages the collection of packets
|
|
* PacketCollectionManager which manages the collection of packets
|
|
*/
|
|
*/
|
|
- private PacketCollectionManager packetCollectionManager;
|
|
|
|
|
|
+ private PacketCollectionManager collectionMan;
|
|
|
|
|
|
/**
|
|
/**
|
|
* PacketExportManager which handles packet export
|
|
* PacketExportManager which handles packet export
|
|
*/
|
|
*/
|
|
- private PacketExportManager packetExportManager;
|
|
|
|
|
|
+ private PacketExportManager exportMan;
|
|
|
|
|
|
/**
|
|
/**
|
|
* Creates a new Simulationmanager
|
|
* Creates a new Simulationmanager
|
|
@@ -78,8 +78,8 @@ public class SimulationManager extends Observable {
|
|
public SimulationManager(Model model) {
|
|
public SimulationManager(Model model) {
|
|
this.model = model;
|
|
this.model = model;
|
|
this.controller = null;
|
|
this.controller = null;
|
|
- this.packetCollectionManager = new PacketCollectionManager(model);
|
|
|
|
- this.packetExportManager = new PacketExportManager(model);
|
|
|
|
|
|
+ this.collectionMan = new PacketCollectionManager(model);
|
|
|
|
+ this.exportMan = new PacketExportManager(model);
|
|
timer = new Timer(0, t -> simulateTimeStep());
|
|
timer = new Timer(0, t -> simulateTimeStep());
|
|
}
|
|
}
|
|
|
|
|
|
@@ -104,7 +104,7 @@ public class SimulationManager extends Observable {
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Simulates one time step at a given time fur a given duration
|
|
|
|
|
|
+ * Simulates one time step at a given time for a given duration
|
|
*
|
|
*
|
|
* @param startTime
|
|
* @param startTime
|
|
* Time the simulation interval starts in
|
|
* Time the simulation interval starts in
|
|
@@ -113,6 +113,26 @@ public class SimulationManager extends Observable {
|
|
* Duration of the simulation interval in milliseconds
|
|
* Duration of the simulation interval in milliseconds
|
|
*/
|
|
*/
|
|
public void simulateTimeIntervall(long startTime, long duration) {
|
|
public void simulateTimeIntervall(long startTime, long duration) {
|
|
|
|
+ //Simulates the network
|
|
|
|
+ simulateNetwork(startTime, duration);
|
|
|
|
+ runAlgorithms(startTime+duration);
|
|
|
|
+ collectionMan.collectPackets();
|
|
|
|
+ //Run all
|
|
|
|
+ collectionMan.runPacketAlgorithms();
|
|
|
|
+ //Export Packets
|
|
|
|
+ exportMan.exportPacketsOfLastTimeStep();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Simulates one time step of the network at a given time for a given duration
|
|
|
|
+ *
|
|
|
|
+ * @param startTime
|
|
|
|
+ * Time the simulation interval starts in
|
|
|
|
+ * System.currentTimeMillis() time
|
|
|
|
+ * @param duration
|
|
|
|
+ * Duration of the simulation interval in milliseconds
|
|
|
|
+ */
|
|
|
|
+ private void simulateNetwork(long startTime, long duration){
|
|
// Nothing changed so far
|
|
// Nothing changed so far
|
|
statusChanged = false;
|
|
statusChanged = false;
|
|
// Simulate all Links, and their connections
|
|
// Simulate all Links, and their connections
|
|
@@ -134,19 +154,8 @@ public class SimulationManager extends Observable {
|
|
model.setChanged();
|
|
model.setChanged();
|
|
model.notifyObservers();
|
|
model.notifyObservers();
|
|
}
|
|
}
|
|
- runAlgorithms(startTime);
|
|
|
|
- packetCollectionManager.collectPackets();
|
|
|
|
- //Run all
|
|
|
|
- for(PacketCollector collector:packetCollectionManager.getPacketCollectors()){
|
|
|
|
- if(collector.getPacketAlgorithm()!=null){
|
|
|
|
- collector.getPacketAlgorithm().processPackets(collector.getPackets());
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- packetExportManager.exportPacketsOfLastTimeStep();
|
|
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* Start the simulation
|
|
* Start the simulation
|
|
*/
|
|
*/
|
|
@@ -322,14 +331,14 @@ public class SimulationManager extends Observable {
|
|
* @return PacketCollectionManager, which contains all the different packet collectors
|
|
* @return PacketCollectionManager, which contains all the different packet collectors
|
|
*/
|
|
*/
|
|
public PacketCollectionManager getPacketCollectionManager(){
|
|
public PacketCollectionManager getPacketCollectionManager(){
|
|
- return packetCollectionManager;
|
|
|
|
|
|
+ return collectionMan;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
* Returns the PacketExportManager
|
|
* Returns the PacketExportManager
|
|
- * @return the packetExportManager
|
|
|
|
|
|
+ * @return the exportMan
|
|
*/
|
|
*/
|
|
public PacketExportManager getPacketExportManager(){
|
|
public PacketExportManager getPacketExportManager(){
|
|
- return packetExportManager;
|
|
|
|
|
|
+ return exportMan;
|
|
}
|
|
}
|
|
}
|
|
}
|