예제 #1
0
 private void updateLog(DataTransferInstant data)
 {
     if (secondCount == 60)
     {
         logHandler.Log(data);
         secondCount = 0;
     }
     else
     {
         secondCount++;
     }
 }
예제 #2
0
 /// <summary>
 /// Stores the specified instant data in a log file
 /// </summary>
 /// <param name="data"></param>
 public void Log(DataTransferInstant data)
 {
     String path = Path.Combine(logPath, getCurrentLogFileName());
     if (data.changed)
     {
         // ensure the path exists
         (new FileInfo(path)).Directory.Create();
         // log
         File.AppendAllText(path, data.ToCSV() + Environment.NewLine);
         data.changed = false;
     }
 }
예제 #3
0
 private void loadDataInstant(long time)
 {
     dataInstant = logHandler.getDataInstant(time);
 }
        /// <summary>
        /// Loads the values regarding the start instant for the tracker
        /// </summary>
        /// <param name="logHandler"></param>
        private void setStartInstantValues(LogHandler logHandler)
        {
            startInstant = logHandler.getDataInstant(ticksAtStartPoint());
            // try looking slightly after a minute ahead to account for any delays in saving
            minuteAfterStartInstant = logHandler.getDataInstant(ticksAtStartPoint() + (long)(TimeSpan.TicksPerMinute * 0.98));

            // work out how many bytes change should be made each second so there's no sudden jump when the minute changes
            long inDiff = minuteAfterStartInstant.bytesIn - startInstant.bytesIn;
            long outDiff = minuteAfterStartInstant.bytesOut - startInstant.bytesOut;
            if (inDiff < 0)
            {
                inDiff = -inDiff;
            }
            if (outDiff < 0)
            {
                outDiff = -outDiff;
            }
            bytesStartPerSecond.bytesIn = inDiff / 60;
            bytesStartPerSecond.bytesOut = outDiff / 60;

            bytesStartLeftover.bytesIn = inDiff - bytesStartPerSecond.bytesIn * 60;
            bytesStartLeftover.bytesOut = outDiff - bytesStartPerSecond.bytesOut * 60;
        }