Merge branch 'master' of https://github.com/ProjectgroepB5/weerstation
This commit is contained in:
+10
-15
@@ -5,9 +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 double currentWindSpeed;
|
private double currentWindSpeed;
|
||||||
private double maxWindSpeed;
|
private double maxWindSpeed;
|
||||||
private double minWindSpeed;
|
private double minWindSpeed;
|
||||||
@@ -15,10 +12,8 @@ public class AvgWindspeed {
|
|||||||
|
|
||||||
//constructor
|
//constructor
|
||||||
public AvgWindspeed(Measurement measurement1, ArrayList<Measurement> measurement2){
|
public AvgWindspeed(Measurement measurement1, ArrayList<Measurement> measurement2){
|
||||||
calculator = new Calculator();
|
|
||||||
updateRecent(measurement1);
|
updateRecent(measurement1);
|
||||||
update24Hour(measurement2);
|
update24Hour(measurement2);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//getters & setters
|
//getters & setters
|
||||||
@@ -61,11 +56,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 +69,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(measurement1.getAvgWindSpeed());
|
||||||
setCurrentWindSpeed(laatsteMeting.getAvgWindSpeed());
|
|
||||||
}
|
}
|
||||||
public void update24Hour(ArrayList<Measurement> measurement2){
|
public void update24Hour(ArrayList<Measurement> measurement2){
|
||||||
this.laatste24Uur = measurement2;
|
calculateMaxMinAvgWindSpeed(measurement2);
|
||||||
calculateMaxMinAvgWindSpeed();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Executable → Regular
+16
-24
@@ -1,12 +1,10 @@
|
|||||||
package weerstation;
|
package weerstation;
|
||||||
|
|
||||||
public class Calculator {
|
public class Calculator {
|
||||||
public Calculator(){
|
|
||||||
}
|
|
||||||
|
|
||||||
// Luchtdruk in hPa
|
// Luchtdruk in hPa
|
||||||
// Malek&Tom
|
// Malek&Tom
|
||||||
public double luchtdruk(short mval)
|
public static double luchtdruk(short mval)
|
||||||
{
|
{
|
||||||
double luchtdruk = (mval / 1000f) * 33.86389;
|
double luchtdruk = (mval / 1000f) * 33.86389;
|
||||||
return luchtdruk;
|
return luchtdruk;
|
||||||
@@ -14,7 +12,7 @@ public class Calculator {
|
|||||||
|
|
||||||
// Temperatuur in graden Celcius
|
// Temperatuur in graden Celcius
|
||||||
// Malek&Tom
|
// Malek&Tom
|
||||||
public double temperatuur(short mval)
|
public static double temperatuur(short mval)
|
||||||
{
|
{
|
||||||
double temperatuur = (((double)mval / 10) -32) / 1.8;
|
double temperatuur = (((double)mval / 10) -32) / 1.8;
|
||||||
return temperatuur;
|
return temperatuur;
|
||||||
@@ -22,7 +20,7 @@ public class Calculator {
|
|||||||
|
|
||||||
// Relatieve luchtvochtigheid in %
|
// Relatieve luchtvochtigheid in %
|
||||||
// Malek&Tom
|
// Malek&Tom
|
||||||
public double luchtVochtigheid(short mval)
|
public static double luchtVochtigheid(short mval)
|
||||||
{
|
{
|
||||||
double luchtvochtigheid = mval;
|
double luchtvochtigheid = mval;
|
||||||
return luchtvochtigheid;
|
return luchtvochtigheid;
|
||||||
@@ -30,7 +28,7 @@ public class Calculator {
|
|||||||
|
|
||||||
// Windsnelheid in m/s
|
// Windsnelheid in m/s
|
||||||
// Janco&Tim
|
// Janco&Tim
|
||||||
public double windSnelheid(short mval)
|
public static double windSnelheid(short mval)
|
||||||
{
|
{
|
||||||
double windSpeed = mval * 0.44704;
|
double windSpeed = mval * 0.44704;
|
||||||
return windSpeed;
|
return windSpeed;
|
||||||
@@ -38,7 +36,7 @@ public class Calculator {
|
|||||||
|
|
||||||
// Windrichting in noord, oost, zuid en west.
|
// Windrichting in noord, oost, zuid en west.
|
||||||
// Kenneth&Daniël
|
// Kenneth&Daniël
|
||||||
public String windRichting(short mval)
|
public static String windRichting(short mval)
|
||||||
{
|
{
|
||||||
String direction = "Error";
|
String direction = "Error";
|
||||||
|
|
||||||
@@ -116,7 +114,7 @@ public class Calculator {
|
|||||||
|
|
||||||
// Regenmeter in mm
|
// Regenmeter in mm
|
||||||
// Kenneth&Daniël
|
// Kenneth&Daniël
|
||||||
public double regenmeter(short mval)
|
public static double regenmeter(short mval)
|
||||||
{
|
{
|
||||||
double rainAmount = (double)mval*0.2;
|
double rainAmount = (double)mval*0.2;
|
||||||
return rainAmount;
|
return rainAmount;
|
||||||
@@ -124,7 +122,7 @@ public class Calculator {
|
|||||||
|
|
||||||
// uvIndex in index
|
// uvIndex in index
|
||||||
// Kenneth&Daniël
|
// Kenneth&Daniël
|
||||||
public double uvIndex(short mval)
|
public static double uvIndex(short mval)
|
||||||
{
|
{
|
||||||
double index = (double) mval/10;
|
double index = (double) mval/10;
|
||||||
return index;
|
return index;
|
||||||
@@ -132,20 +130,20 @@ public class Calculator {
|
|||||||
|
|
||||||
// BatterySpanning in Volt
|
// BatterySpanning in Volt
|
||||||
// Janco&Tim
|
// Janco&Tim
|
||||||
public double batterySpanning(short mval){
|
public static double batterySpanning(short mval){
|
||||||
double voltage = (((double)mval * 300)/512)/100;
|
double voltage = (((double)mval * 300)/512)/100;
|
||||||
return voltage;
|
return voltage;
|
||||||
}
|
}
|
||||||
|
|
||||||
// sunRise en Sunset in tijdformaat hh:mm
|
// sunRise en Sunset in tijdformaat hh:mm
|
||||||
// Janco&Tim
|
// Janco&Tim
|
||||||
public String sunRise(short mval){
|
public static String sunRise(short mval){
|
||||||
return sun(mval);
|
return sun(mval);
|
||||||
}
|
}
|
||||||
public String sunSet(short mval){
|
public static String sunSet(short mval){
|
||||||
return sun(mval);
|
return sun(mval);
|
||||||
}
|
}
|
||||||
private String sun(short sunRaw){
|
private static String sun(short sunRaw){
|
||||||
String tijd = "";
|
String tijd = "";
|
||||||
for(int i = 0; i <= 3; i++){
|
for(int i = 0; i <= 3; i++){
|
||||||
tijd = sunRaw % 10 + tijd;
|
tijd = sunRaw % 10 + tijd;
|
||||||
@@ -159,7 +157,7 @@ public class Calculator {
|
|||||||
|
|
||||||
//windchill in graden Celcius
|
//windchill in graden Celcius
|
||||||
//Janco en Keneth
|
//Janco en Keneth
|
||||||
public double windChill(short gradenFahrenheit, short mijlPerUur)
|
public static double windChill(short gradenFahrenheit, short mijlPerUur)
|
||||||
{
|
{
|
||||||
short windChill = (short) (35.74 + (0.6215*gradenFahrenheit) - 35.75*Math.pow(mijlPerUur, 0.16) + 0.4275*gradenFahrenheit*Math.pow(mijlPerUur, 0.16));
|
short windChill = (short) (35.74 + (0.6215*gradenFahrenheit) - 35.75*Math.pow(mijlPerUur, 0.16) + 0.4275*gradenFahrenheit*Math.pow(mijlPerUur, 0.16));
|
||||||
return temperatuur(windChill);
|
return temperatuur(windChill);
|
||||||
@@ -167,7 +165,7 @@ public class Calculator {
|
|||||||
|
|
||||||
//Heatindex in celcius
|
//Heatindex in celcius
|
||||||
//Tom met Malek
|
//Tom met Malek
|
||||||
public double heatIndex(double luchtv, double t)
|
public static double heatIndex(double luchtv, double t)
|
||||||
{
|
{
|
||||||
double heatindex = -42.379 + (2.04901523 * t) + (10.14333127 * luchtv) - (0.22475541 * t * luchtv)
|
double heatindex = -42.379 + (2.04901523 * t) + (10.14333127 * luchtv) - (0.22475541 * t * luchtv)
|
||||||
- (6.83783 * Math.pow(10,-3) * Math.pow(t,2)) - (5.481717 * Math.pow(10,-2) * Math.pow(luchtv,2))
|
- (6.83783 * Math.pow(10,-3) * Math.pow(t,2)) - (5.481717 * Math.pow(10,-2) * Math.pow(luchtv,2))
|
||||||
@@ -179,23 +177,17 @@ public class Calculator {
|
|||||||
|
|
||||||
//Dauwpunt in Celcius
|
//Dauwpunt in Celcius
|
||||||
//Daniel en Tim
|
//Daniel en Tim
|
||||||
public double dewPoint(double omgevingsTemp, short luchtVochtigheid)
|
public static double dewPoint(double omgevingsTemp, short luchtVochtigheid)
|
||||||
{
|
{
|
||||||
double hm = luchtVochtigheid/100f;
|
double hm = luchtVochtigheid/100f;
|
||||||
double dauwpunt = Math.pow( hm, (1/8f)) * (112 + 0.9*omgevingsTemp) + (0.1*omgevingsTemp) - 112;
|
double dauwpunt = Math.pow( hm, (1/8f)) * (112 + 0.9*omgevingsTemp) + (0.1*omgevingsTemp) - 112;
|
||||||
return dauwpunt;
|
return dauwpunt;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double cloudHeight(double temp, short luchtVochtigheid ){
|
public static double cloudHeight(double temp, short luchtVochtigheid ){
|
||||||
|
|
||||||
double wolkhoogte = 125 * (temp-dewPoint(temp, luchtVochtigheid));
|
double wolkhoogte = 125 * (temp-dewPoint(temp, luchtVochtigheid));
|
||||||
return wolkhoogte;
|
return wolkhoogte;
|
||||||
}
|
}
|
||||||
public void opdrachtEenA(){
|
|
||||||
for(int i = 0; i<4; i++){
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Executable → Regular
+17
-19
@@ -22,11 +22,9 @@ public class Measurement
|
|||||||
private short battLevel;
|
private short battLevel;
|
||||||
private short sunrise;
|
private short sunrise;
|
||||||
private short sunset;
|
private short sunset;
|
||||||
Calculator calc;
|
|
||||||
|
|
||||||
public Measurement()
|
public Measurement()
|
||||||
{
|
{
|
||||||
calc = new Calculator();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// stationId
|
// stationId
|
||||||
@@ -40,52 +38,52 @@ public class Measurement
|
|||||||
// barometer
|
// barometer
|
||||||
public void setRawBarometer (short val) { this.barometer = val;};
|
public void setRawBarometer (short val) { this.barometer = val;};
|
||||||
public short getRawBarometer () { return barometer; };
|
public short getRawBarometer () { return barometer; };
|
||||||
public double getBarometer () { return round(calc.luchtdruk(barometer),0); };
|
public double getBarometer () { return round(Calculator.luchtdruk(barometer),0); };
|
||||||
|
|
||||||
// insideTemp
|
// insideTemp
|
||||||
public void setRawInsideTemp (short val) { this.insideTemp = val;};
|
public void setRawInsideTemp (short val) { this.insideTemp = val;};
|
||||||
public short getRawInsideTemp () { return insideTemp; };
|
public short getRawInsideTemp () { return insideTemp; };
|
||||||
public double getInsideTemp () { return round(calc.temperatuur(insideTemp),2); };
|
public double getInsideTemp () { return round(Calculator.temperatuur(insideTemp),2); };
|
||||||
|
|
||||||
// insideHum
|
// insideHum
|
||||||
public void setRawInsideHum (short val) { this.insideHum = val;};
|
public void setRawInsideHum (short val) { this.insideHum = val;};
|
||||||
public short getRawInsideHum () { return insideHum; };
|
public short getRawInsideHum () { return insideHum; };
|
||||||
public double getInsideHum () { return round(calc.luchtVochtigheid(insideHum),0); };
|
public double getInsideHum () { return round(Calculator.luchtVochtigheid(insideHum),0); };
|
||||||
|
|
||||||
// outsideTemp
|
// outsideTemp
|
||||||
public void setRawOutsideTemp (short val) { this.outsideTemp = val;};
|
public void setRawOutsideTemp (short val) { this.outsideTemp = val;};
|
||||||
public short getRawOutsideTemp () { return outsideTemp; };
|
public short getRawOutsideTemp () { return outsideTemp; };
|
||||||
public double getOutsideTemp () { return round(calc.temperatuur(outsideTemp),2); };
|
public double getOutsideTemp () { return round(Calculator.temperatuur(outsideTemp),2); };
|
||||||
|
|
||||||
// windSpeed
|
// windSpeed
|
||||||
public void setRawWindSpeed (short val) { this.windSpeed = val;};
|
public void setRawWindSpeed (short val) { this.windSpeed = val;};
|
||||||
public short getRawWindSpeed () { return windSpeed; };
|
public short getRawWindSpeed () { return windSpeed; };
|
||||||
public double getWindSpeed () { return round(calc.windSnelheid(windSpeed),2); };
|
public double getWindSpeed () { return round(Calculator.windSnelheid(windSpeed),2); };
|
||||||
|
|
||||||
// avgWindSpeed
|
// avgWindSpeed
|
||||||
public void setRawAvgWindSpeed (short val) { this.avgWindSpeed = val;};
|
public void setRawAvgWindSpeed (short val) { this.avgWindSpeed = val;};
|
||||||
public short getRawAvgWindSpeed () { return avgWindSpeed; };
|
public short getRawAvgWindSpeed () { return avgWindSpeed; };
|
||||||
public double getAvgWindSpeed () { return round(calc.windSnelheid(avgWindSpeed),2); };
|
public double getAvgWindSpeed () { return round(Calculator.windSnelheid(avgWindSpeed),2); };
|
||||||
|
|
||||||
// windDir
|
// windDir
|
||||||
public void setRawWindDir (short val) { this.windDir = val;};
|
public void setRawWindDir (short val) { this.windDir = val;};
|
||||||
public short getRawWindDir () { return windDir; };
|
public short getRawWindDir () { return windDir; };
|
||||||
public String getWindDir () { return calc.windRichting(windDir); };
|
public String getWindDir () { return Calculator.windRichting(windDir); };
|
||||||
|
|
||||||
// outsideHum
|
// outsideHum
|
||||||
public void setRawOutsideHum (short val) { this.outsideHum = val;};
|
public void setRawOutsideHum (short val) { this.outsideHum = val;};
|
||||||
public short getRawOutsideHum () { return outsideHum; };
|
public short getRawOutsideHum () { return outsideHum; };
|
||||||
public double getOutsideHum () { return round(calc.luchtVochtigheid(outsideHum),0); };
|
public double getOutsideHum () { return round(Calculator.luchtVochtigheid(outsideHum),0); };
|
||||||
|
|
||||||
// rainRate
|
// rainRate
|
||||||
public void setRawRainRate (short val) { this.rainRate = val;};
|
public void setRawRainRate (short val) { this.rainRate = val;};
|
||||||
public short getRawRainRate () { return rainRate; };
|
public short getRawRainRate () { return rainRate; };
|
||||||
public double getRainRate () { return calc.regenmeter(rainRate); };
|
public double getRainRate () { return Calculator.regenmeter(rainRate); };
|
||||||
|
|
||||||
// UVLevel
|
// UVLevel
|
||||||
public void setRawUVLevel (short val) { this.UVLevel = val;};
|
public void setRawUVLevel (short val) { this.UVLevel = val;};
|
||||||
public short getRawUVLevel () { return UVLevel; };
|
public short getRawUVLevel () { return UVLevel; };
|
||||||
public double getUVLevel () { return Math.ceil(calc.uvIndex(UVLevel)); };
|
public double getUVLevel () { return Math.ceil(Calculator.uvIndex(UVLevel)); };
|
||||||
|
|
||||||
// solarRad
|
// solarRad
|
||||||
public void setRawSolarRad (short val) { this.solarRad = val;};
|
public void setRawSolarRad (short val) { this.solarRad = val;};
|
||||||
@@ -99,29 +97,29 @@ public class Measurement
|
|||||||
// battLevel
|
// battLevel
|
||||||
public void setRawBattLevel (short val) { this.battLevel = val;};
|
public void setRawBattLevel (short val) { this.battLevel = val;};
|
||||||
public short getRawBattLevel () { return battLevel; };
|
public short getRawBattLevel () { return battLevel; };
|
||||||
public double getBattLevel () { return round(calc.batterySpanning(battLevel),2); };
|
public double getBattLevel () { return round(Calculator.batterySpanning(battLevel),2); };
|
||||||
|
|
||||||
// sunrise
|
// sunrise
|
||||||
public void setRawSunrise (short val) { this.sunrise = val;};
|
public void setRawSunrise (short val) { this.sunrise = val;};
|
||||||
public short getRawSunrise () { return sunrise; };
|
public short getRawSunrise () { return sunrise; };
|
||||||
public String getSunrise () { return calc.sunRise(sunrise); };
|
public String getSunrise () { return Calculator.sunRise(sunrise); };
|
||||||
|
|
||||||
// sunset
|
// sunset
|
||||||
public void setRawSunset (short val) { this.sunset = val;};
|
public void setRawSunset (short val) { this.sunset = val;};
|
||||||
public short getRawSunset () { return sunset; };
|
public short getRawSunset () { return sunset; };
|
||||||
public String getSunset () { return calc.sunSet(sunset); };
|
public String getSunset () { return Calculator.sunSet(sunset); };
|
||||||
|
|
||||||
// windChill
|
// windChill
|
||||||
public double getWindChill () { return round(calc.windChill(outsideTemp, windSpeed),2); };
|
public double getWindChill () { return round(Calculator.windChill(outsideTemp, windSpeed),2); };
|
||||||
|
|
||||||
// heatIndex
|
// heatIndex
|
||||||
public double getHeatIndex () { return round(calc.heatIndex(outsideHum, outsideTemp),0); };
|
public double getHeatIndex () { return round(Calculator.heatIndex(outsideHum, outsideTemp),0); };
|
||||||
|
|
||||||
// dewPoint
|
// dewPoint
|
||||||
public double getDewPoint () { return round(calc.dewPoint( getOutsideTemp() , outsideHum),2); };
|
public double getDewPoint () { return round(Calculator.dewPoint( getOutsideTemp() , outsideHum),2); };
|
||||||
|
|
||||||
//wolkHoogte
|
//wolkHoogte
|
||||||
public double getCloudHeight () { return round(calc.cloudHeight(outsideTemp, outsideHum),1); };
|
public double getCloudHeight () { return round(Calculator.cloudHeight(outsideTemp, outsideHum),1); };
|
||||||
|
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user