Ejemplo n.º 1
0
        public void Init()
        {
            _mock = new Mock <IService <ApproachDTO> >();
            _approachController = new ApproachController(_mock.Object, null);

            _approaches = new List <ApproachDTO>
            {
                new ApproachDTO
                {
                    Id                 = 1,
                    CreatedDate        = DateTime.Now,
                    ModifiedDate       = DateTime.Now,
                    PlannedTimeForRest = 5,
                    SpentTimeForRest   = 5
                },
                new ApproachDTO
                {
                    Id                 = 2,
                    CreatedDate        = DateTime.Now,
                    ModifiedDate       = DateTime.Now,
                    PlannedTimeForRest = 10,
                    SpentTimeForRest   = 9
                },
                new ApproachDTO
                {
                    Id                 = 3,
                    CreatedDate        = DateTime.Now,
                    ModifiedDate       = DateTime.Now,
                    PlannedTimeForRest = 15,
                    SpentTimeForRest   = 14
                }
            };
        }
        public void GetApproachRoute(ApproachScenario scenario)
        {
            var airfield   = Populator.Airfields.First(af => af.Name.Equals(scenario.Airfield));
            var controller = new ApproachController(airfield);

            airfield.WindHeading = scenario.Wind;

            var expected = scenario.Waypoints;

            var actual = controller.GetApproachRoute(scenario.StartPoint).Select(x => x.Name).ToList();

            Console.WriteLine(string.Join(" -> ", actual));

            CollectionAssert.AreEqual(expected, actual);
        }
Ejemplo n.º 3
0
        public static async Task <string> Process(IRadioCall radioCall, string voice,
                                                  ConcurrentQueue <byte[]> responseQueue)
        {
            return(await Task.Run(() =>
            {
                try
                {
                    var airfield = Constants.Airfields.First(x => x.Name == radioCall.ReceiverName);
                    var approachRoute = new ApproachController(airfield).GetApproachRoute(radioCall.Sender.Position);

                    var initialTrueBearing = Geospatial.BearingTo(radioCall.Sender.Position.Coordinate,
                                                                  new Coordinate(approachRoute.First().Latitude, approachRoute.First().Longitude));

                    var initialMagneticBearing =
                        Regex.Replace(
                            Geospatial.TrueToMagnetic(radioCall.Sender.Position, initialTrueBearing).ToString("000"),
                            "\\d{1}", " $0");

                    var response =
                        $"fly heading {initialMagneticBearing}, descend and maintain 2,000, reduce speed 2 0 0 knots, for vectors to {approachRoute.Last().Name}, {approachRoute.First().Name}";

                    var currentPosition = new NavigationPoint
                    {
                        Name = "Current Position",
                        Latitude = radioCall.Sender.Position.Coordinate.Latitude,
                        Longitude = radioCall.Sender.Position.Coordinate.Longitude
                    };

                    approachRoute = approachRoute.Prepend(currentPosition).ToList();

                    new AtcProgressChecker(radioCall.Sender, airfield, voice, approachRoute, responseQueue)
                    .CalledInbound();

                    return response;
                }
                catch (InvalidOperationException)
                {
                    return "There are no ATC services currently available at this airfield.";
                }
                catch (NoActiveRunwaysFoundException ex)
                {
                    Logger.Error(ex, "No Active Runways found");
                    return "We could not find any active runways.";
                }
            }));
        }