Пример #1
0
 private double GetLast(string dsName, string rpnExpression)
 {
     RpnCalculator rpnCalculator = null;
     if(rpnExpression != null)
     {
         rpnCalculator = new RpnCalculator(rpnExpression);
     }
     double [] vals = GetValues(dsName);
     double val = vals[vals.Length - 1];
     if(rpnCalculator != null)
     {
         rpnCalculator.Value = val;
         val = rpnCalculator.Calculate();
     }
     return val;
 }
Пример #2
0
 private double GetMin(string dsName, string rpnExpression)
 {
     RpnCalculator rpnCalculator = null;
     if(rpnExpression != null)
     {
         rpnCalculator = new RpnCalculator(rpnExpression);
     }
     double [] vals = GetValues(dsName);
     double min = Double.NaN;
     for(int i = 0; i < vals.Length - 1; i++)
     {
         double val = vals[i + 1];
         if(rpnCalculator != null)
         {
             rpnCalculator.Value = val;
             val = rpnCalculator.Calculate();
         }
         min = Util.Min(min, val);
     }
     return min;
 }
Пример #3
0
 private double GetAverage(string dsName, string rpnExpression)
 {
     RpnCalculator rpnCalculator = null;
     if(rpnExpression != null)
     {
         rpnCalculator = new RpnCalculator(rpnExpression);
     }
     double [] vals = GetValues(dsName);
     double totalVal = 0;
     long totalSecs = 0;
     for(int i = 0; i < vals.Length - 1; i++)
     {
         long t1 = Math.Max(request.FetchStart, timestamps[i]);
         long t2 = Math.Min(request.FetchEnd, timestamps[i + 1]);
         double val = vals[i + 1];
         if(rpnCalculator != null)
         {
             rpnCalculator.Value = val;
             val = rpnCalculator.Calculate();
         }
         if(!Double.IsNaN(val))
         {
             totalSecs += (t2 - t1);
             totalVal += (t2 - t1) * val;
         }
     }
     return totalSecs > 0? totalVal / totalSecs: Double.NaN;
 }