Jelajahi Sumber

Heatindex en weervoorspelling

Groamer 11 tahun lalu
induk
melakukan
70a3c3fdb0
4 mengubah file dengan 95 tambahan dan 3 penghapusan
  1. 1 1
      Measurement.java
  2. 89 0
      Voorspellingen.java
  3. 3 1
      Weerstation.java
  4. 2 1
      WeerstationConnector.java

+ 1 - 1
Measurement.java

@@ -88,7 +88,7 @@ public class Measurement
     // solarRad
     public void setRawSolarRad (short val) { this.solarRad = val;};
     public short getRawSolarRad () { return solarRad; };
-    public double getSolarRad () { return Calculator.solarRad(solarRad); };
+    public double getSolarRad () {return Calculator.solarRad(solarRad);}
     
 
     // xmitBatt

+ 89 - 0
Voorspellingen.java

@@ -0,0 +1,89 @@
+import java.util.ArrayList;
+
+public class Voorspellingen extends Grootheid{
+    public ArrayList<Double> list;
+    //constructor
+    public Voorspellingen(Measurement measurement1){
+        updateRecent(measurement1);
+    }
+
+    
+    public void updateRecent(Measurement measurement1){
+        setCurrent(measurement1.getBarometer());
+    }
+    
+    public void display()
+    {          
+        if (getCurrent() >= 1033 && getCurrent() <= 1084)
+        {
+            GUIboard.writePageToMatrix("Weersvoorspelling:", "mooi weer", "");
+            GUIboard.writeUpperDigits(10);
+        }
+        else
+        if (getCurrent() >= 1030 && getCurrent() <= 1033)
+        {
+            GUIboard.writePageToMatrix("Weersvoorspelling:", "mooi weer", "");
+            GUIboard.writeUpperDigits(10);
+        }
+        else
+        if (getCurrent() >= 1020 && getCurrent() <= 1030)
+        {
+            GUIboard.writePageToMatrix("Weersvoorspelling:", "goed weer", "");
+            GUIboard.writeUpperDigits(20);
+        }
+        else
+        if (getCurrent() >= 1015 && getCurrent() <= 1020)
+        {
+            GUIboard.writePageToMatrix("Weersvoorspelling:", "wisselvallig weer", "");
+            GUIboard.writeUpperDigits(30);
+        }
+        else
+        if (getCurrent() >= 1010 && getCurrent() <= 1015)
+        {
+            GUIboard.writePageToMatrix("Weersvoorspelling:", "wisselvallig weer", "");
+            GUIboard.writeUpperDigits(40);
+        }
+        else
+        if (getCurrent() >= 1007 && getCurrent() <= 1010)
+        {
+            GUIboard.writePageToMatrix("Weersvoorspelling:", "wisselvallig weer", "");
+            GUIboard.writeUpperDigits(50);
+        }
+        else
+        if (getCurrent() >= 1003 && getCurrent() <= 1007)
+        {
+            GUIboard.writePageToMatrix("Weersvoorspelling:", "regen of wind", "");
+            GUIboard.writeUpperDigits(60);
+        }
+        else
+        if (getCurrent() >= 1000 && getCurrent() <= 1003)
+        {
+            GUIboard.writePageToMatrix("Weersvoorspelling:", "regen of wind", "");
+            GUIboard.writeUpperDigits(70);
+        }
+        else
+        if (getCurrent() >= 990 && getCurrent() <= 1000)
+        {
+            GUIboard.writePageToMatrix("Weersvoorspelling:", "regen of wind", "");
+            GUIboard.writeUpperDigits(80);
+        }
+        else
+        if (getCurrent() >= 980 && getCurrent() <= 990)
+        {
+            GUIboard.writePageToMatrix("Weersvoorspelling:", "veel regen", "");
+            GUIboard.writeUpperDigits(90);
+        }
+        else
+        if (getCurrent() >= 970 && getCurrent() <= 980)
+        {
+            GUIboard.writePageToMatrix("Weersvoorspelling:", "storm", "");
+            GUIboard.writeUpperDigits(90);
+        }
+        else
+        if (getCurrent() >= 870 && getCurrent() <= 970)
+        {
+            GUIboard.writePageToMatrix("Weersvoorspelling:", "zware storm", "");
+            GUIboard.writeUpperDigits(90);
+        }
+    }
+}

+ 3 - 1
Weerstation.java

@@ -46,12 +46,14 @@ public class Weerstation {
 
         //All the different screen classes
     
-        final List<Grootheid> lstScreens = new ArrayList<Grootheid>();
+        final List<Grootheid> lstScreens = new ArrayList<Grootheid>();        
+            
         lstScreens.add(new OutsideTemp(meting1, meting2));
         lstScreens.add(new WindChill(meting1, meting2));
         lstScreens.add(new HeatIndex(meting1, meting2));
         lstScreens.add(new OutsideHum(meting1, meting2));
         lstScreens.add(new Barometer(meting1, meting2));
+        lstScreens.add(new Voorspellingen(meting1));
         lstScreens.add(new AvgWindSpeed(meting1, meting2));
         lstScreens.add(new RainRate(meting1, meting2));
         lstScreens.add(new InsideTemp(meting1, meting2));

+ 2 - 1
WeerstationConnector.java

@@ -25,6 +25,7 @@ public class WeerstationConnector
     //Start connection with Databse
     public WeerstationConnector(String host, String port, String dbName, String userName, String password)
     {
+        System.out.println("Verbinding maken met de database...\n");
         try
         {
             String url = "jdbc:mysql://" + host + ":" + port + "/"+ dbName + "?user="
@@ -33,7 +34,7 @@ public class WeerstationConnector
             + password;
             Class.forName("com.mysql.jdbc.Driver").newInstance ();
             myConn = DriverManager.getConnection(url);
-            System.out.println("Database connection established");
+            System.out.println("Verbonden met de database");
         }
         catch( SQLException ex)
         {