Beispiel #1
0
 private static void PopulatePredictions(IRun run, TimeSpan?currentTime, int segmentIndex, IList <TimeSpan?> predictions, bool simpleCalculation, bool useCurrentRun, TimingMethod method)
 {
     if (currentTime != null)
     {
         PopulatePrediction(predictions, currentTime + run[segmentIndex].BestSegmentTime[method], segmentIndex + 1);
         if (!simpleCalculation)
         {
             foreach (var nullSegment in run[segmentIndex].SegmentHistory.Where(x => !x.Value[method].HasValue))
             {
                 Time segmentTime;
                 if (segmentIndex == 0 ||
                     !run[segmentIndex - 1].SegmentHistory.TryGetValue(nullSegment.Key, out segmentTime) ||
                     segmentTime[method] != null)
                 {
                     var prediction = SumOfSegmentsHelper.TrackBranch(run, currentTime, segmentIndex + 1, nullSegment.Key, method);
                     PopulatePrediction(predictions, prediction.Time[method], prediction.Index);
                 }
             }
         }
         if (useCurrentRun)
         {
             var currentRunPrediction = SumOfSegmentsHelper.TrackCurrentRun(run, currentTime, segmentIndex, method);
             PopulatePrediction(predictions, currentRunPrediction.Time[method], currentRunPrediction.Index);
         }
         var personalBestRunPrediction = SumOfSegmentsHelper.TrackPersonalBestRun(run, currentTime, segmentIndex, method);
         PopulatePrediction(predictions, personalBestRunPrediction.Time[method], personalBestRunPrediction.Index);
     }
 }
Beispiel #2
0
        public static void Clean(IRun run, TimingMethod method, CleanUpCallback callback = null)
        {
            var predictions = new TimeSpan?[run.Count + 1];

            CalculateSumOfBest(run, 0, run.Count() - 1, predictions, true, false, method);
            int      segmentIndex = 0;
            TimeSpan?currentTime  = TimeSpan.Zero;

            foreach (var segment in run)
            {
                currentTime = predictions[segmentIndex];
                foreach (var nullSegment in run[segmentIndex].SegmentHistory.Where(x => !x.Value[method].HasValue))
                {
                    var prediction = SumOfSegmentsHelper.TrackBranch(run, currentTime, segmentIndex + 1, nullSegment.Key, method);
                    CheckPrediction(run, predictions, prediction.Time[method], segmentIndex - 1, prediction.Index - 1, nullSegment.Key, method, callback);
                }
                segmentIndex++;
            }
        }
Beispiel #3
0
 private static void PopulatePredictions(IRun run, TimeSpan?currentTime, int segmentIndex, IList <TimeSpan?> predictions, bool simpleCalculation, TimingMethod method = TimingMethod.RealTime)
 {
     if (currentTime != null)
     {
         PopulatePrediction(predictions, currentTime + run[segmentIndex].BestSegmentTime[method], segmentIndex + 1);
         if (!simpleCalculation)
         {
             foreach (var nullSegment in run[segmentIndex].SegmentHistory.Where(x => !x.Time[method].HasValue))
             {
                 var prediction = SumOfSegmentsHelper.TrackBranch(run, currentTime, segmentIndex + 1, nullSegment.Index, method);
                 PopulatePrediction(predictions, prediction.Time[method], prediction.Index);
             }
         }
         var currentRunPrediction = SumOfSegmentsHelper.TrackCurrentRun(run, currentTime, segmentIndex, method);
         PopulatePrediction(predictions, currentRunPrediction.Time[method], currentRunPrediction.Index);
         var personalBestRunPrediction = SumOfSegmentsHelper.TrackPersonalBestRun(run, currentTime, segmentIndex, method);
         PopulatePrediction(predictions, personalBestRunPrediction.Time[method], personalBestRunPrediction.Index);
     }
 }
Beispiel #4
0
 private static void PopulatePredictions(IRun run, TimeSpan?currentTime, int segmentIndex, IList <TimeSpan?> predictions, bool useCurrentRun, TimingMethod method)
 {
     if (currentTime != null)
     {
         PopulatePrediction(predictions, currentTime + run[segmentIndex].BestSegmentTime[method], segmentIndex + 1);
         foreach (var segment in run[segmentIndex].SegmentHistory)
         {
             var segmentTime = segmentIndex > 0 ? run[segmentIndex - 1].SegmentHistory.FirstOrDefault(x => x.Index == segment.Index) : null;
             if (segmentTime == null || segmentTime.Time[method] != null)
             {
                 var prediction = SumOfSegmentsHelper.TrackBranch(run, currentTime, segmentIndex, segment.Index, method);
                 PopulatePrediction(predictions, prediction.Time[method], prediction.Index);
             }
         }
         if (useCurrentRun)
         {
             var currentRunPrediction = SumOfSegmentsHelper.TrackCurrentRun(run, currentTime, segmentIndex, method);
             PopulatePrediction(predictions, currentRunPrediction.Time[method], currentRunPrediction.Index);
         }
         var personalBestRunPrediction = SumOfSegmentsHelper.TrackPersonalBestRun(run, currentTime, segmentIndex, method);
         PopulatePrediction(predictions, personalBestRunPrediction.Time[method], personalBestRunPrediction.Index);
     }
 }