Fix outFIle
This commit is contained in:
parent
d78d422a07
commit
768de92948
@ -28,20 +28,14 @@ public class Cell {
|
||||
*/
|
||||
private final ResourceBlock[][] frame;
|
||||
private final FileOutputStream outputDataFile;
|
||||
private final int id;
|
||||
|
||||
public Cell(Scheduler scheduler, ResourceBlock[][] frame, List<User> users, String filename) {
|
||||
public Cell(int id, Scheduler scheduler, ResourceBlock[][] frame, List<User> users, FileOutputStream fileOutputStream) {
|
||||
this.id = id;
|
||||
this.users = users;
|
||||
this.scheduler = scheduler;
|
||||
this.frame = frame;
|
||||
FileOutputStream output = null;
|
||||
try{
|
||||
output = new FileOutputStream(filename, true);
|
||||
output.write("tick;x;y;user;bandwidth;delay;\n".getBytes());
|
||||
} catch(IOException e) {
|
||||
System.err.println(e.getClass().getSimpleName() + " : " + e.getMessage());
|
||||
System.exit(1);
|
||||
}
|
||||
this.outputDataFile = output;
|
||||
this.outputDataFile = fileOutputStream;
|
||||
}
|
||||
|
||||
public void updateBandwidth(int ticks) {
|
||||
@ -86,7 +80,7 @@ public class Cell {
|
||||
for(int j = 0; j < frame[i].length; j++) {
|
||||
ResourceBlock ur = frame[i][j];
|
||||
if(ur.getUser() != null) {
|
||||
String data = (tick + ";" + i + ";" + j + ";" + this.users.indexOf(ur.getUser()) + ";" + ur.getBandwidth() + ";" + delayAverage +";\n");
|
||||
String data = (tick + ";" + i + ";" + j + ";" + this.users.indexOf(ur.getUser()) + ";" + ur.getBandwidth() + ";" + delayAverage +";" + id + "\n");
|
||||
try{
|
||||
outputDataFile.write(data.getBytes());
|
||||
}catch(IOException e){
|
||||
|
@ -1,10 +1,11 @@
|
||||
package fr.ntr;
|
||||
|
||||
import fr.ntr.scheduler.MaxSNR;
|
||||
import fr.ntr.scheduler.RoundRobin;
|
||||
import fr.ntr.scheduler.Scheduler;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@ -58,11 +59,18 @@ public class Main {
|
||||
//TODO : changes schedulers
|
||||
Scheduler schedulerCell1 = new RoundRobin(frame, users);
|
||||
Scheduler schedulerCell2 = new RoundRobin(frame, users);
|
||||
try{
|
||||
FileOutputStream output = new FileOutputStream("export" + File.separator + users.size() + ".csv", true);
|
||||
output.write("tick;x;y;user;bandwidth;delay;cell;\n".getBytes());
|
||||
|
||||
Cell cell1 = new Cell(schedulerCell1, frame, users, "export" + File.separator + users.size() + "_cell1" + ".csv");
|
||||
Cell cell2 = new Cell(schedulerCell2, frame, users, "export" + File.separator + users.size() + "_cell2" + ".csv");
|
||||
AccessPoint accessPoint = new AccessPoint(cell1, cell2);
|
||||
executor.submit(() -> accessPoint.startSimulation(numberOfTicks, users));
|
||||
Cell cell1 = new Cell(0, schedulerCell1, frame, users, output);
|
||||
Cell cell2 = new Cell(1, schedulerCell2, frame, users, output);
|
||||
AccessPoint accessPoint = new AccessPoint(cell1, cell2);
|
||||
executor.submit(() -> accessPoint.startSimulation(numberOfTicks, users));
|
||||
} catch(IOException e) {
|
||||
System.err.println(e.getClass().getSimpleName() + " : " + e.getMessage());
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user