Пример #1
0
 /// <summary>
 /// Constructor of a dataSet from some existing data.
 /// </summary>
 /// <param name="workplace">The workplace.</param>
 /// <param name="taskDictionary">The taskDictionary for the workplace. If this parameter is null, it will be taken from crew.taskDictionary</param>
 /// <param name="crew">The crew.</param>
 /// <param name="scenario">The scenario. If the callBack function scenario.loadPhase is null, one function will be generated to use this.phases as the source of phases</param>
 protected SimulationDataSet(Workplace workplace, TaskDictionary taskDictionary, Scenario scenario, Crew crew)
 {        //Whould be better to make a deep copy of everything when creating the dataSet?
     this.workplace      = workplace;
     this.taskDictionary = taskDictionary ?? (crew == null ? null : crew.TaskDictionary);
     this.scenario       = scenario;
     this.crew           = crew;
     this.assertions     = new List <string>();
 }
Пример #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;
 }
Пример #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);
                }
            }
        }
Пример #4
0
        protected internal virtual bool LoadFromXml(TaskDictionary taskDictionary, XElement element)
        {
            XAttribute attr;

            this.name = (attr = element.Attribute("name")) == null?this.id.ToString(CultureInfo.InvariantCulture) : attr.Value;

            this.crewmanType = element.Attribute("crewMemberType").ParseInteger();
            XElement elem;

            this.description = (elem = element.Element("description")) == null ? String.Empty : elem.Value;
            foreach (var taskRef in element.Elements("TaskRef"))
            {
                var            taskId = taskRef.Attribute("refId").ParseInteger();
                SimulationTask task;
                if (taskDictionary.TryGetValue(taskId, out task))
                {
                    this.qualifications.Add(taskId, taskRef.Attribute("percent").Value.ParseByte());
                }
            }
            return(true);
        }
Пример #5
0
 protected internal virtual void SaveToXml(TaskDictionary taskDictionary, XmlWriter xmlWriter)
 {
     xmlWriter.WriteStartElement("CrewMember");
     xmlWriter.WriteAttributeString("id", this.id.ToString(CultureInfo.InvariantCulture));
     xmlWriter.WriteAttributeString("name", this.name);
     xmlWriter.WriteAttributeString("crewMemberType", this.crewmanType.ToString(CultureInfo.InvariantCulture));
     if (!String.IsNullOrEmpty(this.description))
     {
         xmlWriter.WriteElementString("description", this.description);
     }
     foreach (var qualification in this.qualifications)
     {
         if (!taskDictionary.ContainsKey(qualification.Key))
         {
             continue;                                                                   //The task has been deleted from the central list of tasks
         }
         xmlWriter.WriteStartElement("TaskRef");
         xmlWriter.WriteAttributeString("refId", qualification.Key.ToString(CultureInfo.InvariantCulture));
         xmlWriter.WriteAttributeString("percent", qualification.Value.ToString(CultureInfo.InvariantCulture));
         xmlWriter.WriteEndElement();
     }
     xmlWriter.WriteEndElement();
 }
Пример #6
0
 public abstract SimulationDataSet CreateSimulationDataSet(Workplace workplace, TaskDictionary taskDictionary, Scenario scenario, Crew crew);
Пример #7
0
 /// <summary>
 /// Create a new crew.
 /// </summary>
 /// <param name="name">Name of the new crew</param>
 /// <param name="taskDictionary">An existing task dictionnary of the same domain</param>
 /// <returns></returns>
 public abstract Crew CreateCrew(string name, TaskDictionary taskDictionary);
Пример #8
0
 /// <summary>
 /// Create a new phase.
 /// </summary>
 /// <param name="name">Name of the new phase</param>
 /// <param name="taskDictionary">An existing task dictionnary of the same domain</param>
 /// <returns>The new phase</returns>
 public abstract Phase CreatePhase(string name, TaskDictionary taskDictionary);
Пример #9
0
 /// <summary>
 /// New empty crew
 /// </summary>
 /// <param name="name">Name of the crew</param>
 /// <param name="taskDictionary">Reference to the list of all tasks at workplace level.</param>
 protected Crew(string name, TaskDictionary taskDictionary)
 {
     this.name           = name;
     this.taskDictionary = taskDictionary;
 }