Exemplo n.º 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;
 }
Exemplo n.º 2
0
 /// <summary>
 /// Construct a new phase based on an existing reference phase.
 /// A phase and its reference phase share their task list (<see cref="Tasks"/>).
 /// </summary>
 /// <seealso cref="RefPhase"/>
 /// <param name="refPhase">Existing phase used as a reference</param>
 protected Phase(Phase refPhase)
 {
     //if (refPhase == null) return;
     this.name = refPhase.name;
     //this.refPhase = refPhase.RootPhase;
     //if (this.refPhase == null) return;
     this.refPhase    = refPhase;
     this.id          = refPhase.id;
     this.description = refPhase.description;
     this.Duration    = refPhase.Duration;
     this.phaseType   = refPhase.phaseType;
     this.tasks       = refPhase.tasks;
 }
Exemplo n.º 3
0
        public virtual void LoadFromXml(XElement element, TaskDictionary taskList)
        {
            this.description = element.Element("description").Value;
            XAttribute attr;

            this.id        = (attr = element.Attribute("phaseId")) == null ? 0 : attr.Value.ParseInteger();
            this.phaseType = (attr = element.Attribute("phaseType")) == null ? 0 : attr.Value.ParseInteger();
            this.Duration  = XmlIO.ParseTimeDistribution(element.Attribute("phaseDurationUnit"),
                                                         element.Attribute("phaseDurationMin"), element.Attribute("phaseDurationMean"), element.Attribute("phaseDurationMax"));
            foreach (var xmlTaskRef in element.Elements("TaskRef"))
            {
                var taskRef = taskList.LoadTaskRefFromXml(xmlTaskRef);
                if (taskRef != null)
                {
                    taskRef.Validate();
                    this.tasks.Add(taskRef.Id, taskRef);
                }
            }
        }
Exemplo n.º 4
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();
 }