Example #1
0
 private void FilterAndAddReading(ReadingFromSensor reading)
 {
     if (ReadingFromCheckedLocation(reading) && IsNotDuplicate(reading))
     {
         Readings.Add(reading);
         Console.WriteLine("Collected reading.");
     }
     else
     {
         Console.WriteLine("Found reading from an unchecked sensor.");
     }
 }
Example #2
0
        private void RemoveOneExpiredReading(ReadingFromSensor reading)
        {
            if (Readings.Count == 0)
            {
                return;
            }
            var first = Readings.FirstOrDefault(r => r.Timestamp < reading.Timestamp - _expiryTime);

            if (first != null)
            {
                Readings.Remove(first);
            }
        }
Example #3
0
        private void RemoveOneExpiredReading(ReadingFromSensor reading)
        {
            var currentTimestamp = DateTimeOffset.Now.ToUnixTimeMilliseconds();

            if (Readings.Count == 0)
            {
                return;
            }
            var first = Readings.FirstOrDefault(r => r.Timestamp < currentTimestamp - _expiryTime);

            if (first != null)
            {
                Readings.Remove(first);
            }
        }
Example #4
0
 private bool IsNotDuplicate(ReadingFromSensor reading)
 {
     return(!Readings.Contains(reading));
 }
Example #5
0
 private bool ReadingFromCheckedLocation(ReadingFromSensor reading)
 {
     return(_locationIds.Contains(reading.LocationId));
 }