Wip maj roundRobin

This commit is contained in:
iboyeau 2023-03-13 14:56:51 +01:00
parent b9eb223e64
commit 7a83bb134c

View File

@ -1,5 +1,9 @@
package fr.ntr.scheduler;
import java.util.List;
import java.util.Random;
import fr.ntr.AccessPoint;
import fr.ntr.ResourceBlock;
import fr.ntr.User;
@ -25,18 +29,22 @@ public class RoundRobin extends Scheduler {
*/
@Override
public void scheduling() {
//selection aleatoire du premier utilisateur
Random random = new Random();
index = random.nextInt(users.size()-1);
//Pour chaque time slot et sous porteuses
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);
}else{
//sub the packet send need Set packet
users.get(index).getPacketsToSend();
}
frame[Ts][Sp].setUser(UserSelection(Ts, Sp, users));
//AccessPoint.setFrame[Ts][Sp]();
}
}
}
@ -46,11 +54,15 @@ public class RoundRobin extends Scheduler {
* Return the user in function of TS and SP selected
*/
private User UserSelection(int Ts, int Sp, List<User> Users) {
for (int i = 0; i < Ts; i++) {
for (int j = 0; j < Sp; j++) {
index++;
}
}
//for (int i = 0; i < Ts; i++) {
// for (int j = 0; j < Sp; j++) {
// index++;
// }
//}
index = Ts * Sp;
return Users.get(index%(Users.size() - 1));
}