Exemplo n.º 1
0
        void wTick_Tick(object sender, EventArgs e)
        {
            var rand = new Random();
            var wu = new WeatherUpdate();

            // Fow now, return some random values
            wu.Time = DateTime.Now;
            wu.Temperature = 25F + (float)rand.NextDouble();
            wu.Humidity = 50F + 10F*(float)rand.NextDouble();
            wu.Rain = (float)rand.NextDouble();
            wu.Irradiation = 900F + 100F*(float)rand.NextDouble();
            wu.Pressure = 1000F + 50F*(float)rand.NextDouble();
            wu.WindSpeedInstant = 5F * (float)rand.NextDouble();
            wu.WindSpeedAvg2Min = 2F + (float)rand.NextDouble();
            wu.WindSpeedGust10Min = 5F + (float)rand.NextDouble();
            wu.WindDirectionInstant = 45F + 5F * (float)rand.NextDouble();
            wu.WindDirectionAvg2Min = 45F + 1F * (float)rand.NextDouble();
            wu.WindDirectionGust10Min = 45F + 1F * (float)rand.NextDouble();

            var wtea = new WeatherTickEventArgs(wu);
            OnWeatherTick(wtea);
        }
Exemplo n.º 2
0
 static void wl_WeatherTick(object sender, WeatherTickEventArgs e)
 {
     var wu = e.Update;
     Console.WriteLine("Temperature: " + wu.Temperature + " C (" + wu.Temperature.ToF() + " F");
 }
Exemplo n.º 3
0
        void wl_WeatherTick(object sender, WeatherTickEventArgs e)
        {
            // extract the WeatherUpdate object
            WeatherUpdate wu = e.Update;

            StringBuilder sb = new StringBuilder();

            // Show time
            sb.AppendFormat("Time: {0}\r\n\r\n", wu.Time.ToLocalTime());

            // Show temperature
            float tempC = wu.Temperature;
            float tempF = wu.Temperature.ToF();

            sb.AppendFormat("Temperature: {0} °C ({1} °F)\r\n", tempC, tempF);
            sb.AppendLine(WeatherValueProperties(wu.Temperature));

            // Show humidity
            float humid = wu.Humidity;
            sb.AppendFormat("\r\nRelative Humidity: {0}%\r\n", humid);
            sb.AppendLine(WeatherValueProperties(wu.Humidity));

            // Show dew point
            float dpC = wu.DewPoint;
            float dpF = wu.DewPoint.ToF();
            sb.AppendFormat("\r\nDew Point: {0} °C ({1} °F)\r\n", dpC, dpF);
            sb.AppendLine(WeatherValueProperties(wu.DewPoint));

            // Show pressure
            float pressure = wu.Pressure;
            sb.AppendFormat("\r\nAtmospheric Pressure: {0} hPa\r\n", pressure);
            sb.AppendLine(WeatherValueProperties(wu.Pressure));

            // Show irradiation
            float irrad = wu.Irradiation;
            sb.AppendFormat("\r\nSolar Radiation: {0} Watts per square meter\r\n", irrad);
            sb.AppendLine(WeatherValueProperties(wu.Irradiation));

            // Show rain
            float rain = wu.Rain;
            sb.AppendFormat("\r\nHourly rainfall: {0} inches\r\n", rain);
            sb.AppendLine(WeatherValueProperties(wu.Rain));

            // Show wind speeds
            sb.AppendFormat("\r\nWind Speeds (MPH):\r\n\tInstant {0}\r\n\t2 Min Avg: {1}\r\n\t10 Min Gust: {2}\r\n",
                (float)wu.WindSpeedInstant.ToMPH(),
                (float)wu.WindSpeedAvg2Min.ToMPH(),
                (float)wu.WindSpeedGust10Min.ToMPH());
            sb.AppendLine(WeatherValueProperties(wu.WindSpeedInstant));

            // Show wind directions
            sb.AppendFormat("\r\nWind Directions:\r\n\tInstant {0}°\r\n\t2 Min Avg: {1}°\r\n\t10 Min Gust: {2}°\r\n",
                (float)wu.WindDirectionInstant,
                (float)wu.WindDirectionAvg2Min,
                (float)wu.WindDirectionGust10Min);
            sb.AppendLine(WeatherValueProperties(wu.WindDirectionInstant));

            // Angle math test, view with debugger
            AngleValue windangle = wu.WindDirectionInstant - 180F;  // point the other way
            double rads = (double)(windangle.ToRad());
            double cos = Math.Cos((double)rads);
            double sin = Math.Sin((double)rads);

            // Update textbox
            tbConsole.Text = sb.ToString();
        }
Exemplo n.º 4
0
 protected void OnWeatherTick(WeatherTickEventArgs e)
 {
     WeatherTick(this, e);
 }