Beispiel #1
0
        public void AddRawData(Business.RawData raw)
        {
            foreach (KeyValuePair <string, DAO.CalculType> kv in Type)
            {
                if (!ResultCalculType.ContainsKey(raw.MacAddress))
                {
                    ResultCalculType.Add(raw.MacAddress, new Dictionary <string, double>());
                }
                if (!ResultCalculType[raw.MacAddress].ContainsKey(kv.Value.Period))
                {
                    ResultCalculType[raw.MacAddress].Add(kv.Value.Period, 0);
                }
                double temp = ResultCalculType[raw.MacAddress][kv.Value.Period];

                if (!Cache.ContainsKey(raw.MacAddress))
                {
                    Cache.Add(raw.MacAddress, new Dictionary <string, List <RawData> >());
                }
                if (!Cache[raw.MacAddress].ContainsKey(kv.Value.Period))
                {
                    Cache[raw.MacAddress].Add(kv.Value.Period, new List <RawData>());
                }
                Cache[raw.MacAddress][kv.Value.Period].Add(raw);

                temp = temp + raw.MetricValue;

                if (Cache[raw.MacAddress][kv.Value.Period].Count - 1 >= kv.Value.PeriodSecondCount)
                {
                    temp = temp - Cache[raw.MacAddress][kv.Value.Period][0].MetricValue;
                    Cache[raw.MacAddress][kv.Value.Period].RemoveAt(0);
                }
                ResultCalculType[raw.MacAddress][kv.Value.Period] = temp;
            }
        }
Beispiel #2
0
 public double GetCalculated(string macAddress, string period)
 {
     if (ResultCalculType.ContainsKey(macAddress))
     {
         if (ResultCalculType[macAddress].ContainsKey(period))
         {
             return(ResultCalculType[macAddress][period] / Cache[macAddress][period].Count);
         }
         else
         {
             return(0);
         }
     }
     else
     {
         return(0);
     }
 }