浏览代码

Merge branch 'master' of https://github.com/ProjectgroepB5/weerstation

Kenneth van Ewijk 11 年之前
父节点
当前提交
05fb5c0800
共有 3 个文件被更改,包括 43 次插入58 次删除
  1. 10 15
      AvgWindspeed.java
  2. 16 24
      Calculator.java
  3. 17 19
      Measurement.java

+ 10 - 15
AvgWindspeed.java

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

+ 16 - 24
Calculator.java

@@ -1,12 +1,10 @@
 package weerstation; 
 
 public class Calculator {
-	public Calculator(){
-	}
 	
 	// Luchtdruk in hPa
 	// Malek&Tom
-	public double luchtdruk(short mval)
+	public static double luchtdruk(short mval)
     {
         double luchtdruk = (mval / 1000f) * 33.86389;
         return luchtdruk;
@@ -14,7 +12,7 @@ public class Calculator {
 	
 	// Temperatuur in graden Celcius
     // Malek&Tom
-    public double temperatuur(short mval)
+    public static double temperatuur(short mval)
     {
         double temperatuur = (((double)mval / 10) -32) / 1.8;
         return temperatuur;
@@ -22,7 +20,7 @@ public class Calculator {
 	
     // Relatieve luchtvochtigheid in %
     // Malek&Tom
-    public double luchtVochtigheid(short mval)
+    public static double luchtVochtigheid(short mval)
     {
         double luchtvochtigheid = mval;
         return luchtvochtigheid;
@@ -30,7 +28,7 @@ public class Calculator {
     
     // Windsnelheid in m/s
 	// Janco&Tim
-	public double windSnelheid(short mval)
+	public static double windSnelheid(short mval)
 	{
 		double windSpeed = mval * 0.44704;
 		return windSpeed;
@@ -38,7 +36,7 @@ public class Calculator {
 	
 	// Windrichting in noord, oost, zuid en west. 
 	// Kenneth&Daniël
-    public String windRichting(short mval)
+    public static String windRichting(short mval)
     {
         String direction = "Error";
         
@@ -116,7 +114,7 @@ public class Calculator {
 	
     // Regenmeter in mm
     // Kenneth&Daniël
-    public double regenmeter(short mval)
+    public static double regenmeter(short mval)
 	{
     	double rainAmount = (double)mval*0.2;
     	return rainAmount;
@@ -124,7 +122,7 @@ public class Calculator {
     
 	// uvIndex in index    
     // Kenneth&Daniël
-    public double uvIndex(short mval)
+    public static double uvIndex(short mval)
     {
         double index = (double) mval/10;
         return index;
@@ -132,20 +130,20 @@ public class Calculator {
     
     // BatterySpanning in Volt
     // Janco&Tim
-    public double batterySpanning(short mval){
+    public static double batterySpanning(short mval){
 		double voltage = (((double)mval * 300)/512)/100;
     	return voltage; 
 	}
 	
     // sunRise en Sunset in tijdformaat hh:mm
 	// Janco&Tim
-    public String sunRise(short mval){
+    public static String sunRise(short mval){
     	return sun(mval);
     }
-    public String sunSet(short mval){
+    public static String sunSet(short mval){
     	return sun(mval);
     }
-	private String sun(short sunRaw){
+	private static String sun(short sunRaw){
 		String tijd = "";
 		for(int i = 0; i <= 3; i++){
 			tijd = sunRaw % 10 + tijd;
@@ -159,7 +157,7 @@ public class Calculator {
 
     //windchill in graden Celcius
 	//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));
         return temperatuur(windChill);
@@ -167,7 +165,7 @@ public class Calculator {
     
     //Heatindex in celcius
 	//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) 
         - (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
     //Daniel en Tim
-    public double dewPoint(double omgevingsTemp, short luchtVochtigheid)
+    public static double dewPoint(double omgevingsTemp, short luchtVochtigheid)
     {
        double hm = luchtVochtigheid/100f;
        double dauwpunt = Math.pow( hm, (1/8f)) * (112 + 0.9*omgevingsTemp) + (0.1*omgevingsTemp) - 112;
        return dauwpunt;
     }
 	
-    public double cloudHeight(double temp, short luchtVochtigheid ){
+    public static double cloudHeight(double temp, short luchtVochtigheid ){
     	
     	double wolkhoogte = 125 * (temp-dewPoint(temp, luchtVochtigheid));
     	return wolkhoogte; 
-	} 
-    public void opdrachtEenA(){
-    	for(int i = 0; i<4; i++){
-    		
-    	}
-    }
-    
+	}    
 
 }

+ 17 - 19
Measurement.java

@@ -22,11 +22,9 @@ public class Measurement
     private short battLevel;
     private short sunrise;
     private short sunset;
-    Calculator calc;
     
     public Measurement()
     {
-        calc = new Calculator();
     }
     
     // stationId
@@ -40,52 +38,52 @@ public class Measurement
     // barometer
     public void setRawBarometer (short val) { this.barometer = val;};
     public short getRawBarometer () { return barometer; };  
-    public double getBarometer () { return round(calc.luchtdruk(barometer),0); };
+    public double getBarometer () { return round(Calculator.luchtdruk(barometer),0); };
 
     // insideTemp
     public void setRawInsideTemp (short val) { this.insideTemp = val;};
     public short getRawInsideTemp () { return insideTemp; };   
-    public double getInsideTemp () { return round(calc.temperatuur(insideTemp),2); };
+    public double getInsideTemp () { return round(Calculator.temperatuur(insideTemp),2); };
 
     // insideHum
     public void setRawInsideHum (short val) { this.insideHum = val;};
     public short getRawInsideHum () { return insideHum; }; 
-    public double getInsideHum () { return round(calc.luchtVochtigheid(insideHum),0); };
+    public double getInsideHum () { return round(Calculator.luchtVochtigheid(insideHum),0); };
 
     // outsideTemp
     public void setRawOutsideTemp (short val) { this.outsideTemp = val;};
     public short getRawOutsideTemp () { return outsideTemp; };
-    public double getOutsideTemp () { return round(calc.temperatuur(outsideTemp),2); };
+    public double getOutsideTemp () { return round(Calculator.temperatuur(outsideTemp),2); };
 
     // windSpeed
     public void setRawWindSpeed (short val) { this.windSpeed = val;};
     public short getRawWindSpeed () { return windSpeed; };
-    public double getWindSpeed () { return round(calc.windSnelheid(windSpeed),2); };
+    public double getWindSpeed () { return round(Calculator.windSnelheid(windSpeed),2); };
 
     // avgWindSpeed
     public void setRawAvgWindSpeed (short val) { this.avgWindSpeed = val;};
     public short getRawAvgWindSpeed () { return avgWindSpeed; };
-    public double getAvgWindSpeed () { return round(calc.windSnelheid(avgWindSpeed),2); };
+    public double getAvgWindSpeed () { return round(Calculator.windSnelheid(avgWindSpeed),2); };
 
     // windDir
     public void setRawWindDir (short val) { this.windDir = val;};
     public short getRawWindDir () { return windDir; };
-    public String getWindDir () { return calc.windRichting(windDir); };
+    public String getWindDir () { return Calculator.windRichting(windDir); };
 
     // outsideHum
     public void setRawOutsideHum (short val) { this.outsideHum = val;};
     public short getRawOutsideHum () { return outsideHum; };
-    public double getOutsideHum () { return round(calc.luchtVochtigheid(outsideHum),0); };
+    public double getOutsideHum () { return round(Calculator.luchtVochtigheid(outsideHum),0); };
 
     // rainRate
     public void setRawRainRate (short val) { this.rainRate = val;};
     public short getRawRainRate () { return rainRate; };
-    public double getRainRate () { return calc.regenmeter(rainRate); };
+    public double getRainRate () { return Calculator.regenmeter(rainRate); };
 
     // UVLevel
     public void setRawUVLevel (short val) { this.UVLevel = val;};
     public short getRawUVLevel () { return UVLevel; };
-    public double getUVLevel () { return Math.ceil(calc.uvIndex(UVLevel)); };
+    public double getUVLevel () { return Math.ceil(Calculator.uvIndex(UVLevel)); };
 
     // solarRad
     public void setRawSolarRad (short val) { this.solarRad = val;};
@@ -99,29 +97,29 @@ public class Measurement
     // battLevel
     public void setRawBattLevel (short val) { this.battLevel = val;};
     public short getRawBattLevel () { return battLevel; };
-    public double getBattLevel () { return round(calc.batterySpanning(battLevel),2); };
+    public double getBattLevel () { return round(Calculator.batterySpanning(battLevel),2); };
 
     // sunrise
     public void setRawSunrise (short val) { this.sunrise = val;};
     public short getRawSunrise () { return sunrise; };
-    public String getSunrise () { return calc.sunRise(sunrise); };
+    public String getSunrise () { return Calculator.sunRise(sunrise); };
 
     // sunset
     public void setRawSunset (short val) { this.sunset = val;};
     public short getRawSunset () { return sunset; };
-    public String getSunset () { return calc.sunSet(sunset); };
+    public String getSunset () { return Calculator.sunSet(sunset); };
     
     // windChill
-    public double getWindChill () { return round(calc.windChill(outsideTemp, windSpeed),2); };
+    public double getWindChill () { return round(Calculator.windChill(outsideTemp, windSpeed),2); };
      
     // heatIndex
-    public double getHeatIndex () { return round(calc.heatIndex(outsideHum, outsideTemp),0); };
+    public double getHeatIndex () { return round(Calculator.heatIndex(outsideHum, outsideTemp),0); };
      
     // dewPoint
-    public double getDewPoint () { return round(calc.dewPoint( getOutsideTemp() , outsideHum),2); };
+    public double getDewPoint () { return round(Calculator.dewPoint( getOutsideTemp() , outsideHum),2); };
     
     //wolkHoogte
-    public double getCloudHeight () { return round(calc.cloudHeight(outsideTemp, outsideHum),1); };
+    public double getCloudHeight () { return round(Calculator.cloudHeight(outsideTemp, outsideHum),1); };
 
     public String toString()
     {