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();
        }
Beispiel #2
0
        //! Draw Conatact Windows.

        /*!
         * \param ContactWindowsVector Contacts
         * \param bool Draw All if false only scheduled contacts will be drawn
         * \return Image bmp-Image
         * Creates a bmp Image and returns it
         */
        public static Image drawContacts(ContactWindowsVector contacts, bool drawAll)
        {
            if (contacts != null)
            {
                //sort by Groundstations
                contacts.sort(Structs.sortByField.GROUNDSTATION);

                List <string> satNameList = contacts.getSatelliteNames();
                List <string> staNameList = contacts.getStationNames();

                int x_offset     = 100;
                int y_offset     = 20;
                int satBoxheight = 20;

                //calculate Size of Image
                double timeLength = contacts.getStopTime().getEpoch() - contacts.getStartTime().getEpoch();
                int    imWidth    = Convert.ToInt32(timeLength = 8640 * timeLength);
                int    imHeight   = satNameList.Count() * staNameList.Count() * 20;
                Image  dest       = new Bitmap(imWidth + x_offset, imHeight + y_offset);

                //Generate Front and Brusch for drawing
                System.Drawing.Graphics g;
                System.Drawing.Pen      pen = new System.Drawing.Pen(Color.Black, 1F);
                Font       drawFont         = new Font("Arial", 10);
                SolidBrush brush            = new SolidBrush(Color.Black);
                g = Graphics.FromImage(dest);
                g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixelGridFit;

                //Start Drawing Contact Windows
                for (int i = 0; i < contacts.Count(); i++)
                {
                    //Draw only if scheduled unless drawAll = true
                    if (contacts.getAt(i).getSheduledInfo() || drawAll)
                    {
                        int satPosY = satNameList.IndexOf(contacts.getAt(i).getSatName());
                        int staPosY = staNameList.IndexOf(contacts.getAt(i).getStationName());

                        int y            = 0;
                        int x            = 0;
                        int satBoxhWidth = 0;

                        y = satPosY * 20 + staPosY * satNameList.Count() * 20 + y_offset;
                        double satx = 8640 * (contacts.getAt(i).getStartTime().getEpoch() - contacts.getStartTime().getEpoch());
                        x            = Convert.ToInt32(satx) + x_offset;
                        satBoxhWidth = Convert.ToInt32(contacts.getAt(i).getDuration() / 10.0);

                        //brush = new SolidBrush(Color.FromArgb(contacts.getAt(i).getHash()));
                        if (drawAll && !contacts.getAt(i).getSheduledInfo())
                        {
                            brush = new SolidBrush(Color.FromArgb(215, 215, 215));
                            g.FillRectangle(brush, new Rectangle(x, y, satBoxhWidth, satBoxheight));
                            g.DrawString(contacts.getAt(i).getSatName(), drawFont, new SolidBrush(Color.DarkGray), x, y);
                        }
                        else
                        {
                            brush = new SolidBrush(Color.FromArgb(contacts.getAt(i).getHash()));
                            g.FillRectangle(brush, new Rectangle(x, y, satBoxhWidth, satBoxheight));
                            g.DrawString(contacts.getAt(i).getSatName(), drawFont, new SolidBrush(Color.Black), x, y);
                        }
                    }
                }

                System.Drawing.Pen stationPen;
                stationPen = new System.Drawing.Pen(Color.DarkGray, 1);

                g.DrawLine(stationPen, x_offset, 0, x_offset, imHeight);

                //Start Drawing Stations Names
                for (int i = 0; i < staNameList.Count(); i++)
                {
                    int x1 = 0;
                    int y1 = (i + 1) * satNameList.Count() * 20;
                    int x2 = imWidth;
                    int y2 = (i + 1) * satNameList.Count() * 20;
                    g.DrawString(staNameList[i], drawFont, new SolidBrush(Color.Black), 5, y1 - ((satNameList.Count() / 2) * 20));
                    g.DrawLine(stationPen, x1, y1 + y_offset, x2, y2 + y_offset);
                }

                One_Sgp4.EpochTime time = new One_Sgp4.EpochTime(contacts.getStartTime());
                g.DrawString(contacts.getStartTime().ToString(), drawFont, new SolidBrush(Color.Black), x_offset, 5);

                for (int i = x_offset; i < imWidth; i += 180)
                {
                    g.DrawString(time.ToString(), drawFont, new SolidBrush(Color.Black), i, 5);
                    g.DrawLine(stationPen, i, 0, i, imHeight);
                    time.addTick(10 * 180);
                }

                //g.Dispose();
                drawFont.Dispose();
                brush.Dispose();
                pen.Dispose();

                dest.Save("Contacts.bmp");

                return(dest);
            }
            else
            {
                int   imWidth  = 8640;
                int   imHeight = 20;
                Image dest     = new Bitmap(imWidth, imHeight);
                return(dest);
            }
        }