示例#1
0
        /// <summary>
        /// Generate a series of datapoints for use on a graph
        /// </summary>
        /// <param name="startTime"></param>
        /// <returns></returns>
        public Series getSeries(DateTime startTime)
        {
            TimeSpan startTSAgo = TimeSpan.FromTicks(stats.granularity.Ticks * stats.graphYAxisCount);
            string   title      = this.moduleType.StartsWith("Roboto.") ? this.moduleType.Substring(7) : this.moduleType;
            Series   s          = new Series(title + ">" + this.name);

            s.Color = c;

            if (displayMode == stats.displaymode.line)
            {
                s.BorderWidth = 2;
                s.ChartType   = SeriesChartType.Line;
            }
            for (int i = 0; i < stats.graphYAxisCount; i++)
            {
                DateTime  point = startTime.Subtract(TimeSpan.FromTicks(stats.granularity.Ticks * i));
                statSlice slice = getSlice(point);
                if (slice != null)
                {
                    DataPoint p = new DataPoint(point.Subtract(startTime).TotalHours, slice.count);
                    s.Points.Add(p);
                }
            }

            return(s);
        }
示例#2
0
        public void logStat(statItem item)
        {
            statSlice slice = getSlice();

            if (statMode == stats.statmode.increment)
            {
                slice.addCount(item.items);
            }
            else if (statMode == stats.statmode.absolute)
            {
                slice.setCount(item.items);
            }
        }
示例#3
0
        public statSlice getSlice(DateTime time)
        {
            List <statSlice> matches = statSlices.Where(x => time > x.timeSlice && time < x.timeSlice.Add(stats.granularity)).ToList();

            if (matches.Count == 0)
            {
                statSlice s = new statSlice(time);
                statSlices.Add(s);
                return(s);
            }
            else if (matches.Count == 1)
            {
                return(matches[0]);
            }
            else
            {
                Roboto.log.log("More than one match for timeslice!", logging.loglevel.warn);
                return(matches[0]);
            }
        }
示例#4
0
文件: stats.cs 项目: davep1ke/roboto
 public statSlice getSlice(DateTime time)
 {
     List<statSlice> matches = statSlices.Where(x => time > x.timeSlice && time < x.timeSlice.Add (stats.granularity)).ToList();
     if (matches.Count == 0)
     {
         statSlice s = new statSlice(time);
         statSlices.Add(s);
         return s;
     }
     else if (matches.Count == 1)
     {
         return matches[0];
     }
     else
     {
         Roboto.log.log("More than one match for timeslice!", logging.loglevel.warn);
         return matches[0];
     }
 }