Beispiel #1
0
        private void btnRunwayAdd_Click(object sender, EventArgs e)
        {
            string runwayName = this.txtRunwayName.Text;
            string status     = this.cmbRunwayStatus.Text;

            if (runwayName != string.Empty && status != string.Empty)
            {
                int count = db.Runways.Where(r => r.Name.Trim() == runwayName).Count();
                if (count == 0)
                {
                    Runway rnwy = new Runway();
                    rnwy.Name   = runwayName;
                    rnwy.Status = this.chechStatus(status);
                    db.Runways.Add(rnwy);
                    db.SaveChanges();
                    this.clearRunwayText();
                }
                else
                {
                    this.lblRunwayErrors.Text = "Artiq movcuddur.";
                }
            }
            else
            {
                this.lblRunwayErrors.Text = "Boshlugu doldurun !..";
            }
        }
        //checks an airport for extending of runway
        public static void CheckForExtendRunway(Airport airport)
        {
            int minYearsBetweenExpansions = 5;

            long maxRunwayLenght             = (from r in airport.Runways select r.Length).Max();
            long longestRequiredRunwayLenght = AirlinerTypes.GetTypes(a => a.Produced.From <= GameObject.GetInstance().GameTime&& a.Produced.To >= GameObject.GetInstance().GameTime).Max(a => a.MinRunwaylength);

            var airportRoutes  = AirportHelpers.GetAirportRoutes(airport);
            var routeAirliners = airportRoutes.SelectMany(r => r.getAirliners());

            long longestRunwayInUse = routeAirliners.Count() > 0 ? routeAirliners.Max(a => a.Airliner.Type.MinRunwaylength) : 0;

            if (maxRunwayLenght < longestRequiredRunwayLenght / 2 && maxRunwayLenght < longestRunwayInUse * 3 / 4 && GameObject.GetInstance().GameTime.AddYears(-minYearsBetweenExpansions) > airport.LastExpansionDate)
            {
                List <string> runwayNames = (from r in Airports.GetAllAirports().SelectMany(a => a.Runways) select r.Name).Distinct().ToList();

                foreach (Runway r in airport.Runways)
                {
                    runwayNames.Remove(r.Name);
                }

                Runway.SurfaceType surface = airport.Runways[0].Surface;
                long lenght = Math.Min(longestRequiredRunwayLenght * 3 / 4, longestRunwayInUse * 2);

                Runway runway = new Runway(runwayNames[rnd.Next(runwayNames.Count)], lenght, surface, GameObject.GetInstance().GameTime.AddDays(90), false);
                airport.Runways.Add(runway);

                airport.LastExpansionDate = GameObject.GetInstance().GameTime;
            }
        }
Beispiel #3
0
        public void UserInterface(string flight, int progress)
        {
            try
            {
                Airplane a = proxy.GetAirplane(flight);
                Runway   r = a.Runway;
                if (r.RunwayID.Equals("R1"))
                {
                    tForR1 = new Thread(() => UpdateForR1(flight, progress));
                    tForR1.Start();
                }
                if (r.RunwayID.Equals("R2"))
                {
                    tforR2 = new Thread(() => UpdateForR2(flight, progress));
                    tforR2.Start();
                }

                if (r.RunwayID.Equals("R3"))
                {
                    tForR3 = new Thread(() => UpdateForR3(flight, progress));
                    tForR3.Start();
                }
                if (r.RunwayID.Equals("R4"))
                {
                    tforR4 = new Thread(() => UpdateForR4(flight, progress));
                    tforR4.Start();
                }
            }
            catch (Exception)
            { }
        }
Beispiel #4
0
        public void T11_MakingSurePlaneWorksProperly()
        {
            // Given
            int initialFuel = 100;
            int fuelBurn    = 1;
            int fuelGain    = 3;

            PassingTime time  = new PassingTime();
            Plane       plane = PlaneFactory.Create(location: PlaneLocation.InAir, fuel: initialFuel, passingTime: time);

            time.AddTurn();
            time.AddTurn();
            time.AddTurn();
            time.AddTurn();

            Runway runway = new Runway("runway 01", RunwayStatus.Empty);

            plane.TryLandOn(runway);

            // When
            time.AddTurn();

            // Then
            Assert.IsTrue(plane.Fuel == initialFuel - 4 * fuelBurn + 1 * fuelGain);
        }
Beispiel #5
0
        public void T08_ControlTowerGives3EmptyRunways1NullIf3PresentAndRequested()
        {
            // Given
            ControlTower tower = new ControlTower(new Runway[] {
                new Runway("r1"), new Runway("r2"), new Runway("r3")
            });

            // When
            List <Runway> results = new List <Runway>();

            for (int i = 0; i < 4; i++)
            {
                Runway r = tower.GetAvailableRunway();
                if (r != null)
                {
                    r.Status = RunwayStatus.Full;
                }
                results.Add(r);
            }

            // Then
            Assert.IsTrue(results[0].Name == "r1");
            Assert.IsTrue(results[1].Name == "r2");
            Assert.IsTrue(results[2].Name == "r3");
            Assert.IsTrue(results[3] == null);
        }
Beispiel #6
0
        public void T16_PlaneGetsRepairedAfter10TurnsOnRunway()
        {
            // Given
            int initialFuel = 100;
            int maxFuel     = 100;

            PassingTime time  = new PassingTime();
            Plane       plane = PlaneFactory.Create(location: PlaneLocation.InAir, damage: PlaneDamage.Damaged,
                                                    fuel: initialFuel, maxFuel: maxFuel, passingTime: time);
            Runway runway = new Runway("runway 01", RunwayStatus.Empty);

            runway.AcceptPlane(plane);

            for (int i = 0; i < 9; i++) // 9 turns have passed
            {
                time.AddTurn();
            }

            Assert.IsTrue(plane.Damage == PlaneDamage.Damaged);

            // When
            time.AddTurn();

            // Then
            Assert.IsTrue(plane.Damage == PlaneDamage.None);
        }
Beispiel #7
0
    public static Runway FindNearestRunway(double lat, double lon, float altSL, string bodyName, out float horTan, out float verTan)
    {
        Runway nearest    = null;
        double nearestTan = 100000;

        verTan = float.NaN;
        horTan = float.NaN;
        float dist_, horTan_ = float.PositiveInfinity, verTan_ = float.PositiveInfinity;

        foreach (Runway runway in runways)
        {
            if (runway.bodyName == bodyName)
            {
                double distance = SphericDistance(lat, lon, runway.lat, runway.lon, runway.seaLevel);
                //Debug.Log("distance" + distance + " angle" + SphericAngle(lat, lon, runway.lat, runway.lon));
                if (distance < 100000)
                {
                    runway.AssessBias(lat, lon, altSL, out horTan_, out verTan_, out dist_);
                    float horabs = Mathf.Abs(horTan_);
                    if (dist_ > 0 && dist_ < runway.length && horabs < nearestTan && horabs < 0.2f && Mathf.Abs(verTan_) < 0.2f)
                    {
                        nearest    = runway;
                        nearestTan = horabs;
                        verTan     = verTan_;
                        horTan     = horTan_;
                    }
                }
            }
        }
        return(nearest);
    }
Beispiel #8
0
        public void T18_GoToRunwayAfter3TurnsOnHangar()
        {
            // Given
            int initialFuel = 100;
            int maxFuel     = 100;

            PassingTime time  = new PassingTime();
            Plane       plane = PlaneFactory.Create(location: PlaneLocation.OnRunway, damage: PlaneDamage.None,
                                                    fuel: initialFuel, maxFuel: maxFuel, passingTime: time);
            Plane plane2 = PlaneFactory.Create(location: PlaneLocation.OnRunway, damage: PlaneDamage.None,
                                               fuel: initialFuel, maxFuel: maxFuel, passingTime: time);

            Hangar.AddPlaneToHangar(plane);
            Hangar.AddPlaneToHangar(plane2);

            Runway runway = new Runway("runway 01", RunwayStatus.Empty);

            ControlTower tower = new ControlTower(new Runway[] { runway });

            runway.AcceptPlane(plane);

            for (int i = 0; i < 3; i++) // 9 turns have passed
            {
                time.AddTurn();
            }

            // When
            time.AddTurn();
            // Then
            Assert.IsTrue(plane.Location == PlaneLocation.OnRunway);
            Assert.IsTrue(plane2.Location == PlaneLocation.OnRunway);
        }
        private TaxiInstructions GetTaxiInstructionsWhenMultipleRunways(TaxiPoint source, List <Runway> runways)
        {
            var tryGetPaths = _airfield.NavigationGraph.ShortestPathsDijkstra(_airfield.NavigationCostFunction, source);

            var cheapestPathCost = double.PositiveInfinity;
            IEnumerable <TaggedEdge <NavigationPoint, string> > cheapestPath = new List <TaggedEdge <NavigationPoint, string> >();
            Runway closestRunway = null;

            foreach (var runway in runways)
            {
                if (!tryGetPaths(runway, out var path))
                {
                    continue;
                }
                var taggedEdges = path.ToList();
                var pathCost    = PathCost(taggedEdges);
                if (!(pathCost < cheapestPathCost))
                {
                    continue;
                }
                closestRunway    = runway;
                cheapestPath     = taggedEdges;
                cheapestPathCost = pathCost;
            }
            return(CompileInstructions(closestRunway, cheapestPath));
        }
Beispiel #10
0
        /* After this call is executed successfully, the occupied parking stand
         * becomes Available,and the used runway is InOperation for the
         * length of operation duration parameter and can't handle any other
         * operations during this time. After operation finishes, the runway becomes
         * Available again. The call is non-blocking, i.e. it returns before the
         * runway is cleared. */
        public PerformResult PerformTakeOff(TakeOffRequestToken token)
        {
            token.Stop();
            token.Elapsed -= OnExpiredTakeOffToken;
            if (DateTime.Now <= token.expiration && !token.hasExpired)
            {
                Runway runway = GetRunwayById(token.runwayId);
                // Check if the runway exists and if it has been properly reserved
                if (runway == null || runway.state != Runway.RunwayState.Reserved)
                {
                    ReleaseTakeOffResources(token);
                    return(PerformResult.InvalidParameters);
                }
                runway.aircraftId = token.aircraftId;
                runway.Elapsed   += OnTakeOffOperationComplete;

                ParkingStand parkingStand = GetParkingStandByAircraftId(token.aircraftId);
                parkingStand.aircraftId = Guid.Empty;
                parkingStand.state      = ParkingStand.ParkingStandState.Available;

                token.Dispose();
                runway.Operate();
                return(PerformResult.Success);
            }

            else // Token has expired
            {
                if (!token.hasExpired) // If the token's expiration date has passed but the elapsed event hasn't fired yet, then release the resources
                {
                    ReleaseTakeOffResources(token);
                }
                return(PerformResult.ExpiredToken);
            }
        }
Beispiel #11
0
        private List <Runway> GetLogicRunwaysOfAirport(Airport apt)
        {
            List <Runway> runways = new List <Runway>();
            List <RUNWAY> RWYS    = new BLL.RUNWAY().GetModelList("AIRPORTCODE=" + apt.AIRPORTCODE);

            foreach (var rwy in RWYS)
            {
                foreach (var rwytoqfu in (new BLL.RUNWAYTOQFUS().GetModelList("RUNWAYCODE=" + rwy.RUNWAYCODE)))
                {
                    Runway logicrwy = new Runway();

                    logicrwy             = JsonConverter.JsonDeserialize <Runway>(JsonConverter.JsonSerialize <QFU>(new BLL.QFU().GetModel(rwytoqfu.QFUCODE)));
                    logicrwy.DESIGNATION = new BLL.QFUREFERENCE().GetModel(rwytoqfu.QFUREFCODE).DESIGNATION;
                    RUNWAY rwytemp = new BLL.RUNWAY().GetModel(rwy.RUNWAYCODE);
                    logicrwy.MAGNETICHEADING     = rwytemp.MAGNETICHEADING;
                    logicrwy.MAGNETICHEADINGDATE = rwytemp.MAGNETICHEADINGDATE;
                    logicrwy.STRENGTH            = rwytemp.STRENGTH;
                    logicrwy.MAXLENGTH           = rwytemp.MAXLENGTH;
                    logicrwy.WIDTH     = rwytemp.WIDTH;
                    logicrwy.SHOULDER  = rwytemp.SHOULDER;
                    logicrwy.OBSTACLES = JsonConverter.JsonDeserialize <List <Obstacle> >(JsonConverter.JsonSerialize <List <OBSTACLES> >(new BLL.OBSTACLES().GetModelList("QFUCODE=" + rwytoqfu.QFUCODE)));
                    runways.Add(logicrwy);
                }
            }
            return(runways);
        }
        public async Task <ActionResult> DeleteSupervisor(string lastName, int?runwayId)
        {
            if (runwayId == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            if (lastName == null)
            {
                ModelState.AddModelError("lastName", "Nie wybrałeś pracownika");
            }
            if (ModelState.IsValid)
            {
                Supervisor supervisor = db.Supervisors.Where(x => x.lastName == lastName).FirstOrDefault();
                Runway     runway     = await db.Runways.FindAsync(runwayId);

                runway.Supervisors.Remove(supervisor);
                supervisor.Runways.Remove(runway);
                await db.SaveChangesAsync();

                return(RedirectToAction("Details", new { id = runway.id }));
            }
            else
            {
                Runway runway = await db.Runways.FindAsync(runwayId);

                var runwaySupervisors = runway.Supervisors.Select(x => x.id).ToList();
                IEnumerable <Supervisor> availableSupervisors = db.Supervisors.
                                                                Where(x => runwaySupervisors.
                                                                      Contains(x.id));

                ViewBag.lastName = new SelectList(availableSupervisors, "lastName", "lastName");
                return(View(runway));
            }
        }
        private void btnBuildRunway_Click(object sender, RoutedEventArgs e)
        {
            Runway runway = (Runway)PopUpBuildRunway.ShowPopUp(this.Airport);

            if (runway != null)
            {
                double runwayPrice = AirportHelpers.GetAirportRunwayPrice(this.Airport, runway.Length);

                if (runwayPrice > GameObject.GetInstance().HumanAirline.Money)
                {
                    WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2219"), string.Format(Translator.GetInstance().GetString("MessageBox", "2219", "message"), this.Airport.Profile.Name, runwayPrice), WPFMessageBoxButtons.Ok);
                }
                else
                {
                    WPFMessageBoxResult result = WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2218"), string.Format(Translator.GetInstance().GetString("MessageBox", "2218", "message"), this.Airport.Profile.Name, runwayPrice), WPFMessageBoxButtons.YesNo);

                    if (result == WPFMessageBoxResult.Yes)
                    {
                        this.Airport.Runways.Add(runway);

                        AirlineHelpers.AddAirlineInvoice(GameObject.GetInstance().HumanAirline, GameObject.GetInstance().GameTime, Invoice.InvoiceType.Purchases, runwayPrice);

                        showRunways();
                    }
                }
            }
        }
Beispiel #14
0
        public void TestItReturnsElementsInOrder()
        {
            Runway first  = RunwayFactory.Make("EGKK", "08R");
            Runway second = RunwayFactory.Make("EGKK", "08L");
            Runway third  = RunwayFactory.Make("EGKK", "26L");
            Runway fourth = RunwayFactory.Make("EGCC", "23R");
            Runway fifth  = RunwayFactory.Make("EGGD", "09");

            sectorElements.Add(first);
            sectorElements.Add(second);
            sectorElements.Add(third);
            sectorElements.Add(fourth);
            sectorElements.Add(fifth);

            IEnumerable <ICompilableElementProvider> expected = new List <ICompilableElementProvider>()
            {
                fourth,
                fifth,
                second,
                first,
                third
            };

            AssertCollectedItems(expected);
        }
        public void TestItAddsRunways()
        {
            Runway runway = RunwayFactory.Make();

            collection.Add(runway);

            Assert.Equal(runway, collection.Runways[0]);
        }
Beispiel #16
0
        // Release resources resereved by a takeoff request token that will not be used.
        private void ReleaseTakeOffResources(TakeOffRequestToken token)
        {
            Runway runway = GetRunwayById(token.runwayId);

            runway.state      = Runway.RunwayState.Available;
            runway.aircraftId = Guid.Empty;
            token.Dispose();
        }
Beispiel #17
0
 public static double DistanceToRunway(Vessel vessel, Runway runway)
 {
     if (vessel == null)
     {
         return(float.MaxValue);
     }
     return(DistanceFromTo(vessel.longitude, vessel.latitude, runway.coords.longitude, runway.coords.latitude, vessel.mainBody.Radius));
 }
Beispiel #18
0
        public IActionResult OneRunwayDeg(int run_id)
        {
            var runway = _context.Runways.FirstOrDefault(x => x.runway_id == run_id);
            // var runwaydeg = _context.Runways.Where
            Runway thisRunway = _context.Runways.FirstOrDefault(c => c.runway_id == run_id);

            return(Ok(thisRunway.airport_ref));
        }
Beispiel #19
0
            public static double VerticalGlideSlopeDeviation(Vessel vessel, Runway runway)
            {
                double d     = DistanceToRunway(vessel, runway);
                double h     = vessel.altitude - runway.elevation;
                double glide = Utils.RadiansToDegree(Math.Asin(h / d));

                return(glide - runway.glideslope);
            }
Beispiel #20
0
        public EditSIDsWindow(Runway ParamRunway)
        {
            InitializeComponent( );
            CurrentRunway = ParamRunway;
            Title         = String.Format("{0} / {1}", ParamRunway.Number, ParamRunway.ReciprocalNumber);

            FillDataGridView( );
        }
Beispiel #21
0
        public void ImportRunwayData()
        {
            System.Console.WriteLine("Initializing runway data...");

            Runway NewRunway;

            string[] rows = System.IO.File.ReadAllLines(_runways_path);

            for (int y = 1; y < rows.Length; y++)
            {
                NewRunway = new Runway();
                string[] current_column = rows[y].Split(',');
                for (int x = 0; x < current_column.Length; x++)
                {
                    if (x == 1)
                    {
                        int airport_id = _dbQuery.FindAirportByReference(System.Int32.Parse(current_column[x])).AirportId;
                        NewRunway.AirportId = airport_id;
                    }
                    if (x == 3)
                    {
                        try{
                            NewRunway.RunwayLengthFt = System.Int32.Parse(current_column[x]);
                        }catch {
                            System.Console.WriteLine($"Unable to parse runway length value {current_column[x]} setting to 0");
                            NewRunway.RunwayLengthFt = 0;
                        }
                    }
                    if (x == 5)
                    {
                        NewRunway.RunwayMaterial = current_column[x].Replace("\"", "");
                    }

                    if (x == 12)
                    {
                        try{
                            NewRunway.LowHeadingDeg = System.Int32.Parse(current_column[x]);
                        }catch {
                            NewRunway.LowHeadingDeg = null;
                        }
                    }

                    if (x == 8)
                    {
                        NewRunway.RunwayName = current_column[x].Replace("\"", "");
                    }
                }
                if ((y - 1) % 1000 == 0)
                {
                    System.Console.WriteLine($"Adding item {y-1} out of {rows.Length}...");
                    _dbQuery.SaveChanges();
                }
                _dbQuery.AddRunway(NewRunway);
            }

            _dbQuery.SaveChanges();
            System.Console.WriteLine("Database initalized with runways...");
        }
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            Runway runway = await db.Runways.FindAsync(id);

            db.Runways.Remove(runway);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
Beispiel #23
0
    public override GridObject CreateGridObject()
    {
        Runway new_runway_component = (Runway)base.CreateGridObject();

        // also add to airport

        airport.runwayList.Add(new_runway_component);

        return(new_runway_component);
    }
 private static Dictionary<string, object> GetRunwayInformation(Runway runway)
 {
     if (runway == null) return null;
     var info = new Dictionary<string, object>();
     info["markers"] = new[] { runway.outerMarkerDist, runway.middleMarkerDist, runway.innerMarkerDist };
     info["identity"] = runway.ident;
     info["altitude"] = runway.altMSL;
     info["heading"] = runway.hdg;
     return info;
 }
Beispiel #25
0
    void CreateFlight(Flight flight)
    {
        Runway curRunway = airport.runwayList[0];         // very temporary, need to able to chose runway

        // create flight and add to list
        Flight newFlight = new Flight(flight.GetGate(), flight.GetParkingSpot(), curRunway,
                                      secondsDelayBeforeExit, secondsSeparation, secondsVariation,
                                      minutesToBoarding, minutesBoarding, this);

        CreateFlightFinal(newFlight, curRunway);
    }
Beispiel #26
0
        private void dgwRunwayData_RowHeaderMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            int id = Convert.ToInt32(dgwRunwayData.Rows[e.RowIndex].Cells[0].Value);

            this.selectedItem            = db.Runways.Find(id);
            this.txtRunwayName.Text      = this.selectedItem.Name;
            this.cmbRunwayStatus.Text    = this.selectedItem.Status == 1 ? "Active" : "Passive";
            this.btnRunwayAdd.Visible    = false;
            this.btnRunwayUpdate.Visible = true;
            this.btnRunwayDelete.Visible = true;
        }
Beispiel #27
0
        // Release resources reserved by a landing request token that will not be used.
        private void ReleaseLandingResources(LandingRequestToken token)
        {
            Runway       runway       = GetRunwayById(token.runwayId);
            ParkingStand parkingStand = GetParkingStandById(token.parkingStandId);

            runway.state            = Runway.RunwayState.Available;
            runway.aircraftId       = Guid.Empty;
            parkingStand.aircraftId = Guid.Empty;
            parkingStand.state      = ParkingStand.ParkingStandState.Available;
            token.Dispose();
        }
Beispiel #28
0
        // Releases resources and updates states accordingly when the takeoff operation completes (runway timer elapses).
        private void OnTakeOffOperationComplete(object source, ElapsedEventArgs e)
        {
            Runway runway = (Runway)source;

            // Unsubscribe from the runway's timer.
            runway.Elapsed -= OnTakeOffOperationComplete;

            // Update state and data.
            runway.state      = Runway.RunwayState.Available;
            runway.aircraftId = Guid.Empty;
        }
Beispiel #29
0
            public static void updateNavigationData()
            {
                //see if information is current
                if (GetLastNavUpdateUT() != Planetarium.GetUniversalTime())
                {
                    selectedGlideSlope = gsList[gsIdx];
                    selectedRwy        = rwyList[rwyIdx];

                    //Since there seems to be no callback methods to determine whether waypoint has been set or changed, we have to refresh INS data on every update
                    NavWaypoint navpoint = FinePrint.WaypointManager.navWaypoint;
                    if (FinePrint.WaypointManager.navIsActive() && (navpoint != null))
                    {
                        //Trying to find the FinePrint waypoint that navigation is set for:
                        Waypoint waypoint = null;

                        foreach (Waypoint wp in FinePrint.WaypointManager.Instance().Waypoints)
                        {
                            if (navpoint.latitude == wp.latitude && navpoint.longitude == wp.longitude)
                            {
                                waypoint = wp;
                                break;
                            }
                        }
                        if (waypoint != null)
                        {
                            //If waypoint is fine then generate fake target runway every time
                            Runway insTarget = new Runway();
                            insTarget.isINSTarget  = true;
                            insTarget.ident        = waypoint.name;
                            insTarget.hdg          = selectedRwy != null ? selectedRwy.hdg : 0;
                            insTarget.altMSL       = (float)(waypoint.height + waypoint.altitude);
                            insTarget.locLatitude  = (float)navpoint.latitude;
                            insTarget.locLongitude = (float)navpoint.longitude;
                            insTarget.gsLatitude   = (float)navpoint.latitude;
                            insTarget.gsLongitude  = (float)navpoint.longitude;
                            selectedRwy            = insTarget;
                        }
                    }

                    currentVessel = FlightGlobals.ActiveVessel;

                    bearing        = NavUtilLib.Utils.CalcBearingToBeacon(currentVessel, selectedRwy);
                    dme            = NavUtilLib.Utils.CalcDistanceToBeacon(currentVessel, selectedRwy);
                    elevationAngle = NavUtilLib.Utils.CalcElevationAngle(currentVessel, selectedRwy);
                    //locDeviation = NavUtilLib.Utils.CalcLocalizerDeviation(bearing, selectedRwy);
                    locDeviation = (float)NavUtilLib.Utils.CalcLocalizerDeviation(currentVessel, selectedRwy);
                    gsDeviation  = NavUtilLib.Utils.CalcGlideslopeDeviation(elevationAngle, selectedGlideSlope);

                    //
                    runwayHeading = (float)NavUtilLib.Utils.CalcProjectedRunwayHeading(currentVessel, selectedRwy);

                    SetLastNavUpdateUT();
                }
            }
Beispiel #30
0
        public void T06_ControlTowerGivesNullRunwayIfNotPresentAndRequested()
        {
            // Given
            Runway       runway = new Runway("runway 01", RunwayStatus.Full);
            ControlTower tower  = new ControlTower(new Runway[] { runway });

            // When
            Runway result = tower.GetAvailableRunway();

            // Then
            Assert.IsTrue(result == null);
        }
Beispiel #31
0
        public void T01_RunwayAcceptsAPlaneIfPlaneInAirAndRunwayEmpty()
        {
            // Given
            Plane  plane  = PlaneFactory.Create(PlaneLocation.InAir);
            Runway runway = new Runway("runway 01", RunwayStatus.Empty);

            // When
            runway.AcceptPlane(plane);

            // Then
            Assert.IsTrue(runway.Status == RunwayStatus.Full);
        }
Beispiel #32
0
        static void Main(string[] args)
        {
            Runway c = new Runway();
            object o = c.inspect(new int[] { }, new int[] { });

            if (o is IEnumerable)
            {
                foreach (object oi in (IEnumerable)o)
                {
                    System.Console.Out.WriteLine(oi);

                }
            }
            else
                System.Console.Out.WriteLine(o);
            System.Console.In.ReadLine();
        }
Beispiel #33
0
    public Flight(Gate _gate, ParkingSpot parking_spot, Runway _runway, 
		int delayBeforeExit, int seperation, int variation,
		int _minutesToBoarding, int _minutesBoarding, FlightController _flightController)
    {
        gate = _gate;
        parkingSpot = parking_spot;
        runway = _runway;

        secondsDelayBeforeExit = delayBeforeExit;
         		secondsSeparation = seperation;
         		secondsVariation = variation;

         		minutesToBoarding = _minutesToBoarding;
         		minutesBoarding = _minutesBoarding;

         		flightController = _flightController;

        origin = "Sydney"; // need to pull from some sort of database
        state = STATE_START;
    }
            public static void updateNavigationData()
            {
                //see if information is current
                if (GetLastNavUpdateUT() != Planetarium.GetUniversalTime())
                {

                    selectedGlideSlope = gsList[gsIdx];
                    selectedRwy = rwyList[rwyIdx];

                    //Since there seems to be no callback methods to determine whether waypoint has been set or changed, we have to refresh INS data on every update
                    NavWaypoint navpoint = FinePrint.WaypointManager.navWaypoint;
                    if (FinePrint.WaypointManager.navIsActive() && (navpoint != null))
                    {
                        //Trying to find the FinePrint waypoint that navigation is set for:
                        Waypoint waypoint = null;

                        foreach (Waypoint wp in FinePrint.WaypointManager.Instance().Waypoints)
                        {
                            if (navpoint.latitude == wp.latitude && navpoint.longitude == wp.longitude)
                            {
                                waypoint = wp;
                                break;
                            }
                        }
                        if (waypoint != null)
                        {
                            //If waypoint is fine then generate fake target runway every time
                            Runway insTarget = new Runway();
                            insTarget.isINSTarget = true;
                            insTarget.ident = waypoint.name;
                            insTarget.hdg = selectedRwy != null ? selectedRwy.hdg : 0;
                            insTarget.altMSL = (float)(waypoint.height + waypoint.altitude);
                            insTarget.locLatitude = (float)navpoint.latitude;
                            insTarget.locLongitude = (float)navpoint.longitude;
                            insTarget.gsLatitude = (float)navpoint.latitude;
                            insTarget.gsLongitude = (float)navpoint.longitude;
                            selectedRwy = insTarget;
                        }
                    }

                    currentVessel = FlightGlobals.ActiveVessel;

                    bearing = NavUtilLib.Utils.CalcBearingToBeacon(currentVessel, selectedRwy);
                    dme = NavUtilLib.Utils.CalcDistanceToBeacon(currentVessel, selectedRwy);
                    elevationAngle = NavUtilLib.Utils.CalcElevationAngle(currentVessel, selectedRwy);
                    //locDeviation = NavUtilLib.Utils.CalcLocalizerDeviation(bearing, selectedRwy);
                    locDeviation = (float)NavUtilLib.Utils.CalcLocalizerDeviation(currentVessel, selectedRwy);
                    gsDeviation = NavUtilLib.Utils.CalcGlideslopeDeviation(elevationAngle, selectedGlideSlope);

                    //
                    runwayHeading = (float)NavUtilLib.Utils.CalcProjectedRunwayHeading(currentVessel, selectedRwy);

                    SetLastNavUpdateUT();
                }
            }
            public static void updateNavigationData()
            {
                selectedGlideSlope = gsList[gsIdx];
                selectedRwy = rwyList[rwyIdx];
                currentVessel = FlightGlobals.ActiveVessel;

                bearing = NavUtilLib.Utils.CalcBearingToBeacon(currentVessel, selectedRwy);
                dme = NavUtilLib.Utils.CalcDistanceToBeacon(currentVessel, selectedRwy);
                elevationAngle = NavUtilLib.Utils.CalcElevationAngle(currentVessel, selectedRwy);
                //locDeviation = NavUtilLib.Utils.CalcLocalizerDeviation(bearing, selectedRwy);
                locDeviation = (float)NavUtilLib.Utils.CalcLocalizerDeviation(currentVessel, selectedRwy);
                gsDeviation = NavUtilLib.Utils.CalcGlideslopeDeviation(elevationAngle, selectedGlideSlope);

                //
                runwayHeading = (float)NavUtilLib.Utils.CalcProjectedRunwayHeading(currentVessel, selectedRwy);

                SetLastNavUpdateUT();
            }
    void CreateFlightFinal(Flight flight, Runway runway)
    {
        flights.Add(flight);

        // need to create method for spawning airplanes if there are different types of airplanes
        flight.SpawnAirplane(runway.GetPositionCenter2(), airplane, airplaneParent);
        flight.AddPassengers();	// adds both incoming and outgoing passengers

        // TEMPORARY needs to be delayed somehow?
        flight.SpawnIncomingPassengers();

        Debug.Log("created flight!");
    }