Ejemplo n.º 1
0
 internal void AddValue(string fieldName, double value, DateTime timestamp)
 {
     if (StatisticsLogger.IsValidField(fieldName))
     {
         // add value for StatisticsLogger use
         statValues.Add(new StatValue(value, timestamp));
     }
     // "value" is the occurring event in this very moment,
     // so "Current" is holding previous value right now
     if (Current.Value != value)
     {
         lastEvent = new StatValue(Current.Value, Current.Timestamp);
         if (value == 0 && lastEvent.Value > 0)
         {
             lastOn  = lastEvent;
             lastOff = new StatValue(value, timestamp);
         }
         else if (value > 0 && lastEvent.Value == 0)
         {
             lastOff = lastEvent;
             lastOn  = new StatValue(value, timestamp);
         }
     }
     // keeep size within historyLimit (minutes)
     try
     {
         while ((DateTime.UtcNow - historyValues[historyValues.Count - 1].Timestamp).TotalMinutes > historyLimit)
         {
             historyValues.RemoveAll(sv => (DateTime.UtcNow - sv.Timestamp).TotalMinutes > historyLimit);
         }
         // leave this wrapped in a try..catch
     } catch { }
     // insert current value into history and so update "Current" to "value"
     historyValues.Insert(0, new StatValue(value, timestamp));
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Remove all parameters from this store.
 /// </summary>
 public void Reset()
 {
     storeList.RemoveAll(s => s.Name == storeName);
 }