Exemple #1
0
        /// <summary>
        /// 创建一个天线实例,采用第一行解析初始化。
        /// </summary>
        /// <param name="firstLine">第一行</param>
        /// <returns></returns>
        private static Antenna CreateAntenna(string firstLine)
        {
            Antenna antenna = new Antenna();

            antenna.AntennaType = (firstLine.Substring(0, 15).Trim()).ToUpper();
            antenna.Radome      = (firstLine.Substring(16, 4).Trim());

            antenna.SerialOrSatFreqCode = (firstLine.Substring(20, 20).Trim());
            antenna.SatCode             = firstLine.Substring(40, 10).Trim();
            antenna.CosparID            = firstLine.Substring(50, 10).Trim();
            return(antenna);
        }
Exemple #2
0
        private static List <double> ParseArrayLine(Antenna antenna, string line)
        {
            List <double> pcVec = new List <double>();

            for (double zen = antenna.ZenithStart; zen <= antenna.ZenithEnd; zen += antenna.DeltaZenith)
            {
                double value = Convert.ToDouble(StringUtil.TrimFirstWord(ref line));
                pcVec.Add(value / 1000.0);//Extract values (they are in milimeters) store values as meters
            }

            return(pcVec);
        }
Exemple #3
0
        /// <summary>
        /// 从天线文件查找一个,只负责查找
        /// </summary>
        /// <param name="uModel"></param>
        /// <param name="uRadome"></param>
        /// <returns></returns>
        private Antenna FindFromFile(string uModel, string uRadome = "NONE")
        {
            if (String.IsNullOrWhiteSpace(uRadome))
            {
                uRadome = "NONE";
            }

            Antenna antenna = null;
            //Fla that signals if we found the antenna
            bool antennaFound = false;

            //read the satData stream/file from the beginning
            using (StreamReader sr = new StreamReader(FilePath))
            {
                //Repeat until antenna is found or End of file
                while (!antennaFound)
                {
                    string label = null;
                    string line  = null;

                    //lool for 'typeSerial' line
                    while (label != AntexLabel.TYPE_ERIAL_NO)
                    {
                        //Read one line from file
                        line = sr.ReadLine();

                        if (line == null)
                        {
                            return(antenna);
                        }
                        //修改截断错误
                        label = line.Substring(60).Trim();
                    }

                    //Check if model matches. Read only model, not radome//Check if radome matches
                    if (uModel == line.Substring(0, 15).Trim() &&
                        line.Substring(16, 4).Trim() == uRadome)
                    {
                        //found the antenna,fill it with satData
                        antenna      = ParseAntenna(line, sr, this.Header);
                        antennaFound = true;
                        return(antenna);
                    }
                }//End of while(!=antennaFound)...
            }

            return(antenna);
        }
Exemple #4
0
        /// <summary>
        /// 从指定的IGS天线类型中,获取天线数据。
        /// 首先判断缓存中是否具有该数据,如果没有则从文件中读取,如果也没有 则抛出异常,or 返回空 null??
        ///  Method to get antenna satData from a given IGS model.
        /// </summary>
        /// <param name="model">20个字符或15以内,IGS天线名称或加上天线罩</param>
        /// <returns></returns>
        public virtual Antenna GetAntenna(string model)
        {
            model = model.ToUpper();
            string typeName = model.Trim();

            if (model.Length > 15)  //取前15个字
            {
                typeName = model.Substring(0, 15).Trim();
            }

            string uRadome = "NONE";

            //天线类型如果小于17个字符,则认为没有天线罩
            if (model.Length >= 20)
            {
                uRadome = Geo.Utils.StringUtil.SubString(model, 16, 4).Trim();
            }
            var key = StringUtil.FillSpaceRight(typeName, 15) + StringUtil.FillSpaceRight(uRadome, 4);

            if (SiteAntennas.Count > 0 && SiteAntennas.Contains(key))
            {
                return(SiteAntennas[key]);
            }

            Antenna antenna = FindFromFile(typeName, uRadome);

            if (antenna == null && uRadome != "NONE")//如果没有找到,尝试使用NONE
            {
                log.Warn("没有找到天线 " + model + " 啊!😭😭😭 不着急,我们将尝试无罩信息替代!");
                antenna = FindFromFile(typeName, "NONE");
                if (antenna == null)
                {
                    log.Warn("完蛋了! " + typeName + " NONE 也没有啊!😭😭😭 !请尝试到 https://www.ngs.noaa.gov/ANTCAL/ 下载对应天线改正信息,并追加到.atx文件中!");
                }
                else
                {
                    log.Warn("找到! " + typeName + " NONE 了! 讲究用着吧,如果要求高,请尝试到 https://www.ngs.noaa.gov/ANTCAL/ 下载对应天线改正信息,并追加到.atx文件中!");
                }
            }


            SiteAntennas.Add(key, antenna);  //无论找到否,都添加,避免下次继续查找

            return(antenna);
        }
Exemple #5
0
        /// <summary>
        /// 通过 SERIAL 和时段查找,这个通常为卫星接收机。
        /// </summary>
        /// <param name="epoch"></param>
        /// <param name="uSerial">G01,E01d等</param>
        /// <returns></returns>
        private Antenna FindFromFile(Time epoch, string uSerial)
        {
            Antenna antenna = null;

            //read the satData stream/file from the beginning
            using (StreamReader sr = new StreamReader(FilePath))
            {
                //flag that signals if we found the antenna
                bool antennaFound = false;
                //Repeat until antenna is found or End of file
                while (!antennaFound)
                {
                    string label = null;
                    string line  = null;
                    //lool for 'typeSerial' line
                    while (label != AntexLabel.TYPE_ERIAL_NO)
                    {
                        //Read one line from file
                        line = sr.ReadLine();
                        if (line == null)
                        {
                            return(null);
                        }
                        label = line.Substring(60).Trim();
                    }
                    //Check if serial matches
                    if (uSerial == line.Substring(20, 20).Trim())
                    {
                        //found the antenna,fill it with satData
                        antenna = ParseAntenna(line, sr, this.Header);

                        if (antenna.TimePeriod.Contains(epoch))
                        {
                            antennaFound = true;
                            return(antenna);
                        }
                    }
                }
            }

            return(antenna);
        }
Exemple #6
0
        /// <summary>
        /// 解析主体数据部分
        /// </summary>
        /// <param name="sr"></param>
        /// <param name="antenna"></param>
        /// <param name="line"></param>
        /// <returns></returns>
        private static string ParseFrequency(StreamReader sr, Antenna antenna, string line)
        {
            var freqString = line.Substring(3, 3).Trim();
            var freq       = RinexSatFrequency.Parse(freqString);

            // Read new line and extract label
            line = sr.ReadLine();
            var label = line.Substring(60).Trim();

            //Repeat until 'endOfFreq' line
            while (label != AntexLabel.END_OF_FREQUENCY)
            {
                //Eccentricities of the mean antenna phase center relative to the antenna reference point (ARP)(in millimeters).
                //平均天线相位中心相对于天线参考点(ARP)的偏心率(以毫米计)。
                if (label == AntexLabel.NORTH_EAST_UP)
                {
                    var neu = ParseNEU(line);
                    antenna.SetAntennaEcc(freq, neu);
                }
                else
                {
                    //Check if this line contains "NOAZI" pattern
                    if (line.Substring(3, 5).Trim() == "NOAZI")//常常为第一行:表明不依赖方位角,如卫星
                    {
                        StringUtil.TrimFirstWord(ref line);
                        List <double> pcVec = ParseArrayLine(antenna, line);
                        antenna.SetAntennaNoAziPattern(freq, pcVec);
                    }
                    else//依赖方位角,如测站
                    {
                        double        azi   = Convert.ToDouble(StringUtil.TrimFirstWord(ref line));
                        List <double> pcVec = ParseArrayLine(antenna, line);
                        antenna.SetAntennaPattern(freq, azi, pcVec);
                    }
                }
                //Read new line and extract label
                line  = sr.ReadLine();
                label = line.Substring(60).Trim();
            }//End of While(label != endOfFreq)

            return(label);
        }
Exemple #7
0
        /// <summary>
        ///  The section includes the rms values of  the phase center eccentricities and of the phase pattern values.
        /// </summary>
        /// <param name="sr"></param>
        /// <param name="antenna"></param>
        /// <param name="line"></param>
        /// <returns></returns>
        private static string ParseFrequencyRms(StreamReader sr, Antenna antenna, ref string line)
        {
            string label;
            string freqString = line.Substring(3, 3).Trim();

            RinexSatFrequency freq = RinexSatFrequency.Parse(freqString);

            // Read new line and extract label
            line  = sr.ReadLine();
            label = line.Substring(60).Trim();
            //Repeat until 'endOfFreqRMS' line
            while (label != AntexLabel.END_OF_FREQ_RMS)
            {
                //Process this line
                if (label == AntexLabel.NORTH_EAST_UP)//Rms of the eccentricities (in milli meters)
                {
                    //Add antenna eccentricities RMS, as Meters
                    antenna.SetAntennaRmsEcc(freq, ParseNEU(line));
                }
                else
                {
                    //Check if this line contains "NOAZI" pattern RMS
                    if (line.Substring(3, 5).Trim() == "NOAZI") //表明不依赖方位角,如卫星
                    {
                        StringUtil.TrimFirstWord(ref line);
                        List <double> pcVec = ParseArrayLine(antenna, line);
                        antenna.SetAntennaNoAziRms(freq, pcVec);
                    }
                    else//依赖方位角,如测站
                    {
                        double        azi   = Convert.ToDouble(StringUtil.TrimFirstWord(ref line));
                        List <double> pcVec = ParseArrayLine(antenna, line);
                        antenna.SetAntennaPatternRms(freq, azi, pcVec);
                    }
                }
                //Read new line and extract label
                line  = sr.ReadLine();
                label = line.Substring(60).Trim();
            }

            return(label);
        }
Exemple #8
0
        /// <summary>
        /// 获取文件中所有的天线对象。
        /// </summary>
        /// <param name="fileName"></param>
        /// <returns></returns>
        public static AntennaFile ReadFile(string fileName)
        {
            AntennaFile file = new AntennaFile();

            file.Header = ReadHeader(fileName);

            using (StreamReader sr = new StreamReader(fileName))
            {
                string line;
                RinexUtil.SkipHeader(sr);

                while ((line = sr.ReadLine()) != null)
                {
                    Antenna Antenna = ParseAntenna(line, sr, file.Header);
                    file.Antennas.Add(Antenna);
                }
            }

            return(file);
        }
Exemple #9
0
        /// <summary>
        /// 解析一个天线段。
        ///  Fill most Antenna satData
        /// </summary>
        /// <param name="firstLine"></param>
        /// <param name="sr"></param>
        /// <param name="header"></param>
        /// <returns></returns>
        private static Antenna ParseAntenna(string firstLine, StreamReader sr, AntennaHeader header)
        {
            //These flags take care of "Valid From" and "Valid Until"
            bool validFromPresent  = false;
            bool validUntilPresent = false;
            //Create 'Antenna' object to be returned
            Antenna antenna = CreateAntenna(firstLine);

            antenna.Header = header;

            //Read the rest of satData
            string line;

            //Read one line from file
            line = sr.ReadLine();
            string label = line.Substring(60).Trim();

            // Repeat until 'endOfAntenna' line
            while (label != AntexLabel.END_OF_ANTENNA)
            {
                //Process 'calibrationMehtod' line
                switch (label)
                {
                case AntexLabel.METH_BY_DATE:
                    antenna.CalibrationMethod = (line.Substring(0, 20).Trim());
                    antenna.Agency            = line.Substring(20, 20).Trim();
                    antenna.NumOfAntennas     = line.Substring(40, 6).Trim();
                    antenna.Date = line.Substring(50, 10).Trim();
                    break;

                case AntexLabel.DAZI:
                    antenna.DeltaAzimuth = (Convert.ToDouble(line.Substring(2, 6).Trim()));
                    break;

                case AntexLabel.ZEN1_ZEN2_DZEN:
                    antenna.ZenithStart = (Convert.ToDouble(line.Substring(2, 6).Trim()));
                    antenna.ZenithEnd   = (Convert.ToDouble(line.Substring(8, 6).Trim()));
                    antenna.DeltaZenith = (Convert.ToDouble(line.Substring(14, 6).Trim()));

                    break;

                case AntexLabel.NUM_OF_FREQUENCIES:
                    antenna.NumOfFrequencies = (Convert.ToInt32(line.Substring(0, 6).Trim()));
                    break;

                case AntexLabel.VALID_FROM:
                    Time valFrom = Time.Parse(line.Substring(0, 43));
                    antenna.ValidDateFrom = (valFrom);
                    validFromPresent      = true;// Mark that we found "Valid From"

                    break;

                case AntexLabel.VALID_UNTIL:     // Get validity as Year, Month, Day, Hour, Min, Sec
                    Time valUntil = Time.Parse(line.Substring(0, 43));
                    antenna.ValidDateUntil = (valUntil);
                    // Mark that we found "Valid Until"
                    validUntilPresent = true;
                    break;

                case AntexLabel.SINEX_CODE:      //Get antenna Sinex Code
                    antenna.SinexCode = line.Substring(0, 10).Trim();
                    break;

                case AntexLabel.COMMENT:
                    antenna.AddComment(line.Substring(0, 60).Trim());
                    break;

                case AntexLabel.START_OF_FREQUENCY:    //Get frequency indicator
                    label = ParseFrequency(sr, antenna, line);
                    break;

                case AntexLabel.START_OF_FREQ_RMS:    //Get frequency indicator
                    label = ParseFrequencyRms(sr, antenna, ref line);
                    break;

                default:
                    break;
                }
                //Read another line from file
                line = sr.ReadLine();
                //Get current label
                label = line.Substring(60).Trim();
            }
            //Take care of "Valid From" field if it was not present
            if (!validFromPresent)
            {
                //Set as "DayTime: BEGINNING_OF_TIME"
                antenna.ValidDateFrom = (Time.MinValue);
            }
            if (!validUntilPresent)
            {
                antenna.ValidDateUntil = (Time.MaxValue);
            }
            return(antenna);
        }