本文整理汇总了Python中Units.timeDifference方法的典型用法代码示例。如果您正苦于以下问题:Python Units.timeDifference方法的具体用法?Python Units.timeDifference怎么用?Python Units.timeDifference使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Units
的用法示例。
在下文中一共展示了Units.timeDifference方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: generateParametersAndState
# 需要导入模块: import Units [as 别名]
# 或者: from Units import timeDifference [as 别名]
def generateParametersAndState(airports, entry):
# TODO (niwang)
# airports: a dict of AirportID to Airport object
# the original list of Airport is a tuple of Airport and Environment, now we only keep
# the Airport Object
# entry: FlightEntry
aircraftType = Aircraft.mediumRange
departureAirport = airports[entry.DepartureAirport] #['Airport.Code']
arrivalAirport = airports[entry.ArrivalAirport] #['Airport.Code']
timeElapsed = Units.timeDifference(0.0, entry.ActualGateDepartureTime)
maximumFuel = Units.fuelGallonsToFuelPounds(aircraftType.FuelCapacity)
initialFuel = entry.InitialFuel
fuelConsumed = entry.ConsumedFuel
flightParameters = FlightParameters(
entry.Id,
'Eastbound' if departureAirport.Position.PositionX < \
arrivalAirport.Position.PositionX else 'Westbound',
aircraftType,
arrivalAirport,
entry.Payload,
initialFuel,
entry.ScheduledGateDepartureTime,
entry.ActualGateDepartureTime,
entry.ScheduledGateArrivalTime,
entry.ScheduledRunwayArrivalTime)
flightState = FlightState(
entry.Position,
0.0,
0.0,
timeElapsed,
fuelConsumed,
Airspace.emptyIntersection,
0.0,
[])
return (flightParameters, flightState)
示例2: simulateFlight
# 需要导入模块: import Units [as 别名]
# 或者: from Units import timeDifference [as 别名]
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)
}