当前位置: 首页>>代码示例>>Python>>正文


Python Units.timeIncrement方法代码示例

本文整理汇总了Python中Units.timeIncrement方法的典型用法代码示例。如果您正苦于以下问题:Python Units.timeIncrement方法的具体用法?Python Units.timeIncrement怎么用?Python Units.timeIncrement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Units的用法示例。


在下文中一共展示了Units.timeIncrement方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: simulateFlight

# 需要导入模块: import Units [as 别名]
# 或者: from Units import timeIncrement [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)
    }
开发者ID:kaihua-cai,项目名称:ge_contest,代码行数:79,代码来源:Simulator.py


注:本文中的Units.timeIncrement方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。