Esempio n. 1
0
        public static DayAhead operator -(DayAhead c1, DayAhead c2)
        {
            DayAhead result = new DayAhead();

            if (c1.Hourly.Count == 0 && c2.Hourly.Count != 0)
            {
                for (int i = 0; i < 24; i++)
                {
                    HourDataPoint dataPoint = new HourDataPoint();
                    dataPoint.ActivePower   = c2.Hourly[i].ActivePower;
                    dataPoint.ReactivePower = c2.Hourly[i].ReactivePower;
                    dataPoint.Time          = c2.Hourly[i].Time;
                    result.Hourly.Add(dataPoint);
                }
            }
            else
            {
                for (int i = 0; i < 24; i++)
                {
                    HourDataPoint dataPoint = new HourDataPoint();
                    dataPoint.ActivePower   = c1.Hourly[i].ActivePower - c2.Hourly[i].ActivePower;
                    dataPoint.ReactivePower = c1.Hourly[i].ReactivePower - c2.Hourly[i].ReactivePower;
                    dataPoint.Time          = c1.Hourly[i].Time;
                    result.Hourly.Add(dataPoint);
                }
            }
            return(result);
        }
Esempio n. 2
0
        public DayAhead GetDayAhead()
        {
            DayAhead consumerDayAhead = new DayAhead();

            foreach (KeyValuePair <TimeSpan, double> HourToActivePower in Hourly)
            {
                HourDataPoint dataPoint = new HourDataPoint();
                if (HourToActivePower.Key.Hours >= DateTime.Now.Hour || HourToActivePower.Key.Hours == 0)
                {
                    dataPoint.Time = DateTime.Now.Date + HourToActivePower.Key;
                }
                else
                {
                    DateTime date = DateTime.Now;
                    dataPoint.Time = date.Date + HourToActivePower.Key;
                }
                if (dataPoint.Time.Hour.Equals(23))
                {
                    HourDataPoint dataPointTemp = new HourDataPoint();
                    TimeSpan      timeSpan      = new TimeSpan(23, 0, 0);

                    dataPointTemp.Time          = dataPoint.Time.AddDays(-1).Date + timeSpan;
                    dataPointTemp.ActivePower   = (float)HourToActivePower.Value;
                    dataPointTemp.ReactivePower = (float)HourToActivePower.Value / 50;

                    consumerDayAhead.Hourly.Add(dataPointTemp);
                }
                //else if (dataPoint.Time.Hour.Equals(22))
                //{
                //    HourDataPoint dataPointTemp = new HourDataPoint();
                //    TimeSpan timeSpan = new TimeSpan(22, 0, 0);

                //    dataPointTemp.Time = dataPoint.Time.AddDays(-1).Date + timeSpan;
                //    dataPointTemp.ActivePower = (float)HourToActivePower.Value;
                //    dataPointTemp.ReactivePower = (float)HourToActivePower.Value / 50;

                //    consumerDayAhead.Hourly.Add(dataPointTemp);
                //}
                else
                {
                    dataPoint.ActivePower   = (float)HourToActivePower.Value;
                    dataPoint.ReactivePower = (float)HourToActivePower.Value / 50;

                    consumerDayAhead.Hourly.Add(dataPoint);
                }
            }

            consumerDayAhead.Hourly = consumerDayAhead.Hourly.OrderBy(o => o.Time).ToList();
            return(consumerDayAhead);
        }
        public DayAhead CloneHourly(DayAhead dayAhead)
        {
            DayAhead result = new DayAhead();

            if (!dayAhead.Hourly.Count.Equals(0))
            {
                for (int i = 0; i < 24; i++)
                {
                    HourDataPoint dataPoint = new HourDataPoint();
                    dataPoint.ActivePower   = dayAhead.Hourly[i].ActivePower;
                    dataPoint.ReactivePower = dayAhead.Hourly[i].ReactivePower;
                    dataPoint.Time          = dayAhead.Hourly[i].Time;
                    result.Hourly.Add(dataPoint);
                }
            }

            return(result);
        }