internal AnalyticsCounter(DeviceCounterBase deviceCounter, IIntervalTimer timer) { _deviceCounter = deviceCounter; _timer = timer; _numberOfReads = deviceCounter.LogInterval / deviceCounter.ReadInterval; _timer.Interval = (deviceCounter.LogInterval / _numberOfReads) * 1000; }
public AnalyticsCounter CreateCounter(DeviceCounterBase deviceCounter) { if (deviceCounter is DevicePerformanceCounter) { return(new PerformanceAnalyticsCounter(deviceCounter as DevicePerformanceCounter)); } return(null); }
private StatusData.Status GetCurrentDeviceCounterStatus(DeviceCounterBase counter) { var result = _context.Results .Where(r => r.DeviceCounter.Id == counter.Id) .Where(r => r.LogDate >= EntityFunctions.AddMinutes(DateTime.Now, -5)) .Select(r => r.AverageRead) .FirstOrDefault(); if (result <= counter.MinThreshold) { return(StatusData.Status.Green); } return(result >= counter.MaxThreshold ? StatusData.Status.Red : StatusData.Status.Yellow); }
public static string GetDescription(this DeviceCounterBase counter) { var actual = counter as DevicePerformanceCounter; if (actual != null) { if (!string.IsNullOrEmpty(actual.InstanceName)) { return(string.Format("{1}-{2} ({0})", actual.InstanceName, actual.Category, actual.Name)); } return(string.Format("{0}-{1} Performance Counter", actual.Category, actual.Name)); } return("Unknown Counter Type"); }
protected AnalyticsCounter(DeviceCounterBase deviceCounter) : this(deviceCounter, new IntervalTimer()) { }