"Some" improvements

This commit is contained in:
jancoow
2014-10-22 21:40:15 +02:00
parent 1a167b8f35
commit b4258909e3
31 changed files with 374 additions and 444 deletions
+11 -20
View File
@@ -1,34 +1,21 @@
package weerstation1;
import java.util.ArrayList;
public class AvgWindSpeed extends Grootheid{
public ArrayList<Double> list;
//constructor
//constructor
public AvgWindSpeed(Measurement measurement1, ArrayList<Measurement> measurement2){
list = new ArrayList<Double>();
updateRecent(measurement1);
setName("Gem. Windsnelheid");
updateRecent(measurement1);
updatePeriod(measurement2);
}
public void updateRecent(Measurement measurement1){
setCurrent(measurement1.getAvgWindSpeed());
}
public void updatePeriod(ArrayList<Measurement> measurement2){
createList(measurement2);
calculateMaxMin(list);
setDeviation(StatisticsCalculator.afwijking(list));
}
public void display(){
super.display();
GUIboard.writePageToMatrix("Gem. Windsnelheid", "Afwijking: " + getDeviation(), "");
}
public void displayGraph()
{
GUIboard.writeGraphToMatrix(list, getMin(), getMax());
maxMin();
afwijking();
}
private void createList(ArrayList<Measurement> measurement2)
@@ -40,7 +27,11 @@ public class AvgWindSpeed extends Grootheid{
for(Measurement ms : measurement2)
{
list.add(ms.getAvgWindSpeed());
list.add((double)ms.getRawAvgWindSpeed());
}
}
public double calculate(double value){
return Calculator.windSnelheid((short)value);
}
}
+11 -22
View File
@@ -1,35 +1,20 @@
package weerstation1;
import java.util.ArrayList;
public class Barometer extends Grootheid{
public ArrayList<Double> list;
//constructor
//constructor
public Barometer(Measurement measurement1, ArrayList<Measurement> measurement2){
list = new ArrayList<Double>();
updateRecent(measurement1);
setName("Luchtdruk");
updateRecent(measurement1);
updatePeriod(measurement2);
}
public void updateRecent(Measurement measurement1){
setCurrent(measurement1.getBarometer());
}
public void updatePeriod(ArrayList<Measurement> measurement2){
createList(measurement2);
calculateMaxMin(list);
setMode(StatisticsCalculator.modus(list));
}
public void display(){
super.display();
GUIboard.clearLeft();
GUIboard.clearRight();
GUIboard.writePageToMatrix("Luchtdruk", "Modus: " + getMode(), "");
}
public void displayGraph()
{
GUIboard.writeGraphToMatrix(list, getMin(), getMax());
modus();
}
private void createList(ArrayList<Measurement> measurement2)
@@ -41,7 +26,11 @@ public class Barometer extends Grootheid{
for(Measurement ms : measurement2)
{
list.add(ms.getBarometer());
list.add((double)ms.getRawBarometer());
}
}
public double calculate(double value){
return Calculator.luchtdruk((short)value);
}
}
+1
View File
@@ -1,3 +1,4 @@
package weerstation1;
import java.sql.Timestamp;
import java.util.Calendar;
import java.util.Date;
+6 -22
View File
@@ -1,36 +1,20 @@
package weerstation1;
import java.util.ArrayList;
public class CloudHeight extends Grootheid{
public ArrayList<Double> list;
//constructor
//constructor
public CloudHeight(Measurement measurement1, ArrayList<Measurement> measurement2){
list = new ArrayList<Double>();
updateRecent(measurement1);
setName("Wolkhoogte");
updateRecent(measurement1);
updatePeriod(measurement2);
}
public void updateRecent(Measurement measurement1){
setCurrent(measurement1.getCloudHeight());
}
public void updatePeriod(ArrayList<Measurement> measurement2){
createList(measurement2);
calculateMaxMin(list);
setAvg(StatisticsCalculator.avg(list));
}
public void display(){
super.display();
GUIboard.clearLeft();
GUIboard.clearRight();
GUIboard.writePageToMatrix("Wolkhoogte", "Gemiddelde: " + getAvg(), "");
}
public void displayGraph()
{
GUIboard.writeGraphToMatrix(list, getMin(), getMax());
modus();
}
private void createList(ArrayList<Measurement> measurement2)
@@ -42,7 +26,7 @@ public class CloudHeight extends Grootheid{
for(Measurement ms : measurement2)
{
list.add(ms.getCloudHeight());
list.add((double)ms.getCloudHeight());
}
}
}
+7 -20
View File
@@ -1,35 +1,22 @@
package weerstation1;
import java.util.ArrayList;
public class DewPoint extends Grootheid
{
public ArrayList<Double> list;
//constructor
//constructor
public DewPoint(Measurement measurement1, ArrayList<Measurement> measurement2){
list = new ArrayList<Double>();
updateRecent(measurement1);
setName("Dauwpunt");
updateRecent(measurement1);
updatePeriod(measurement2);
}
public void updateRecent(Measurement measurement1){
setCurrent(measurement1.getDewPoint());
}
public void updatePeriod(ArrayList<Measurement> measurement2){
createList(measurement2);
calculateMaxMin(list);
setMedian(StatisticsCalculator.median(list));
}
public void display(){
super.display();
GUIboard.writePageToMatrix("Dauwpunt", "Mediaan: " + getMedian(), "");
}
public void displayGraph()
{
GUIboard.writeGraphToMatrix(list, getMin(), getMax());
maxMin();
median();
}
private void createList(ArrayList<Measurement> measurement2)
@@ -41,7 +28,7 @@ public class DewPoint extends Grootheid
for(Measurement ms : measurement2)
{
list.add(ms.getDewPoint());
list.add((double)ms.getDewPoint());
}
}
}
+1
View File
@@ -1,3 +1,4 @@
package weerstation1;
import java.util.ArrayList;
+1
View File
@@ -1,3 +1,4 @@
package weerstation1;
import java.util.ArrayList;
+88 -35
View File
@@ -1,17 +1,24 @@
package weerstation1;
import java.util.ArrayList;
public class Grootheid
{
// instance variables - replace the example below with your own
private double avg;
private double statics;
private double max;
private double min;
private double mode;
private double median;
private double deviation;
private double current;
private Periode period;
ArrayList<Double> list = new ArrayList<Double>();
//boolean to check if the variables are set
private boolean max_min_check = false;
private boolean current_check = false;
private String statics_name = "";
private String name = "";
private String custom = "";
//constructor
public Grootheid(){
}
@@ -22,7 +29,8 @@ public class Grootheid
}
public void setCurrent(double current) {
this.current = current;
current_check = true;
this.current = current;
}
public double getMax() {
@@ -41,46 +49,68 @@ public class Grootheid
this.min = Math.round(min * 100.0) / 100.0;;
}
public double getAvg() {
return avg;
}
public void setAvg(double avg) {
this.avg = Math.round(avg * 100.0) / 100.0;
}
public double getMode() {
return mode;
public double getStatics() {
return statics;
}
public void setMode(double mode) {
this.mode = Math.round(mode * 100.0) / 100.0;
public void setStatics(double statics) {
this.statics = Math.round(statics * 100.0) / 100.0;
}
public String getName() {
return name;
}
public double getMedian() {
return median;
public void setName(String name) {
this.name = name;
}
public void setMedian(double median) {
this.median = Math.round(median * 100.0) / 100.0;
public Periode getPeriod() {
return period;
}
public double getDeviation() {
return deviation;
public void setPeriod(Periode period) {
this.period = period;
}
public void setDeviation(double deviation) {
this.deviation = Math.round(deviation * 100.0) / 100.0;
public void setStatics_name(String statics_name) {
this.statics_name = statics_name;
}
public String getCustom() {
return custom;
}
public void setCustom(String custom) {
this.custom = custom;
}
//Methods
public void calculateMaxMin(ArrayList<Double> array){
setMax(StatisticsCalculator.max(array));
setMin(StatisticsCalculator.min(array));
public void maxMin(){
max_min_check = true;
setMax(calculate(StatisticsCalculator.max(list)));
setMin(calculate(StatisticsCalculator.min(list)));
}
public void median(){
setStatics_name("Mediaan: ");
setStatics(calculate(StatisticsCalculator.median(list)));
}
public void modus(){
setStatics_name("Modus: ");
setStatics(calculate(StatisticsCalculator.modus(list)));
}
public void avg(){
setStatics_name("Gemiddelde: ");
setStatics(calculate(StatisticsCalculator.avg(list)));
}
public void afwijking(){
setStatics_name("Afwijking: ");
setStatics(calculate(StatisticsCalculator.afwijking(list)));
}
public void updateRecent(Measurement measurement1){
public void updateRecent(Measurement measurement1){
}
public void updatePeriod(ArrayList<Measurement> measurement2){
@@ -88,13 +118,36 @@ public class Grootheid
}
public void display(){
GUIboard.writeUpperDigits(getCurrent());
GUIboard.writeLeftDigits(getMax());
GUIboard.writeRightDigits(getMin());
GUIboard.clearLeft();
GUIboard.clearRight();
GUIboard.clearTop();
GUIboard.clearBottom();
if(current_check){
GUIboard.writeUpperDigits(getCurrent());
}
if(max_min_check){
GUIboard.writeLeftDigits(getMax());
GUIboard.writeRightDigits(getMin());
}
if(!(statics_name == "")){
GUIboard.writePageToMatrix(getName(), statics_name + getStatics(), "");
}else if(!(custom == "")){
GUIboard.writePageToMatrix(getName(), custom, "");
}
if(!(period == null)){
GUIboard.writePageToMatrix(getName(), period.toString(), "");
}
}
public void displayGraph()
{
GUIboard.writeGraphToMatrix(list, getMin(), getMax());
}
public double calculate(double value){
return value;
}
}
+7 -19
View File
@@ -1,33 +1,21 @@
package weerstation1;
import java.util.ArrayList;
public class HeatIndex extends Grootheid{
public ArrayList<Double> list;
//constructor
//constructor
public HeatIndex(Measurement measurement1, ArrayList<Measurement> measurement2){
list = new ArrayList<Double>();
updateRecent(measurement1);
setName("HeatIndex");
updateRecent(measurement1);
updatePeriod(measurement2);
}
public void updateRecent(Measurement measurement1){
setCurrent(measurement1.getHeatIndex());
}
public void updatePeriod(ArrayList<Measurement> measurement2){
createList(measurement2);
calculateMaxMin(list);
setMedian(StatisticsCalculator.median(list));
}
public void display(){
super.display();
GUIboard.writePageToMatrix("Warmte indexcijfer", "Mediaan: " + getMedian(), "");
}
public void displayGraph()
{
GUIboard.writeGraphToMatrix(list, getMin(), getMax());
maxMin();
median();
}
private void createList(ArrayList<Measurement> measurement2)
@@ -39,7 +27,7 @@ public class HeatIndex extends Grootheid{
for(Measurement ms : measurement2)
{
list.add(ms.getHeatIndex());
list.add((double)ms.getHeatIndex());
}
}
}
Executable → Regular
+1
View File
@@ -1,3 +1,4 @@
package weerstation1;
//
// Port IO emulator class. All read/writes are send over TCP/IP to the host
+10 -18
View File
@@ -1,34 +1,22 @@
package weerstation1;
import java.util.ArrayList;
public class InsideHum extends Grootheid{
public ArrayList<Double> list;
//constructor
public InsideHum(Measurement measurement1, ArrayList<Measurement> measurement2){
list = new ArrayList<Double>();
updateRecent(measurement1);
setName("Luchtv. Binnen");
updateRecent(measurement1);
updatePeriod(measurement2);
}
public void updateRecent(Measurement measurement1){
setCurrent(measurement1.getInsideHum());
}
public void updatePeriod(ArrayList<Measurement> measurement2){
createList(measurement2);
calculateMaxMin(list);
setAvg(StatisticsCalculator.avg(list));
}
public void display(){
super.display();
GUIboard.writePageToMatrix("Luchtv. Binnen", "Gemiddelde: " + getAvg(), "");
}
public void displayGraph()
{
GUIboard.writeGraphToMatrix(list, getMin(), getMax());
maxMin();
avg();
}
private void createList(ArrayList<Measurement> measurement2)
@@ -40,7 +28,11 @@ public class InsideHum extends Grootheid{
for(Measurement ms : measurement2)
{
list.add(ms.getInsideHum());
list.add((double)ms.getRawInsideHum());
}
}
public double calculate(double value){
return Calculator.luchtVochtigheid((short)value);
}
}
+11 -19
View File
@@ -1,34 +1,22 @@
package weerstation1;
import java.util.ArrayList;
public class InsideTemp extends Grootheid{
public ArrayList<Double> list;
//constructor
//constructor
public InsideTemp(Measurement measurement1, ArrayList<Measurement> measurement2){
list = new ArrayList<Double>();
updateRecent(measurement1);
setName("Binnentemperatuur");
updateRecent(measurement1);
updatePeriod(measurement2);
}
public void updateRecent(Measurement measurement1){
setCurrent(measurement1.getInsideTemp());
}
public void updatePeriod(ArrayList<Measurement> measurement2){
createList(measurement2);
calculateMaxMin(list);
setAvg(StatisticsCalculator.avg(list));
}
public void display(){
super.display();
GUIboard.writePageToMatrix("Binnentemperatuur", "Gemiddelde: " + getAvg(), "");
}
public void displayGraph()
{
GUIboard.writeGraphToMatrix(list, getMin(), getMax());
maxMin();
avg();
}
private void createList(ArrayList<Measurement> measurement2)
@@ -40,7 +28,11 @@ public class InsideTemp extends Grootheid{
for(Measurement ms : measurement2)
{
list.add(ms.getInsideTemp());
list.add((double)ms.getRawInsideTemp());
}
}
public double calculate(double value){
return Calculator.temperatuur((short)value);
}
}
+1
View File
@@ -1,3 +1,4 @@
package weerstation1;
import java.util.ArrayList;
public class LangsteRegenPeriode extends Grootheid{
+2 -1
View File
@@ -1,3 +1,4 @@
package weerstation1;
import java.util.ArrayList;
public class LangsteTempStijgingPeriode extends Grootheid
@@ -23,7 +24,7 @@ public class LangsteTempStijgingPeriode extends Grootheid
public void updatePeriod(ArrayList<Measurement> measurement2)
{
createList(measurement2);
calculateMaxMin(list);
int[] index = StatisticsCalculator.langsteTempStijgingPeriode(list);
StijgingPeriode= Calculator.timeStampToPeriode( measurement2.get(index[0]).getDateStamp(), measurement2.get(index[1]).getDateStamp());
+8 -19
View File
@@ -1,36 +1,25 @@
package weerstation1;
import java.util.ArrayList;
public class LangsteZomerPeriode extends Grootheid{
private ArrayList<Short> list;
private Periode zomerPeriode;
//constructor
public LangsteZomerPeriode(Measurement measurement1, ArrayList<Measurement> measurement2){
list = new ArrayList<Short>();
zomerPeriode = new Periode("Zomer");
updateRecent(measurement1);
setName("Langste zomerse periode");
updatePeriod(measurement2);
}
public void updateRecent(Measurement measurement1){
setCurrent(measurement1.getOutsideTemp());
}
public void updatePeriod(ArrayList<Measurement> measurement2){
createList(measurement2);
int[] index = StatisticsCalculator.langsteZomersePeriode(list);
zomerPeriode = Calculator.timeStampToPeriode( measurement2.get(index[0]).getDateStamp(), measurement2.get(index[1]).getDateStamp());
}
public void display(){
GUIboard.writePageToMatrix("Langste zomerse periode", zomerPeriode.toString(), "");
int[] index = StatisticsCalculator.langsteDroogstePeriode(list);
System.out.println(list.size());
System.out.println(index[0]);
System.out.println(index[1]);
setPeriod(Calculator.timeStampToPeriode( measurement2.get(index[0]).getDateStamp(), measurement2.get(index[1]).getDateStamp()));
}
public void displayGraph()
{
display();
}
private void createList(ArrayList<Measurement> measurement2)
@@ -42,7 +31,7 @@ public class LangsteZomerPeriode extends Grootheid{
for(Measurement ms : measurement2)
{
list.add(ms.getRawOutsideTemp());
list.add((double)ms.getRawOutsideTemp());
}
}
}
+1
View File
@@ -1,3 +1,4 @@
package weerstation1;
public class Main {
+6 -14
View File
@@ -1,33 +1,25 @@
package weerstation1;
import java.util.ArrayList;
public class MaximaleRegenPeriode extends Grootheid{
private ArrayList<Short> list;
//constructor
public MaximaleRegenPeriode(Measurement measurement1, ArrayList<Measurement> measurement2){
list = new ArrayList<Short>();
updateRecent(measurement1);
setName("Totale regenval");
updatePeriod(measurement2);
}
public void updateRecent(Measurement measurement1){
setCurrent(measurement1.getRainRate());
}
public void updatePeriod(ArrayList<Measurement> measurement2){
createList(measurement2);
setCustom(StatisticsCalculator.maximaleRegenPeriode(list) + " ");
}
public void display(){
GUIboard.writePageToMatrix("Totale regenval", Calculator.regenmeter(StatisticsCalculator.maximaleRegenPeriode(list)) + "", "");
}
public void displayGraph()
{
display();
}
private void createList(ArrayList<Measurement> measurement2)
{
if(!list.isEmpty())
@@ -37,7 +29,7 @@ public class MaximaleRegenPeriode extends Grootheid{
for(Measurement ms : measurement2)
{
list.add(ms.getRawRainRate());
list.add((double)ms.getRawRainRate());
}
}
}
+1
View File
@@ -1,3 +1,4 @@
package weerstation1;
import java.sql.Timestamp;
import java.math.BigDecimal;
+11 -20
View File
@@ -1,34 +1,21 @@
package weerstation1;
import java.util.ArrayList;
public class OutsideHum extends Grootheid{
public ArrayList<Double> list;
//constructor
//constructor
public OutsideHum(Measurement measurement1, ArrayList<Measurement> measurement2){
list = new ArrayList<Double>();
updateRecent(measurement1);
setName("Luchtv. Buiten");
updateRecent(measurement1);
updatePeriod(measurement2);
}
public void updateRecent(Measurement measurement1){
setCurrent(measurement1.getOutsideHum());
}
public void updatePeriod(ArrayList<Measurement> measurement2){
createList(measurement2);
calculateMaxMin(list);
setAvg(StatisticsCalculator.avg(list));
}
public void display(){
super.display();
GUIboard.writePageToMatrix("Luchtv. Buiten", "Gemiddelde: " + getAvg(), "");
}
public void displayGraph()
{
GUIboard.writeGraphToMatrix(list, getMin(), getMax());
maxMin();
avg();
}
private void createList(ArrayList<Measurement> measurement2)
@@ -40,7 +27,11 @@ public class OutsideHum extends Grootheid{
for(Measurement ms : measurement2)
{
list.add(ms.getOutsideHum());
list.add((double)ms.getRawOutsideHum());
}
}
public double calculate(double value){
return Calculator.luchtVochtigheid((short)value);
}
}
+12 -20
View File
@@ -1,34 +1,22 @@
package weerstation1;
import java.util.ArrayList;
public class OutsideTemp extends Grootheid{
public ArrayList<Double> list;
//constructor
//constructor
public OutsideTemp(Measurement measurement1, ArrayList<Measurement> measurement2){
list = new ArrayList<Double>();
updateRecent(measurement1);
setName("Buitentemperatuur");
updateRecent(measurement1);
updatePeriod(measurement2);
}
public void updateRecent(Measurement measurement1){
setCurrent(measurement1.getOutsideTemp());
}
public void updatePeriod(ArrayList<Measurement> measurement2){
createList(measurement2);
calculateMaxMin(list);
setAvg(StatisticsCalculator.avg(list));
}
public void display(){
super.display();
GUIboard.writePageToMatrix("Buitentemperatuur", "Gemiddelde: " + getAvg(), "");
}
public void displayGraph()
{
GUIboard.writeGraphToMatrix(list, getMin(), getMax());
maxMin();
avg();
}
private void createList(ArrayList<Measurement> measurement2)
@@ -40,7 +28,11 @@ public class OutsideTemp extends Grootheid{
for(Measurement ms : measurement2)
{
list.add(ms.getOutsideTemp());
list.add((double)ms.getRawOutsideTemp());
}
}
public double calculate(double value){
return Calculator.temperatuur((short)value);
}
}
+3 -2
View File
@@ -1,3 +1,4 @@
package weerstation1;
import java.util.GregorianCalendar;
import java.util.Calendar;
@@ -19,8 +20,8 @@ public class Periode
{
beginPeriode = new GregorianCalendar();
eindePeriode = new GregorianCalendar();
setBeginPeriode(jaar, maand, dag);
setEindePeriode(eindjaar, eindmaand, einddag);
setBeginPeriode(jaar, maand-1, dag);
setEindePeriode(eindjaar, eindmaand-1, einddag);
this.name = name;
}
+11 -19
View File
@@ -1,33 +1,21 @@
package weerstation1;
import java.util.ArrayList;
public class RainRate extends Grootheid{
public ArrayList<Double> list;
//constructor
//constructor
public RainRate(Measurement measurement1, ArrayList<Measurement> measurement2){
list = new ArrayList<Double>();
updateRecent(measurement1);
setName("Regenval in mm/h");
updateRecent(measurement1);
updatePeriod(measurement2);
}
public void updateRecent(Measurement measurement1){
setCurrent(measurement1.getRainRate());
}
public void updatePeriod(ArrayList<Measurement> measurement2){
createList(measurement2);
calculateMaxMin(list);
setAvg(StatisticsCalculator.avg(list));
}
public void display(){
super.display();
GUIboard.writePageToMatrix("Regenval in mm/h", "Gemiddelde: " + getAvg(), "");
}
public void displayGraph()
{
GUIboard.writeGraphToMatrix(list, getMin(), getMax());
maxMin();
avg();
}
private void createList(ArrayList<Measurement> measurement2)
@@ -39,7 +27,11 @@ public class RainRate extends Grootheid{
for(Measurement ms : measurement2)
{
list.add(ms.getRainRate());
list.add((double)ms.getRawRainRate());
}
}
public double calculate(double value){
return Calculator.regenmeter((short)value);
}
}
+61 -20
View File
@@ -1,5 +1,7 @@
import java.util.ArrayList;
import java.util.Collections;
package weerstation1;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
public class StatisticsCalculator {
@@ -217,7 +219,7 @@ public class StatisticsCalculator {
return index;
}
public static short maximaleRegenPeriode(ArrayList<Short> array)
public static short maximaleRegenPeriode(ArrayList<Double> array)
{
short regen = 0;
ArrayList<Short> regenPerUur = new ArrayList<Short>();
@@ -245,15 +247,15 @@ public class StatisticsCalculator {
return totaleRegen;
}
public static int[] langsteZomersePeriode(ArrayList<Short> array)
public static int[] langsteZomersePeriode(ArrayList<Double> array)
{
ArrayList<Double> maxTempDag = new ArrayList<Double>();
int i = 0;
short maxTemp = 0;
double maxTemp = 0;
//Bereken de maximale temperatuur per dag.
for(short db : array)
for(double db : array)
{
i++;
if(i%1440==0)
@@ -284,7 +286,7 @@ public class StatisticsCalculator {
//Doorloop je maximale temperaturen en zoek de langste periode
for(int t=0; t<maxTempDag.size(); t++) {
if(maxTempDag.get(t) > 25) {
if(maxTempDag.get(t) > 770) {
p++;
if(!zomers)
{
@@ -312,19 +314,55 @@ public class StatisticsCalculator {
return index;
}
public static int[] langsteHitteGolfPeriode(ArrayList<Double> array)
{
int[] index = new int[2];
int index1 = 0;
int index2 = 0;
//Code
index[0] = index1;
index[1] = index2;
return index;
public static Periode langsteHittegolfPeriode(ArrayList<Measurement> array){
double maxDay = 0;
ArrayList<Double> maxTempPerDay = new ArrayList<Double>();
//calculate the max for every day
for(int i = 0; i < array.size(); i++){
if((i % 1440) == 0){
maxTempPerDay.add(maxDay);
maxDay = 0;
}
if(array.get(i).getRawOutsideTemp() > maxDay){
maxDay = array.get(i).getRawOutsideTemp();
}
}
int periodLength = 0;
int maxPeriodLength = 5;
int numberOfTropicalDays = 0;
Calendar begin = Calendar.getInstance();
Calendar eind = Calendar.getInstance();
Periode periode = new Periode(begin, eind, "Geen hittegolfperiode gevonden");
for(int i = 0; i < maxTempPerDay.size(); i++){
if( maxTempPerDay.get(i) >= 770){ // If the temperature is bigger then 25 degree Celcius (770 degree Fahrenheit) the summer period will start
periodLength++;
if (maxTempPerDay.get(i) >= 860){ // If the temperature is bigger then 30 degree Celcius (860 degree Fahrenheit) it will add a tropical day
numberOfTropicalDays++;
}
}else if(periodLength > maxPeriodLength && numberOfTropicalDays >= 3){ //period has ended. If it is bigger then 5 days AND there are 3 or more tropical days, the period is a heat wave
maxPeriodLength = periodLength;
periodLength = 0;
numberOfTropicalDays = 0;
eind.setTimeInMillis(array.get((i-1)*1440).getDateStamp().getTime());
periode = new Periode(eind, begin, "Langste hittegolf periode");
}else{
numberOfTropicalDays = 0;
periodLength = 0;
}
if(periodLength == 5){
begin.setTimeInMillis(array.get((i-5)*1440).getDateStamp().getTime());
}
}
return periode;
}
public static int[] langsteTempStijgingPeriode(ArrayList<Double> array)
{
ArrayList<Double> maxTempDag = new ArrayList<Double>();
@@ -371,7 +409,7 @@ public class StatisticsCalculator {
indexStart = indexEind;
}
}
}
Integer tempMax = Collections.max(periodeLengteList); //onthoudt de grootste periode van een temp.stijging
@@ -390,4 +428,7 @@ public class StatisticsCalculator {
}
}
}
+7 -15
View File
@@ -1,8 +1,5 @@
package weerstation1;
import java.util.ArrayList;
public class Sun extends Grootheid{
//fields
@@ -12,6 +9,8 @@ public class Sun extends Grootheid{
//constructor
public Sun(Measurement measurement1){
updateRecent(measurement1);
setName("Zons opkomst: " + sunRise);
setCustom("Zons ondergang: " + sunSet);
}
//Getters and setters
@@ -32,19 +31,12 @@ public class Sun extends Grootheid{
this.sunRise = sunRise;
}
public void displayGraph()
{
}
public void updateRecent(Measurement measurement1){
setSunSet(measurement1.getSunset());
setSunRise(measurement1.getSunrise());
}
public void updatePeriod(ArrayList<Measurement> measurement2){
}
public void display(){
GUIboard.clearLeft();
GUIboard.clearRight();
GUIboard.clearTop();
GUIboard.writePageToMatrix("Sunset: " + sunSet, "Sunrise: " + sunRise, "");
}
}
+11 -20
View File
@@ -1,34 +1,21 @@
package weerstation1;
import java.util.ArrayList;
public class UVLevel extends Grootheid{
public ArrayList<Double> list;
//constructor
//constructor
public UVLevel(Measurement measurement1, ArrayList<Measurement> measurement2){
list = new ArrayList<Double>();
updateRecent(measurement1);
setName("UVlevel");
updateRecent(measurement1);
updatePeriod(measurement2);
}
public void updateRecent(Measurement measurement1){
setCurrent(measurement1.getUVLevel());
}
public void updatePeriod(ArrayList<Measurement> measurement2){
createList(measurement2);
calculateMaxMin(list);
setAvg(StatisticsCalculator.avg(list));
}
public void display(){
super.display();
GUIboard.writePageToMatrix("UV Level", "Gemiddelde: " + getAvg(), "");
}
public void displayGraph()
{
GUIboard.writeGraphToMatrix(list, getMin(), getMax());
maxMin();
avg();
}
private void createList(ArrayList<Measurement> measurement2)
@@ -40,7 +27,11 @@ public class UVLevel extends Grootheid{
for(Measurement ms : measurement2)
{
list.add(ms.getUVLevel());
list.add((double)ms.getRawUVLevel());
}
}
public double calculate(double value){
return Calculator.uvIndex((short)value);
}
}
+43 -41
View File
@@ -1,89 +1,91 @@
import java.util.ArrayList;
package weerstation1;
public class Voorspellingen extends Grootheid{
public ArrayList<Double> list;
private double barometer;
//constructor
public Voorspellingen(Measurement measurement1){
updateRecent(measurement1);
setName("Weersvoorspelling:");
updateRecent(measurement1);
}
public void updateRecent(Measurement measurement1){
setCurrent(measurement1.getBarometer());
barometer = measurement1.getBarometer();
}
public void display()
{
if (getCurrent() >= 1033 && getCurrent() <= 1084)
if (barometer >= 1033 && barometer <= 1084)
{
GUIboard.writePageToMatrix("Weersvoorspelling:", "mooi weer", "");
GUIboard.writeUpperDigits(10);
setCustom("Mooi weer");
setCurrent(10);
}
else
if (getCurrent() >= 1030 && getCurrent() <= 1033)
if (barometer >= 1030 && barometer <= 1033)
{
GUIboard.writePageToMatrix("Weersvoorspelling:", "mooi weer", "");
GUIboard.writeUpperDigits(10);
setCustom("Mooi weer");
setCurrent(10);
}
else
if (getCurrent() >= 1020 && getCurrent() <= 1030)
if (barometer >= 1020 && barometer <= 1030)
{
GUIboard.writePageToMatrix("Weersvoorspelling:", "goed weer", "");
GUIboard.writeUpperDigits(20);
setCustom("Goed weer");
setCurrent(20);
}
else
if (getCurrent() >= 1015 && getCurrent() <= 1020)
if (barometer >= 1015 && barometer <= 1020)
{
GUIboard.writePageToMatrix("Weersvoorspelling:", "wisselvallig weer", "");
GUIboard.writeUpperDigits(30);
setCustom("Wisselvallig weer");
setCurrent(30);
}
else
if (getCurrent() >= 1010 && getCurrent() <= 1015)
if (barometer >= 1010 && barometer <= 1015)
{
GUIboard.writePageToMatrix("Weersvoorspelling:", "wisselvallig weer", "");
GUIboard.writeUpperDigits(40);
setCustom("Wisselvallig weer");
setCurrent(40);
}
else
if (getCurrent() >= 1007 && getCurrent() <= 1010)
if (barometer >= 1007 && barometer <= 1010)
{
GUIboard.writePageToMatrix("Weersvoorspelling:", "wisselvallig weer", "");
GUIboard.writeUpperDigits(50);
setCustom("Wisselvallig weer");
setCurrent(50);
}
else
if (getCurrent() >= 1003 && getCurrent() <= 1007)
if (barometer >= 1003 && barometer <= 1007)
{
GUIboard.writePageToMatrix("Weersvoorspelling:", "regen of wind", "");
GUIboard.writeUpperDigits(60);
setCustom("Regen of wind");
setCurrent(60);
}
else
if (getCurrent() >= 1000 && getCurrent() <= 1003)
if (barometer >= 1000 && barometer <= 1003)
{
GUIboard.writePageToMatrix("Weersvoorspelling:", "regen of wind", "");
GUIboard.writeUpperDigits(70);
setCustom("Regen of wind");
setCurrent(70);
}
else
if (getCurrent() >= 990 && getCurrent() <= 1000)
if (barometer >= 990 && barometer <= 1000)
{
GUIboard.writePageToMatrix("Weersvoorspelling:", "regen of wind", "");
GUIboard.writeUpperDigits(80);
setCustom("Regen of wind");
setCurrent(80);
}
else
if (getCurrent() >= 980 && getCurrent() <= 990)
if (barometer >= 980 && barometer <= 990)
{
GUIboard.writePageToMatrix("Weersvoorspelling:", "veel regen", "");
GUIboard.writeUpperDigits(90);
setCustom("Veel regen");
setCurrent(90);
}
else
if (getCurrent() >= 970 && getCurrent() <= 980)
if (barometer >= 970 && barometer <= 980)
{
GUIboard.writePageToMatrix("Weersvoorspelling:", "storm", "");
GUIboard.writeUpperDigits(90);
setCustom("Storm");
setCurrent(90);
}
else
if (getCurrent() >= 870 && getCurrent() <= 970)
if (barometer >= 870 && barometer <= 970)
{
GUIboard.writePageToMatrix("Weersvoorspelling:", "zware storm", "");
GUIboard.writeUpperDigits(90);
setCustom("Zware storm");
setCurrent(90);
}
super.display();
}
}
+18 -12
View File
@@ -1,3 +1,4 @@
package weerstation1;
@@ -29,7 +30,7 @@ public class Weerstation {
public Weerstation(){
now = Calendar.getInstance();
calPeriod = Calendar.getInstance();
ArrayList<Periode> periods = new ArrayList<Periode>();
final ArrayList<Periode> periods = new ArrayList<Periode>();
GUIboard.init();
startupState = true;
@@ -73,7 +74,7 @@ public class Weerstation {
System.out.println("2 Years: " + periods.get(6));
//Kies hier welke periode je wil laden, hij veranderd in een keer alles:
int periodeNr = 1;
final int periodeNr = 2;
weerstation1 = new WeerstationConnector();
meting1 = weerstation1.getMostRecentMeasurement();
@@ -90,25 +91,30 @@ public class Weerstation {
final List<Grootheid> lstScreens = new ArrayList<Grootheid>();
lstScreens.add(new OutsideTemp(meting1, meting2)); //Buitentemperatuur
lstScreens.add(new WindDirection(meting1, meting2)); //Windrichting
lstScreens.add(new WindChill(meting1, meting2)); //Gevoelstemperatuur
lstScreens.add(new OutsideHum(meting1, meting2)); //Luchtv. Buiten
lstScreens.add(new Barometer(meting1, meting2)); //Luchtdruk
lstScreens.add(new AvgWindSpeed(meting1, meting2)); //Gem. Windsnelheid
lstScreens.add(new RainRate(meting1, meting2)); //Regenval
lstScreens.add(new InsideTemp(meting1, meting2)); //Binnentemperatuur
lstScreens.add(new InsideHum(meting1, meting2)); //Luchtv. Binnen
lstScreens.add(new AvgWindSpeed(meting1, meting2)); //Gem. Windsnelheid
lstScreens.add(new WindDirection(meting1, meting2)); //Windrichting
lstScreens.add(new WindChill(meting1, meting2)); //Gevoelstemperatuur
lstScreens.add(new Barometer(meting1, meting2)); //Luchtdruk
lstScreens.add(new Voorspellingen(meting1)); //Weervoorspelling
lstScreens.add(new RainRate(meting1, meting2)); //Regenval
lstScreens.add(new CloudHeight(meting1, meting2)); //Wolkhoogte
lstScreens.add(new UVLevel(meting1, meting2)); //UV Level
lstScreens.add(new HeatIndex(meting1, meting2)); //Dauwpunt
lstScreens.add(new Zonsterkte(meting1, meting2)); //Zonkracht
lstScreens.add(new DewPoint(meting1, meting2)); //Dauwpunt
lstScreens.add(new Sun(meting1)); //Sunrise en Sunset
lstScreens.add(new LangsteZomerPeriode(meting1, meting2));//Langste Zomerse Periode
lstScreens.add(new LangsteTempStijgingPeriode(meting1, meting2)); //Langste temperatuurstijging
lstScreens.add(new LangsteRegenPeriode(meting1, meting2)); //Langste Regen Periode
lstScreens.add(new MaximaleRegenPeriode(meting1, meting2)); //Totale regenval in een periode
lstScreens.add(new GraadDagen(meting1, meting2)); //Aantal graaddagen in een periode
lstScreens.add(new LangsteHittegolfPeriode(meting1, meting2));
lstScreens.add(new LangsteZomerPeriode(meting1, meting2)); //Langste Zomerse Periode
// lstScreens.add(new LangsteTempStijgingPeriode(meting1, meting2)); //Langste temperatuurstijging
lstScreens.add(new LangsteRegenPeriode(meting1, meting2)); //Langste Regen Periode
lstScreens.add(new MaximaleRegenPeriode(meting1, meting2)); //Totale regenval in een periode
lstScreens.add(new GraadDagen(meting1, meting2)); //Aantal graaddagen in een periode
stopStartupAnimatie();
while(startup)
{
+1
View File
@@ -1,3 +1,4 @@
package weerstation1;
import java.sql.Connection;
import java.sql.DriverManager;
+7 -19
View File
@@ -1,13 +1,11 @@
package weerstation1;
import java.util.ArrayList;
public class WindChill extends Grootheid{
public ArrayList<Double> list;
//constructor
//constructor
public WindChill(Measurement measurement1, ArrayList<Measurement> measurement2){
list = new ArrayList<Double>();
updateRecent(measurement1);
setName("WindChill");
updateRecent(measurement1);
updatePeriod(measurement2);
}
@@ -16,18 +14,8 @@ public class WindChill extends Grootheid{
}
public void updatePeriod(ArrayList<Measurement> measurement2){
createList(measurement2);
calculateMaxMin(list);
setAvg(StatisticsCalculator.avg(list));
}
public void display(){
super.display();
GUIboard.writePageToMatrix("Gevoelstemp", "Gemiddelde: " + getAvg(), "");
}
public void displayGraph()
{
GUIboard.writeGraphToMatrix(list, getMin(), getMax());
maxMin();
avg();
}
private void createList(ArrayList<Measurement> measurement2)
@@ -39,7 +27,7 @@ public class WindChill extends Grootheid{
for(Measurement ms : measurement2)
{
list.add(ms.getWindChill());
list.add((double)ms.getWindChill());
}
}
}
+8 -25
View File
@@ -1,43 +1,26 @@
package weerstation1;
import java.util.ArrayList;
public class WindDirection extends Grootheid{
public ArrayList<Double> list;
//constructor
public WindDirection(Measurement measurement1, ArrayList<Measurement> measurement2){
list = new ArrayList<Double>();
updateRecent(measurement1);
public WindDirection(Measurement measurement1, ArrayList<Measurement> measurement2){
setName("Windrichting");
updateRecent(measurement1);
updatePeriod(measurement2);
}
public void updateRecent(Measurement measurement1){
setCurrent(measurement1.getRawWindDir());
}
public void updatePeriod(ArrayList<Measurement> measurement2){
createList(measurement2);
setMode(StatisticsCalculator.modus(list));
}
public void display(){
super.display();
GUIboard.clearLeft();
GUIboard.clearRight();
GUIboard.writePageToMatrix("Windrichting", "Modus: " + getMode(), "");
maxMin();
//modus();
}
public void displayGraph()
{
GUIboard.clearBottom();
char[] charray = " West East".toCharArray();
IO.writeShort(0x40, '\n');
for(char ch : charray)
{
IO.writeShort(0x40, ch);
}
GUIboard.writePageToMatrix("", "West East", "");
int x,y;
int radius = 15;
+7 -22
View File
@@ -1,36 +1,21 @@
package weerstation1;
import java.util.ArrayList;
public class Zonsterkte extends Grootheid{
public ArrayList<Double> list;
//constructor
//constructor
public Zonsterkte(Measurement measurement1, ArrayList<Measurement> measurement2){
list = new ArrayList<Double>();
updateRecent(measurement1);
setName("Zonsterkte");
updateRecent(measurement1);
updatePeriod(measurement2);
}
public void updateRecent(Measurement measurement1){
setCurrent(measurement1.getSolarRad());
}
public void updatePeriod(ArrayList<Measurement> measurement2){
createList(measurement2);
calculateMaxMin(list);
setAvg(StatisticsCalculator.avg(list));
}
public void display(){
super.display();
GUIboard.clearLeft();
GUIboard.clearRight();
GUIboard.writePageToMatrix("Zonsterkte", "Gemiddelde: " + getAvg(), "");
}
public void displayGraph()
{
GUIboard.writeGraphToMatrix(list, getMin(), getMax());
maxMin();
avg();
}
private void createList(ArrayList<Measurement> measurement2)
@@ -42,7 +27,7 @@ public class Zonsterkte extends Grootheid{
for(Measurement ms : measurement2)
{
list.add(ms.getSolarRad());
list.add((double)ms.getRawSolarRad());
}
}
}