示例#1
0
        /// <summary>
        /// gets Hourly Power Usage (prioritises Temperature manager, calculates other devices power usage).
        /// </summary>
        /// <param name="weatherData"></param>
        /// <returns>PowerUsage in kW</returns>
        private static float getHourlyPowerUsage(Weather.WeatherData weatherData)
        {
            float powerUsage   = 0;
            int   expectedTemp = ExpectedTemperatureData.getExpectedTemperature(Calendar.WhatDay(weatherData.TimeStamp), weatherData.TimeStamp.Hour);

            powerUsage += OtherDevicesPowerData.getOtherDevicesPower(Calendar.WhatDay(weatherData.TimeStamp), weatherData.TimeStamp.Hour);
            //If we want to increase home temperature
            if (Home.Temperature < expectedTemp - 1)
            {
                powerUsage += HeatPowerData.getHeatingPower((int)weatherData.Temperature).heatingPower;
            }
            //If temp difference is smaller or equal to 1
            if (Math.Abs((decimal)(Home.Temperature - expectedTemp)) <= 1)
            {
                powerUsage += HeatPowerData.getHeatingPower((int)weatherData.Temperature).maintainTempPower;
            }

            try
            {
                Home.decreaseTemperature(1 / HeatPowerData.getHeatingPower((int)weatherData.Temperature).decreasingTime);
            }
            catch (InvalidOperationException)
            {
            }

            return(powerUsage);
        }
示例#2
0
        /// <summary>
        /// Manages home Temperature every hour.
        /// </summary>
        /// <param name="weatherData">weather data required to decide the action.</param>
        private static void homeTemperatureManager(Weather.WeatherData weatherData)
        {
            int expectedTemp = ExpectedTemperatureData.getExpectedTemperature(Calendar.WhatDay(weatherData.TimeStamp), weatherData.TimeStamp.Hour);

            if (Home.Temperature < expectedTemp - 1)
            {
                Home.addTemperature();
            }
            else if (Home.Temperature > expectedTemp + 1)
            {
                try
                {
                    Home.decreaseTemperature(1 / HeatPowerData.getHeatingPower(expectedTemp).decreasingTime);
                }
                catch (InvalidOperationException)
                {
                }
            }
        }