public IEnumerable <RangeEntry> ScanRanges(DateTime start, DateTime end, string[] ids)
        {
            if (ids == null || ids.Length == 0)
            {
                yield break;
            }

            var pending = new PendingEnumerators();

            for (int i = 0; i < ids.Length; i++)
            {
                var enumerator = ScanRange(start, end, ids[i]).GetEnumerator();
                if (enumerator.MoveNext() == false)
                {
                    continue;
                }
                pending.Enqueue(new PendingEnumerator
                {
                    Enumerator = enumerator,
                    Index      = i
                });
            }

            var result = new RangeEntry
            {
                Values = new double?[ids.Length]
            };

            while (pending.IsEmpty == false)
            {
                Array.Clear(result.Values, 0, result.Values.Length);
                var entries = pending.Dequeue();
                if (entries.Count == 0)
                {
                    break;
                }
                foreach (var entry in entries)
                {
                    var current = entry.Enumerator.Current;
                    result.Timestamp           = current.Timestamp;
                    result.Values[entry.Index] = current.Value;
                    if (entry.Enumerator.MoveNext())
                    {
                        pending.Enqueue(entry);
                    }
                }
                yield return(result);
            }
        }
        private static List <RangeEntry> SetRanges([ItemNotNull][NotNull] List <House> houses, [NotNull] Dictionary <string, double> pvPotentialByHouse)
        {
            var    rangeEntries      = new List <RangeEntry>();
            double currentRangeValue = 0;

            foreach (var house in houses)
            {
                var weight = pvPotentialByHouse[house.HouseGuid];
                var entry  = new RangeEntry(house, weight, currentRangeValue, currentRangeValue + weight);
                currentRangeValue += weight;
                rangeEntries.Add(entry);
            }

            return(rangeEntries);
        }
        public IEnumerable<RangeEntry> ScanRanges(DateTime start, DateTime end, string[] ids)
        {
            if (ids == null || ids.Length == 0)
                yield break;

            var pending = new PendingEnumerators();
            for (int i = 0; i < ids.Length; i++)
            {
                var enumerator = ScanRange(start, end, ids[i]).GetEnumerator();
                if(enumerator.MoveNext() == false)
                    continue;
                pending.Enqueue(new PendingEnumerator
                {
                    Enumerator = enumerator,
                    Index = i
                });
            }

            var result = new RangeEntry
            {
                Values = new double?[ids.Length]
            };
            while (pending.IsEmpty == false)
            {
                Array.Clear(result.Values,0,result.Values.Length);
                var entries = pending.Dequeue();
                if (entries.Count == 0)
                    break;
                foreach (var entry in entries)
                {
                    var current = entry.Enumerator.Current;
                    result.Timestamp = current.Timestamp;
                    result.Values[entry.Index] = current.Value;
                    if(entry.Enumerator.MoveNext())
                        pending.Enqueue(entry);
                }
                yield return result;
            }
        }
Exemple #4
0
 protected static SetEntry Except(RangeEntry rangeEntry)
 {
     return(Except(new SetEntry(new[] { rangeEntry })));
 }