Пример #1
0
        public virtual IEnumerable <byte[]> Iterator(int[] apids, Int64 startTime, Int64 stopTime, long skip = 0L)
        {
            var counter = 0L;

            foreach (var p in Iterator())
            {
                var timestamp = PacketAccessor.Time42(p);
                if (timestamp < startTime || timestamp > stopTime)
                {
                    continue;
                }
                var apid = PacketAccessor.APID(p);
                var len  = apids.Length;
                for (var i = 0; i < len; i++)
                {
                    if (apid == apids[i])
                    {
                        if (counter++ >= skip)
                        {
                            yield return(p);
                        }
                        break;
                    }
                }
            }
        }
Пример #2
0
 public virtual IEnumerable <byte[]> Iterator(Int64 startTime, Int64 stopTime)
 {
     return(from p in Iterator()
            let timestamp = PacketAccessor.Time42(p)
                            where timestamp >= startTime && timestamp <= stopTime
                            select p);
 }
Пример #3
0
        public IEnumerable <byte[]> Iterator(int[] apids, Int64 startTime, Int64 stopTime, long skip = 0L)
        {
            var counter = 0L;

            return(from p in Iterator()
                   let timestamp = PacketAccessor.Time42(p)
                                   let apid = PacketAccessor.APID(p)
                                              where startTime <= timestamp && timestamp <= stopTime && apids.Contains(apid) && counter++ > skip
                                              select p);
            //return Iterator();
        }
Пример #4
0
        public void CheckPacketLength(byte[] packet, int packetPtr)
        {
            var len = PacketAccessor.PacketFixedHeaderLength + 1 + PacketAccessor.Length(packet);

            //if (len != packetPtr)
            //    throw new Exception("Packet Length Check Exception");
            if (len != packetPtr)
            {
                Console.Error.WriteLine(@"Packet length check exception: apid={0} timestamp={1}", PacketAccessor.APID(packet),
                                        PacketAccessor.Time42(packet));
            }
        }
Пример #5
0
        public IEnumerable <byte[]> Iterator(Int64 startTime, Int64 stopTime)
        {
            //foreach (byte[] p in Iterator())
            //{
            //    var timestamp = PacketAccessor.Time42(p);
            //    if (startTime <= timestamp && timestamp <= stopTime) yield return p;
            //}

            return(from p in Iterator()
                   let timestamp = PacketAccessor.Time42(p)
                                   where startTime <= timestamp && timestamp <= stopTime
                                   select p);

            /*
             * Console.WriteLine("startTime={0} stopTime={1}", startTime, stopTime);
             * Console.WriteLine("startTime={0} stopTime={1}", TimeUtilities.Time42ToString(startTime),  TimeUtilities.Time42ToString(stopTime));
             * foreach (byte[] p in Iterator())
             * {
             *  var timestamp = PacketAccessor.Time42(p);
             *  if (startTime <= timestamp && timestamp <= stopTime)
             *      yield return p;
             * }
             */
        }
Пример #6
0
        // 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*/
        }