Beispiel #1
0
        public void landing()
        {
            //Establishing communication
            Console.WriteLine(credentials + " is Searching for control tower...");
            //ITuple controlTowerTupleInner = new dotSpace.Objects.Space.Tuple("Control Tower Nr.", typeof(int), typeof(ControlTower));
            //ITuple controlTowerTuple = airport.QueryP("Control Towers", controlTowerTupleInner);
            if (controlTowerSpace != null)
            {
                ITuple controlTowerTuple = controlTowerSpace.Query("Control Tower Nr.", typeof(int), typeof(ControlTower));
                //Console.WriteLine(controlTowerTuple);
                if (controlTowerTuple != null)
                {
                    //Getting landing clearance
                    ControlTower controlTower = (ControlTower)controlTowerTuple[2];
                    Console.WriteLine(credentials + " found control tower and getting landing clearance...");
                    ITuple freeRunwayLock = controlTower.getRunwayClearance();
                    if (freeRunwayLock != null)
                    {
                        //runwaySpace.Get(freeRunwayLock);
                        Console.WriteLine(credentials + " got landing clearance with ID " + freeRunwayLock[0] + freeRunwayLock[1]);

                        //Leave airspace, land in airport
                        //Thread.sleep(5000);

                        //Landing & Taxiway step
                        Console.WriteLine(credentials + " is searching for free landing taxiway...");
                        //ITuple freeTaxiWayTuple = taxiwaySpace.Query("Taxiway Nr.", controlTowerTuple[1], typeof(int), true);
                        //ITuple freeTaxiWayTuple = taxiwayLandingSpace.Get("Taxiway L", controlTowerTuple[1], typeof(int), true);
                        ITuple freeTaxiWayTuple = taxiwayLandingSpace.Get("Taxiway L", freeRunwayLock[1], typeof(int), true);
                        int    barrierLimit     = (int)freeTaxiWayTuple[2] - 1;
                        Console.WriteLine(credentials + " found free landing taxiway with barrier value " + (barrierLimit + 1) + " and getting free taxiway tuple...");
                        //taxiwaySpace.Get((string)freeTaxiWayTuple[0], freeTaxiWayTuple[1], barrierLimit);
                        Console.WriteLine(credentials + " is putting runway lock with ID " + freeRunwayLock[0] + freeRunwayLock[1]);
                        //runwaySpace.Put(freeRunwayLock);
                        controlTower.putRunway(freeRunwayLock);
                        Console.WriteLine(credentials + " is putting free landing taxiway back with new barrier " + barrierLimit);
                        taxiwayLandingSpace.Put((string)freeTaxiWayTuple[0], freeTaxiWayTuple[1], barrierLimit, (barrierLimit) > 0);
                        //System.Threading.Thread.Sleep(2500);

                        //Hanger step
                        Console.WriteLine(credentials + " is searching for same landing taxiway, to increase barrier...");
                        //ITuple usedTaxiWay = taxiwayLandingSpace.Get("Taxiway L", controlTowerTuple[1], typeof(int), typeof(bool));
                        ITuple usedTaxiWay = taxiwayLandingSpace.Get("Taxiway L", freeTaxiWayTuple[1], typeof(int), typeof(bool));
                        barrierLimit = (int)usedTaxiWay[2] + 1;
                        Console.WriteLine(credentials + " is increasing landing taxiway " + usedTaxiWay[1] + "'s barrierLimit to " + barrierLimit);
                        taxiwayLandingSpace.Put((string)freeTaxiWayTuple[0], freeTaxiWayTuple[1], barrierLimit, (barrierLimit) > 0);
                        Console.WriteLine(credentials + " has safely arrived in the hangar!");
                        // Thread kill
                        //return;
                    }
                }
            }
        }
Beispiel #2
0
        public void takeoff()
        {
            // Leaving hangar, entering taxiway
            Console.WriteLine(credentials + " is searching for free take-off taxiway...");
            //ITuple freeTaxiWayTuple = taxiwayTakeoffSpace.Get("Taxiway T", controlTowerTuple[1], typeof(int), true);
            ITuple freeTaxiWayTuple = taxiwayTakeoffSpace.Get("Taxiway T", typeof(int), typeof(int), true);
            int    barrierLimit     = (int)freeTaxiWayTuple[2] - 1;

            Console.WriteLine(credentials + " found free take-off taxiway with barrier value " + (barrierLimit + 1) + " and getting free taxiway tuple...");
            //System.Threading.Thread.Sleep(2500);
            Console.WriteLine(credentials + " is putting free take-off taxiway back with new barrier " + barrierLimit);
            taxiwayTakeoffSpace.Put((string)freeTaxiWayTuple[0], freeTaxiWayTuple[1], barrierLimit, barrierLimit > 0);

            // Leaving taxiway, entering runway

            //Getting takeoff clearance
            //Establishing communication
            Console.WriteLine(credentials + " is searching for control tower...");
            //ITuple controlTowerTupleInner = new dotSpace.Objects.Space.Tuple("Control Tower Nr.", typeof(int), typeof(ControlTower));
            //ITuple controlTowerTuple = airport.QueryP("Control Towers", controlTowerTupleInner);
            if (controlTowerSpace != null)
            {
                ITuple controlTowerTuple = controlTowerSpace.Query("Control Tower Nr.", typeof(int), typeof(ControlTower));
                //Console.WriteLine(controlTowerTuple);
                if (controlTowerTuple != null)
                {
                    ControlTower controlTower = (ControlTower)controlTowerTuple[2];
                    Console.WriteLine(credentials + " found control tower and getting takeoff clearance...");
                    ITuple freeRunwayLock = controlTower.getRunwayClearance();
                    if (freeRunwayLock != null)
                    {
                        //Make space on the taxiway you just left
                        Console.WriteLine(credentials + " is searching for same take-off taxiway, to increase barrier...");
                        //ITuple usedtaxiway = taxiwayTakeoffSpace.Get("Taxiway T", controlTowerTuple[1], typeof(int), typeof(bool));
                        ITuple usedtaxiway = taxiwayTakeoffSpace.Get("Taxiway T", freeTaxiWayTuple[1], typeof(int), typeof(bool));
                        barrierLimit = (int)usedtaxiway[2] + 1;
                        Console.WriteLine(credentials + " is increasing take-off taxiway " + usedtaxiway[1] + "'s barrierlimit to " + barrierLimit);
                        taxiwayTakeoffSpace.Put((string)usedtaxiway[0], usedtaxiway[1], barrierLimit, barrierLimit > 0);
                        Console.WriteLine(credentials + " has safely left the taxiway!");

                        //Leave the runway
                        //runwaySpace.Get(freeRunwayLock);
                        Console.WriteLine(credentials + " got takeoff clearance with ID " + freeRunwayLock[0] + freeRunwayLock[1] + " and left the airport!");
                        //leave airport, enter in airspace
                        //Thread.sleep(5000);
                        //runwaySpace.Put(freeRunwayLock);
                        controlTower.putRunway(freeRunwayLock);
                        //Airspace step
                    }
                }
            }
        }
Beispiel #3
0
 public void efficientTakeoff()
 {
     //Establishing communication
     Console.WriteLine(credentials + " is searching for control tower...");
     //ITuple controlTowerTupleInner = new dotSpace.Objects.Space.Tuple("Control Tower Nr.", typeof(int), typeof(ControlTower));
     //ITuple controlTowerTuple = airport.QueryP("Control Towers", controlTowerTupleInner);
     if (controlTowerSpace != null)
     {
         ITuple controlTowerTuple = controlTowerSpace.Query("Control Tower Nr.", typeof(int), typeof(ControlTower));
         //Console.WriteLine(controlTowerTuple);
         if (controlTowerTuple != null)
         {
             ControlTower controlTower = (ControlTower)controlTowerTuple[2];
             while (true)
             {
                 hangarToTaxiway("Charlie");
                 ITuple freeRunwayS = controlTower.isRunwayFreeForTakeoff(credentials, 0);
                 if (freeRunwayS != null)
                 {
                     taxiwayToRunway("Charlie", freeRunwayS, controlTower, "efficient");
                     break;
                 }
                 taxiwayToTaxiway("Charlie", "Delta");
                 ITuple freeRunwayW = controlTower.isRunwayFreeForTakeoff(credentials, 90);
                 if (freeRunwayW != null)
                 {
                     taxiwayToRunway("Delta", freeRunwayW, controlTower, "efficient");
                     break;
                 }
                 taxiwayToTaxiway("Delta", "Epsilon");
                 ITuple freeRunwayN = controlTower.isRunwayFreeForTakeoff(credentials, 0);
                 if (freeRunwayN != null)
                 {
                     taxiwayToRunway("Epsilon", freeRunwayN, controlTower, "efficient");
                     break;
                 }
                 taxiwayToTaxiway("Epsilon", "Alfa");
                 ITuple freeRunwayE = controlTower.isRunwayFreeForTakeoff(credentials, 90);
                 if (freeRunwayE != null)
                 {
                     taxiwayToRunway("Alfa", freeRunwayE, controlTower, "efficient");
                     break;
                 }
                 taxiwayToTaxiway("Alfa", "Beta");
                 taxiwayToHangar("Beta");
             }
         }
     }
 }
Beispiel #4
0
        public void realisticTakeoff()
        {
            //Establishing communication
            Console.WriteLine(credentials + " is searching for control tower...");
            //ITuple controlTowerTupleInner = new dotSpace.Objects.Space.Tuple("Control Tower Nr.", typeof(int), typeof(ControlTower));
            //ITuple controlTowerTuple = airport.QueryP("Control Towers", controlTowerTupleInner);
            if (controlTowerSpace != null)
            {
                ITuple controlTowerTuple = controlTowerSpace.Query("Control Tower Nr.", typeof(int), typeof(ControlTower));
                //Console.WriteLine(controlTowerTuple);
                if (controlTowerTuple != null)
                {
                    ControlTower controlTower = (ControlTower)controlTowerTuple[2];
                    switch (windDirection)
                    {
                    case "S":
                        hangarToTaxiway("Charlie");
                        ITuple freeTakeoffRunwayS = runwaySpace.Query("Runway Nr.", 0);
                        taxiwayToRunway("Charlie", freeTakeoffRunwayS, controlTower, "realistic");
                        break;

                    case "N":
                        hangarToTaxiway("Charlie");
                        taxiwayToTaxiway("Charlie", "Delta");
                        taxiwayToTaxiway("Delta", "Epsilon");
                        ITuple freeTakeoffRunwayN = runwaySpace.Query("Runway Nr.", 0);
                        taxiwayToRunway("Epsilon", freeTakeoffRunwayN, controlTower, "realistic");
                        break;

                    case "W":
                        hangarToTaxiway("Charlie");
                        taxiwayToTaxiway("Charlie", "Delta");
                        ITuple freeTakeoffRunwayW = runwaySpace.Query("Runway Nr.", 90);
                        taxiwayToRunway("Delta", freeTakeoffRunwayW, controlTower, "realistic");
                        break;

                    case "E":
                        hangarToTaxiway("Charlie");
                        taxiwayToTaxiway("Charlie", "Delta");
                        taxiwayToTaxiway("Delta", "Epsilon");
                        taxiwayToTaxiway("Epsilon", "Alfa");
                        ITuple freeTakeoffRunwayE = runwaySpace.Query("Runway Nr.", 90);
                        taxiwayToRunway("Alfa", freeTakeoffRunwayE, controlTower, "realistic");
                        break;
                    }
                }
            }
        }
Beispiel #5
0
        private void runwayToTaxiway(string taxiway, ControlTower ct, ITuple frwT)
        {
            updateGraphics(credentials, airspaceName, "" + frwT[0] + frwT[1]);
            //runwaySpace.Get(runwayGUILock);

            Console.WriteLine(credentials + " is searching for free landing taxiway " + taxiway);
            ITuple freeTaxiWayTupleTo = taxiwaySpace.Get("Taxiway", taxiway, typeof(int), true);
            int    barrierLimitA      = (int)freeTaxiWayTupleTo[2] - 1;

            Console.WriteLine(credentials + " found free taxiway " + taxiway + " with barrier value " + (barrierLimitA + 1) + " and getting free taxiway tuple...");
            Console.WriteLine(credentials + " is putting runway lock with ID " + frwT[0] + frwT[1]);
            ct.putRunway(credentials, frwT);
            updateGraphics(credentials, "" + frwT[0] + frwT[1], "" + freeTaxiWayTupleTo[0] + freeTaxiWayTupleTo[1]);
            Console.WriteLine(credentials + " is putting free taxiway " + taxiway + " back with lower barrier " + barrierLimitA);
            taxiwaySpace.Put((string)freeTaxiWayTupleTo[0], freeTaxiWayTupleTo[1], barrierLimitA, (barrierLimitA) > 0);
            //taxiwaySpace.Get(taxiwayGUILock);
            //System.Threading.Thread.Sleep(2500);
        }
Beispiel #6
0
        private void taxiwayToRunway(string taxiway, ITuple frwL, ControlTower ct, string mode)
        {
            //Make space on the taxiway you just left
            if (mode == "realistic")
            {
                ct.getRunway(credentials, frwL);
            }
            Console.WriteLine(credentials + " is searching for same take-off taxiway, to increase barrier...");
            ITuple usedtaxiway = taxiwaySpace.Get("Taxiway", taxiway, typeof(int), typeof(bool));
            int    bl          = (int)usedtaxiway[2] + 1;

            Console.WriteLine(credentials + " is increasing take-off taxiway " + usedtaxiway[1] + "'s barrierlimit to " + bl);


            taxiwaySpace.Put((string)usedtaxiway[0], usedtaxiway[1], bl, bl > 0);
            Console.WriteLine(credentials + " has safely left the taxiway!");

            //Leave the runway
            Console.WriteLine(credentials + " got takeoff clearance with ID " + frwL[0] + frwL[1] + " and left the airport!");
            ct.putRunway(credentials, frwL);
            //Airspace step
        }
Beispiel #7
0
        public void efficientLanding()
        {
            //Establishing communication
            Console.WriteLine(credentials + " is Searching for control tower...");
            ITuple controlTowerTuple = controlTowerSpace.Query("Control Tower Nr.", typeof(int), typeof(ControlTower));

            //Getting landing clearance
            ControlTower controlTower = (ControlTower)controlTowerTuple[2];

            Console.WriteLine(credentials + " found control tower and getting landing clearance...");
            ITuple freeRunwayForLanding = controlTower.getRunwayClearance(credentials);

            switch ((int)freeRunwayForLanding[1])
            {
            case 0:
                //Leave airspace, land in airport
                runwayToTaxiway("Alfa", controlTower, freeRunwayForLanding);

                // Leaving taxiway Afa, entering taxiway Beta
                taxiwayToTaxiway("Alfa", "Beta");

                // Leaving taxiway Beta, entering hangar
                taxiwayToHangar("Beta");
                break;

            case 18:
                //Leave airspace, land in airport
                runwayToTaxiway("Delta", controlTower, freeRunwayForLanding);

                taxiwayToTaxiway("Delta", "Epsilon");

                taxiwayToTaxiway("Epsilon", "Alfa");

                taxiwayToTaxiway("Alfa", "Beta");
                // Leaving taxiway Charlie, entering hangar
                taxiwayToHangar("Beta");
                break;


            case 90:
                //Leave airspace, land in airport
                runwayToTaxiway("Beta", controlTower, freeRunwayForLanding);

                // Leaving taxiway Beta, entering hangar
                taxiwayToHangar("Beta");
                break;

            case 27:
                // Leave airspace, land in aiport
                runwayToTaxiway("Epsilon", controlTower, freeRunwayForLanding);

                // Leaving taxiway epsilon, entering taxiway Alfa
                taxiwayToTaxiway("Epsilon", "Alfa");

                // Leaving taxiway Alfa, entering taxiway Beta
                taxiwayToTaxiway("Alfa", "Beta");

                // Leaving taxiway Beta, entering hangar
                taxiwayToHangar("Beta");
                break;
            }
        }
Beispiel #8
0
        public void realisticLanding()
        {
            //Establishing communication
            Console.WriteLine(credentials + " is Searching for control tower...");
            ITuple controlTowerTuple = controlTowerSpace.Query("Control Tower Nr.", typeof(int), typeof(ControlTower));

            //Getting landing clearance
            ControlTower controlTower = (ControlTower)controlTowerTuple[2];

            Console.WriteLine(credentials + " found control tower and getting landing clearance...");


            switch (windDirection)
            {
            case "S":
                ITuple freeLandingRunwayS = runwaySpace.Get("Runway Nr.", 0);

                runwayToTaxiway("Alfa", controlTower, freeLandingRunwayS);

                taxiwayToTaxiway("Alfa", "Beta");

                taxiwayToHangar("Beta");


                break;

            case "N":
                ITuple freeLandingRunwayN = runwaySpace.Get("Runway Nr.", 0);

                runwayToTaxiway("Delta", controlTower, freeLandingRunwayN);

                taxiwayToTaxiway("Delta", "Epsilon");

                taxiwayToTaxiway("Epsilon", "Alfa");

                taxiwayToTaxiway("Alfa", "Beta");

                taxiwayToHangar("Beta");

                break;

            case "W":
                ITuple freeLandingRunwayW = runwaySpace.Get("Runway Nr.", 90);

                runwayToTaxiway("Beta", controlTower, freeLandingRunwayW);
                taxiwayToHangar("Beta");

                break;

            case "E":
                ITuple freeLandingRunwayE = runwaySpace.Get("Runway Nr.", 90);

                runwayToTaxiway("Epsilon", controlTower, freeLandingRunwayE);

                taxiwayToTaxiway("Epsilon", "Alfa");

                taxiwayToTaxiway("Alfa", "Beta");

                taxiwayToHangar("Beta");

                break;
            }
        }
Beispiel #9
0
        public Airport(ITuple setup)//, int noOfHangers, int noOfControlTowers)
        {
            //this.airport = new SpaceRepository();
            this.runWaySpace       = new SequentialSpace();
            this.taxiWaySpace      = new SequentialSpace();
            this.controlTowerSpace = new SequentialSpace();
            this.airplaneSpace     = new SequentialSpace();
            //this.hanger = new SequentialSpace();
            //this.controlTower = new SequentialSpace();
            this.noOfRunways   = (int)setup[0];
            this.noOfTaxiways  = (int)setup[1];
            this.barrier       = (int)setup[2];
            this.noOfPlanes    = (int)setup[3];
            this.airField      = (AirField)setup[4];
            this.realisticMode = (bool)setup[5];
            this.windDirection = (string)setup[6];
            //this.noOfHangers = noOfHangers;
            //this.noOfControlTowers = noOfControlTowers;
            while (noOfRunways > 0 || noOfTaxiways > 0)//|| noOfHangers > 0)
            {
                if (noOfRunways > 0)
                {
                    if (noOfRunways == 2)
                    {
                        this.runWaySpace.Put("Runway Nr.", 0);
                    }

                    else
                    {
                        this.runWaySpace.Put("Runway Nr.", 90);
                    }

                    //this.runWaySpace.Put("Runway Nr. " + noOfRunways + " -lock");
                    noOfRunways--;
                }
                if (noOfTaxiways > 0)
                {
                    if (noOfTaxiways == 5)
                    {
                        this.taxiWaySpace.Put("Taxiway", "Alfa", barrier, barrier > 0);
                    }
                    else if (noOfTaxiways == 4)
                    {
                        this.taxiWaySpace.Put("Taxiway", "Beta", barrier, barrier > 0);
                    }
                    else if (noOfTaxiways == 3)
                    {
                        this.taxiWaySpace.Put("Taxiway", "Charlie", barrier, barrier > 0);
                    }
                    else if (noOfTaxiways == 2)
                    {
                        this.taxiWaySpace.Put("Taxiway", "Delta", barrier, barrier > 0);
                    }
                    else
                    {
                        this.taxiWaySpace.Put("Taxiway", "Epsilon", barrier, barrier > 0);
                    }
                    noOfTaxiways--;
                }

                /*if (noOfHangers > 0)
                 * {
                 *  this.hanger.Put("Hanger Nr.", noOfHangers);
                 *  noOfHangers--;
                 * }*/
                while (noOfControlTowers > 0)
                {
                    ControlTower controlTower = new ControlTower(runWaySpace, taxiWaySpace, hangerSpace, airplaneSpace);
                    if (controlTowerSpace != null)
                    {
                        this.controlTowerSpace.Put("Control Tower Nr.", noOfControlTowers, controlTower);
                        noOfControlTowers--;
                    }
                }
            }
            spawnAirplanes(airField);
            //this.airport.AddSpace("Runways", runWaySpace);
            //this.airport.AddSpace("Runway Locks", runWayLockSpace);
            //this.airport.AddSpace("Taxiways", taxiWaySpace);
            //this.airport.AddSpace("Hangers", hangerSpace);
            //this.airport.AddSpace("Control Towers", controlTowerSpace);
        }