public void SeperationEvent_is_raised_on_detection()
        {
            Track track1 = new Track()
            {
                Tag       = "JHG654",
                X         = 30000,
                Y         = 30000,
                Altitude  = 5000,
                TimeStamp = DateTime.ParseExact("20151006213456789", "yyyyMMddHHmmssfff", CultureInfo.InvariantCulture)
            };

            _activeTracks.Add(track1);

            Track track2 = new Track()
            {
                Tag       = "NIC888",
                X         = 30000,
                Y         = 30000,
                Altitude  = 4800,
                TimeStamp = DateTime.ParseExact("20151006213456800", "yyyyMMddHHmmssfff", CultureInfo.InvariantCulture)
            };

            _activeTracks.Add(track2);

            SeperationCheckerEventArgs SCEargs = new SeperationCheckerEventArgs(_activeEvents, _activeTracks, track1);

            _updater.SeperationChecker += Raise.EventWith(this, SCEargs);

            Assert.That(_raisedEvent.Track.Tag, Is.EqualTo(track1.Tag));
            Assert.That(_raisedEvent.ConflictingTrack.Tag, Is.EqualTo(track2.Tag));
        }
        public void SeperationStopEvent_is_raised_on_event1()
        {
            Track track1 = new Track()
            {
                Tag       = "JHG654",
                X         = 30000,
                Y         = 30000,
                Altitude  = 5000,
                TimeStamp = DateTime.ParseExact("20151006213456789", "yyyyMMddHHmmssfff", CultureInfo.InvariantCulture)
            };

            _activeTracks.Add(track1);

            Track track2 = new Track()
            {
                Tag       = "NIC888",
                X         = 30000,
                Y         = 30000,
                Altitude  = 4800,
                TimeStamp = DateTime.ParseExact("20151006213456800", "yyyyMMddHHmmssfff", CultureInfo.InvariantCulture)
            };

            Track track2updated = new Track()
            {
                Tag       = "NIC888",
                X         = 30000,
                Y         = 30000,
                Altitude  = 4000,
                TimeStamp = DateTime.ParseExact("20151006213456800", "yyyyMMddHHmmssfff", CultureInfo.InvariantCulture)
            };

            _activeTracks.Add(track2updated);

            IEvent alertEvent = new Event(_activeEvents, "SEPERATION ALERT", track2, DateTime.Now, track1, _seperationChecker);

            _activeEvents.Add(alertEvent);

            SeperationCheckerEventArgs SCEargs = new SeperationCheckerEventArgs(_activeEvents, _activeTracks, track2updated);

            _updater.SeperationChecker += Raise.EventWith(this, SCEargs);

            Assert.That(_raisedEvent.Track.Tag, Is.EqualTo(track1.Tag));
            Assert.That(_raisedEvent.ConflictingTrack.Tag, Is.EqualTo(track2.Tag));
        }
Esempio n. 3
0
        private void CheckSeperation(object o, SeperationCheckerEventArgs args)
        {
            IEvent eventFound1 = SeperationAlertList.Find(i => i.Track.Tag == args.Track.Tag);
            IEvent eventFound2 = SeperationAlertList.Find(i => i.ConflictingTrack.Tag == args.Track.Tag);

            foreach (var updatedTrack in args.UpdatedTracks)
            {
                if (args.Track.Tag != updatedTrack.Tag)
                {
                    if (CheckForSeparation(args.Track, updatedTrack))
                    {
                        if (eventFound1 == null && eventFound2 == null)
                        {
                            //Event is getting a SeperationChecker object, this, and by this it can make an event to SeperationStop.
                            IEvent alertEvent = new Event(args.EventList, "SEPERATION ALERT", args.Track, DateTime.Now, updatedTrack, this);
                            SeperationAlertList.Add(alertEvent);
                            SeperationAlert?.Invoke(this, new SeperationAlertEventArgs(alertEvent));
                        }
                    }
                    else if (eventFound1 != null || eventFound2 != null)
                    {
                        if (eventFound1 != null)
                        {
                            if (updatedTrack.Tag == eventFound1.ConflictingTrack.Tag)
                            {
                                SeperationStop?.Invoke(this, new SeperationStopEventArgs(eventFound1));
                                SeperationAlertList.Remove(eventFound1);
                            }
                        }
                        else if (updatedTrack.Tag == eventFound2.Track.Tag)
                        {
                            SeperationStop?.Invoke(this, new SeperationStopEventArgs(eventFound2));
                            SeperationAlertList.Remove(eventFound2);
                        }
                    }
                }
            }
        }