예제 #1
0
        public void WaitForStart()
        {
            ScheduleTask t = this;

            while (true)
            {
                ScheduleActivity ac       = t.Activities[0];
                bool             canStart = true;
                foreach (LinkedListNode <UnitReservation> ur in ac.UnitReservations)
                {
                    if (ur.Previous != null &&
                        (ur.Previous.Value.Activity.Status != Status.Cancelled && ur.Previous.Value.Activity.Status != Status.Processed && ur.Previous.Value.Activity.WaitingForCompleted != true))
                    {
                        canStart = false;
                    }
                }

                foreach (ScheduleTask pt in t.TasksRunAfterEnd)
                {
                    if (pt.Status != Status.Processed && pt.Status != Status.Cancelled)
                    {
                        canStart = false;
                    }
                }


                foreach (ScheduleTask pt in t.TasksRunAfterStart)
                {
                    if (pt.Status == Status.Scheduled)
                    {
                        canStart = false;
                    }
                }
                if (Scheduler.CurrentExecuteTime < t.Activities[0].PlannedStart || Scheduler.IsRunning == false)
                {
                    canStart = false;
                }
                if (canStart)
                {
                    break;
                }
                else
                {
                    Thread.Sleep(600);
                }
            }
            Status = Status.Running;
            FireTaskStarted(this, new TaskEventArg(this));
        }
예제 #2
0
 public void FreeUnits(int[] units, ScheduleTask task, ScheduleActivity activity)
 {
     for (int i = 0; i < units.Length; i++)
     {
         if (_unitStatus[units[i]] != false)
         {
             throw new Exception(string.Format("task {2} activity {3} resource {0} unit {1} is not in useing", Name, units[i], activity.Task.ID, activity.Name));
         }
         _unitStatus[units[i]] = true;
         lockedBy.Remove(units[i]);
     }
     if (ResourceFreed != null)
     {
         for (int i = 0; i < units.Length; i++)
         {
             ResourceFreed(this, new ResourceEventArgs(Name, units[i], true, task, activity));
         }
     }
 }
예제 #3
0
 //runtime
 public bool LockUnits(int[] units, ScheduleTask task, ScheduleActivity activity)
 {
     for (int i = 0; i < units.Length; i++)
     {
         if (_unitStatus[units[i]] != true)
         {
             throw new Exception(string.Format("task {2} activity {3} resource {0} unit {1} is in using", Name, units[i], activity.Task.ID, activity.Name));
         }
         _unitStatus[units[i]] = false;
         lockedBy[units[i]]    = activity;
     }
     if (ResourceLocked != null)
     {
         for (int i = 0; i < units.Length; i++)
         {
             ResourceLocked(this, new ResourceEventArgs(Name, units[i], false, task, activity));
         }
     }
     return(true);
 }
예제 #4
0
        //Добавление события в планировщик, сортировка по начальному времени
        public void AddEvent(ScheduleTask note)
        {
            bool eventAdded = false;

            if (notes.Count > 0)
            {
                for (int i = 0; i < notes.Count; i++)
                {
                    if (notes[i].BeginTime > note.BeginTime)
                    {
                        notes.Insert(i, note);
                        eventAdded = true;
                        break;
                    }
                }
            }
            if (!eventAdded)
            {
                notes.Add(note);
            }
        }
예제 #5
0
 public ResourceEventArgs(string name, int unit, bool free, ScheduleTask task, ScheduleActivity activity)
 {
     _name   = name;
     _unit   = unit;
     _isFree = free;
 }
예제 #6
0
 public TaskEventArg(ScheduleTask task)
 {
     Task = task;
 }
예제 #7
0
 //обновление информации о записи
 public void UpdateEvent(int position, ScheduleTask scheduleTask)
 {
     notes.RemoveAt(position);
     AddEvent(scheduleTask);
 }
예제 #8
0
 public RuntimeTask(ScheduleTask t)
 {
     _task = t;
 }
예제 #9
0
 public TaskExecuter(Scheduler scheduler, ScheduleTask task)
 {
     _task      = task;
     _scheduler = scheduler;
 }