From a22170efd02c96a99eaa3a7af4ce86588bbe9505 Mon Sep 17 00:00:00 2001 From: Quentin Legot Date: Fri, 17 Mar 2023 11:04:32 +0100 Subject: [PATCH] update analyzeData --- src/main/java/fr/ntr/AccessPoint.java | 11 ++++++++--- src/main/java/fr/ntr/ResourceBlock.java | 18 +++++++++++++----- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/main/java/fr/ntr/AccessPoint.java b/src/main/java/fr/ntr/AccessPoint.java index 8afa8d7..e35f33b 100644 --- a/src/main/java/fr/ntr/AccessPoint.java +++ b/src/main/java/fr/ntr/AccessPoint.java @@ -101,9 +101,14 @@ public class AccessPoint { } private void analyseData() throws IOException { - FileOutputStream file = new FileOutputStream("data.csv", true); - // file.write("data1;data2".getBytes()); - file.close(); + try(FileOutputStream file = new FileOutputStream("data.csv", true)) { + for(int i = 0; i < frame.length; i++) { + for(int j = 0; j < frame[i].length; j++) { + ResourceBlock ur = frame[i][j]; + file.write((i + ";" + j + ";" + this.users.indexOf(ur.getUser()) + ";" + ur.getBandwidth() + ";\n").getBytes()); + } + } + } } private void plotData() { diff --git a/src/main/java/fr/ntr/ResourceBlock.java b/src/main/java/fr/ntr/ResourceBlock.java index 588e40e..4fcc575 100644 --- a/src/main/java/fr/ntr/ResourceBlock.java +++ b/src/main/java/fr/ntr/ResourceBlock.java @@ -2,18 +2,26 @@ package fr.ntr; public class ResourceBlock { private User user; - private double bandwith; + private double bandwidth; - public ResourceBlock (User user, double bandwith) { + public ResourceBlock (User user, double bandwidth) { this.user = user; - this.bandwith = bandwith; + this.bandwidth = bandwidth; } public void setUser(User user) { this.user = user; } - public void setBandwith(double bandwith) { - this.bandwith = bandwith; + public void setBandwidth(double bandwidth) { + this.bandwidth = bandwidth; + } + + public User getUser() { + return user; + } + + public double getBandwidth() { + return bandwidth; } }