Beispiel #1
0
        int CalcTotalSlots2(out List <DateTime> timestamps)
        {
            timestamps = new List <DateTime>();
            var plots = Graphs.SelectMany(g => g.Plots).OrderBy(p => p.DataSeries.Elements.ToArray().First().Timestamp).ToArray();

            if (plots.Length == 0)
            {
                return(0);
            }
            else
            {
                int count = 0;
                for (int i = 0; i < plots.Length - 1; i++)
                {
                    PlotBoundaries[plots[i]] = new PlotInfo {
                        Left = count, Right = count + plots[i].DataSeries.Elements.ToArray().Count() - 1
                    };

                    //DateTime nextFirst = plots[i + 1].DataSeries.Elements.ToArray().First().Timestamp;
                    DateTime?nextFirst    = null;
                    var      nextExtender = plots.Skip(i).FirstOrDefault(p =>
                                                                         p.DataSeries.Elements.Last().Timestamp > plots[i].DataSeries.Elements.Last().Timestamp);
                    if (nextExtender != null)
                    {
                        nextFirst = nextExtender.DataSeries.Elements.First().Timestamp;
                    }
                    foreach (var el in plots[i].DataSeries.Elements.ToArray())
                    {
                        if (nextFirst.HasValue && el.Timestamp == nextFirst.Value)
                        {
                            break;
                        }
                        else
                        {
                            timestamps.Add(el.Timestamp);
                            count++;
                        }
                    }
                }
                timestamps.AddRange(plots.Last().DataSeries.Elements.ToArray().Select(e => e.Timestamp));
                var lastCount = plots.Last().DataSeries.Elements.ToArray().Count();
                PlotBoundaries[plots.Last()] = new PlotInfo {
                    Left = count, Right = count + lastCount - 1
                };
                count += lastCount;
                return(count);
            }
        }
Beispiel #2
0
        int CalcTotalSlots(out List <DateTime> timestamps)
        {
            var plots = Graphs.SelectMany(g => g.Plots).OrderBy(p => p.DataSeries.Elements.ToArray().First().Timestamp).ToArray();

            var z = Lists.Mesh(plots, p => p.DataSeries.Elements, dse => dse.Timestamp, dt => dt.AddDays(1), (ps, dses) => new { Plots = ps, Elements = dses.ToList() })
                    .Where(x => x.Plots.Any()).Select(x => new { Plots = x.Plots, Elements = x.Elements, Timestamp = x.Elements.First().Timestamp }).ToList();

            timestamps = z.Select(x => x.Timestamp).ToList();

            foreach (var p in plots)
            {
                var left = z.FindIndex(x => x.Plots.Contains(p));
                PlotBoundaries[p] = new PlotInfo {
                    Left = left, Right = left + p.DataSeries.Length - 1
                };
            }
            return(z.Count);
        }