Exemple #1
0
 public void Reset()
 {
     foreach (var t in wf.Tasks)
     {
         t.ScheduledInstance = null;
     }
     Plan.Clear();
     Wrappers    = TaskScheduler.GenerateWrappers(wf);
     Estimations = TaskScheduler.MakeOverallEstimations(wf, Wrappers);
     if (!IgnoreNonUrgentTasks)
     {
         var additions = new Dictionary <int, List <ActiveEstimatedTask> >();
         for (var i = 0; i < Estimations.Count; i++)
         {
             var ests     = Estimations[i];
             var busyEsts = ests.Where(e =>
             {
                 var busyNodes = e.Estimation.NodesTimings.Where(n => n.LaunchedTask != null).ToArray();
                 if (!busyNodes.Any())
                 {
                     return(false);
                 }
                 var maxUrgentTime = busyNodes.Max(n => n.LaunchedTask.IsUrgent ? n.LaunchedTask.Estimation.Result.Time : 0);
                 return(busyNodes.Any(n => !n.LaunchedTask.IsUrgent && n.LaunchedTask.Estimation.Result.Time > maxUrgentTime));
             });
             foreach (var e in busyEsts.ToArray())
             {
                 additions.GetOrCreateValue(i, () => new List <ActiveEstimatedTask>()).Add(new ActiveEstimatedTask(e)
                 {
                     IgnoreNonUrgent = false
                 });
             }
         }
         foreach (var p in additions)
         {
             (Estimations[p.Key] as List <ActiveEstimatedTask>).AddRange(p.Value);
         }
     }
 }