Beispiel #1
0
        //! Create and save all scheduling data

        /*!
         * \param string path and name of file to save
         * \param ContactWindowsVector contacts to save
         */
        public static void saveToFile(string filePathName, ContactWindowsVector contacts, Main f)
        {
            Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.GetCultureInfo("en-US");
            XmlWriterSettings settings = new XmlWriterSettings();

            settings.Indent = true;

            XmlWriter writer = XmlWriter.Create(filePathName, settings);

            writer.WriteStartDocument();
            writer.WriteStartElement("Contacts");
            writer.WriteElementString("StartYear", contacts.getStartTime().getYear().ToString());
            writer.WriteElementString("StartEpoch", contacts.getStartTime().getEpoch().ToString());
            writer.WriteElementString("StopYear", contacts.getStopTime().getYear().ToString());
            writer.WriteElementString("StopEpoch", contacts.getStopTime().getEpoch().ToString());
            List <ContactWindow> cwList = contacts.getAllContacts();

            f.setProgressBar(cwList.Count());
            int count = 0;

            foreach (ContactWindow cw in cwList)
            {
                writer.WriteStartElement("ContactWindow");
                writer.WriteElementString("SatName", cw.getSatName());
                writer.WriteElementString("StaName", cw.getStationName());
                writer.WriteElementString("StartTime", cw.getStartTime().getEpoch().ToString());
                writer.WriteElementString("StartYear", cw.getStartTime().getYear().ToString());
                writer.WriteElementString("StopTime", cw.getStopTime().getEpoch().ToString());
                writer.WriteElementString("StopYear", cw.getStopTime().getYear().ToString());
                writer.WriteElementString("Scheduled", cw.getSheduledInfo().ToString());
                writer.WriteElementString("Excluded", cw.getExclusion().ToString());
                writer.WriteElementString("ID", cw.getID().ToString());
                writer.WriteElementString("RequID", cw.getRequestID().ToString());
                writer.WriteElementString("Priority", cw.getPriority().ToString());

                writer.WriteStartElement("TrackingData");
                List <TrackingData> tdList = cw.getTrackingData();
                foreach (TrackingData td in tdList)
                {
                    writer.WriteStartElement("Data");
                    writer.WriteElementString("Azimuth", td.getAzimuth().ToString());
                    writer.WriteElementString("Elevation", td.getElevation().ToString());
                    writer.WriteElementString("Range", td.getRange().ToString());
                    writer.WriteElementString("RangeRate", td.getRangeRate().ToString());
                    writer.WriteElementString("TimeStamp", td.getTimeStamp());
                    writer.WriteEndElement();
                }
                writer.WriteEndElement();
                writer.WriteEndElement();
                f.updateProgressBar(count++);
            }
            writer.WriteEndElement();
            writer.WriteEndDocument();
            writer.Flush();
            writer.Close();
            writer.Dispose();
            f.resetProgressBar();
        }