Esempio n. 1
0
        /// <summary>
        /// Gets the offset time from ticks
        /// </summary>
        /// <param name="captureTimerInfo"></param>
        /// <param name="ticks"></param>
        /// <returns></returns>
        public static DateTime GetOffsetTime(this CaptureTimerInfo captureTimerInfo, long ticks)
        {
            //Get the seconds
            var seconds = captureTimerInfo.TicksToSeconds(ticks);

            //Connvert to seconds
            return(captureTimerInfo.StartTime.AddSeconds(seconds));
        }
        private void Refresh()
        {
            //var output = new StringBuilder();
            Packets.Clear();

            //Create the reader
            using (var captureReader = new CaptureFileReader(_captureFilePath))
            {
                var sample = captureReader.Read();

                //Keep track of the last sample so we now how far apart they are
                Sample lastSample = null;

                var buffer = new List<byte>();

                var captureTimerInfo = new CaptureTimerInfo(captureReader.StartTime, captureReader.TicksPerSecond);

                while (sample != null)
                {
                    if (lastSample != null)
                    {
                        //Get the elapsed Ms
                        var elapsedMs = captureTimerInfo.TicksToMilliseconds(sample.Ticks - lastSample.Ticks);

                        if (elapsedMs >= _packetThreshold)
                        {
                            Packets.Add(new PacketViewModel(buffer.ToArray()));
                            buffer.Clear();
                        }
                    }

                    //Add an item to the buffer
                    buffer.Add(sample.Value);

                    //Save this sample for next time
                    lastSample = sample;

                    //Get the next sample
                    sample = captureReader.Read();

                    //See if we have any last bits... (might take this out)
                    if (sample == null && buffer.Any())
                    {
                        Packets.Add(new PacketViewModel(buffer.ToArray()));
                        buffer.Clear();
                    }
                }
            }
        }
Esempio n. 3
0
        /// <summary>
        /// TickstoMiliseconds
        /// </summary>
        /// <param name="captureTimerInfo"></param>
        /// <param name="ticks"></param>
        /// <returns></returns>
        public static double TicksToMilliseconds(this CaptureTimerInfo captureTimerInfo, long ticks)
        {
            //return ((double)ticks * 1000.0) / ((double)captureTimerInfo.TicksPerSecond);

            return(captureTimerInfo.TicksToSeconds(ticks) * 1000.0);
        }
Esempio n. 4
0
 /// <summary>
 /// Converts ticks to real world seconds.
 /// </summary>
 /// <param name="captureTimerInfo"></param>
 /// <param name="ticks"></param>
 /// <returns></returns>
 public static double TicksToSeconds(this CaptureTimerInfo captureTimerInfo, long ticks)
 {
     return((double)ticks / (double)captureTimerInfo.TicksPerSecond);
 }