|
@@ -5,8 +5,6 @@ import java.util.ArrayList;
|
|
|
public class AvgWindspeed {
|
|
public class AvgWindspeed {
|
|
|
|
|
|
|
|
//fields
|
|
//fields
|
|
|
- private Measurement laatsteMeting;
|
|
|
|
|
- private ArrayList<Measurement> laatste24Uur;
|
|
|
|
|
private Calculator calculator;
|
|
private Calculator calculator;
|
|
|
private double currentWindSpeed;
|
|
private double currentWindSpeed;
|
|
|
private double maxWindSpeed;
|
|
private double maxWindSpeed;
|
|
@@ -18,7 +16,6 @@ public class AvgWindspeed {
|
|
|
calculator = new Calculator();
|
|
calculator = new Calculator();
|
|
|
updateRecent(measurement1);
|
|
updateRecent(measurement1);
|
|
|
update24Hour(measurement2);
|
|
update24Hour(measurement2);
|
|
|
-
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//getters & setters
|
|
//getters & setters
|
|
@@ -61,11 +58,11 @@ public class AvgWindspeed {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//Methods
|
|
//Methods
|
|
|
- private void calculateMaxMinAvgWindSpeed(){
|
|
|
|
|
|
|
+ private void calculateMaxMinAvgWindSpeed(ArrayList<Measurement> laatste24uur){
|
|
|
int max = 0;
|
|
int max = 0;
|
|
|
int min = 1000;
|
|
int min = 1000;
|
|
|
float avg = 0;
|
|
float avg = 0;
|
|
|
- for(Measurement minut :laatste24Uur){
|
|
|
|
|
|
|
+ for(Measurement minut :laatste24uur){
|
|
|
if(minut.getRawAvgWindSpeed() > max){
|
|
if(minut.getRawAvgWindSpeed() > max){
|
|
|
max = minut.getRawAvgWindSpeed();
|
|
max = minut.getRawAvgWindSpeed();
|
|
|
}
|
|
}
|
|
@@ -74,26 +71,26 @@ public class AvgWindspeed {
|
|
|
}
|
|
}
|
|
|
avg += minut.getRawWindSpeed();
|
|
avg += minut.getRawWindSpeed();
|
|
|
}
|
|
}
|
|
|
- avg /= laatste24Uur.size();
|
|
|
|
|
|
|
+ avg /= laatste24uur.size();
|
|
|
|
|
|
|
|
setAvgWindSpeed(calculator.windSnelheid((short)avg));
|
|
setAvgWindSpeed(calculator.windSnelheid((short)avg));
|
|
|
setMaxWindSpeed(calculator.windSnelheid((short)max));
|
|
setMaxWindSpeed(calculator.windSnelheid((short)max));
|
|
|
setMinWindSpeed(calculator.windSnelheid((short)min));
|
|
setMinWindSpeed(calculator.windSnelheid((short)min));
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
|
|
|
public void updateRecent(Measurement measurement1){
|
|
public void updateRecent(Measurement measurement1){
|
|
|
- this.laatsteMeting = measurement1;
|
|
|
|
|
- setCurrentWindSpeed(laatsteMeting.getAvgWindSpeed());
|
|
|
|
|
|
|
+ setCurrentWindSpeed(measurement1.getAvgWindSpeed());
|
|
|
}
|
|
}
|
|
|
public void update24Hour(ArrayList<Measurement> measurement2){
|
|
public void update24Hour(ArrayList<Measurement> measurement2){
|
|
|
- this.laatste24Uur = measurement2;
|
|
|
|
|
- calculateMaxMinAvgWindSpeed();
|
|
|
|
|
|
|
+ calculateMaxMinAvgWindSpeed(measurement2);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public void display(){
|
|
public void display(){
|
|
|
GUIboard.writeUpperDigits(getCurrentWindSpeed());
|
|
GUIboard.writeUpperDigits(getCurrentWindSpeed());
|
|
|
GUIboard.writeLeftDigits(getMaxWindSpeed());
|
|
GUIboard.writeLeftDigits(getMaxWindSpeed());
|
|
|
GUIboard.writeRightDigits(getMinWindSpeed());
|
|
GUIboard.writeRightDigits(getMinWindSpeed());
|
|
|
|
|
+ GUIboard.writePageToMatrix("Windsnelheid in m/s", "Avg: " + avgWindSpeed, "");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|