Esempio n. 1
0
        public override AirplaneState ComputeNextState(FlightPlan flightPlan, AtcInstruction instruction)
        {
            FlightPlan.Validate(flightPlan);

            ApproachClearance approachClearance = instruction as ApproachClearance;

            if (approachClearance != null)
            {
                if (this.Fix == approachClearance.LocationOrLimit)
                {
                    return(new ApproachState(approachClearance.LocationOrLimit));
                }
            }

            EnrouteClearance enrouteClearance = instruction as EnrouteClearance;

            if (enrouteClearance != null)
            {
                Fix next = flightPlan.GetNextFix(this.Fix);

                if (enrouteClearance.IsClearedTo(this.Fix, next))
                {
                    return(new EnrouteState(this.Fix, next));
                }
            }

            // By default continue holding
            return(this);
        }
Esempio n. 2
0
        public override AirplaneState ComputeNextState(FlightPlan flightPlan, AtcInstruction instruction)
        {
            FlightPlan.Validate(flightPlan);

            TakeoffClearance clearance = instruction as TakeoffClearance;

            if (clearance == null || clearance.LocationOrLimit != this.Airport)
            {
                Debug.Assert(clearance == null && instruction == null, "We have received an unexpected instruction or a takeoff clearance for the wrong airport");
                return(this);  // Waiting for takeoff clearance
            }
            else
            {
                var newState = new DepartingState(this.Airport);
                return(newState);
            }
        }
Esempio n. 3
0
        public override AirplaneState ComputeNextState(FlightPlan flightPlan, AtcInstruction instruction)
        {
            FlightPlan.Validate(flightPlan);

            // Hold at the airport if we have received a holding instruction
            HoldInstruction holdInstruction = instruction as HoldInstruction;

            if (holdInstruction != null && holdInstruction.LocationOrLimit == this.Airport)
            {
                return(new HoldingState(this.Airport));
            }
            else
            {
                Debug.Assert(flightPlan.FlightPath[0] == this.Airport);
                Fix next = flightPlan.FlightPath[1];
                return(new EnrouteState(this.Airport, next));
            }
        }
Esempio n. 4
0
        public override AirplaneState ComputeNextState(FlightPlan flightPlan, AtcInstruction instruction)
        {
            FlightPlan.Validate(flightPlan);

            if (this.To == flightPlan.Destination)
            {
                ApproachClearance clearance = instruction as ApproachClearance;
                if (clearance != null && clearance.LocationOrLimit == flightPlan.Destination)
                {
                    return(new ApproachState(flightPlan.Destination));
                }
                else
                {
                    return(new HoldingState(flightPlan.Destination));
                }
            }
            else
            {
                Fix next = flightPlan.GetNextFix(this.To);
                return(new EnrouteState(this.To, next));
            }
        }
Esempio n. 5
0
 public abstract AirplaneState ComputeNextState(FlightPlan flightPlan, AtcInstruction instruction);