Wip roundRobin

This commit is contained in:
iboyeau 2023-03-10 11:38:52 +01:00
parent aa7be85663
commit 665ca35c69
3 changed files with 40 additions and 5 deletions

View File

@ -92,7 +92,12 @@ public class AccessPoint {
public ResourceBlock[][] getFrame() { public ResourceBlock[][] getFrame() {
return frame; return frame;
} }
public void setFrame(ResourceBlock[][] frame) {
this.frame = frame; public static int getTimeSlotNb() {
return timeSlotNb;
}
public static int getSubCarrierNb() {
return subCarrierNb;
} }
} }

View File

@ -8,4 +8,12 @@ public class ResourceBlock {
this.user = user; this.user = user;
this.bandwith = bandwith; this.bandwith = bandwith;
} }
public void setUser(User user) {
this.user = user;
}
public void setBandwith(double bandwith) {
this.bandwith = bandwith;
}
} }

View File

@ -1,5 +1,9 @@
package fr.ntr.scheduler; package fr.ntr.scheduler;
import java.util.List; import java.util.List;
import java.util.Random;
import fr.ntr.AccessPoint;
import fr.ntr.ResourceBlock;
import fr.ntr.User; import fr.ntr.User;
@ -8,19 +12,37 @@ public class RoundRobin extends Scheduler {
private String name; private String name;
private int index; private int index;
public RoundRobin(String name, int index) { private List<User> users;
private ResourceBlock[][] frame;
public RoundRobin(String name, int index, List<User> users, ResourceBlock[][] frame ) {
this.name = name; this.name = name;
this.index = index; this.index = index;
this.users = users;
this.frame = frame;
} }
/** /**
* Entry * Entry
* Rempli la trame avec les utilisateurs
* Return * Return
*/ */
@Override @Override
public void scheduling() { 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]();
}
}
} }
/** /**
@ -30,7 +52,7 @@ public class RoundRobin extends Scheduler {
private User UserSelection(int Ts, int Sp, List<User> Users) { private User UserSelection(int Ts, int Sp, List<User> Users) {
for (int i = 0; i < Ts; i++) { for (int i = 0; i < Ts; i++) {
for (int j = 0; j < Sp; j++) { for (int j = 0; j < Sp; j++) {
index++; index++;
} }
} }
return Users.get(index%(Users.size() - 1)); return Users.get(index%(Users.size() - 1));