Exemplo n.º 1
0
        /// <summary>
        /// Legge la fase di checklist richiesta
        /// </summary>
        /// <param name="phase"></param>
        public void ReadPhase(ChecklistPhase phase)
        {

            backgroundSpeaker = new SpeakingThread(Controller);
 
            if (phase == null)
            {
                string s = "Checklist phase unavailable, select it on config section";
                backgroundSpeaker.AddInSpeakingBuffer(s,s);
                backgroundThread = new Thread(new ThreadStart(backgroundSpeaker.Run));
                backgroundThread.IsBackground = true;//issue 107
                backgroundThread.Start();
                return;
            }

            StringBuilder toBeSpeeked = new StringBuilder();
            string msg = string.Empty;

            #region lettura dell'header di checklist
            msg = string.Format(TEMPLATE_READ_CHECKLISTPHASE, phase.PhaseName);
            toBeSpeeked.Append(msg);
            toBeSpeeked.Append(SSML_PAUSE_MEDIUM);
            backgroundSpeaker.AddInSpeakingBuffer(toBeSpeeked.ToString(), phase.PhaseName + " checklist:");
            #endregion


            foreach (ChecklistItem item in phase.Items)
            {
                toBeSpeeked = new StringBuilder();
                msg = string.Format(TEMPLATE_READ_COUPLE, item.Description, item.Value);
                toBeSpeeked.Append(msg);
                toBeSpeeked.Append(string.Format(TEMPLATE_SSML_PAUSE_IN_SECONDS, item.Delay));

                backgroundSpeaker.AddInSpeakingBuffer(toBeSpeeked.ToString(), item.Description + " : " + item.Value);
            }

            #region lettura del footer
            toBeSpeeked = new StringBuilder();
            msg = string.Empty;

            toBeSpeeked.Append(SSML_PAUSE_MEDIUM);
            msg = string.Format(TEMPLATE_READ_CHECKLISTPHASECOMPLETED, phase.PhaseName);
            toBeSpeeked.Append(msg);

            backgroundSpeaker.AddInSpeakingBuffer(toBeSpeeked.ToString(), phase.PhaseName + " checklist completed");
            #endregion

            if (backgroundThread != null && backgroundThread.IsAlive)
            {
                backgroundThread.Abort();
            }

            backgroundThread = new Thread(new ThreadStart(backgroundSpeaker.Run));
            backgroundThread.IsBackground = true;//issue 107
            backgroundThread.Start();

        }
Exemplo n.º 2
0
        /// <summary>
        /// Selezionata la checklist la costruisce OOP
        /// </summary>
        /// <param name="checkListName"></param>
        /// <returns></returns>
        public static Checklist ReadChecklist(string checkListName)
        {
            FileInfo fi = new FileInfo(Path.Combine(Path.Combine(Directory.GetCurrentDirectory(),CHECKLIST_RELATIVE_PATH) , checkListName + "." + CHECKLIST_FILE_EXTENSION));
            if (!fi.Exists) return null;

            XmlTextReader reader = new XmlTextReader( Path.Combine(Path.Combine(Directory.GetCurrentDirectory(),CHECKLIST_RELATIVE_PATH) , checkListName + "." + CHECKLIST_FILE_EXTENSION));
            Checklist toBeRet = new Checklist();
            toBeRet.Phases = new List<ChecklistPhase>();

            while (reader.Read())
            {
                XmlNodeType nType = reader.NodeType;
                if (nType == XmlNodeType.Element)
                {
                    if (reader.Name == "aircraft")
                    {
                        toBeRet.AircraftIcaoCode = reader.GetAttribute("icao");
                        toBeRet.Vr = reader.GetAttribute("Vr");
                        toBeRet.Vs = reader.GetAttribute("Vs");
                        toBeRet.Vapp = reader.GetAttribute("Vapp");
                        toBeRet.Vf0 = reader.GetAttribute("Vf0");
                        toBeRet.Vldg = reader.GetAttribute("Vldg");
                        toBeRet.Vne = reader.GetAttribute("Vne");
                    }
                    if (reader.Name == "phase")
                    {
                        ChecklistPhase phase = new ChecklistPhase();
                        phase.PhaseName = reader.GetAttribute("desc");
                        phase.Items = new List<ChecklistItem>();
                        toBeRet.Phases.Add(phase);
                    }
                    if (reader.Name == "chklstItem")
                    {
                        ChecklistItem item = new ChecklistItem();
                        item.Description = reader.GetAttribute("desc");
                        item.Value = reader.GetAttribute("value");
                        if (reader.GetAttribute("delay") != null)
                        {
                            item.Delay = int.Parse(reader.GetAttribute("delay"));
                        }
                        toBeRet.Phases[toBeRet.Phases.Count - 1].Items.Add(item);
                    }
                }
            }
            reader.Close();//issue 70
            return toBeRet;
        }