Exemple #1
0
        private bool CorelateTrack(TargetTrack track, Sector sector)
        {
            bool ret = false;

            if (track.IsFake)       //假航迹,满分,直接返回
            {
                track.ScoreAdd(TargetTrack.ScoreMaximum);
                return(false);
            }
            PolarCoordinate predictCoordinate = track.PredictCoordinate(DateTime.Now);  //预测的位置

            foreach (TargetDot newDot in sector.NewDots)
            {
                if (newDot.Adopted || !newDot.IsClotDot) //被之前的航迹相关上了,或者不是凝聚点
                {
                    continue;
                }
                if (!(predictCoordinate.DistanceTo(newDot.CurrentCoordinate) < track.GetCorelateRadius()))
                {
                    continue;
                }
                newDot.Adopted = true;
                track.Update(newDot.CurrentCoordinate);
                track.ScoreAdd(3);
                ret = true;
                break; //已经相关上,返回上层循环
            }

            return(ret);
        }
        protected virtual bool CorelateDotToSector(TargetDot oldDot, Sector sector)   //自由点和一个扇区的新点相关,返回true表示相关成功
        {
            bool ret = false;

            if (!oldDot.IsClotDot)
            {
                return(false);
            }
            foreach (TargetDot newDot in sector.NewDots)
            {
                if (newDot.Adopted || !newDot.IsClotDot) //已经被航迹相关上的点不作处理
                {
                    continue;
                }

                if (oldDot.IsDotRelated(newDot) && DotsCanCorelate(oldDot, newDot))   //两个点是否相关成功
                {
                    TargetTrack track =
                        TargetTrack.CreateTargetTrack(newDot, oldDot, 3);
                    if (track == null)   //创建航迹失败,航迹编号满
                    {
                        continue;
                    }

                    //newDot.Adopted = true;    //自由点相关时,一个目标点可以与多个自由点相关
                    oldDot.Adopted = true;
                    sector.AddTrack(track);

                    ret = true;
                    break;  //相关成功,返回上层循环
                }
            }
            return(ret);
        }
Exemple #3
0
 public void RegisterTrack(TargetTrack track)
 {
     UnregisterTrack(track);
     subjectTrack = track;
     ChangeSectorHandler(track, track.SectorIndex);
     track.ChangeSector += ChangeSectorHandler;
 }
Exemple #4
0
 public void UnregisterTrack(TargetTrack track)
 {
     if (subjectTrack != null && subjectTrack == track)
     {
         subjectTrack.ChangeSector -= ChangeSectorHandler;
     }
     subjectTrack = null;
 }
Exemple #5
0
 public void AddTrack(TargetTrack track)
 {
     lock (_locker)
     {
         track.SectorIndex = Index;
         StableTracks.Add(track);
     }
 }
Exemple #6
0
 public void AcceptTrackFromOtherSector(TargetTrack track)
 {
     lock (_locker)
     {
         ExchangeTracks.Add(track);
         track.SectorIndex = Index;
     }
 }
Exemple #7
0
 public void RemoveTrack(TargetTrack track)
 {
     lock (_locker)
     {
         if (track != null)
         {
             StableTracks.Remove(track);
         }
     }
 }
        private int GetTrackSectorId(TargetTrack t)
        {
            foreach (var s in targetManager.Sectors)
            {
                if (s.IsAngleInArea(t.Az))
                {
                    return(s.Index);
                }
            }

            return(-1);
        }
Exemple #9
0
        public void SendTrack(TargetTrack t)
        {
            //List<byte> cmdBytes = new List<byte> {0x68, 0x2, 0x1, 0x1, (byte) t.trackID};
            //cmdBytes.AddRange(SystemCommunicator.IntToByteLsb((int)t.Dis, 4));
            //cmdBytes.AddRange(SystemCommunicator.IntToByteLsb((int)(t.AZ * 100),2));
            //cmdBytes.AddRange(SystemCommunicator.IntToByteLsb((int)(t.EL * 100), 2));
            //cmdBytes.AddRange(CRC16(cmdBytes.ToArray()));

            //SendData(cmdBytes.ToArray());

            SendData(new X68Command(t).Serialize());
        }
        public TrackGenerator(TargetManager targetManager, PolarCoordinate coordinate)
        {
            this.targetManager = targetManager;
            //track = new TargetTrack(coordinate);

            track = TargetTrack.CreateTargetTrack(new TargetDot(coordinate.Az, coordinate.El, coordinate.Dis), null, 13);
            int sectorIndex = GetTrackSectorId(track);

            targetManager.Sectors[sectorIndex].AddTrack(track);
            track.IsFake      = true;
            track.SectorIndex = GetTrackSectorId(track);
            targetManager.NotifyAllObservers(track, NotifyType.Add);
            center = coordinate;
        }
        public void MoveTrack()
        {
            track.Update(NextStraightCoordinate());
            TargetTrack.SetTrackHeight(track, MouseTargetTracker.TrackHeight);
            int sectorIndex = GetTrackSectorId(track);

            if (track.SectorIndex != sectorIndex)
            {
                //targetManager.NotifyAllObservers(track, NotifyType.Delete);
                targetManager.Sectors[track.SectorIndex].RemoveTrack(track);
                track.SectorIndex = sectorIndex;
                targetManager.Sectors[sectorIndex].AddTrack(track);
            }

            //targetManager.NotifyAllObservers(track, NotifyType.Update);
        }
Exemple #12
0
 public X68Command(TargetTrack track) : base(0x68, 0x2, 0x1)
 {
     _track = track;
 }
        public TrackManager_TestCase_Random()
        {
            mode = TargetManagerMode.Auto;

            tracks            = new List <TargetTrack>();
            dots              = new List <TargetDot>();
            obs               = new List <ITargetObserver>();
            timerDot          = new Timer();
            timerDot.Interval = 1000;
            timerDot.Tick    += TimerDot_Tick;
            timerDot.Start();


            timerTrack          = new Timer();
            timerTrack.Interval = 1000;
            timerTrack.Tick    += TimerTrack_Tick;
            timerTrack.Start();

            if (dot1 == null)       //dot1是静态成员,只有第一次实例化时才对dot1赋值
            {
                Random rd = new Random();
                dot1     = new TargetDot();
                dot1.AZ  = rd.Next(0, 180);
                dot1.EL  = rd.Next(10, 19);
                dot1.Dis = rd.Next(2000, 4000);

                dot2     = new TargetDot();
                dot2.AZ  = dot1.AZ + 2;
                dot2.EL  = dot1.EL + 1;
                dot2.Dis = dot1.Dis + 100;
            }

            dots.Add(dot1);
            NotifyAllObservers(dot1, NotifyType.Add);
            dots.Add(dot2);
            NotifyAllObservers(dot2, NotifyType.Add);

            if (track1 == null)
            {
                Random rd = new Random();
                track1         = new TargetTrack();
                track1.trackID = 15;
                track1.AZ      = rd.Next(180, 360);
                track1.EL      = rd.Next(20, 89);
                track1.Dis     = rd.Next(100, 4000);
            }

            float dis    = 4000;
            float el     = 10;
            float az     = 0;
            float azStep = 30;

            for (int i = 1; az < 360; i++)
            {
                TargetTrack t = new TargetTrack();
                az        = 15 + azStep * i;
                t.AZ      = az;
                t.Dis     = dis;
                t.EL      = el;
                t.trackID = i;
                tracks.Add(t);
                NotifyAllObservers(t, NotifyType.Add);
            }
            tracks.Add(track1);
            NotifyAllObservers(track1, NotifyType.Add);
        }
Exemple #14
0
 public X80Data(TargetTrack t) : base(0x80, LocalDeviceCode, SystmDeviceCode)
 {
     _track = t;
 }
        public static void Send0X80Cmd(TargetTrack t)
        {
            byte[] cmdBytes = new X80Data(t).Serialize();

            UdpEthernetCenter.SendData(cmdBytes, LocalIpAndPortString, SystemIpAndPortString);
        }
 public static void DeleteTrack(TargetTrack track)
 {
     track.Dis = 0;
     Send0X80Cmd(track);
 }
 public static void UpdateTrack(TargetTrack track)
 {
     Send0X80Cmd(track);
 }