/// <summary>
 /// Constructor
 /// </summary>
 /// <param name="speed"></param>
 /// <param name="temp"></param>
 /// <param name="data"></param>
 public WeatherAggregate(int speed, int temp, IWeatherData data)
 {
     SpeedUnit = speed;
     TempUnit  = temp;
     //Dep inject
     DataAccess = data;
 }
        public CurrentConditionsDisplay(IWeatherData wd)
        {
            this.weatherData = wd;
            weatherData.RegisterObserver(this);

            this._dataObject = new WeatherDataObject();
        }
Esempio n. 3
0
        public HeatIndexDisplay(IWeatherData wd)
        {
            this.weatherData = wd;
            weatherData.RegisterObserver(this);

            this._dataObject = new WeatherDataObject();
        }
Esempio n. 4
0
 private void SetCustomPropsOnStart()
 {
     WeatherData = null;
     WeatherService.dTemperature = Temperature.SetDefaultTemperature;
     WeatherService.dHumidity    = Humidity.SetDefaultHumidity;
     WeatherService.dPressure    = Pressure.SetDefaultPressure;
 }
Esempio n. 5
0
        public void Update(IWeatherData weatherData)
        {
            WeatherData temp = (WeatherData)weatherData;

            _device.Text = "temp: " + temp.Temperature1 + Environment.NewLine
                           + "hum: " + temp.Humidity1 + Environment.NewLine
                           + "pres: " + temp.Pressure;
        }
Esempio n. 6
0
 public HomeController(ILogger <HomeController> logger, IConfiguration configuration,
                       IWeatherClient weatherClient, IWeatherData weatherData)
 {
     _logger        = logger;
     _configuration = configuration;
     _weatherClient = weatherClient;
     _weatherData   = weatherData;
 }
Esempio n. 7
0
 public void Update(IWeatherData observable, WeatherDataObject obj)
 {
     if (observable is WeatherData && obj != null)
     {
         this._dataObject = obj;
     }
     Display();
 }
Esempio n. 8
0
        public void GetWeatherAgainTest()
        {
            var weather = new OpenWeatherConnection();

            weather.City = "Krosno";
            IWeatherData data = weather.GetWeatherData();

            Assert.AreNotEqual(data, WeatherData.ERRORMODEL);
        }
        public void update(IWeatherData weather)
        {
            var temperature = weather.GetTemperature();

            Min     = temperature.Min;
            Max     = temperature.Max;
            Average = temperature.Average;
            Display();
        }
Esempio n. 10
0
 public bool Validate(IWeatherData weather)
 {
     if (weather.main.temp < 10 || weather.main.temp > 30 || weather.wind.speed > 7 || weather.weather[0].id < 700)
     {
         return(false);
     }
     else
     {
         return(true);
     }
 }
        protected override void Because()
        {
            base.Because();
            _mockBBCWeather  = Substitute.For <IWeatherData>();
            _mockAccuWeather = Substitute.For <IWeatherData>();

            _mockBBCWeather.WindspeedKPH.Returns(4.97d);
            _mockAccuWeather.WindspeedKPH.Returns(10d);
            MockConverters.BBCToGeneric(Arg.Any <BbcWeatherResult>()).Returns(_mockBBCWeather);
            MockConverters.AccuToGeneric(Arg.Any <AccWeatherResult>()).Returns(_mockAccuWeather);
        }
        protected override void Because()
        {
            base.Because();
            _mockBBCWeather  = Substitute.For <IWeatherData>();
            _mockAccuWeather = Substitute.For <IWeatherData>();

            _mockBBCWeather.TemperatureCelsius.Returns(10d);
            _mockAccuWeather.TemperatureCelsius.Returns(20d);
            MockConverters.BBCToGeneric(Arg.Any <BbcWeatherResult>()).Returns(_mockBBCWeather);
            MockConverters.AccuToGeneric(Arg.Any <AccWeatherResult>()).Returns(_mockAccuWeather);
        }
 public ActionResult <CyclingConditions> Create(bool isCyclable, IWeatherData weather)
 {
     return(new CyclingConditions()
     {
         isItCyclable = isCyclable,
         temperature = weather.main.temp,
         windSpeed = weather.wind.speed,
         windDirectionDeg = weather.wind.deg,
         weatherCondition = weather.weather.FirstOrDefault().main,
         lastUpdated = DateTime.Now.ToString("yyyy-MM-dd H:mm:ss")
     });
 }
Esempio n. 14
0
        public string Format(IWeatherData data)
        {
            StringBuilder str = new StringBuilder();

            var current = data.Forecasts.First(f => f.Type == ForecastType.Current);

            str.AppendLine("Weather:");
            str.AppendLine();
            str.AppendFormat("Now: {0}", current.Description, current.High, current.Low);
            str.AppendLine();
            str.AppendFormat("Feels Like: {0} {1}", Math.Round(current.High), data.TemperatureUnit);

            return(str.ToString());
        }
Esempio n. 15
0
        public void GetWeatherDataTest()
        {
            var weather = new OpenWeatherConnection();

            weather.City = "Krosno";
            IWeatherData data = weather.GetWeatherData();

            Assert.AreNotEqual(data, WeatherData.ERRORMODEL);
            Assert.IsNotNull(data.MainInformation);
            Assert.IsNotNull(data.Description);
            Assert.IsNotNull(data.KelvinTemperature);
            Assert.IsNotNull(data.Humidity);
            Assert.IsNotNull(data.WindDegree);
            Assert.IsNotNull(data.WindSpeed);
        }
Esempio n. 16
0
        private bool AssignInitializeWeatherData()
        {
            try
            {
                if (CitiesComboBox.SelectedItem.GetType().Equals((new ComboBoxItem()).GetType()))
                {
                    _city = ((ComboBoxItem)CitiesComboBox.SelectedItem).Content.ToString();
                }
                else
                {
                    _city = CitiesComboBox.SelectedItem.ToString();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show($"Message returned by application: {ex.Message} \n Probably city name is invalid. \n Selected item is {CitiesComboBox.SelectedItem.GetType()}");
                return(false);
            }

            if (OpenWeatherServiceRadio.IsChecked == true)
            {
                try
                {
                    _baseURL           = @"http://api.openweathermap.org/data/2.5/weather";
                    _urlBuilder        = new OpenWeatherAPIURLBuilder(_baseURL, _apiKey);
                    _weatherDownloader = new OpenWeatherDownloader(_urlBuilder);
                    _weatherData       = new OpenWeatherObject();
                    _dataBinder        = new OpenWeatherDataBinder <OpenWeatherObject>();
                    _weatherDownloader.DownloadDataByCity(_city);
                    _weatherData = _dataBinder.DeserializeJSON(_weatherDownloader.PushURL());
                }
                catch (Exception ex)
                {
                    MessageBox.Show($"Error: {ex.Message}");
                    return(false);
                }
            }

            if (CitiesComboBox.SelectedItem == null || CitiesComboBox.SelectedItem.ToString().Length == 0)
            {
                MessageBox.Show("You have not selected city!");
                return(false);
            }

            return(true);
        }
Esempio n. 17
0
        private IDateWeatherData parseToDateWeatherData(string connectionString)
        {
            using (XmlReader xmlReader = XmlReader.Create(connectionString + "&units=standard")) // sample api call = http://api.openweathermap.org/data/2.5/forecast?q=Krosno&lang=pl&APPID=29a20f74935ebf1b87a71157e2d58600&mode=xml&units=standard
            {
                xmlReader.ReadToFollowing("forecast");

                DateWeatherData dateWeatherData = new DateWeatherData();
                for (int i = 0; i < CountOfForecastSections3Hours5Days; i++)
                {
                    DateTime forecastDateTime = DateTime.Parse(
                        xmlReader.ParseApiData("time", "from"));
                    IWeatherData date = ParseXMLToWeatherData(xmlReader);
                    dateWeatherData.Add(forecastDateTime, date);
                }
                return(dateWeatherData);
            }
        }
Esempio n. 18
0
        public void Update(IWeatherData observable, WeatherDataObject obj)
        {
            if (observable is WeatherData && obj != null)
            {
                this._numberOfReadings++;
                if (obj.temp > _maxTemp)
                {
                    this._maxTemp = obj.temp;
                }

                if (obj.temp < _minTemp)
                {
                    this._minTemp = obj.temp;
                }

                this._averageTemp = (_minTemp + _maxTemp) / _numberOfReadings;
            }

            Display();
        }
Esempio n. 19
0
        public WeatherAggregate_Test_Data()
        {
            var mock = new Mock <IWeatherData>();

            mock.Setup(x => x.GetForecastsAsync(It.IsAny <String>())).ReturnsAsync(new List <WeatherDataQuery>()
            {
                new WeatherDataQuery
                {
                    Temperature = 68,
                    WindSpeed   = 10,
                    TempMetric  = 2,
                    SpeedMetric = 1
                },
                new WeatherDataQuery
                {
                    Temperature = 10,
                    WindSpeed   = 8,
                    TempMetric  = 1,
                    SpeedMetric = 2
                }
            });
            DataAccess = mock.Object;
        }
Esempio n. 20
0
        public void AddDataEntry(string data)
        {
            // I really do not like this, if I get time I will return and do something better... #sloppy
            IWeatherData genericData = null;

            if (data.Contains("location"))
            {
                // BBC
                var results = JsonConvert.DeserializeObject <BbcWeatherResult>(data);
                genericData = _dataConverters.BBCToGeneric(results);
            }
            else if (data.Contains("where"))
            {
                //ACCu
                var results = JsonConvert.DeserializeObject <AccWeatherResult>(data);
                genericData = _dataConverters.AccuToGeneric(results);
            }

            if (genericData != null)
            {
                _weatherAppModel.AddSpeedData(genericData.WindspeedKPH);
                _weatherAppModel.AddTemperatureData(genericData.TemperatureCelsius);
            }
        }
 public WeatherFromProviderInfo(IDataProviderInfo dataProviderInfo, IWeatherData weatherData)
 {
     DataProviderInfo = dataProviderInfo;
     WeatherData = weatherData;
 }
Esempio n. 22
0
 public void update(IWeatherData weatherData)
 {
     Humidity = weatherData.GetHumidity();
     Display();
 }
Esempio n. 23
0
 void getWeatherData()
 {
     WeatherData = _weatherConnection.GetWeatherData();
         OnPropertyChanged("WeatherData");
 }
Esempio n. 24
0
 public ExportData(IWeatherData weatherData)
 {
     _weatherData = weatherData;
 }
Esempio n. 25
0
 public void Add(DateTime dateTime, IWeatherData weatherData)
 {
     DateTimes.Add(dateTime);
     WeatherDatas.Add(weatherData);
 }
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="weatherData"></param>
 public WeatherService(IWeatherData weatherData)
 {
     _weatherData = weatherData;
 }
Esempio n. 27
0
 public void Subscribe(IWeatherData weatherData)
 {
     weatherData.AddDisplay(this);
 }
Esempio n. 28
0
 public IndexModel(IWeatherData weatherData)
 {
     _weatherData = weatherData;
 }
Esempio n. 29
0
 public void Unsubscribe(IWeatherData weatherData)
 {
     weatherData.RemoveDisplay(this);
 }
Esempio n. 30
0
 public Weather(IServiceProvider serviceProvider, HomeAutomationPlatform hub, string id) : base(hub, id)
 {
     Data = serviceProvider.GetService <IWeatherData>();
 }
Esempio n. 31
0
 public WeatherFromProviderInfo(IDataProviderInfo dataProviderInfo, IWeatherData weatherData)
 {
     DataProviderInfo = dataProviderInfo;
     WeatherData      = weatherData;
 }
Esempio n. 32
0
 public void Add(DateTime dateTime, IWeatherData weatherData)
 {
     DateTimes.Add(dateTime);
     WeatherDatas.Add(weatherData);
 }
 public void Setup()
 {
     _sut = new InMemoryWeatherData();
 }
Esempio n. 34
0
 internal override void Initialize(Rainmeter.API api)
 {
     base.Initialize(api);
     _data = new TencentWeather();
     _data.WeatherArrive += OnSourceUpdate;
 }