예제 #1
0
        internal override void CalculateValue(double value, DateTime timestamp)
        {
            GaugeDuration aggregateDuration = base.aggregateDuration;

            if (aggregateDuration.IsEmpty || ((IValueConsumer)this).GetProvider() == null)
            {
                base.CalculateValue(value, timestamp);
                return;
            }
            noMoreData = false;
            HistoryCollection data = ((IValueConsumer)this).GetProvider().GetData(aggregateDuration, timestamp);

            HistoryEntry[] array = data.Select(aggregateDuration, timestamp);
            double         num   = value;
            bool           flag  = false;

            HistoryEntry[] array2 = array;
            foreach (HistoryEntry historyEntry in array2)
            {
                if (!double.IsNaN(historyEntry.Value))
                {
                    num  = Math.Max(historyEntry.Value, num);
                    flag = true;
                }
            }
            if (!flag)
            {
                num        = ((data.Count <= 0) ? double.NaN : data.Top.Value);
                noMoreData = true;
            }
            base.CalculateValue(num, timestamp);
        }
예제 #2
0
 HistoryCollection IValueProvider.GetData(GaugeDuration period, DateTime currentDate)
 {
     if (History.Count > 0)
     {
         queryDept.Extend(period, currentDate, History[0].Timestamp);
     }
     return(History);
 }
예제 #3
0
 public virtual void Reset()
 {
     History.Clear();
     queryDept = new GaugeDuration(historyDept.Count, historyDept.DurationType);
     foreach (IValueConsumer consumer in consumers)
     {
         consumer.Reset();
     }
 }
 internal HistoryEntry[] Select(GaugeDuration duration, DateTime currentDate)
 {
     if (!duration.IsInfinity)
     {
         if (duration.IsTimeBased)
         {
             DateTime fromDate = currentDate - duration.ToTimeSpan();
             return(Select(fromDate, currentDate));
         }
         return(Select((int)duration.Count));
     }
     return(Select());
 }
        internal override void CalculateValue(double value, DateTime timestamp)
        {
            GaugeDuration aggregateDuration = base.aggregateDuration;

            if (aggregateDuration.IsEmpty)
            {
                base.CalculateValue(value, timestamp);
                return;
            }
            noMoreData = false;
            double num = value;

            if (((IValueConsumer)this).GetProvider() != null)
            {
                HistoryEntry[] array = ((IValueConsumer)this).GetProvider().GetData(aggregateDuration, timestamp).Select(aggregateDuration, timestamp);
                if (array.Length > 1)
                {
                    num = 0.0;
                    long num2 = 0L;
                    long num3 = 0L;
                    for (int i = 0; i < array.Length - 1; i++)
                    {
                        num2 = array[i + 1].Timestamp.Ticks - array[i].Timestamp.Ticks;
                        if (num2 == 0L)
                        {
                            num += (array[i + 1].Value - array[i].Value) / 2.0;
                            continue;
                        }
                        num  += array[i + 1].Value * (double)num2;
                        num3 += num2;
                    }
                    if (num3 > 0)
                    {
                        num /= (double)num3;
                    }
                }
                else if (array.Length != 0)
                {
                    num = array[0].Value;
                }
                else
                {
                    noMoreData = true;
                }
            }
            base.CalculateValue(num, timestamp);
        }
        internal void Truncate(GaugeDuration d)
        {
            if (d.IsInfinity)
            {
                return;
            }
            if (d.IsEmpty)
            {
                lock (this)
                {
                    Clear();
                }
                return;
            }
            if (d.IsCountBased)
            {
                if (!((double)base.Count > d.Count))
                {
                    return;
                }
                lock (this)
                {
                    while ((double)base.Count > d.Count)
                    {
                        RemoveAt(0);
                    }
                }
                return;
            }
            DateTime t = Top.Timestamp - d.ToTimeSpan();

            if (!(this[0].Timestamp < t))
            {
                return;
            }
            lock (this)
            {
                while (this[0].Timestamp < t)
                {
                    RemoveAt(0);
                }
            }
        }
예제 #7
0
 internal void Extend(GaugeDuration extend, DateTime topDate, DateTime btmDate)
 {
     if (extend.IsInfinity)
     {
         DurationType = DurationType.Infinite;
     }
     else if (extend.IsCountBased && Count < extend.Count)
     {
         Count = extend.Count;
     }
     else if (extend.IsTimeBased)
     {
         DateTime t = topDate - extend.ToTimeSpan();
         if (btmDate > t)
         {
             Count++;
         }
     }
 }