コード例 #1
0
ファイル: UpdaterUnitTest.cs プロジェクト: Chr1000/ATM
        public void Initial_TrackStartCalcOneTrack_TracksIsCorrect()
        {
            List <Track> listToTest = new List <Track>();
            Track        track      = new Track()
            {
                Tag       = "NIC222",
                X         = 25000,
                Y         = 25000,
                Altitude  = 5000,
                TimeStamp = DateTime.ParseExact("20151006213456789", "yyyyMMddHHmmssfff", CultureInfo.InvariantCulture)
            };

            listToTest.Add(track);
            TracksFilteredEventArgs args = new TracksFilteredEventArgs(listToTest);

            _filter.TracksFiltered += Raise.EventWith(this, args);

            List <Track> listToTest2 = new List <Track>();
            Track        newTrack    = new Track()
            {
                Tag       = "NIC222",
                X         = 25010,
                Y         = 25002,
                Altitude  = 4980,
                TimeStamp = DateTime.ParseExact("20151006213456800", "yyyyMMddHHmmssfff", CultureInfo.InvariantCulture)
            };

            listToTest2.Add(newTrack);
            TracksFilteredEventArgs args2 = new TracksFilteredEventArgs(listToTest2);

            _filter.TracksFiltered += Raise.EventWith(this, args2);

            Assert.That(_prevTrackStartCal, Is.EqualTo(track));
            Assert.That(_newTrackStartCal, Is.EqualTo(newTrack));
        }
コード例 #2
0
ファイル: Filter.cs プロジェクト: Chr1000/ATM
        public void FilterTrack(object o, TracksChangedEventArgs args)
        {
            List <Track> newFilteredTracks = new List <Track>();

            foreach (var track in args.Tracks)
            {
                var newEvent = new IsTrackInAirspaceEventArgs(track);
                IsTrackInAirspace?.Invoke(this, newEvent);
                if (newEvent.IsInAirspace)
                {
                    newFilteredTracks.Add(track);
                }
                else
                {
                    foreach (var trackInUpdatedList in UpdatedTracksList)
                    {
                        if (track.Tag == trackInUpdatedList.Tag)
                        {
                            TrackLeft?.Invoke(this, new TrackLeftAirspaceEventArgs(track));
                            break;
                        }
                    }
                }
            }
            TracksFilteredEventArgs Args = new TracksFilteredEventArgs(newFilteredTracks);

            TracksFiltered?.Invoke(this, Args);
            UpdatedTracksList = Args.UpdatedTracks;
        }
コード例 #3
0
ファイル: Updater.cs プロジェクト: Chr1000/ATM
        private void UpdateTrack(object o, TracksFilteredEventArgs args)
        {
            if (args.FilteredTracks.Count != 0 && UpdatedTracksList.Count == 0)
            {
                foreach (var track in args.FilteredTracks)
                {
                    UpdatedTracksList.Add(track);
                }
            }

            else if (args.FilteredTracks.Count != 0 && UpdatedTracksList.Count != 0)
            {
                foreach (var filteredTrack in args.FilteredTracks)
                {
                    var updatedTrack = UpdatedTracksList.Find(i => i.Tag == filteredTrack.Tag);
                    if (updatedTrack == null)
                    {
                        UpdatedTracksList.Add(filteredTrack);
                    }

                    else
                    {
                        filteredTrack.Course = _calculator.CalCourse(UpdatedTracksList[UpdatedTracksList.IndexOf(updatedTrack)],
                                                                     filteredTrack);
                        filteredTrack.Velocity =
                            _calculator.CalVelocity(UpdatedTracksList[UpdatedTracksList.IndexOf(updatedTrack)], filteredTrack);
                        UpdatedTracksList[UpdatedTracksList.IndexOf(updatedTrack)] = filteredTrack;
                    }
                }
            }

            var handler = TracksUpdated;

            handler?.Invoke(this, new TracksUpdatedEventArgs(UpdatedTracksList));
        }
コード例 #4
0
ファイル: UpdatingUnitTests.cs プロジェクト: TeamSWT30/ATM
        public void UpdateTrack_NoTracksInUpdatedTracks_AddedToUpdatedTracks()
        {
            List <Track> testTracks = new List <Track>();

            testTracks.Add(_testTrack1);
            var args = new TracksFilteredEventArgs(testTracks);

            _filtering.TracksFiltered += Raise.EventWith(args);

            Assert.That(_updatedTracks.Contains(_testTrack1));
        }
コード例 #5
0
ファイル: UpdatingUnitTests.cs プロジェクト: TeamSWT30/ATM
        public void UpdateTrack_OneTrackInUpdatedTracksNewTrackAdded_NewTrackAddedToUpdatedTracks()
        {
            List <Track> testTracks = new List <Track>();

            testTracks.Add(_testTrack1);
            var args = new TracksFilteredEventArgs(testTracks);

            _filtering.TracksFiltered += Raise.EventWith(args);
            args.FilteredTracks.Add(_testTrack2);
            _filtering.TracksFiltered += Raise.EventWith(args);

            Assert.That(_updatedTracks.Count, Is.EqualTo(2));
        }
コード例 #6
0
ファイル: UpdatingUnitTests.cs プロジェクト: TeamSWT30/ATM
        public void UpdateTrack_TracksAddedTwice_NumberOfEventsReceivedIsCorrect()
        {
            List <Track> testTracks = new List <Track>();

            testTracks.Add(_testTrack1);
            var args = new TracksFilteredEventArgs(testTracks);

            _filtering.TracksFiltered += Raise.EventWith(args);
            args.FilteredTracks.Add(_testTrack2);
            _filtering.TracksFiltered += Raise.EventWith(args);

            Assert.That(_nEventsRecieved, Is.EqualTo(2));
        }
コード例 #7
0
ファイル: UpdatingUnitTests.cs プロジェクト: TeamSWT30/ATM
        public void UpdateTrack_OneTrackInUpdatedTracksTrackChanged_TrackUpdatedInUpdatedTracks()
        {
            List <Track> testTracks = new List <Track>();

            testTracks.Add(_testTrack1);
            var args = new TracksFilteredEventArgs(testTracks);

            _filtering.TracksFiltered += Raise.EventWith(args);
            _testTrack1.X              = 52000;


            args.FilteredTracks.Add(_testTrack1);
            _filtering.TracksFiltered += Raise.EventWith(args);

            Assert.That(_updatedTracks[_updatedTracks.IndexOf(_testTrack1)].X, Is.EqualTo(52000));
        }
コード例 #8
0
ファイル: UpdaterUnitTest.cs プロジェクト: Chr1000/ATM
        public void Initial_TrackLeftedOneTrack_TrackInEventIsCorrect()
        {
            List <Track> listToTest = new List <Track>();
            Track        track      = new Track()
            {
                Tag       = "NIC333",
                X         = 25000,
                Y         = 10000,
                Altitude  = 5000,
                TimeStamp = DateTime.ParseExact("20151006213456789", "yyyyMMddHHmmssfff", CultureInfo.InvariantCulture)
            };

            listToTest.Add(track);
            TracksFilteredEventArgs args = new TracksFilteredEventArgs(listToTest);

            _filter.TracksFiltered += Raise.EventWith(this, args);

            List <Track> listToTest2 = new List <Track>();
            Track        newTrack    = new Track()
            {
                Tag       = "NIC333",
                X         = 25010,
                Y         = 10000,
                Altitude  = 4980,
                TimeStamp = DateTime.ParseExact("20151006213456800", "yyyyMMddHHmmssfff", CultureInfo.InvariantCulture)
            };

            listToTest2.Add(newTrack);
            TracksFilteredEventArgs args2 = new TracksFilteredEventArgs(listToTest2);

            _filter.TracksFiltered += Raise.EventWith(this, args2);
            Track trackOutOfSpace = new Track()
            {
                Tag       = "NIC333",
                X         = 25010,
                Y         = 9980,
                Altitude  = 4980,
                TimeStamp = DateTime.ParseExact("20151006213456800", "yyyyMMddHHmmssfff", CultureInfo.InvariantCulture)
            };
            TrackLeftAirspaceEventArgs args3 = new TrackLeftAirspaceEventArgs(trackOutOfSpace);

            _filter.TrackLeft += Raise.EventWith(args3);

            Assert.That(_eventLefted.Track.Tag, Is.EqualTo(track.Tag));
        }
コード例 #9
0
ファイル: UpdaterUnitTest.cs プロジェクト: Chr1000/ATM
        public void Initial_SeperationCheckerTwoTracks_TracksIsCorrect()
        {
            List <Track> listToTest = new List <Track>();
            Track        track      = new Track()
            {
                Tag       = "NIC444",
                X         = 25000,
                Y         = 20000,
                Altitude  = 5000,
                TimeStamp = DateTime.ParseExact("20151006213456789", "yyyyMMddHHmmssfff", CultureInfo.InvariantCulture)
            };

            listToTest.Add(track);
            TracksFilteredEventArgs args = new TracksFilteredEventArgs(listToTest);

            _filter.TracksFiltered += Raise.EventWith(this, args);

            List <Track> listToTest2 = new List <Track>();
            Track        newTrack1   = new Track()
            {
                Tag       = "NIC444",
                X         = 25010,
                Y         = 20020,
                Altitude  = 4980,
                TimeStamp = DateTime.ParseExact("20151006213456800", "yyyyMMddHHmmssfff", CultureInfo.InvariantCulture)
            };
            Track newTrack2 = new Track()
            {
                Tag       = "GOG123",
                X         = 34010,
                Y         = 15000,
                Altitude  = 4980,
                TimeStamp = DateTime.ParseExact("20151006213456800", "yyyyMMddHHmmssfff", CultureInfo.InvariantCulture)
            };

            listToTest2.Add(newTrack1);
            listToTest2.Add(newTrack2);
            TracksFilteredEventArgs args2 = new TracksFilteredEventArgs(listToTest2);

            _filter.TracksFiltered += Raise.EventWith(this, args2);

            Assert.That(_sepTrack.Tag, Is.EqualTo(newTrack1.Tag));
            Assert.That(_tracksUpdatedeInSeperationList[1].Tag, Is.EqualTo(newTrack2.Tag));
        }
コード例 #10
0
        private void EvalTrack(object o, TracksFilteredEventArgs args)
        {
            if (args.FilteredTracks.Count != 0 && UpdatedTracksList.Count == 0)
            {
                foreach (var track in args.FilteredTracks)
                {
                    UpdatedTracksList.Add(track);
                    TrackEntered?.Invoke(this, new TrackEnteredAirspaceEventArgs(new Event(EventsList, "Track Entered Airspace", track, DateTime.Now)));
                }
            }

            else if (args.FilteredTracks.Count != 0 && UpdatedTracksList.Count != 0)
            {
                foreach (var filteredTrack in args.FilteredTracks)
                {
                    var updatedTrack = UpdatedTracksList.Find(i => i.Tag == filteredTrack.Tag);

                    if (updatedTrack == null)
                    {
                        UpdatedTracksList.Add(filteredTrack);
                        TrackEntered?.Invoke(this, new TrackEnteredAirspaceEventArgs(new Event(EventsList, "Track Entered Airspace", filteredTrack, DateTime.Now)));
                    }
                    else
                    {
                        var newCalEvent = new TrackStartCalEventArgs(
                            UpdatedTracksList[UpdatedTracksList.IndexOf(updatedTrack)],
                            filteredTrack);
                        TrackStartCal?.Invoke(this, newCalEvent);
                        if (newCalEvent.CalculatedTrack != null)
                        {
                            filteredTrack.Course   = newCalEvent.CalculatedTrack.Course;
                            filteredTrack.Velocity = newCalEvent.CalculatedTrack.Velocity;
                            UpdatedTracksList[UpdatedTracksList.IndexOf(updatedTrack)] = filteredTrack;
                        }

                        SeperationChecker?.Invoke(this, new SeperationCheckerEventArgs(EventsList, UpdatedTracksList, filteredTrack));
                    }
                }
            }
            args.UpdatedTracks = UpdatedTracksList;
            TracksUpdated?.Invoke(this, new TracksUpdatedEventArgs(UpdatedTracksList, EventsList));
        }
コード例 #11
0
ファイル: UpdaterUnitTest.cs プロジェクト: Chr1000/ATM
        public void Initial_TracksUpdatedThreeTracks_TracksCountIsCorrect()
        {
            List <Track> listToTest = new List <Track>();

            listToTest.Add(new Track()
            {
                Tag = "NIC111", X = 25000, Y = 65000, Altitude = 15000, TimeStamp = DateTime.ParseExact("20151006213456789", "yyyyMMddHHmmssfff", CultureInfo.InvariantCulture)
            });
            listToTest.Add(new Track()
            {
                Tag = "GJO222", X = 35000, Y = 55000, Altitude = 5000, TimeStamp = DateTime.ParseExact("20151006213456789", "yyyyMMddHHmmssfff", CultureInfo.InvariantCulture)
            });
            listToTest.Add(new Track()
            {
                Tag = "ASD333", X = 45000, Y = 45000, Altitude = 7000, TimeStamp = DateTime.ParseExact("20151006213456789", "yyyyMMddHHmmssfff", CultureInfo.InvariantCulture)
            });
            TracksFilteredEventArgs args = new TracksFilteredEventArgs(listToTest);

            _filter.TracksFiltered += Raise.EventWith(this, args);

            List <Track> listToTest2 = new List <Track>();

            listToTest2.Add(new Track()
            {
                Tag = "NIC111", X = 25010, Y = 64987, Altitude = 14998, TimeStamp = DateTime.ParseExact("20151006213456800", "yyyyMMddHHmmssfff", CultureInfo.InvariantCulture)
            });
            listToTest2.Add(new Track()
            {
                Tag = "GJO222", X = 35005, Y = 55015, Altitude = 5010, TimeStamp = DateTime.ParseExact("20151006213456800", "yyyyMMddHHmmssfff", CultureInfo.InvariantCulture)
            });
            listToTest2.Add(new Track()
            {
                Tag = "ASD333", X = 45008, Y = 44994, Altitude = 7002, TimeStamp = DateTime.ParseExact("20151006213456800", "yyyyMMddHHmmssfff", CultureInfo.InvariantCulture)
            });
            TracksFilteredEventArgs args2 = new TracksFilteredEventArgs(listToTest2);

            _filter.TracksFiltered += Raise.EventWith(this, args2);

            Assert.That(_updatedTrackList.Count, Is.EqualTo(3));
        }