Beispiel #1
0
        public IEnumerable <DataPoint> Daily([FromUri] DateTime start, [FromUri] DateTime end, [FromBody] string[] FactoryList)
        {
            try
            {
                var energy = EnergyUtils.EnergyHistory(start, end, FactoryList);

                List <DataPoint> result = new List <DataPoint>();

                DateTime time = new DateTime(start.Year, start.Month, start.Day);

                do
                {
                    foreach (string factory in FactoryList)
                    {
                        if (factory != null)
                        {
                            result.Add(new DataPoint {
                                DateTime = time, TagName = factory, Value = EnergyUtils.GetEnergyByDay(energy, time, factory)
                            });
                        }
                    }

                    time = time.AddDays(1);
                } while (time.CompareTo(end) < 0);

                return(result);
            }
            catch { return(new List <DataPoint>()); }
        }
Beispiel #2
0
        public IEnumerable <DataPoint> HourlySummary([FromUri] DateTime start, [FromUri] DateTime end, [FromBody] string[] FactoryList)
        {
            try
            {
                var energy = EnergyUtils.EnergyHistory(start, end, FactoryList);

                List <DataPoint> result = new List <DataPoint>();

                DateTime time = new DateTime(start.Year, start.Month, start.Day);

                do
                {
                    // Total Energy per Hour
                    result.Add(new DataPoint {
                        DateTime = time, TagName = "ETOTAL", Value = EnergyUtils.GetTotalEnergyByHour(energy, time)
                    });

                    time = time.AddHours(1);
                } while (time.CompareTo(end) < 0);

                return(result);
            }
            catch { return(new List <DataPoint>()); }
        }