From 7a83bb134cd3276709200df322c7eb98016f4e1d Mon Sep 17 00:00:00 2001 From: iboyeau Date: Mon, 13 Mar 2023 14:56:51 +0100 Subject: [PATCH] Wip maj roundRobin --- .../java/fr/ntr/scheduler/RoundRobin.java | 26 ++++++++++++++----- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/src/main/java/fr/ntr/scheduler/RoundRobin.java b/src/main/java/fr/ntr/scheduler/RoundRobin.java index bd9b9a8..920e5b9 100644 --- a/src/main/java/fr/ntr/scheduler/RoundRobin.java +++ b/src/main/java/fr/ntr/scheduler/RoundRobin.java @@ -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 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)); }