diff --git a/src/main/java/fr/ntr/AccessPoint.java b/src/main/java/fr/ntr/AccessPoint.java index e2c8d50..20a6b4b 100644 --- a/src/main/java/fr/ntr/AccessPoint.java +++ b/src/main/java/fr/ntr/AccessPoint.java @@ -37,15 +37,15 @@ public class AccessPoint { * Lancer la simulation * @param duration */ - public void startSimulation(int duration) { - /*try{ - this.outputDataFile = new FileOutputStream("export" + File.separator + this.users.size() + ".csv", true); + public void startSimulation(int duration, List users) { + try{ + this.outputDataFile = new FileOutputStream("export" + File.separator + users.size() + ".csv", true); outputDataFile.write("tick;x;y;user;bandwidth;delay;\n".getBytes()); } catch(IOException e) { System.err.println(e.getClass().getSimpleName() + " : " + e.getMessage()); System.exit(1); return; - } */ + } for (int ticks = 0; ticks < duration; ++ticks) { // Simulation cell1.reset(); @@ -58,7 +58,7 @@ public class AccessPoint { computeInterference(); // traite les données et les enregistre dans un fichier try { - analyseData(ticks); + analyseData(ticks, users); } catch (IOException e) { System.out.println("Can't export data"); } @@ -66,7 +66,7 @@ public class AccessPoint { } } - public void computeInterference () { + public void computeInterference() { ResourceBlock[][] frameCell1 = cell1.getFrame(); ResourceBlock[][] frameCell2 = cell2.getFrame(); @@ -93,10 +93,10 @@ public class AccessPoint { } } - private void analyseData(int tick) throws IOException { - /*double delayAverage = 0.0; + private void analyseData(int tick, List users) throws IOException { + /* double delayAverage = 0.0; int nbPacketsSent = 0; - for(User u: this.users){ + for(User u: users){ List packets = u.getPacketsSent(); nbPacketsSent += packets.size(); for (Packets p: packets){ diff --git a/src/main/java/fr/ntr/Cell.java b/src/main/java/fr/ntr/Cell.java index 925ae3c..5d5800d 100644 --- a/src/main/java/fr/ntr/Cell.java +++ b/src/main/java/fr/ntr/Cell.java @@ -9,7 +9,7 @@ public class Cell { private final List users; /** - * scheduler utilisé par la cellule + * Scheduler utilisé par la cellule */ private final Scheduler scheduler; /** @@ -24,13 +24,6 @@ public class Cell { * Trame */ private final ResourceBlock[][] frame; - /** - * Reste pour la prochaine source - */ - private double leftForNextSource; - - private final Random random = new Random(); - public Cell(Scheduler scheduler, ResourceBlock[][] frame, List users) { this.users = users; this.scheduler = scheduler; diff --git a/src/main/java/fr/ntr/Main.java b/src/main/java/fr/ntr/Main.java index bb490c2..a6a6c32 100644 --- a/src/main/java/fr/ntr/Main.java +++ b/src/main/java/fr/ntr/Main.java @@ -56,13 +56,13 @@ public class Main { List users = generateUsers(i, timeSlotNb, subCarrierNb); ResourceBlock[][] frame = new ResourceBlock[timeSlotNb][subCarrierNb]; //TODO : changes schedulers - Scheduler schedulerCell1 = new MaxSNR(frame, users); - Scheduler schedulerCell2 = new MaxSNR(frame, users); + Scheduler schedulerCell1 = new RoundRobin(frame, users); + Scheduler schedulerCell2 = new RoundRobin(frame, users); Cell cell1 = new Cell(schedulerCell1, frame, users); Cell cell2 = new Cell(schedulerCell2, frame, users); AccessPoint accessPoint = new AccessPoint(cell1, cell2); - executor.submit(() -> accessPoint.startSimulation(numberOfTicks)); + executor.submit(() -> accessPoint.startSimulation(numberOfTicks, users)); } } } else {