示例#1
0
 /// <summary>
 /// Reset to the default parameters of the parent Task, except for readonly attributes (e.g. this.id) and lists.
 /// </summary>
 public void Reset()
 {
     if (this.refTask == null)
     {
         this.name     = "!Invalid";
         this.TaskType = (int)default(StandardTaskType);
         this.taskInterruptionPolicy     = TaskInterruptionPolicies.Undefined;
         this.phaseInterruptionPolicy    = PhaseInterruptionPolicies.Undefined;
         this.scenarioInterruptionPolicy = ScenarioInterruptionPolicies.Undefined;
         return;
     }
     this.InternalId = refTask.InternalId;
     this.name       = this.refTask.name;
     this.TaskType   = this.refTask.taskType;
     //this.systemTask = this.refTask.systemTask;
     this.autoExpandToAllCrewmen = this.refTask.autoExpandToAllCrewmen;
     this.RelativeDate           = this.refTask.relativeDate;
     this.DateOffset             = this.refTask.DateOffset;
     this.StartDate                  = this.refTask.StartDate;
     this.relativeTime               = this.refTask.relativeTime;
     this.DailyHourStart             = this.refTask.DailyHourStart;
     this.DailyHourEnd               = this.refTask.DailyHourEnd;
     this.onHolidays                 = this.refTask.onHolidays;
     this.Duration                   = this.refTask.Duration;
     this.taskInterruptionPolicy     = this.refTask.taskInterruptionPolicy;
     this.phaseInterruptionPolicy    = this.refTask.phaseInterruptionPolicy;
     this.scenarioInterruptionPolicy = this.refTask.scenarioInterruptionPolicy;
     this.interruptionErrorPolicy    = this.refTask.interruptionErrorPolicy;
     this.priority                   = this.refTask.priority;
     this.numberOfCrewmenNeeded      = this.refTask.numberOfCrewmenNeeded;
     this.Rotation                   = this.refTask.Rotation;
     this.description                = this.refTask.description;
     this.duplicatesPolicy           = this.refTask.duplicatesPolicy;
 }
示例#2
0
 public void Validate()
 {
                 #pragma warning disable 618     //Disable warning for obsolete "DoNotInterrupt"
     if (this.phaseInterruptionPolicy == PhaseInterruptionPolicies.DoNotInterrupt)
                 #pragma warning restore 618
     {            //Back compatibility
         this.taskInterruptionPolicy  = TaskInterruptionPolicies.ContinueOrResumeWithError;
         this.phaseInterruptionPolicy = PhaseInterruptionPolicies.ContinueOrDropWithError;
     }
     if (this.taskType.IsSubCodeOf(StandardTaskType.ExternalCondition) ||
         this.taskType.IsSubCodeOf(StandardTaskType.CriticalEvents))
     {
         this.taskInterruptionPolicy     = TaskInterruptionPolicies.DropWithError;
         this.phaseInterruptionPolicy    = PhaseInterruptionPolicies.ResumeOrDropWithError;
         this.scenarioInterruptionPolicy = ScenarioInterruptionPolicies.DropWithoutError;
         //this.relativeTime = Task.RelativeTimeType.TimeWindow;
         //this.dailyHourStart = TimeSpan.Zero;
         //this.dailyHourEnd = TimeSpan.Zero;
         //this.onHolidays = true;
         this.autoExpandToAllCrewmen = false;
         this.numberOfCrewmenNeeded  = 0;
         this.Rotation         = SimulationTime.Zero;
         this.duplicatesPolicy = TaskDuplicatesPolicy.MergeDuplicates;
         this.masterTasks.Clear();
         this.parallelTasks.Clear();
         this.priority = 700;
     }
     else
     {
         this.slaveTasks.Clear();                        //Only external conditions can have slaves
         if (this.relativeDate == RelativeDateType.TriggeredByAnEvent)
         {
             this.StartDate        = TimeDistribution.Zero;
             this.Duration         = new TimeDistribution(SimulationTime.ArbitraryLargeDuration);
             this.duplicatesPolicy = TaskDuplicatesPolicy.MergeDuplicates;
             this.parallelTasks.Clear();
             this.phaseTypes.Clear();
         }
         else
         {
             this.masterTasks.Clear();
         }
         if (this.phaseInterruptionPolicy == PhaseInterruptionPolicies.WholePhase)
         {
             this.DailyHourStart = SimulationTime.Zero;
             this.DailyHourEnd   = SimulationTime.Zero;
             this.RelativeDate   = RelativeDateType.RelativeStartFromStartOfPhase;
             this.StartDate      = TimeDistribution.Zero;
             this.Duration       = new TimeDistribution(SimulationTime.ArbitraryLargeDuration);
             this.parallelTasks.Clear();
         }
         else if ((this.phaseInterruptionPolicy == PhaseInterruptionPolicies.Obligatory) &&
                  (this.relativeDate != RelativeDateType.RelativeStartFromStartOfPhase) &&
                  (this.relativeDate != RelativeDateType.RelativeStartFromEndOfPhase) &&
                  (this.relativeDate != RelativeDateType.RelativeStopFromEndOfPhase))
         {
             this.phaseInterruptionPolicy = PhaseInterruptionPolicies.DropWithError;
         }
         switch (this.relativeDate)
         {
         case RelativeDateType.RelativeStopFromEndOfPhase:
         case RelativeDateType.RelativeStartFromStartOfPhase:
         case RelativeDateType.RelativeStartFromEndOfPhase:
         case RelativeDateType.RelativeStartFromPreviousStart:
             this.DateOffset = default(TimeDistribution);
             break;
         }
         if (((this.relativeDate == RelativeDateType.AbsoluteStartMonthDay) ||
              (this.relativeDate == RelativeDateType.AbsoluteStartWeekDay)))
         {
             this.StartDate.Unit = TimeUnit.Days;
         }
         if (this.autoExpandToAllCrewmen)
         {
             this.numberOfCrewmenNeeded = 1;
             this.Rotation = SimulationTime.Zero;
         }
     }
     this.Duration.Validate();
     this.StartDate.Validate();
 }