コード例 #1
0
ファイル: PacketFile.cs プロジェクト: Costigan/rocksdb-test
 public void InsertStats(Dictionary <int, int> ApidCount, Int64 begin, Int64 end, int count)
 {
     _ApidCount   = ApidCount;
     _BeginTime42 = begin;
     _BeginString = TimeUtilities.Time42ToString(_BeginTime42);
     _EndTime42   = end;
     _EndString   = TimeUtilities.Time42ToString(_EndTime42);
     _PacketCount = count;
 }
コード例 #2
0
        public static void DumpPacket(byte[] p, TextWriter sb)
        {
            sb.WriteLine("Packet: apid={0} seq={1} len={2}", APID(p), SequenceCount(p), Length(p));
            sb.WriteLine("        timestamp={0} = {1}", Time42(p), TimeUtilities.Time42ToString(Time42(p)));
            var currentPacketSize = Length(p) + 7;
            var col = 0; // Not really the display column, but the virtual column

            for (var i = 0; i < currentPacketSize; i++)
            {
                if (Rem(i, 16) == 0 && i > 0)
                {
                    // Display the ascii version
                    sb.Write("  |  ");
                    for (var j = i - 16; j < i; j++)
                    {
                        sb.Write(SafeChar(p[j]));
                    }

                    sb.Write("\r\n");
                    col = 0;
                }
                else if (Rem(i, 4) == 0 && i > 0)
                {
                    sb.Write("  ");
                }
                sb.Write("{0:x2}", p[i]);
                col++;
            }

            // Handle the tail end
            var skip = 40 - (2 * col + ((col / 4) * 2));

            for (var i = 0; i < skip; i++)
            {
                sb.Write(' ');
            }
            sb.Write("|  ");
            for (var i = currentPacketSize - col; i < currentPacketSize; i++)
            {
                sb.Write(SafeChar(p[i]));
            }
            sb.WriteLine();
            sb.WriteLine("----------------------------");
        }
コード例 #3
0
ファイル: PacketFile.cs プロジェクト: Costigan/rocksdb-test
        // 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*/
        }
コード例 #4
0
ファイル: PacketFile.cs プロジェクト: Costigan/rocksdb-test
        public Boolean Touches(DateTime day)
        {
            var t = TimeUtilities.DateTimeToTime42(day);

            return(!(_EndTime42 < t || (t + DayInSubseconds) < _BeginTime42));
        }