Beispiel #1
0
        //! Sets the TLE-Data for this object

        /*!
         *  \pram tle TwoLineElement data
         *  \return bool if successful
         */
        public bool setTleData(One_Sgp4.Tle _tleData)
        {
            //toDo
            //Check Tle Data if its newer
            tleData = _tleData;
            return(true);
        }
Beispiel #2
0
        //! Delete a object from the Satellite and TLE Database

        /*!
         *
         */
        private void toolStripMenuItem10_Click(object sender, EventArgs e)
        {
            string satname = satelliteDataGrid.SelectedRows[0].Cells[0].Value.ToString();

            One_Sgp4.Tle tle = _MainDataBase.getTleDataFromDB(satelliteNameLabel.Text);
            _MainDataBase.deleteSatellite(satname);
            _MainDataBase.deleteTle(tle.getNoradID());
            UpdateAllLists();
        }
Beispiel #3
0
        //! Satellite grid on Selection Changed

        /*!
         *  Displays information about the currently selected satellite
         */
        private void satelliteDataGrid_SelectionChanged(object sender, EventArgs e)
        {
            if (!_MainDataBase.connected())
            {
                _MainDataBase.connectDB();
            }
            try
            {
                satelliteNameLabel.Text = satelliteDataGrid.SelectedRows[0].Cells[0].Value.ToString();

                One_Sgp4.Tle tle = _MainDataBase.getTleDataFromDB(satelliteNameLabel.Text);
                if (tle.getStartYear() < 85)
                {
                    if (tle.getStartYear() > 10)
                    {
                        SatLabel1.Text = "20" + tle.getStartYear().ToString();
                    }
                    else
                    {
                        SatLabel1.Text = "200" + tle.getStartYear().ToString();
                    }
                }
                else
                {
                    SatLabel1.Text = "19" + tle.getStartYear().ToString();
                }
                SatLabel2.Text = tle.getStartNr().ToString();
                SatLabel3.Text = tle.getNoradID().ToString();
                if (tle.getClassification() == 0)
                {
                    SatLabel4.Text = "UNCLASSIFIED";
                }
                if (tle.getClassification() == 1)
                {
                    SatLabel4.Text = "CLASSIFIED";
                }
                if (tle.getClassification() == 1)
                {
                    SatLabel4.Text = "SECRET";
                }
                SatLabel5.Text = tle.getSetNumber().ToString();

                pictureBox4.Image = Drawer.MapDrawer.drawSatellite(tle);
            }
            catch
            {
                satelliteNameLabel.Text = " -- ";
            }
        }
Beispiel #4
0
        //! Get the satellites selected for Schedule

        /*!
         * /param string Logfile
         */
        private List <One_Sgp4.Tle> getSatelliteData(string logfile)
        {
            satTleData = new List <One_Sgp4.Tle>();
            //get selected Satellites to calculate Orbits
            for (int i = 0; i < checkedSatellites.Items.Count; i++)
            {
                if (checkedSatellites.GetItemChecked(i))
                {
                    One_Sgp4.Tle sattle = _MainDataBase.getTleDataFromDB(checkedSatellites.Items[i].ToString());
                    satTleData.Add(sattle);
                    updateLog(logfile, "Adding Satellite: " + sattle.getName());
                }
            }
            return(satTleData);
        }
Beispiel #5
0
        //! Draw selected satellite path to image.

        /*!
         * \param One_Sgp4.Tle tle data from selected Satellite
         * \return Image bmp-Image
         */
        public static Image drawSatellite(One_Sgp4.Tle tleData)
        {
            Image imgSatellite = Properties.Resources.worldsmaller;

            try
            {
                One_Sgp4.Sgp4      task      = new One_Sgp4.Sgp4(tleData, Properties.Settings.Default.orbit_Wgs);
                One_Sgp4.EpochTime starttime = new One_Sgp4.EpochTime(DateTime.UtcNow);
                One_Sgp4.EpochTime stoptime  = new One_Sgp4.EpochTime(DateTime.UtcNow.AddHours(4));
                task.setStart(starttime, stoptime, 30.0 / 60.0);
                Task thread = new Task(task.starThread);
                thread.Start();
                Task.WaitAll(thread);
                List <One_Sgp4.Sgp4Data> calcPposData = null;
                calcPposData = task.getRestults();

                Pen penRest = new Pen(Color.Red, 1);
                Pen penSat  = new Pen(Color.Red, 10);
                using (var graphics = Graphics.FromImage(imgSatellite))
                {
                    for (int i = 0; i < calcPposData.Count; i++)
                    {
                        One_Sgp4.Coordinate oneSubPoint =
                            One_Sgp4.SatFunctions.calcSatSubPoint(starttime, calcPposData[i]);

                        Definition.GeoCoordinate subPoint = new Definition.GeoCoordinate(oneSubPoint.getLatetude(), oneSubPoint.getLongitude(), oneSubPoint.getHeight());

                        Point p = subPoint.toPoint(imgSatellite.Width, imgSatellite.Height);

                        graphics.DrawRectangle(penRest, p.X - 1, p.Y - 1, 2, 2);
                        if (i == 0)
                        {
                            graphics.DrawRectangle(penSat, p.X - 5, p.Y - 5, 2, 2);
                        }
                        starttime.addTick(30.0);
                    }
                }
            }
            catch
            {
                imgSatellite = Properties.Resources.worldsmaller;
            }
            return(imgSatellite);
        }
Beispiel #6
0
        //! Get TLE-data from satellite from DataBase

        /*!
         * \param string Name of the satellite to get TLE-data from DB
         */
        public One_Sgp4.Tle getTleDataFromDB(string SatName)
        {
            if (!isConnected)
            {
                connectDB();
            }
            SQLiteCommand command = new SQLiteCommand(m_dbConnection);

            One_Sgp4.Tle tleItem;
            command.CommandText = String.Format("SELECT * FROM {0} WHERE satName='{1}';",
                                                Constants.TleDB, SatName);
            using (SQLiteDataReader read = command.ExecuteReader())
            {
                while (read.Read())
                {
                    tleItem = new One_Sgp4.Tle(read.GetString(0),
                                               read.GetString(1),
                                               read.GetInt32(2),
                                               read.GetInt32(3),
                                               read.GetInt32(4),
                                               read.GetString(5),
                                               read.GetInt32(6),
                                               read.GetDouble(7),
                                               read.GetDouble(8),
                                               read.GetDouble(9),
                                               read.GetDouble(10),
                                               read.GetDouble(11),
                                               read.GetInt32(12),
                                               read.GetInt32(13),
                                               read.GetInt32(14),
                                               read.GetDouble(15),
                                               read.GetDouble(16),
                                               read.GetDouble(17),
                                               read.GetDouble(18),
                                               read.GetDouble(19),
                                               read.GetDouble(20),
                                               read.GetDouble(21),
                                               read.GetInt32(22));
                    return(tleItem);
                }
            }
            return(null);
        }
Beispiel #7
0
        public static void UpdateTLeFromWeb()
        {
            string userName = Properties.Settings.Default.email;
            string password = Login.getPassword();

            DataBase.DataBase db      = new DataBase.DataBase();
            List <string>     tleList = db.getAllNoradID();

            string[] searchIDs = new string[tleList.Count];

            for (int i = 0; i < tleList.Count; i++)
            {
                searchIDs[i] = tleList[i];
            }


            //Forms.Login loginForm = new Forms.Login(this);
            //loginForm.ShowDialog();
            if (userName != null && password != null)
            {
                string res = One_Sgp4.SpaceTrack.GetSpaceTrack(searchIDs, userName, password);
                if (res.Count() > 0)
                {
                    string[] tleLines = res.Split(new string[] { "\r\n", "\n" }, StringSplitOptions.None);

                    if (tleLines.Count() >= 3)
                    {
                        for (int i = 0; i < tleLines.Count() - 1; i += 3)
                        {
                            One_Sgp4.Tle satTleData = new One_Sgp4.Tle();
                            satTleData = One_Sgp4.ParserTLE.parseTle(tleLines[i + 1], tleLines[i + 2], tleLines[i]);
                            db.writeTleData(satTleData);
                        }
                    }
                    else
                    {
                        //error
                        //error parsing information
                    }
                }
            }
        }
Beispiel #8
0
        //! Write TLE-Data to DataBase

        /*!
         * \param tleData TLEData to be writen in DataBase.
         */
        public void writeTleData(One_Sgp4.Tle tleData)
        {
            if (!isConnected)
            {
                connectDB();
            }
            SQLiteCommand command       = new SQLiteCommand(m_dbConnection);
            SQLiteCommand addSatCommand = new SQLiteCommand(m_dbConnection);

            int count = 0;

            command.CommandText = String.Format("SELECT count(*) FROM {0} WHERE noradID='{1}';",
                                                Constants.TleDB, tleData.getNoradID());
            try
            {
                count = Convert.ToInt32(command.ExecuteScalar());
            }
            catch
            {
                count = 0;
            }

            if (count == 0)
            {
                command.CommandText = String.Format(
                    Constants.insertTle,
                    Constants.TleDB, tleData.getName(), tleData.getNoradID(),
                    tleData.getClassification(), tleData.getStartYear(),
                    tleData.getStartNr(), tleData.getPice(), tleData.getEpochYear(),
                    tleData.getEpochDay(), tleData.getFirstMeanMotion(),
                    tleData.getSecondMeanMotion(), tleData.getDrag(),
                    tleData.getEphemeris(), tleData.getSetNumber(), tleData.getFirstCheckSum(),
                    tleData.getSatNumber(), tleData.getInclination(),
                    tleData.getRightAscendingNode(), tleData.getEccentriciy(),
                    tleData.getPerigee(), tleData.getMeanAnomoly(), tleData.getMeanMotion(),
                    tleData.getRelevationNumber(), tleData.getSecCheckSum());
                command.ExecuteNonQuery();

                addSatCommand.CommandText = String.Format(
                    Constants.insertSat,
                    Constants.SatDB, tleData.getName(), tleData.getNoradID());
                addSatCommand.ExecuteNonQuery();
            }
            else
            {
                //delet old Entry
                command.CommandText = String.Format(
                    Constants.deleteTLE,
                    Constants.TleDB,
                    tleData.getNoradID());
                command.ExecuteNonQuery();

                //insert new Entry
                command.CommandText = String.Format(
                    Constants.insertTle,
                    Constants.TleDB, tleData.getName(), tleData.getNoradID(),
                    tleData.getClassification(), tleData.getStartYear(),
                    tleData.getStartNr(), tleData.getPice(), tleData.getEpochYear(),
                    tleData.getEpochDay(), tleData.getFirstMeanMotion(),
                    tleData.getSecondMeanMotion(), tleData.getDrag(),
                    tleData.getEphemeris(), tleData.getSetNumber(), tleData.getFirstCheckSum(),
                    tleData.getSatNumber(), tleData.getInclination(),
                    tleData.getRightAscendingNode(), tleData.getEccentriciy(),
                    tleData.getPerigee(), tleData.getMeanAnomoly(), tleData.getMeanMotion(),
                    tleData.getRelevationNumber(), tleData.getSecCheckSum());
                command.ExecuteNonQuery();

                SQLiteCommand delcommand = new SQLiteCommand(m_dbConnection);
                delcommand.CommandText = String.Format(
                    Constants.deleteSatellite2,
                    Constants.SatDB,
                    tleData.getNoradID());
                delcommand.ExecuteNonQuery();

                addSatCommand.CommandText = String.Format(
                    Constants.insertSat,
                    Constants.SatDB, tleData.getName(), tleData.getNoradID());
                addSatCommand.ExecuteNonQuery();
            }
        }
Beispiel #9
0
        private void button1_Click(object sender, EventArgs e)
        {
            DataBase.DataBase db = new DataBase.DataBase();
            //if selected to import a txt- file containg TLE data
            if (radioButton1.Checked)
            {
                this.Cursor = Cursors.WaitCursor;
                List <One_Sgp4.Tle> satTleData = new List <One_Sgp4.Tle>();
                satTleData = One_Sgp4.ParserTLE.ParseFile(tleFilePath);
                for (int i = 0; i < satTleData.Count(); i++)
                {
                    db.writeTleData(satTleData[i]);
                }
            }
            //if selected to add TLE - Data Manuely
            if (radioButton3.Checked)
            {
                this.Cursor = Cursors.WaitCursor;
                One_Sgp4.Tle satTleData = new One_Sgp4.Tle();
                satTleData = One_Sgp4.ParserTLE.parseTle(textTleLine1.Text, textTleLine2.Text, textNameID.Text);
                db.writeTleData(satTleData);
            }
            //if selected to load TLE - Data from Internet
            if (radioButton2.Checked)
            {
                string[]    searchIDs = textBox1.Text.Split(',');
                Forms.Login loginForm = new Forms.Login(this);
                loginForm.ShowDialog();
                if (userName != null && password != null)
                {
                    this.Cursor = Cursors.WaitCursor;
                    string res = One_Sgp4.SpaceTrack.GetSpaceTrack(searchIDs, userName, password);
                    if (res.Count() > 0)
                    {
                        string[] tleLines = res.Split(new string[] { "\r\n", "\n" }, StringSplitOptions.None);

                        if (tleLines.Count() >= 3)
                        {
                            for (int i = 0; i < tleLines.Count() - 1; i += 3)
                            {
                                One_Sgp4.Tle satTleData = new One_Sgp4.Tle();
                                satTleData = One_Sgp4.ParserTLE.parseTle(tleLines[i + 1], tleLines[i + 2], tleLines[i]);
                                db.writeTleData(satTleData);
                            }
                        }
                        else
                        {
                            errorCode = 1;
                            //error parsing information
                        }
                    }
                }
                else
                {
                    errorCode = 2;
                    //No UserName or Password were given
                }
            }
            if (radioButton4.Checked)
            {
                List <string> tleList   = db.getAllNoradID();
                string[]      searchIDs = new string[tleList.Count];

                for (int i = 0; i < tleList.Count; i++)
                {
                    searchIDs[i] = tleList[i];
                }

                Forms.Login loginForm = new Forms.Login(this);
                loginForm.ShowDialog();
                if (userName != null && password != null)
                {
                    this.Cursor = Cursors.WaitCursor;
                    string res = One_Sgp4.SpaceTrack.GetSpaceTrack(searchIDs, userName, password);
                    if (res.Count() > 0)
                    {
                        string[] tleLines = res.Split(new string[] { "\r\n", "\n" }, StringSplitOptions.None);

                        if (tleLines.Count() >= 3)
                        {
                            for (int i = 0; i < tleLines.Count() - 1; i += 3)
                            {
                                One_Sgp4.Tle satTleData = new One_Sgp4.Tle();
                                satTleData = One_Sgp4.ParserTLE.parseTle(tleLines[i + 1], tleLines[i + 2], tleLines[i]);
                                db.writeTleData(satTleData);
                            }
                        }
                        else
                        {
                            errorCode = 1;
                            //error parsing information
                        }
                    }
                }
                else
                {
                    errorCode = 2;
                    //No UserName or Password were given
                }
            }
            db.closeDB();
            db = null;
            switch (errorCode)
            {
            case 1:
                MessageBox.Show("Unable to Update from Server.\n Login information could be wrong or server is not reachable", "Error",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                break;

            case 2:
                //MessageBox.Show("No Login information given", "Error",
                //    MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Close();
                this.Cursor = Cursors.Default;
                break;

            default:
                this.Close();
                this.Cursor = Cursors.Default;
                break;
            }
        }
Beispiel #10
0
        //! Satellite constructor.

        /*!
         *  \param string name of the satellite
         *  \param Tle Two Line Element data
         */
        public Satellite(string _name, One_Sgp4.Tle _tleData)
        {
            name    = _name;
            tleData = _tleData;
        }