Beispiel #1
0
        //! Open and Load saved scheduling data

        /*!
         * \param string path to Load file
         * \param Main Form to update loading bar
         */
        public static ContactWindowsVector loadFile(string filepath, Main f)
        {
            Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.GetCultureInfo("en-US");

            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.Load(filepath);
            XmlNodeList dataNodes = xmlDoc.SelectNodes("//Contacts/ContactWindow");

            f.setProgressBar(dataNodes.Count);

            int    startYear  = Int32.Parse(xmlDoc.SelectSingleNode("//Contacts/StartYear").InnerText);
            double startEpoch = double.Parse(xmlDoc.SelectSingleNode("//Contacts/StartEpoch").InnerText);
            int    stopYear   = Int32.Parse(xmlDoc.SelectSingleNode("//Contacts/StopYear").InnerText);
            double stopEpoch  = double.Parse(xmlDoc.SelectSingleNode("//Contacts/StopEpoch").InnerText);

            One_Sgp4.EpochTime start = new One_Sgp4.EpochTime(startYear, startEpoch);
            One_Sgp4.EpochTime stop  = new One_Sgp4.EpochTime(stopYear, stopEpoch);

            ContactWindowsVector saved = new ContactWindowsVector();

            saved.setStartTime(start);
            saved.setStopTime(stop);
            int count = 0;

            foreach (XmlNode node in dataNodes)
            {
                string             sa        = node.SelectSingleNode("SatName").InnerText;
                string             st        = node.SelectSingleNode("StaName").InnerText;
                int                year      = Int32.Parse(node.SelectSingleNode("StartYear").InnerText);
                double             epoch     = double.Parse(node.SelectSingleNode("StartTime").InnerText);
                ContactWindow      cw        = new ContactWindow(sa, st);
                One_Sgp4.EpochTime starttime = new One_Sgp4.EpochTime(year, epoch);
                cw.setStartTime(starttime);
                year  = Int32.Parse(node.SelectSingleNode("StopYear").InnerText);
                epoch = double.Parse(node.SelectSingleNode("StopTime").InnerText);
                One_Sgp4.EpochTime stoptime = new One_Sgp4.EpochTime(year, epoch);
                cw.setStopTime(stoptime);
                if (node.SelectSingleNode("Scheduled").InnerText != "False")
                {
                    cw.setSheduled();
                }
                cw.setExclusion(bool.Parse(node.SelectSingleNode("Scheduled").InnerText));
                cw.setID(Guid.Parse(node.SelectSingleNode("ID").InnerText));
                cw.setRequestID(Guid.Parse(node.SelectSingleNode("RequID").InnerText));
                cw.setPriority(Global.Funktions.ParseEnum <Global.Structs.priority>(node.SelectSingleNode("Priority").InnerText));

                XmlNodeList children = node.SelectNodes("TrackingData/Data");
                foreach (XmlNode childNode in children)
                {
                    double       azi  = double.Parse(childNode.SelectSingleNode("Azimuth").InnerText);
                    double       ele  = double.Parse(childNode.SelectSingleNode("Elevation").InnerText);
                    double       ran  = double.Parse(childNode.SelectSingleNode("Range").InnerText);
                    double       ranR = double.Parse(childNode.SelectSingleNode("RangeRate").InnerText);
                    string       time = childNode.SelectSingleNode("TimeStamp").InnerText;
                    TrackingData td   = new TrackingData(azi, ele, ran, time);
                    cw.addTrackingData(td);
                }
                f.updateProgressBar(count++);
                System.Windows.Forms.Application.DoEvents();
                saved.add(cw);
            }
            f.resetProgressBar();
            return(saved);
        }
Beispiel #2
0
        //! Calculate ContactWindows for satellite and groundstations

        /*!
         *  \param Station to calcuate if satellite is in View
         *  \param TimeDate start time
         *  \param List<Sgp4Data> satellite position vector
         *  \param string name of the satellite
         *  \param double tick in witch time is increased by each step
         *  \return List<contactWindow>
         */
        public void calcContactWindows()
        {
            One_Sgp4.EpochTime starttime = new One_Sgp4.EpochTime(_time);
            bool          visible        = false;
            ContactWindow window         = null;
            double        minElevation   = _station.getMinElevation();

            for (int i = 0; i < _satPosData.Count(); i++)
            {
                double          lsr            = starttime.getLocalSiderealTime(_station.getLongitude());
                Structs.point3D groundLocation = _station.getEci(lsr);

                Structs.point3D v = new Structs.point3D();
                v.x = _satPosData[i].getX() - groundLocation.x;
                v.y = _satPosData[i].getY() - groundLocation.y;
                v.z = _satPosData[i].getZ() - groundLocation.z;

                double r_lat = _station.getLatitude() * Constants.toRadians;

                double sin_lat = Math.Sin(r_lat);
                double cos_lat = Math.Cos(r_lat);
                double sin_srt = Math.Sin(lsr);
                double cos_srt = Math.Cos(lsr);


                double rs = sin_lat * cos_srt * v.x
                            + sin_lat * sin_srt * v.y
                            - cos_lat * v.z;
                double re = -sin_srt * v.x
                            + cos_srt * v.y;
                double rz = cos_lat * cos_srt * v.x
                            + cos_lat * sin_srt * v.y + sin_lat * v.z;

                double range     = Math.Sqrt(rs * rs + re * re + rz * rz);
                double elevation = Math.Asin(rz / range);
                double azimuth   = Math.Atan(-re / rs);

                if (rs > 0.0)
                {
                    azimuth += Constants.pi;
                }
                if (azimuth < 0.0)
                {
                    azimuth += Constants.twoPi;
                }

                if (elevation >= minElevation)
                {
                    if (visible == false)
                    {
                        window = new ContactWindow(_satName, _station.getName());
                        window.setStartTime(starttime);
                    }
                    TrackingData testTrack = new TrackingData(azimuth,
                                                              elevation, range, starttime.ToString());
                    window.addTrackingData(testTrack);
                    visible = true;
                }
                else
                {
                    if (visible == true)
                    {
                        window.setStopTime(starttime);
                        results.Add(window);
                    }
                    visible = false;
                }

                azimuth = azimuth * Constants.toDegrees;
                starttime.addTick(_tick);
            }
        }