diff --git a/Wetterstation/Form1.Designer.cs b/Wetterstation/Form1.Designer.cs index 742d84e1f77c40b23070f24dc51bd61c11ad0554..97b2e47a4a2555faaa7b336dd5917a9386793553 100644 --- a/Wetterstation/Form1.Designer.cs +++ b/Wetterstation/Form1.Designer.cs @@ -182,10 +182,10 @@ namespace Wetterstation this.pbKompassrose.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(88)))), ((int)(((byte)(10)))), ((int)(((byte)(80)))), ((int)(((byte)(147))))); this.pbKompassrose.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; this.pbKompassrose.Image = global::Wetterstation.Properties.Resources.WindRose_neu; - this.pbKompassrose.Location = new System.Drawing.Point(1160, 64); + this.pbKompassrose.Location = new System.Drawing.Point(1143, 64); this.pbKompassrose.Margin = new System.Windows.Forms.Padding(4, 0, 4, 4); this.pbKompassrose.Name = "pbKompassrose"; - this.pbKompassrose.Size = new System.Drawing.Size(120, 121); + this.pbKompassrose.Size = new System.Drawing.Size(160, 151); this.pbKompassrose.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; this.pbKompassrose.TabIndex = 10; this.pbKompassrose.TabStop = false; @@ -249,10 +249,10 @@ namespace Wetterstation this.lbWindricht.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(90)))), ((int)(((byte)(10)))), ((int)(((byte)(80)))), ((int)(((byte)(147))))); this.lbWindricht.Font = new System.Drawing.Font("Arial", 15.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.lbWindricht.ForeColor = System.Drawing.SystemColors.ButtonFace; - this.lbWindricht.Location = new System.Drawing.Point(1160, 186); + this.lbWindricht.Location = new System.Drawing.Point(1137, 219); this.lbWindricht.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.lbWindricht.Name = "lbWindricht"; - this.lbWindricht.Size = new System.Drawing.Size(120, 32); + this.lbWindricht.Size = new System.Drawing.Size(166, 32); this.lbWindricht.TabIndex = 18; this.lbWindricht.Text = "---"; this.lbWindricht.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; @@ -579,11 +579,11 @@ namespace Wetterstation // lbForecastTemp1 // this.lbForecastTemp1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(90)))), ((int)(((byte)(10)))), ((int)(((byte)(80)))), ((int)(((byte)(147))))); - this.lbForecastTemp1.Font = new System.Drawing.Font("Microsoft Sans Serif", 7.8F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lbForecastTemp1.Font = new System.Drawing.Font("Microsoft Sans Serif", 7.2F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.lbForecastTemp1.ForeColor = System.Drawing.SystemColors.ButtonFace; - this.lbForecastTemp1.Location = new System.Drawing.Point(182, 406); + this.lbForecastTemp1.Location = new System.Drawing.Point(165, 406); this.lbForecastTemp1.Name = "lbForecastTemp1"; - this.lbForecastTemp1.Size = new System.Drawing.Size(51, 17); + this.lbForecastTemp1.Size = new System.Drawing.Size(71, 17); this.lbForecastTemp1.TabIndex = 55; this.lbForecastTemp1.Text = "---"; this.lbForecastTemp1.TextAlign = System.Drawing.ContentAlignment.MiddleRight; @@ -591,11 +591,11 @@ namespace Wetterstation // lbForecastTemp2 // this.lbForecastTemp2.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(90)))), ((int)(((byte)(10)))), ((int)(((byte)(80)))), ((int)(((byte)(147))))); - this.lbForecastTemp2.Font = new System.Drawing.Font("Microsoft Sans Serif", 7.8F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lbForecastTemp2.Font = new System.Drawing.Font("Microsoft Sans Serif", 7.2F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.lbForecastTemp2.ForeColor = System.Drawing.SystemColors.ButtonFace; - this.lbForecastTemp2.Location = new System.Drawing.Point(252, 406); + this.lbForecastTemp2.Location = new System.Drawing.Point(236, 406); this.lbForecastTemp2.Name = "lbForecastTemp2"; - this.lbForecastTemp2.Size = new System.Drawing.Size(51, 17); + this.lbForecastTemp2.Size = new System.Drawing.Size(71, 17); this.lbForecastTemp2.TabIndex = 56; this.lbForecastTemp2.Text = "---"; this.lbForecastTemp2.TextAlign = System.Drawing.ContentAlignment.MiddleRight; @@ -603,11 +603,11 @@ namespace Wetterstation // lbForecastTemp3 // this.lbForecastTemp3.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(90)))), ((int)(((byte)(10)))), ((int)(((byte)(80)))), ((int)(((byte)(147))))); - this.lbForecastTemp3.Font = new System.Drawing.Font("Microsoft Sans Serif", 7.8F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lbForecastTemp3.Font = new System.Drawing.Font("Microsoft Sans Serif", 7.2F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.lbForecastTemp3.ForeColor = System.Drawing.SystemColors.ButtonFace; - this.lbForecastTemp3.Location = new System.Drawing.Point(325, 406); + this.lbForecastTemp3.Location = new System.Drawing.Point(307, 406); this.lbForecastTemp3.Name = "lbForecastTemp3"; - this.lbForecastTemp3.Size = new System.Drawing.Size(51, 17); + this.lbForecastTemp3.Size = new System.Drawing.Size(71, 17); this.lbForecastTemp3.TabIndex = 57; this.lbForecastTemp3.Text = "---"; this.lbForecastTemp3.TextAlign = System.Drawing.ContentAlignment.MiddleRight; @@ -615,11 +615,11 @@ namespace Wetterstation // lbForecastTemp4 // this.lbForecastTemp4.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(90)))), ((int)(((byte)(10)))), ((int)(((byte)(80)))), ((int)(((byte)(147))))); - this.lbForecastTemp4.Font = new System.Drawing.Font("Microsoft Sans Serif", 7.8F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lbForecastTemp4.Font = new System.Drawing.Font("Microsoft Sans Serif", 7.2F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.lbForecastTemp4.ForeColor = System.Drawing.SystemColors.ButtonFace; - this.lbForecastTemp4.Location = new System.Drawing.Point(389, 406); + this.lbForecastTemp4.Location = new System.Drawing.Point(376, 406); this.lbForecastTemp4.Name = "lbForecastTemp4"; - this.lbForecastTemp4.Size = new System.Drawing.Size(51, 17); + this.lbForecastTemp4.Size = new System.Drawing.Size(67, 17); this.lbForecastTemp4.TabIndex = 58; this.lbForecastTemp4.Text = "---"; this.lbForecastTemp4.TextAlign = System.Drawing.ContentAlignment.MiddleRight; @@ -627,11 +627,11 @@ namespace Wetterstation // lbForecastTemp5 // this.lbForecastTemp5.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(90)))), ((int)(((byte)(10)))), ((int)(((byte)(80)))), ((int)(((byte)(147))))); - this.lbForecastTemp5.Font = new System.Drawing.Font("Microsoft Sans Serif", 7.8F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lbForecastTemp5.Font = new System.Drawing.Font("Microsoft Sans Serif", 7.2F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.lbForecastTemp5.ForeColor = System.Drawing.SystemColors.ButtonFace; - this.lbForecastTemp5.Location = new System.Drawing.Point(457, 406); + this.lbForecastTemp5.Location = new System.Drawing.Point(441, 406); this.lbForecastTemp5.Name = "lbForecastTemp5"; - this.lbForecastTemp5.Size = new System.Drawing.Size(51, 17); + this.lbForecastTemp5.Size = new System.Drawing.Size(71, 17); this.lbForecastTemp5.TabIndex = 59; this.lbForecastTemp5.Text = "---"; this.lbForecastTemp5.TextAlign = System.Drawing.ContentAlignment.MiddleRight; diff --git a/Wetterstation/Form1.cs b/Wetterstation/Form1.cs index 622d690b66bd2296910c9af34fe9487e1816c8cc..ac88e06605bc953b7995b0f035b150acd36114c4 100644 --- a/Wetterstation/Form1.cs +++ b/Wetterstation/Form1.cs @@ -22,7 +22,6 @@ namespace Wetterstation Sensor node1In = new Sensor(); Sensor node1Out = new Sensor(); Sensor owm = new Sensor(); - int tendenzCount = 10; public Hintergrund() { @@ -246,7 +245,7 @@ namespace Wetterstation lbTempOutMin.Invoke(new Action(() => { lbTempOutMin.Text = weatherData.tempMin + " °C"; })); lbTempOutMax.Invoke(new Action(() => { lbTempOutMax.Text = weatherData.tempMax + " °C"; })); owm.Temperatures = weatherData.temp; - if (owm._temperatures.Count < tendenzCount && owm.tempTendenz() != -1) pbTendenzTempOut.Invoke(new Action(() => { pbTendenzTempOut.Visible = false; })); + if (owm.tempTendenz() == -1) pbTendenzTempOut.Invoke(new Action(() => { pbTendenzTempOut.Visible = false; })); else pbTendenzTempOut.Invoke(new Action(() => { pbTendenzTempOut.Visible = true; })); pbTendenzTempOut.Invoke(new Action(() => { pbTendenzTempOut.Image = RotateImage((Bitmap)global::Wetterstation.Properties.Resources.ResourceManager.GetObject("Tendenz"), owm.tempTendenz()); })); } @@ -254,7 +253,7 @@ namespace Wetterstation { lbLuftfeuchtAussen.Invoke(new Action(() => { lbLuftfeuchtAussen.Text = weatherData.humidity + " %"; })); owm.Humiditys = (double)weatherData.humidity; - if (owm._humiditys.Count < 10 && owm.humidityTendenz() != -1) lbTendenzHumidityOut.Invoke(new Action(() => { lbTendenzHumidityOut.Visible = false; })); + if (owm.humidityTendenz() == -1) lbTendenzHumidityOut.Invoke(new Action(() => { lbTendenzHumidityOut.Visible = false; })); else lbTendenzHumidityOut.Invoke(new Action(() => { lbTendenzHumidityOut.Visible = true; })); lbTendenzHumidityOut.Invoke(new Action(() => { lbTendenzHumidityOut.Image = RotateImage((Bitmap)global::Wetterstation.Properties.Resources.ResourceManager.GetObject("Tendenz"), owm.humidityTendenz()); })); } @@ -271,7 +270,7 @@ namespace Wetterstation { lbLuftdruck.Invoke(new Action(() => { lbLuftdruck.Text = weatherData.pressure + " mbar"; })); owm.Pressures = (double)weatherData.pressure; - if (owm._pressures.Count < tendenzCount && owm.pressureTendenz() != -1) pbTendenzPressure.Invoke(new Action(() => { pbTendenzPressure.Visible = false; })); + if (owm.pressureTendenz() == -1) pbTendenzPressure.Invoke(new Action(() => { pbTendenzPressure.Visible = false; })); else pbTendenzPressure.Invoke(new Action(() => { pbTendenzPressure.Visible = true; })); pbTendenzPressure.Invoke(new Action(() => { pbTendenzPressure.Image = RotateImage((Bitmap)global::Wetterstation.Properties.Resources.ResourceManager.GetObject("Tendenz"), owm.pressureTendenz()); })); } @@ -367,7 +366,7 @@ namespace Wetterstation lbTempInMin.Invoke(new Action(() => { lbTempInMin.Text = node1In.tempMin + " °C"; })); lbTempInMax.Invoke(new Action(() => { lbTempInMax.Text = node1In.tempMax + " °C"; })); node1In.Temperatures = (double)weatherData[0]["temperature"]; - if (node1In._temperatures.Count < tendenzCount && node1In.tempTendenz() != -1) pbTendenzTempIn.Invoke(new Action(() => { pbTendenzTempIn.Visible = false; })); + if (node1In.tempTendenz() == -1) pbTendenzTempIn.Invoke(new Action(() => { pbTendenzTempIn.Visible = false; })); else pbTendenzTempIn.Invoke(new Action(() => { pbTendenzTempIn.Visible = true; })); pbTendenzTempIn.Invoke(new Action(() => { pbTendenzTempIn.Image = RotateImage((Bitmap)global::Wetterstation.Properties.Resources.ResourceManager.GetObject("Tendenz"), node1In.tempTendenz()); })); } @@ -376,7 +375,7 @@ namespace Wetterstation node1In.humidity = true; lbLuftFeuchtInnen.Invoke(new Action(() => { lbLuftFeuchtInnen.Text = weatherData[0]["humidity"] + " %"; })); node1Out.Humiditys = (double)weatherData[0]["humidity"]; - if (node1In._humiditys.Count < tendenzCount && node1In.humidityTendenz() != -1) lbTendenzHumidityIn.Invoke(new Action(() => { lbTendenzHumidityIn.Visible = false; })); + if (node1In.humidityTendenz() == -1) lbTendenzHumidityIn.Invoke(new Action(() => { lbTendenzHumidityIn.Visible = false; })); else lbTendenzHumidityIn.Invoke(new Action(() => { lbTendenzHumidityIn.Visible = true; })); lbTendenzHumidityIn.Invoke(new Action(() => { lbTendenzHumidityIn.Image = RotateImage((Bitmap)global::Wetterstation.Properties.Resources.ResourceManager.GetObject("Tendenz"), node1In.humidityTendenz()); })); } @@ -385,7 +384,7 @@ namespace Wetterstation node1In.pressure = true; lbLuftdruck.Invoke(new Action(() => { lbLuftdruck.Text = weatherData[0]["pressure"] + " hPa"; })); node1In.Pressures = (double)weatherData[0]["pressure"]; - if (node1In._pressures.Count < tendenzCount && node1In.pressureTendenz() != -1) pbTendenzPressure.Invoke(new Action(() => { pbTendenzPressure.Visible = false; })); + if (node1In.pressureTendenz() == -1) pbTendenzPressure.Invoke(new Action(() => { pbTendenzPressure.Visible = false; })); else pbTendenzPressure.Invoke(new Action(() => { pbTendenzPressure.Visible = true; })); pbTendenzPressure.Invoke(new Action(() => { pbTendenzPressure.Image = RotateImage((Bitmap)global::Wetterstation.Properties.Resources.ResourceManager.GetObject("Tendenz"), node1In.pressureTendenz()); })); } @@ -400,7 +399,7 @@ namespace Wetterstation lbTempOutMin.Invoke(new Action(() => { lbTempOutMin.Text = node1Out.tempMin + " °C"; })); lbTempOutMax.Invoke(new Action(() => { lbTempOutMax.Text = node1Out.tempMax + " °C"; })); node1Out.Temperatures = (double)weatherData[0]["temperature"]; - if (node1Out._temperatures.Count < tendenzCount && node1Out.tempTendenz() != -1) pbTendenzTempOut.Invoke(new Action(() => { pbTendenzTempOut.Visible = false; })); + if (node1Out.tempTendenz() == -1) pbTendenzTempOut.Invoke(new Action(() => { pbTendenzTempOut.Visible = false; })); else pbTendenzTempOut.Invoke(new Action(() => { pbTendenzTempOut.Visible = true; })); pbTendenzTempOut.Invoke(new Action(() => { pbTendenzTempOut.Image = RotateImage((Bitmap)global::Wetterstation.Properties.Resources.ResourceManager.GetObject("Tendenz"), node1Out.tempTendenz()); })); } @@ -409,7 +408,7 @@ namespace Wetterstation node1Out.humidity = true; lbLuftfeuchtAussen.Invoke(new Action(() => { lbLuftfeuchtAussen.Text = weatherData[0]["humidity"] + " %"; })); node1Out.Humiditys = (double)weatherData[0]["humidity"]; - if (node1Out._humiditys.Count < tendenzCount && node1Out.humidityTendenz() != -1) lbTendenzHumidityOut.Invoke(new Action(() => { lbTendenzHumidityOut.Visible = false; })); + if (node1Out.humidityTendenz() == -1) lbTendenzHumidityOut.Invoke(new Action(() => { lbTendenzHumidityOut.Visible = false; })); else lbTendenzHumidityOut.Invoke(new Action(() => { lbTendenzHumidityOut.Visible = true; })); lbTendenzHumidityOut.Invoke(new Action(() => { lbTendenzHumidityOut.Image = RotateImage((Bitmap)global::Wetterstation.Properties.Resources.ResourceManager.GetObject("Tendenz"), node1Out.humidityTendenz()); })); } diff --git a/Wetterstation/Sensor.cs b/Wetterstation/Sensor.cs index 8fda3399f12938745387f1e2b19b0ac3eaeb67ab..a809799306d042903eda2efd5d1cce02a5f02c8b 100644 --- a/Wetterstation/Sensor.cs +++ b/Wetterstation/Sensor.cs @@ -17,14 +17,14 @@ namespace Wetterstation public bool snow { get; set; } public double tempMin { get; set; } public double tempMax { get; set; } - public List<double> _temperatures = new List<double>(); - public List<double> _pressures = new List<double>(); - public List<double> _humiditys = new List<double>(); + private List<double> _temperatures = new List<double>(); + private List<double> _pressures = new List<double>(); + private List<double> _humiditys = new List<double>(); public double Temperatures { set { - if (_temperatures.Count == 3) + if (_temperatures.Count == 10) { _temperatures.RemoveAt(0); } @@ -35,7 +35,7 @@ namespace Wetterstation { set { - if (_pressures.Count == 3) + if (_pressures.Count == 10) { _pressures.RemoveAt(0); } @@ -46,7 +46,7 @@ namespace Wetterstation { set { - if (_humiditys.Count == 3) + if (_humiditys.Count == 10) { _humiditys.RemoveAt(0); } @@ -62,7 +62,6 @@ namespace Wetterstation foreach (double temp in _temperatures) { - Console.WriteLine("--> tempTendenz " + oldTemp + " / " + temp); if (temp > oldTemp) { up++; @@ -79,9 +78,12 @@ namespace Wetterstation oldTemp = temp; } } - - if (up > down && up > (same / 2)) return 180; - else if (down > up && down > (same / 2)) return 0; + if ((up > 5 || down > 5) && _temperatures.Count == 10) + { + if (up > down) return 180; + else if (down > up) return 0; + else return -1; + } else return -1; } public float pressureTendenz() @@ -93,7 +95,6 @@ namespace Wetterstation foreach (double pressure in _pressures) { - Console.WriteLine("--> pressureTendenz " + oldPressure + " / " + pressure); if (pressure > oldPressure) { up++; @@ -111,8 +112,11 @@ namespace Wetterstation } } - if (up > down && up > (same / 2)) return 180; - else if (down > up && down > (same / 2)) return 0; + if ((up > 5 || down > 5) && _pressures.Count == 10) { + if (up > down) return 180; + else if (down > up) return 0; + else return -1; + } else return -1; } public float humidityTendenz() @@ -124,7 +128,6 @@ namespace Wetterstation foreach (double humidity in _humiditys) { - Console.WriteLine("--> humidityTendenz " + oldHumidity + " / " + humidity); if (humidity > oldHumidity) { up++; @@ -141,9 +144,12 @@ namespace Wetterstation oldHumidity = humidity; } } - - if (up > down && up > (same / 2)) return 180; - else if (down > up && down > (same / 2)) return 0; + if ((up > 5 || down > 5) && _humiditys.Count == 10) + { + if (up > down) return 180; + else if (down > up) return 0; + else return -1; + } else return -1; } }