def simulateFlight(coreFunctions, simParams, airportEnvironment, airspace, costParameters, weather, state, flightParams, instructions): # (coreFunctions:SimulationCoreFunctions) (simParams:SimulationParameters) airportEnvironment airspace # costParameters (weather:WeatherState) (state:FlightState) (flightParams:FlightParameters) (instructions:Route) = instructionStatus, remainingSteps, log, endState = Flight.runInstructions( coreFunctions, simParams, flightParams, weather, airspace, state, instructions) reachedArrivalPoint = (instructionStatus != 'Failed' and simParams['LandingMode'] != SimulationParameters.LandingMode.NoLanding \ and Arrival.withinArrivalZone(flightParams, endState)) landed = False if reachedArrivalPoint: weight = coreFunctions.WeightModel(flightParams, endState) time = Units.timeIncrement(flightParams.ActualGateDepartureTime, endState.TimeElapsed) landingState = coreFunctions.ArrivalModel(flightParams) #airportEnvironment, FuelModel.flightFunctions, # flightParams, endState.AircraftPosition, weight, # time) updatedState = Flight.updateSimulationState(endState, landingState) # // Check that fuel tank was not exhausted during arrival if updatedState.FuelConsumed > flightParams.InitialFuel: airport = flightParams.DestinationAirport message = Messages.FuelExhausted(flightParams.FlightId, endState.AircraftPosition) Flight.addMessageToState(updatedState, message) else: landed = True results = updatedState else: airport = flightParams.DestinationAirport # print airport message = Messages.CannotLand( flightParams.FlightId, endState.AircraftPosition, airport.Code) Flight.addMessageToState(endState, message) results = endState fuelConsumed = Units.fuelPoundsToFuelGallons(results.FuelConsumed) delay = None if landed: arrivalTime = Units.timeIncrement(flightParams.ActualGateDepartureTime, results.TimeElapsed) delay = Units.timeDifference(arrivalTime, flightParams.ScheduledGateArrivalTime) costs = CostModel.flightCost(costParameters, instructions, flightParams.Payload, fuelConsumed, delay, results.TimeElapsedInTurbulence) # // Add final record to flight log (east,north,altitude) = results.AircraftPosition finalLogEntry = FlightTypes.FlightLogEntry( FlightId = flightParams.FlightId, Latitude = 0.0, # <Latitude> Longitude = 0.0, # <Longitude> Easting = east, Northing = north, ElapsedTime = results.TimeElapsed, AirSpeed = 0.0, # <Knots> GroundSpeed = 0.0, #<Knots> Altitude = altitude, FuelConsumed = results.FuelConsumed, Weight = coreFunctions.WeightModel(flightParams, results), InRestrictedZones = False, InTurbulentZones = False, Status = 'Landed' if landed else 'Crashed' ) updatedLog = log.append(finalLogEntry) return { 'FlightId' : flightParams.FlightId, 'Duration' : results.TimeElapsed, 'FuelBurned' : results.FuelConsumed, 'Messages' : results.Messages, 'Log' : updatedLog, 'ReachedDestination' : landed, 'CostDetail' : costs, 'Cost' : CostModel.accumulateCosts(costs) }