示例#1
0
        /// <summary>
        /// 设置值
        /// </summary>
        public void InitSelector(Time from, List <SatelliteNumber> exceptPrns = null)
        {
            this.PeriodSats = new Dictionary <BufferedTimePeriod, SatelliteNumber>();

            //选星策略:选择时段最长的星,以此类推
            var nextStart = from;
            var end       = SatVisiblePeriodMarker.TimePeriod.End;

            while (nextStart < end)
            {
                List <SatPeriod> satPeriods = SatVisiblePeriodMarker.GetSortedSatPeriods(nextStart);

                if (satPeriods.Count == 0)        //没有搜索到区域,则添加时间继续搜索
                {
                    nextStart = nextStart + 60.0; //添加 1 分钟
                }
                else
                {
                    List <SatPeriodWeight> sats = new List <SatPeriodWeight>();
                    foreach (var period in satPeriods)
                    {
                        int count = 0;
                        for (var i = period.TimePeriod.Start; i < period.TimePeriod.End; i += SatCycleSlipMaker.Interval)
                        {
                            if (SatCycleSlipMaker.Contains(period.Prn, i))
                            {
                                count++;
                            }
                        }
                        sats.Add(new SatPeriodWeight(period.Prn, period.TimePeriod, count));
                    }
                    sats.Sort();
                    sats.Reverse();

                    var best = sats[0];
                    if (exceptPrns != null)
                    {
                        foreach (var item in sats)
                        {
                            if (!exceptPrns.Contains(item.Prn))
                            {
                                best = item;
                            }
                        }
                    }

                    //添加一个最好的。
                    PeriodSats.Add(best.TimePeriod, best.Prn);

                    //下一段
                    nextStart = best.TimePeriod.End;
                }
            }
        }
示例#2
0
        /// <summary>
        /// 从当前时间选择最优的卫星序列,越往前越优。
        /// </summary>
        /// <param name="from">时间</param>
        /// <returns></returns>
        public List <SatPeriodWeight> GetSortedSatPeriods(Time from)
        {
            //选星策略:选择时段最长的星,以此类推
            var nextStart = from;
            List <SatPeriod> satPeriods = null;

            while (nextStart < SatVisiblePeriodMarker.TimePeriod.End)
            {
                satPeriods = SatVisiblePeriodMarker.GetSortedSatPeriods(nextStart);

                if (satPeriods.Count == 0)        //没有搜索到区域,则添加时间继续搜索,指导结束
                {
                    nextStart = nextStart + 60.0; //添加 1 分钟
                }
                else
                {
                    break;
                }
            }
            List <SatPeriodWeight> sats = new List <SatPeriodWeight>();

            foreach (var period in satPeriods)
            {
                int count = 0;
                for (var i = period.TimePeriod.Start; i < period.TimePeriod.End; i += SatCycleSlipMaker.Interval)
                {
                    if (SatCycleSlipMaker.Contains(period.Prn, i))
                    {
                        count++;
                    }
                }
                sats.Add(new SatPeriodWeight(period.Prn, period.TimePeriod, count));
            }
            sats.Sort();
            sats.Reverse();
            return(sats);
        }