コード例 #1
0
ファイル: FcbFileReader.cs プロジェクト: yxw027/GNSSer
        /// <summary>
        /// 读取FCB信息。
        /// 由于信息文件较小,这里一次性读取完毕。
        /// </summary>
        /// <returns></returns>
        public FcbFile Read()
        {
            if (!File.Exists(FilePath))
            {
                log.Error("FCB文件不存在!" + FilePath);
                return(null);
            }

            log.Info("载入:" + FilePath);
            FcbFileHeader header = ReadHeader(FilePath);
            FcbFile       file   = new FcbFile(header);

            using (var streamReader = new StreamReader(FilePath))
            {
                var line = "";
                SkipHeader(streamReader, line);
                Time time = Time.Default;
                Geo.BaseDictionary <SatelliteNumber, FcbValue> currentEpochData = null;
                while ((line = streamReader.ReadLine()) != null)
                {
                    if (line.StartsWith("*"))
                    {
                        time             = Time.Parse(Geo.Utils.StringUtil.SubString(line, 1));
                        currentEpochData = file.GetOrCreate(time);
                    }

                    if (line.StartsWith("P"))
                    {
                        SatelliteNumber prn  = SatelliteNumber.Parse(line.Substring(1, 3));
                        var             val  = Double.Parse(line.Substring(23, 10));
                        var             rms  = Geo.Utils.StringUtil.ParseDouble(line, 53);
                        var             item = new FcbValue(prn, time, val, rms);
                        currentEpochData[item.Prn] = item;
                    }
                }
            }
            return(file);
        }
コード例 #2
0
        private string CheckFileLoaded(Time time)
        {
            var fileName = BuildName(time);

            if (!Files.ContainsKey(fileName))
            {
                var     path = Path.Combine(this.Option.FilePath, fileName);
                FcbFile file = null;
                if (!File.Exists(path))
                {
                    var dir = BuildDirectory(time);
                    path = Path.Combine(this.Option.FilePath, dir, fileName);
                }
                if (File.Exists(path))
                {
                    FcbFileReader reader = new FcbFileReader(path);
                    file = reader.Read();
                }
                Files.Add(fileName, file);
            }

            return(fileName);
        }