// This calculates that start, stop and a pseudo-start that's after 2014 (heuristically trying to find // times when the clock had been jammed). public void LoadStats() { var jamfilter = TimeUtilities.DateTimeToTime42(new DateTime(2014, 1, 1)); //var endFilter = TimeUtilities.DateTimeToTime42(new DateTime(2018, 1, 1)); const long endFilter = 37226859724800L; try { var dict = new Dictionary <int, int>(); var begin = Int64.MaxValue; var jam = Int64.MaxValue; var end = Int64.MinValue; var count = 0; foreach (var packet in Iterator()) { count++; var apid = PacketAccessor.APID(packet); var timestamp = PacketAccessor.Time42(packet); if (timestamp == 0L) { continue; // ignore CLCW packets, no timestamp } if (timestamp < begin) { begin = timestamp; } if (timestamp < endFilter) { if (timestamp > end) { end = timestamp; } if (timestamp < jam && timestamp > jamfilter) { jam = timestamp; } } int prev; if (dict.TryGetValue(apid, out prev)) { dict[apid] = prev + 1; } else { dict.Add(apid, 1); } } if (count > 0) { _BeginTime42 = begin; _EndTime42 = end; _BeginTime42Jammed = jam == long.MaxValue ? jamfilter : jam; } else { _BeginTime42 = 0L; _EndTime42 = 0L; _BeginTime42Jammed = 0L; } _PacketCount = count; _isFullyReadable = true; _ApidCount = dict; _Changed = true; _BeginString = TimeUtilities.Time42ToString(_BeginTime42); _EndString = TimeUtilities.Time42ToString(_EndTime42); _JammedString = TimeUtilities.Time42ToString(_BeginTime42Jammed); //Console.WriteLine("b={0}\nj={1}\ne={2} f={3}", _BeginString, _JammedString, _EndString, Name); } catch (Exception e1) { Console.WriteLine(e1); Console.WriteLine(e1.StackTrace); _isFullyReadable = false; } /* Console.WriteLine(Path); * var a = _PacketCount; * var b = Iterator().Count(); * var c = _ApidCount.Sum(pair => pair.Value); * * Console.WriteLine("_PacketCount={0}", a); * Console.WriteLine("Actual={0}", b); * Console.WriteLine("_ApidCount={0}",c); * if (a != b || b != c) * Console.WriteLine("friday"); * //todo*/ }
public Boolean Touches(DateTime day) { var t = TimeUtilities.DateTimeToTime42(day); return(!(_EndTime42 < t || (t + DayInSubseconds) < _BeginTime42)); }