/// <summary> /// Планирует расписание /// </summary> /// <returns>расписание</returns> private List <Tuple <Executor, Task, double, double> > _plan() { var duration = Duration; var tasks = new Stack <Task>(Tasks.Select(task => (Task)task.Clone())); var plan = new List <Tuple <Executor, Task, double, double> >(); Executors.ForEach(executor => { var executorTime = duration; double taskStart = 0; double taskEnd = 0; var order = 1; if (tasks.Count == 0) { plan.Add(Tuple.Create <Executor, Task, double, double>(executor, new Task() { Name = "<Отдыхает>", Duration = 0 }, 0, 0)); } while (executorTime > 0 && tasks.Count > 0) { var task = tasks.Pop(); if (task.Duration > executorTime) { tasks.Push(new Task() { Name = task.Name, Duration = task.Duration - executorTime }); task.Duration = executorTime; taskEnd = taskStart + executorTime; } else { taskEnd = taskStart + task.Duration; } plan.Add(new Tuple <Executor, Task, double, double>(executor, task, taskStart, taskEnd)); executorTime -= task.Duration; taskStart += task.Duration; order++; } }); return(plan); }