public IPrintCalculation CalculateTrack(ITrackCalculator calculator)
 {
     _calculators.Add(calculator);
     foreach (var trackPoint in _track.TrackPoints)
     {
         calculator.Calculate(trackPoint);
     }
     return(this);
 }
Exemplo n.º 2
0
        public double Calculate(ITrack firstTrack, ITrack secondTrack)
        {
            var dist            = _trackHorizontalDistanceCalculator.Calculate(firstTrack, secondTrack);
            var timeFirstTrack  = ConvertTimeStringToDateTime(firstTrack.TimeStamp);
            var timeSecondTrack = ConvertTimeStringToDateTime(secondTrack.TimeStamp);
            var timeDiff        = Math.Abs(timeFirstTrack.Subtract(timeSecondTrack).TotalSeconds);

            return(dist / timeDiff);
        }
        public void Calculate_CalculateRightTrackDistance_ReturnIsCorrect()
        {
            var firstTrack  = FakeTrackFactory.GetTrackWithTime("20190101000000000", 100, 100, 100);
            var secondTrack = FakeTrackFactory.GetTrackWithTime("20190101000500000", 100, 100, 100);//5 minutes after the last

            _fakeTrackHorizontalDistanceCalculator.Calculate(Arg.Any <ITrack>(), Arg.Any <ITrack>()).Returns(300);


            var result = _uutTrackSpeedCalculator.Calculate(firstTrack, secondTrack);

            Assert.That(result, Is.EqualTo(1));
        }
Exemplo n.º 4
0
        public void Update_TheUpdateCalculatesSpeed_SpeedIsCorrect()
        {
            List <ITrack> firstTracks = new List <ITrack>()
            {
                FakeTrackFactory.GetTrackWithTag("tag1", 100, 100, 100),
                FakeTrackFactory.GetTrackWithTag("tag2", 200, 200, 300),
                FakeTrackFactory.GetTrackWithTag("tag3", 200, 200, 400),
            };
            List <ITrack> secondTracks = new List <ITrack>()
            {
                FakeTrackFactory.GetTrackWithTag("tag1", 200, 300, 100),
                FakeTrackFactory.GetTrackWithTag("tag2", 100, 400, 300),
                FakeTrackFactory.GetTrackWithTag("tag3", 300, 500, 600),
            };

            _speedCalculator.Calculate(Arg.Any <ITrack>(), Arg.Any <ITrack>()).Returns(100);

            _uutAirspaceUpdater.Update(ref firstTracks, secondTracks);

            Assert.That(firstTracks.Select(track => track.Speed), Is.All.EqualTo(100.0).Within(1).Percent);
        }
Exemplo n.º 5
0
        public void Update(ref List <ITrack> needsUpdate, List <ITrack> theUpdate)
        {
            foreach (var track in theUpdate)
            {
                var trackHistory = needsUpdate.Find(t => t.Tag == track.Tag);
                if (trackHistory == null)
                {
                    continue;
                }
                track.Speed  = _speedCalculator.Calculate(trackHistory, track);
                track.Course = _trajectoryCalculator.Calculate(trackHistory, track);
            }

            needsUpdate = theUpdate;
        }