Ejemplo n.º 1
0
 public void StartMeasure()
 {
     for (int i = 0; i < measurePeriodSeconds / IntervaMeasurelSeconds; i++)
     {
         Console.WriteLine($"\nNew weather data...\n");
         WeatherEventArgs newWeather = GetNewWeather();
         OnWeatherChanged(this, newWeather);
         Console.WriteLine(new string('-', 70));
         Thread.Sleep(IntervaMeasurelSeconds * 1000);
     }
 }
Ejemplo n.º 2
0
        private WeatherEventArgs GetNewWeather()
        {
            Random           random     = new Random();
            WeatherEventArgs newWeather = new WeatherEventArgs()
            {
                Temperature = random.Next(10, 20),
                Humidity    = random.Next(60, 100),
                Pressure    = random.Next(600, 700)
            };

            return(newWeather);
        }
Ejemplo n.º 3
0
 protected virtual void OnWeatherChanged(object sender, WeatherEventArgs e)
 {
     WeatherChanged?.Invoke(this, e);
 }
Ejemplo n.º 4
0
 public WeatherData(int measurePeriodSeconds, int intervalSeconds)
 {
     currentWeather         = new WeatherEventArgs();
     IntervaMeasurelSeconds = intervalSeconds;
     MeasurePeriodSeconds   = measurePeriodSeconds;
 }