Beispiel #1
0
        /// <summary>
        /// Updates TBD Weather Day from SAM WeatherDay
        /// </summary>
        /// <param name="weatherDay_TBD">Destination TBD WeatherDay</param>
        /// <param name="weatherDay">Source SAM WeatherDay </param>
        /// <returns>True if data updated</returns>
        public static bool Update(this TBD.WeatherDay weatherDay_TBD, WeatherDay weatherDay)
        {
            if (weatherDay_TBD == null || weatherDay == null)
            {
                return(false);
            }

            for (int i = 1; i <= 24; i++)
            {
                double value = double.NaN;

                if (weatherDay.TryGetValue(WeatherDataType.CloudCover, i - 1, out value))
                {
                    weatherDay_TBD.cloudCover[i] = System.Convert.ToSingle(value);
                }

                if (weatherDay.TryGetValue(WeatherDataType.DryBulbTemperature, i - 1, out value))
                {
                    weatherDay_TBD.dryBulb[i] = System.Convert.ToSingle(value);
                }

                if (weatherDay.TryGetValue(WeatherDataType.WindSpeed, i - 1, out value))
                {
                    weatherDay_TBD.windSpeed[i] = System.Convert.ToSingle(value);
                }

                if (weatherDay.TryGetValue(WeatherDataType.DiffuseSolarRadiation, i - 1, out value))
                {
                    weatherDay_TBD.diffuseRadiation[i] = System.Convert.ToSingle(value);
                }

                if (weatherDay.TryGetValue(WeatherDataType.GlobalSolarRadiation, i - 1, out value))
                {
                    weatherDay_TBD.globalRadiation[i] = System.Convert.ToSingle(value);
                }
                else
                {
                    value = weatherDay.CalculatedGlobalRadiation(i - 1);
                    weatherDay_TBD.globalRadiation[i] = System.Convert.ToSingle(value);
                }

                if (weatherDay.TryGetValue(WeatherDataType.RelativeHumidity, i - 1, out value))
                {
                    weatherDay_TBD.humidity[i] = System.Convert.ToSingle(value);
                }


                if (weatherDay.TryGetValue(WeatherDataType.WindDirection, i - 1, out value))
                {
                    weatherDay_TBD.windDirection[i] = System.Convert.ToSingle(value);
                }
            }

            return(true);
        }
Beispiel #2
0
        /// <summary>
        /// Updates SAM WeatherDay from TBD WeatherDay
        /// </summary>
        /// <param name="weatherDay">Destination SAM WeatherDay</param>
        /// <param name="weatherDay_TBD">Source TBD WeatherDay</param>
        /// <returns>True if data Updated</returns>
        public static bool Update(this WeatherDay weatherDay, TBD.WeatherDay weatherDay_TBD)
        {
            if (weatherDay_TBD == null || weatherDay == null)
            {
                return(false);
            }

            for (int i = 1; i <= 24; i++)
            {
                weatherDay[WeatherDataType.CloudCover, i - 1]            = weatherDay_TBD.cloudCover[i];
                weatherDay[WeatherDataType.DryBulbTemperature, i - 1]    = weatherDay_TBD.dryBulb[i];
                weatherDay[WeatherDataType.WindSpeed, i - 1]             = weatherDay_TBD.windSpeed[i];
                weatherDay[WeatherDataType.DiffuseSolarRadiation, i - 1] = weatherDay_TBD.diffuseRadiation[i];
                weatherDay[WeatherDataType.GlobalSolarRadiation, i - 1]  = weatherDay_TBD.globalRadiation[i];
                weatherDay[WeatherDataType.RelativeHumidity, i - 1]      = weatherDay_TBD.humidity[i];
                weatherDay[WeatherDataType.WindDirection, i - 1]         = weatherDay_TBD.windDirection[i];
            }

            return(true);
        }
Beispiel #3
0
        public static List <TBD.WeatherDay> WeatherDays(this TBD.WeatherYear weatherYear)
        {
            if (weatherYear == null)
            {
                return(null);
            }

            List <TBD.WeatherDay> result = new List <TBD.WeatherDay>();

            int index = 1;

            TBD.WeatherDay weatherDay = weatherYear.weatherDays(index);
            while (weatherDay != null)
            {
                result.Add(weatherDay);
                index++;

                weatherDay = weatherYear.weatherDays(index);
            }

            return(result);
        }
Beispiel #4
0
        public static DesignDay ToSAM(this TBD.DesignDay designDay, string name = null, int year = 2018)
        {
            if (designDay == null)
            {
                return(null);
            }

            string name_Temp = name;

            if (string.IsNullOrWhiteSpace(name_Temp))
            {
                name_Temp = designDay.name;
            }

            int      dayOfYear = designDay.yearDay;
            DateTime dateTime  = new DateTime(year, 1, 1);

            dateTime = dateTime.AddDays(dayOfYear - 1);

            TBD.WeatherDay weatherDay_TBD = designDay.GetWeatherDay();

            DesignDay result = new DesignDay(name_Temp, System.Convert.ToInt16(dateTime.Year), System.Convert.ToByte(dateTime.Month), System.Convert.ToByte(dateTime.Day));

            for (int i = 1; i <= 24; i++)
            {
                result[WeatherDataType.CloudCover, i - 1]            = weatherDay_TBD.cloudCover[i];
                result[WeatherDataType.DryBulbTemperature, i - 1]    = weatherDay_TBD.dryBulb[i];
                result[WeatherDataType.WindSpeed, i - 1]             = weatherDay_TBD.windSpeed[i];
                result[WeatherDataType.DiffuseSolarRadiation, i - 1] = weatherDay_TBD.diffuseRadiation[i];
                result[WeatherDataType.GlobalSolarRadiation, i - 1]  = weatherDay_TBD.globalRadiation[i];
                result[WeatherDataType.RelativeHumidity, i - 1]      = weatherDay_TBD.humidity[i];
                result[WeatherDataType.WindDirection, i - 1]         = weatherDay_TBD.windDirection[i];
            }

            return(result);
        }
 internal WeatherDay(TBD.WeatherDay WeatherDay)
 {
     pWeatherDay = WeatherDay;
 }