コード例 #1
0
        private static List <DimFeedback> GetDimFeedbackForWeekend(DateTime initDate, double latitude, double longitude, bool usesTimeZoneHandler)
        {
            DateTime sunset   = usesTimeZoneHandler ? TimeZoneHandler.Sunset(latitude, longitude, initDate) : new DateTime(initDate.Year, initDate.Month, initDate.Day, 18, 01, 00);
            DateTime midnight = new DateTime(initDate.Year, initDate.Month, initDate.Day, 00, 00, 00).AddDays(1);
            DateTime six      = new DateTime(initDate.Year, initDate.Month, initDate.Day, 06, 00, 00).AddDays(1);
            DateTime sunrise  = usesTimeZoneHandler ? TimeZoneHandler.Sunrise(latitude, longitude, initDate.AddDays(1)) : new DateTime(initDate.Year, initDate.Month, initDate.Day, 7, 01, 00).AddDays(1);

            DateTime date3 = six <= sunrise ? six : sunrise;
            DateTime date4 = six <= sunrise ? sunrise : six;

            double hoursFromSunsetTillMidnight = (midnight - sunset).TotalMinutes / 60;
            double hoursFromMidnightTillDate3  = (date3 - midnight).TotalMinutes / 60;
            double hoursFromDate3TillDate4     = (date4 - date3).TotalMinutes / 60;

            List <DimFeedback> dimFeedbacks = new List <DimFeedback>();

            dimFeedbacks.Add(new DimFeedback()
            {
                Date = sunset, DimLevel = 100, EnergyConsumption = 0, ACPower = 85.8, ACCurrent = 0.379, ACCPowerFactor = 1
            });
            dimFeedbacks.Add(new DimFeedback()
            {
                Date = midnight, DimLevel = 70, EnergyConsumption = Math.Round(0.0858 * hoursFromSunsetTillMidnight, 2), ACPower = 85.8 * 0.7, ACCurrent = 0.379 * 0.7, ACCPowerFactor = 0.379 * 0.7
            });
            dimFeedbacks.Add(new DimFeedback()
            {
                Date = date3, DimLevel = 100, EnergyConsumption = Math.Round(0.0858 * 0.7 * hoursFromMidnightTillDate3, 2), ACPower = 85.8, ACCurrent = 0.379, ACCPowerFactor = 1.0
            });
            dimFeedbacks.Add(new DimFeedback()
            {
                Date = date4, DimLevel = 0, EnergyConsumption = Math.Round(0.0858 * hoursFromDate3TillDate4, 2), ACPower = 0.0, ACCurrent = 0.0, ACCPowerFactor = 0.0
            });

            return(dimFeedbacks);
        }
コード例 #2
0
        private static List <DimFeedback> GetDimFeedbackForWeekdays(DateTime initDate, double latitude, double longitude, bool usesTimeZoneHandler)
        {
            DateTime sunset    = usesTimeZoneHandler ?  TimeZoneHandler.Sunset(latitude, longitude, initDate) : new DateTime(initDate.Year, initDate.Month, initDate.Day, 18, 01, 00);
            DateTime twentytwo = new DateTime(initDate.Year, initDate.Month, initDate.Day, 22, 00, 00);
            DateTime five      = new DateTime(initDate.Year, initDate.Month, initDate.Day, 05, 00, 00).AddDays(1);
            DateTime sunrise   = usesTimeZoneHandler ?  TimeZoneHandler.Sunrise(latitude, longitude, initDate.AddDays(1)) : new DateTime(initDate.Year, initDate.Month, initDate.Day, 7, 01, 00).AddDays(1);

            DateTime date3 = five <= sunrise ? five : sunrise;
            DateTime date4 = five <= sunrise ? sunrise : five;

            double hoursFromSunsetTillTwentyTwo = (twentytwo - sunset).TotalMinutes / 60;
            double hoursFromTwentyTwoTillDate3  = (date3 - twentytwo).TotalMinutes / 60;
            double hoursFromDate3TillDate4      = (date4 - date3).TotalMinutes / 60;

            List <DimFeedback> dimFeedbacks = new List <DimFeedback>();

            dimFeedbacks.Add(new DimFeedback()
            {
                Date = sunset, DimLevel = 100, EnergyConsumption = 0, ACPower = 85.8, ACCurrent = 0.379, ACCPowerFactor = 1
            });
            dimFeedbacks.Add(new DimFeedback()
            {
                Date = twentytwo, DimLevel = 70, EnergyConsumption = Math.Round(0.0858 * hoursFromSunsetTillTwentyTwo, 2), ACPower = 85.8 * 0.7, ACCurrent = 0.379 * 0.7, ACCPowerFactor = 0.379 * 0.7
            });
            dimFeedbacks.Add(new DimFeedback()
            {
                Date = date3, DimLevel = 100, EnergyConsumption = Math.Round(0.0858 * 0.7 * hoursFromTwentyTwoTillDate3, 2), ACPower = 85.8, ACCurrent = 0.379, ACCPowerFactor = 1.0
            });
            dimFeedbacks.Add(new DimFeedback()
            {
                Date = date4, DimLevel = 0, EnergyConsumption = Math.Round(0.0858 * hoursFromDate3TillDate4, 2), ACPower = 0.0, ACCurrent = 0.0, ACCPowerFactor = 0.0
            });

            return(dimFeedbacks);
        }