diff --git a/src/main/java/fr/ntr/AccessPoint.java b/src/main/java/fr/ntr/AccessPoint.java index 7e54cda..9f255e6 100644 --- a/src/main/java/fr/ntr/AccessPoint.java +++ b/src/main/java/fr/ntr/AccessPoint.java @@ -92,7 +92,12 @@ public class AccessPoint { public ResourceBlock[][] getFrame() { return frame; } - public void setFrame(ResourceBlock[][] frame) { - this.frame = frame; + + public static int getTimeSlotNb() { + return timeSlotNb; + } + + public static int getSubCarrierNb() { + return subCarrierNb; } } diff --git a/src/main/java/fr/ntr/ResourceBlock.java b/src/main/java/fr/ntr/ResourceBlock.java index ec0bc6d..588e40e 100644 --- a/src/main/java/fr/ntr/ResourceBlock.java +++ b/src/main/java/fr/ntr/ResourceBlock.java @@ -8,4 +8,12 @@ public class ResourceBlock { this.user = user; this.bandwith = bandwith; } + + public void setUser(User user) { + this.user = user; + } + + public void setBandwith(double bandwith) { + this.bandwith = bandwith; + } } diff --git a/src/main/java/fr/ntr/scheduler/RoundRobin.java b/src/main/java/fr/ntr/scheduler/RoundRobin.java index 2d8f8b6..bd9b9a8 100644 --- a/src/main/java/fr/ntr/scheduler/RoundRobin.java +++ b/src/main/java/fr/ntr/scheduler/RoundRobin.java @@ -1,6 +1,6 @@ package fr.ntr.scheduler; import java.util.List; -import fr.ntr.UserGroup; +import fr.ntr.User; public class RoundRobin extends Scheduler { @@ -8,29 +8,47 @@ public class RoundRobin extends Scheduler { private String name; private int index; - public RoundRobin(String name, int index) { + private List users; + private ResourceBlock[][] frame; + + public RoundRobin(String name, int index, List users, ResourceBlock[][] frame ) { this.name = name; this.index = index; + this.users = users; + this.frame = frame; } /** * Entry + * Rempli la trame avec les utilisateurs * Return */ @Override public void scheduling() { - index = 0; + Random random = new Random(); + index = random.nextInt(users.size()-1); + for (int Ts = 0; Ts < AccessPoint.getTimeSlotNb(); Ts++) { + for(int Sp = 0; Sp < AccessPoint.getSubCarrierNb(); Sp++) { + + if (users.get(index).getPacketsToSend() == null) { + users.remove(index); + } + frame[Ts][Sp].setUser(UserSelection(Ts, Sp, users)); + + //AccessPoint.setFrame[Ts][Sp](); + } + } } /** * Entry Time slot (int), Sous porteuse(int), and users ( List) * Return the user in function of TS and SP selected */ - private UserGroup UserSelection(int Ts, int Sp, UserGroup Users) { + private User UserSelection(int Ts, int Sp, List Users) { for (int i = 0; i < Ts; i++) { for (int j = 0; j < Sp; j++) { - index++; + index++; } } return Users.get(index%(Users.size() - 1));