[298] | 1 |
|
---|
| 2 | import const
|
---|
[619] | 3 | import gates
|
---|
[298] | 4 | import checks
|
---|
| 5 | import fs
|
---|
[384] | 6 | from i18n import xstr
|
---|
[298] | 7 | import util
|
---|
| 8 |
|
---|
| 9 | import sys
|
---|
| 10 | import time
|
---|
| 11 | import traceback
|
---|
| 12 |
|
---|
| 13 | from collections import deque
|
---|
| 14 |
|
---|
| 15 | #---------------------------------------------------------------------------------------
|
---|
| 16 |
|
---|
[297] | 17 | ## @package mlx.acft
|
---|
| 18 | #
|
---|
| 19 | # The simulator-independent aircraft classes.
|
---|
| 20 | #
|
---|
| 21 | # This module contains the aircraft classes that contain some general data
|
---|
| 22 | # about each aircraft type in the MAVA Fleet. The base class, \ref Aircraft
|
---|
| 23 | # also implements some parts of the logging and traces some data. The classes
|
---|
| 24 | # are also responsible for creating the \ref mlx.checks "checkers". Most of
|
---|
| 25 | # them are created by the \ref Aircraft class' constructor, but there can be
|
---|
| 26 | # type-specific differences. For example the lights are different for different
|
---|
| 27 | # types, so there is a \ref Aircraft._appendLightsLoggers "function" which can
|
---|
| 28 | # be reimplemented in child classes, if needed. This class maintains also the
|
---|
| 29 | # \ref SmoothedValue "smoothed values" of the IAS and the VS and set these
|
---|
| 30 | # values in the \ref mlx.fs.AircraftState "aircraft state" when it is received
|
---|
| 31 | # from the simulator.
|
---|
[4] | 32 |
|
---|
| 33 | #---------------------------------------------------------------------------------------
|
---|
| 34 |
|
---|
[512] | 35 | # Derate type: no derate possible
|
---|
| 36 | DERATE_NONE = 0
|
---|
| 37 |
|
---|
| 38 | # Derate type: Boeing, i.e. a percentage value.
|
---|
| 39 | # For logging, the percentage value is expected as a string (i.e. whatever the
|
---|
| 40 | # pilot enters into the text field).
|
---|
| 41 | DERATE_BOEING = 1
|
---|
| 42 |
|
---|
| 43 | # Derate type: EPR, i.e. an EPR value.
|
---|
| 44 | # For logging, the EPR value is expected as a string (i.e. whatever the pilot
|
---|
| 45 | # enters into the text field).
|
---|
| 46 | DERATE_EPR = 2
|
---|
| 47 |
|
---|
| 48 | # Derate type: Tupolev, i.e. nominal or takeoff
|
---|
| 49 | # For logging, one of the DERATE_TUPOLEV_xxx values are expected.
|
---|
| 50 | DERATE_TUPOLEV = 3
|
---|
| 51 |
|
---|
| 52 | # Tupolev derate value: nominal
|
---|
| 53 | DERATE_TUPOLEV_NOMINAL = 1
|
---|
| 54 |
|
---|
| 55 | # Tupolev derate value: takeoff
|
---|
| 56 | DERATE_TUPOLEV_TAKEOFF = 2
|
---|
| 57 |
|
---|
| 58 | # Derate type: BAe-146, i.e. enabled or not
|
---|
| 59 | # For logging, a boolean is expected.
|
---|
| 60 | DERATE_B462 = 4
|
---|
| 61 |
|
---|
| 62 | #---------------------------------------------------------------------------------------
|
---|
| 63 |
|
---|
[197] | 64 | class SmoothedValue(object):
|
---|
| 65 | """A smoothed value."""
|
---|
| 66 | def __init__(self):
|
---|
| 67 | """Construct the value."""
|
---|
| 68 | self._deque = deque()
|
---|
| 69 | self._sum = 0
|
---|
| 70 |
|
---|
| 71 | def add(self, length, value):
|
---|
| 72 | """Add the given value and smooth with the given length."""
|
---|
| 73 | dequeLength = len(self._deque)
|
---|
| 74 | while dequeLength>=length:
|
---|
| 75 | self._sum -= self._deque.popleft()
|
---|
| 76 | dequeLength -= 1
|
---|
| 77 |
|
---|
| 78 | self._sum += value
|
---|
| 79 | self._deque.append(value)
|
---|
| 80 |
|
---|
| 81 | def get(self):
|
---|
| 82 | """Get the average."""
|
---|
| 83 | return self._sum / len(self._deque)
|
---|
[331] | 84 |
|
---|
[4] | 85 | #---------------------------------------------------------------------------------------
|
---|
| 86 |
|
---|
| 87 | class Aircraft(object):
|
---|
| 88 | """Base class for aircraft."""
|
---|
[8] | 89 | @staticmethod
|
---|
| 90 | def create(flight):
|
---|
| 91 | """Create an aircraft instance for the type in the given flight."""
|
---|
| 92 | return _classes[flight.aircraftType](flight)
|
---|
| 93 |
|
---|
[592] | 94 | def __init__(self, flight, minLandingFuel = None,
|
---|
| 95 | recommendedLandingFuel = None):
|
---|
[4] | 96 | """Construct the aircraft for the given type."""
|
---|
[8] | 97 | self._flight = flight
|
---|
[591] | 98 | self._minLandingFuel = minLandingFuel
|
---|
[592] | 99 | self._recommendedLandingFuel = recommendedLandingFuel
|
---|
[369] | 100 |
|
---|
| 101 | self._name = None
|
---|
| 102 | self._modelName = None
|
---|
| 103 |
|
---|
[4] | 104 | self._aircraftState = None
|
---|
[331] | 105 |
|
---|
[9] | 106 | self._maxVS = -10000.0
|
---|
| 107 | self._minVS = 10000.0
|
---|
[4] | 108 |
|
---|
[101] | 109 | self._v1r2LineIndex = None
|
---|
[384] | 110 | self._derateLineID = None
|
---|
[391] | 111 | self._takeoffAntiIceLineID = None
|
---|
[96] | 112 | self._vrefLineIndex = None
|
---|
[391] | 113 | self._landingAntiIceLineID = None
|
---|
[96] | 114 |
|
---|
[117] | 115 | self.humanWeight = 82.0
|
---|
| 116 |
|
---|
[598] | 117 | self.initialClimbSpeedAltitude = 1500
|
---|
| 118 | self.reverseMinSpeed = 50
|
---|
[360] | 119 |
|
---|
[644] | 120 | self.hasStrobeLight = True
|
---|
| 121 |
|
---|
[611] | 122 | self.maxTakeOffPitch = 15.0
|
---|
| 123 | self.maxTouchDownPitch = 15.0
|
---|
[624] | 124 | self.brakeCoolTime = 10.0
|
---|
[611] | 125 |
|
---|
[8] | 126 | self._checkers = []
|
---|
| 127 |
|
---|
[197] | 128 | config = flight.config
|
---|
[11] | 129 | # Loggers
|
---|
| 130 |
|
---|
[8] | 131 | self._checkers.append(checks.StageChecker())
|
---|
[9] | 132 | self._checkers.append(checks.TakeOffLogger())
|
---|
[8] | 133 |
|
---|
| 134 | self._checkers.append(checks.AltimeterLogger())
|
---|
[321] | 135 |
|
---|
[366] | 136 | self._ilsLogger = checks.ILSLogger()
|
---|
| 137 | self._checkers.append(self._ilsLogger)
|
---|
[321] | 138 | self._nav1Logger = checks.NAV1Logger()
|
---|
| 139 | self._checkers.append(self._nav1Logger)
|
---|
| 140 | self._nav2Logger = checks.NAV2Logger()
|
---|
| 141 | self._checkers.append(self._nav2Logger)
|
---|
| 142 |
|
---|
| 143 | self._adf1Logger = checks.ADF1Logger()
|
---|
| 144 | self._checkers.append(self._adf1Logger)
|
---|
| 145 | self._adf2Logger = checks.ADF2Logger()
|
---|
| 146 | self._checkers.append(self._adf2Logger)
|
---|
[331] | 147 |
|
---|
[8] | 148 | self._checkers.append(checks.SquawkLogger())
|
---|
| 149 |
|
---|
[211] | 150 | self._appendLightsLoggers()
|
---|
[8] | 151 |
|
---|
| 152 | self._checkers.append(checks.FlapsLogger())
|
---|
| 153 |
|
---|
| 154 | self._checkers.append(checks.GearsLogger())
|
---|
[601] | 155 | self._checkers.append(checks.InitialClimbSpeedLogger())
|
---|
[9] | 156 | self._checkers.append(checks.CruiseSpeedLogger())
|
---|
[10] | 157 | self._checkers.append(checks.SpoilerLogger())
|
---|
[338] | 158 | self._checkers.append(checks.APLogger())
|
---|
[9] | 159 |
|
---|
[197] | 160 | if config.isMessageTypeFS(const.MESSAGETYPE_VISIBILITY):
|
---|
[134] | 161 | self._checkers.append(checks.VisibilityChecker())
|
---|
| 162 |
|
---|
[139] | 163 | # FIXME: we should have a central data model object, and not collect
|
---|
| 164 | # the data from the GUI. However, some pieces of data (e.g. V-speeds,
|
---|
| 165 | # etc. that is entered into the GUI) *should* be a part of the GUI and
|
---|
| 166 | # queried from it, so the model should have a reference to the GUI as
|
---|
| 167 | # well and access such data via the GUI!
|
---|
[215] | 168 | if config.onlineACARS and flight.loggedIn and not flight.entranceExam:
|
---|
[139] | 169 | self._checkers.append(checks.ACARSSender(flight._gui))
|
---|
| 170 |
|
---|
[11] | 171 | # Fault checkers
|
---|
[211] | 172 |
|
---|
| 173 | self._appendLightsCheckers()
|
---|
[11] | 174 |
|
---|
[335] | 175 | self._checkers.append(checks.TransponderChecker())
|
---|
| 176 |
|
---|
[11] | 177 | self._checkers.append(checks.BankChecker())
|
---|
| 178 |
|
---|
| 179 | self._checkers.append(checks.FlapsRetractChecker())
|
---|
| 180 | self._checkers.append(checks.FlapsSpeedLimitChecker())
|
---|
| 181 |
|
---|
| 182 | self._checkers.append(checks.GearsDownChecker())
|
---|
| 183 | self._checkers.append(checks.GearSpeedLimitChecker())
|
---|
| 184 |
|
---|
| 185 | self._checkers.append(checks.GLoadChecker())
|
---|
| 186 |
|
---|
| 187 | self._checkers.append(checks.MLWChecker())
|
---|
| 188 | self._checkers.append(checks.MTOWChecker())
|
---|
| 189 | self._checkers.append(checks.MZFWChecker())
|
---|
| 190 | self._checkers.append(checks.PayloadChecker())
|
---|
| 191 |
|
---|
[539] | 192 | self._checkers.append(checks.SpeedChecker())
|
---|
[11] | 193 | self._checkers.append(checks.VSChecker())
|
---|
[197] | 194 |
|
---|
[447] | 195 | timeout = 30.0 + config.realIASSmoothingLength - 1
|
---|
[622] | 196 | self._checkers.append(checks.OverspeedChecker(faultTimeout = timeout))
|
---|
[331] | 197 |
|
---|
[11] | 198 | self._checkers.append(checks.StallChecker())
|
---|
| 199 |
|
---|
| 200 | self._checkers.append(checks.PitotChecker())
|
---|
[331] | 201 |
|
---|
[598] | 202 | self._checkers.append(checks.ReverserLogger())
|
---|
[11] | 203 | self._checkers.append(checks.ReverserChecker())
|
---|
| 204 |
|
---|
[273] | 205 | if flight.aircraftType is not None and config.enableApproachCallouts:
|
---|
| 206 | approachCallouts = flight.config.getApproachCallouts(flight.aircraftType)
|
---|
| 207 | if approachCallouts:
|
---|
| 208 | self._checkers.append(checks.ApproachCalloutsPlayer(approachCallouts))
|
---|
| 209 |
|
---|
[197] | 210 | self._smoothedIAS = SmoothedValue()
|
---|
| 211 | self._smoothedVS = SmoothedValue()
|
---|
| 212 |
|
---|
[4] | 213 | @property
|
---|
| 214 | def type(self):
|
---|
| 215 | """Get the type of the aircraft."""
|
---|
[8] | 216 | return self._flight.aircraftType
|
---|
| 217 |
|
---|
| 218 | @property
|
---|
| 219 | def flight(self):
|
---|
| 220 | """Get the flight the aircraft belongs to."""
|
---|
| 221 | return self._flight
|
---|
[4] | 222 |
|
---|
[8] | 223 | @property
|
---|
[592] | 224 | def minLandingFuel(self):
|
---|
| 225 | """Get the minimum acceptable amount of the landing fuel."""
|
---|
| 226 | return self._minLandingFuel
|
---|
| 227 |
|
---|
| 228 | @property
|
---|
| 229 | def recommendedLandingFuel(self):
|
---|
| 230 | """Get the recommended amount of the landing fuel."""
|
---|
| 231 | return self._recommendedLandingFuel
|
---|
| 232 |
|
---|
| 233 | @property
|
---|
[8] | 234 | def logger(self):
|
---|
| 235 | """Get the logger to use for the aircraft."""
|
---|
| 236 | return self._flight.logger
|
---|
| 237 |
|
---|
[139] | 238 | @property
|
---|
| 239 | def state(self):
|
---|
| 240 | """Get the current aircraft state."""
|
---|
| 241 | return self._aircraftState
|
---|
[241] | 242 |
|
---|
| 243 | @property
|
---|
| 244 | def speedInKnots(self):
|
---|
| 245 | """Indicate if the speed is in knots.
|
---|
| 246 |
|
---|
| 247 | This default implementation returns True."""
|
---|
| 248 | return True
|
---|
[304] | 249 |
|
---|
| 250 | @property
|
---|
[635] | 251 | def aglInFeet(self):
|
---|
| 252 | """Indicate if AGL altitudes are to be logged in feet.
|
---|
| 253 |
|
---|
| 254 | This default implementation returns True."""
|
---|
| 255 | return True
|
---|
| 256 |
|
---|
| 257 | @property
|
---|
[304] | 258 | def timestamp(self):
|
---|
| 259 | """Get the timestamp of the current state."""
|
---|
| 260 | return None if self._aircraftState is None \
|
---|
| 261 | else self._aircraftState.timestamp
|
---|
[331] | 262 |
|
---|
[384] | 263 | @property
|
---|
[512] | 264 | def derateType(self):
|
---|
| 265 | """Get the derate type for this aircraft.
|
---|
| 266 |
|
---|
| 267 | This default implementation returns DERATE_NONE."""
|
---|
| 268 | return DERATE_NONE
|
---|
[384] | 269 |
|
---|
[512] | 270 | def getDerateLine(self, value):
|
---|
| 271 | """Get the log line for the given derate value.
|
---|
| 272 |
|
---|
| 273 | It uses the the derate type and produces the standard message for
|
---|
| 274 | each. This children need not override it, although they can."""
|
---|
| 275 | dt = self.derateType
|
---|
[384] | 276 |
|
---|
[512] | 277 | if dt==DERATE_BOEING:
|
---|
| 278 | return "Derate calculated by the pilot: %s %%" % \
|
---|
| 279 | ("-" if value is None else value,)
|
---|
| 280 | elif dt==DERATE_EPR:
|
---|
| 281 | return "EPR calculated by the pilot: %s" % \
|
---|
| 282 | ("-" if value is None else value,)
|
---|
| 283 | elif dt==DERATE_TUPOLEV:
|
---|
| 284 | return "Thrust setting calculated by the pilot: %s" % \
|
---|
| 285 | ("-" if value is None else
|
---|
| 286 | "nominal" if value==DERATE_TUPOLEV_NOMINAL else "takeoff",)
|
---|
| 287 | elif dt==DERATE_B462:
|
---|
| 288 | return "Derate setting: %s" % \
|
---|
| 289 | ("-" if value is None else "enabled" if value else "disabled",)
|
---|
| 290 | elif dt!=DERATE_NONE:
|
---|
| 291 | print "mlx.acft.getDerateLine: invalid derate type: " + dt
|
---|
[384] | 292 |
|
---|
| 293 | return None
|
---|
| 294 |
|
---|
[11] | 295 | def getFlapsSpeedLimit(self, flaps):
|
---|
| 296 | """Get the speed limit for the given flaps setting."""
|
---|
| 297 | return self.flapSpeedLimits[flaps] if flaps in self.flapSpeedLimits \
|
---|
| 298 | else None
|
---|
| 299 |
|
---|
[8] | 300 | def modelChanged(self, timestamp, aircraftName, modelName):
|
---|
[4] | 301 | """Called when the simulator's aircraft changes."""
|
---|
[369] | 302 | self._name = aircraftName
|
---|
| 303 | self._modelName = modelName
|
---|
| 304 | if self._flight.stage is not None:
|
---|
| 305 | self._logNameAndModel(timestamp)
|
---|
[4] | 306 |
|
---|
| 307 | def handleState(self, aircraftState):
|
---|
[197] | 308 | """Called when the state of the aircraft changes.
|
---|
| 309 |
|
---|
| 310 | This is the function that the simulator calls directly with the new
|
---|
| 311 | state."""
|
---|
[274] | 312 | try:
|
---|
| 313 | config = self._flight.config
|
---|
[197] | 314 |
|
---|
[274] | 315 | self._smoothedIAS.add(config.realIASSmoothingLength, aircraftState.ias)
|
---|
| 316 | aircraftState.smoothedIAS = self._smoothedIAS.get()
|
---|
| 317 |
|
---|
| 318 | self._smoothedVS.add(config.realVSSmoothingLength, aircraftState.vs)
|
---|
| 319 | aircraftState.smoothedVS = self._smoothedVS.get()
|
---|
[197] | 320 |
|
---|
[274] | 321 | for checker in self._checkers:
|
---|
| 322 | try:
|
---|
| 323 | checker.check(self._flight, self, self._flight.logger,
|
---|
| 324 | self._aircraftState, aircraftState)
|
---|
| 325 | except:
|
---|
| 326 | print >> sys.stderr, "Checker", checker, "failed"
|
---|
| 327 | traceback.print_exc()
|
---|
[7] | 328 |
|
---|
[274] | 329 | self._flight.handleState(self._aircraftState, aircraftState)
|
---|
[89] | 330 |
|
---|
[274] | 331 | self._maxVS = max(self._maxVS, aircraftState.vs)
|
---|
| 332 | self._minVS = min(self._minVS, aircraftState.vs)
|
---|
| 333 | except:
|
---|
| 334 | print >> sys.stderr, "Failed to handle the state"
|
---|
| 335 | traceback.print_exc()
|
---|
| 336 | finally:
|
---|
| 337 | self._aircraftState = aircraftState
|
---|
[331] | 338 |
|
---|
[8] | 339 | def setStage(self, aircraftState, newStage):
|
---|
| 340 | """Set the given stage as the new one and do whatever should be
|
---|
| 341 | done."""
|
---|
[369] | 342 | if newStage==const.STAGE_BOARDING:
|
---|
| 343 | self._logNameAndModel(aircraftState.timestamp)
|
---|
| 344 |
|
---|
[624] | 345 | oldStage = self._flight.stage
|
---|
| 346 |
|
---|
[9] | 347 | if self._flight.setStage(aircraftState.timestamp, newStage):
|
---|
| 348 | if newStage==const.STAGE_PUSHANDTAXI:
|
---|
| 349 | self.logger.message(aircraftState.timestamp, "Block time start")
|
---|
[274] | 350 | self._flight.logFuel(aircraftState)
|
---|
[331] | 351 | self.logger.message(aircraftState.timestamp,
|
---|
[313] | 352 | "ZFW: %.2f kg" % (aircraftState.zfw))
|
---|
[134] | 353 | flight = self._flight
|
---|
| 354 | if flight.v1 is None or flight.vr is None or flight.v2 is None:
|
---|
| 355 | fs.sendMessage(const.MESSAGETYPE_HELP,
|
---|
| 356 | "Don't forget to set the takeoff V-speeds!",
|
---|
| 357 | 5)
|
---|
[9] | 358 | elif newStage==const.STAGE_TAKEOFF:
|
---|
[624] | 359 | if oldStage == const.STAGE_RTO and self._flight.hasRTO:
|
---|
| 360 | rtoState = self._flight.rtoState
|
---|
| 361 | if (aircraftState.timestamp - rtoState.timestamp) < \
|
---|
| 362 | (self.brakeCoolTime * 60.0):
|
---|
| 363 | self.logger.fault("brakeCoolTime",
|
---|
| 364 | aircraftState.timestamp,
|
---|
| 365 | "Did not cool the brakes for at least %.f minutes after the RTO" % (self.brakeCoolTime,),
|
---|
| 366 | 15.0)
|
---|
[241] | 367 | self.logger.message(aircraftState.timestamp,
|
---|
| 368 | "Flight time start")
|
---|
[331] | 369 | self.logger.message(aircraftState.timestamp,
|
---|
[9] | 370 | "Takeoff weight: %.0f kg, MTOW: %.0f kg" % \
|
---|
| 371 | (aircraftState.grossWeight, self.mtow))
|
---|
[409] | 372 | self._logQNH(aircraftState)
|
---|
[9] | 373 | self.logger.message(aircraftState.timestamp,
|
---|
[333] | 374 | "Wind %03.0f/%.0f" % \
|
---|
[331] | 375 | (aircraftState.windDirection,
|
---|
[9] | 376 | aircraftState.windSpeed))
|
---|
[321] | 377 | self._logRadios(aircraftState)
|
---|
[345] | 378 | self._logV1R2(aircraftState)
|
---|
[384] | 379 | self._logDerate(aircraftState)
|
---|
[391] | 380 | self._logTakeoffAntiIce(aircraftState)
|
---|
[321] | 381 | elif newStage==const.STAGE_DESCENT or newStage==const.STAGE_LANDING:
|
---|
| 382 | self._logRadios(aircraftState)
|
---|
[409] | 383 | if newStage==const.STAGE_LANDING:
|
---|
| 384 | self._logQNH(aircraftState)
|
---|
[634] | 385 | elif newStage==const.STAGE_GOAROUND:
|
---|
| 386 | from logger import Logger
|
---|
| 387 | self._flight.handleFault("goaround",
|
---|
| 388 | aircraftState.timestamp,
|
---|
| 389 | "Go-around detected, please, explain!",
|
---|
| 390 | Logger.NO_SCORE)
|
---|
[9] | 391 | elif newStage==const.STAGE_TAXIAFTERLAND:
|
---|
[184] | 392 | flight = self._flight
|
---|
| 393 | bookedFlight = flight.bookedFlight
|
---|
| 394 | config = flight.config
|
---|
[136] | 395 | if config.onlineGateSystem and \
|
---|
[215] | 396 | flight.loggedIn and \
|
---|
[184] | 397 | not flight.entranceExam and \
|
---|
[136] | 398 | bookedFlight.arrivalICAO=="LHBP" and \
|
---|
| 399 | config.isMessageTypeFS(const.MESSAGETYPE_GATE_SYSTEM):
|
---|
[134] | 400 | self._flight.getFleet(callback = self._fleetRetrieved,
|
---|
| 401 | force = True)
|
---|
[9] | 402 | self.logger.message(aircraftState.timestamp, "Flight time end")
|
---|
[274] | 403 | self._flight.logFuel(aircraftState)
|
---|
[591] | 404 | if self._minLandingFuel is not None and \
|
---|
| 405 | aircraftState.totalFuel<self._minLandingFuel:
|
---|
[597] | 406 | self._flight.handleFault(self.__class__,
|
---|
| 407 | aircraftState.timestamp,
|
---|
| 408 | "The amount of the landing fuel is less than the minimum for this type: %ukgs (possible NO GO!)" %
|
---|
| 409 | (self._minLandingFuel,), 0)
|
---|
[9] | 410 | self.logger.message(aircraftState.timestamp,
|
---|
| 411 | "Landing weight: %.0f kg, MLW: %.0f" % \
|
---|
| 412 | (aircraftState.grossWeight, self.mlw))
|
---|
| 413 | self.logger.message(aircraftState.timestamp,
|
---|
| 414 | "Vertical speed range: %.0f..%.0f feet/min" % \
|
---|
[12] | 415 | (self._minVS, self._maxVS))
|
---|
[359] | 416 | # elif newStage==const.STAGE_PARKING:
|
---|
| 417 | # self.logger.message(aircraftState.timestamp, "Block time end")
|
---|
[89] | 418 | elif newStage==const.STAGE_END:
|
---|
| 419 | flightLength = self._flight.flightTimeEnd - self._flight.flightTimeStart
|
---|
[359] | 420 | self.logger.message(aircraftState.timestamp, "Block time end")
|
---|
[89] | 421 | self.logger.message(aircraftState.timestamp,
|
---|
| 422 | "Flight time: " +
|
---|
| 423 | util.getTimeIntervalString(flightLength))
|
---|
| 424 | self.logger.message(aircraftState.timestamp,
|
---|
| 425 | "Flown distance: %.2f NM" % \
|
---|
[331] | 426 | (self._flight.flownDistance,))
|
---|
[89] | 427 | blockLength = self._flight.blockTimeEnd - self._flight.blockTimeStart
|
---|
| 428 | self.logger.message(aircraftState.timestamp,
|
---|
| 429 | "Block time: " +
|
---|
| 430 | util.getTimeIntervalString(blockLength))
|
---|
[8] | 431 |
|
---|
[9] | 432 | def prepareFlare(self):
|
---|
| 433 | """Called when it is detected that we will soon flare.
|
---|
[8] | 434 |
|
---|
| 435 | On the first call, it should start monitoring some parameters more
|
---|
| 436 | closely to determine flare time."""
|
---|
[9] | 437 | self.flight.simulator.startFlare()
|
---|
| 438 |
|
---|
[331] | 439 | def flareStarted(self, windSpeed, windDirection, visibility,
|
---|
[9] | 440 | flareStart, flareStartFS):
|
---|
| 441 | """Called when the flare has started."""
|
---|
| 442 | self.logger.message(self._aircraftState.timestamp, "The flare has begun")
|
---|
| 443 | self.logger.message(self._aircraftState.timestamp,
|
---|
[333] | 444 | "Wind %03.0f/%.0f" % \
|
---|
[9] | 445 | (windDirection, windSpeed))
|
---|
| 446 | self.logger.message(self._aircraftState.timestamp,
|
---|
| 447 | "Visibility: %.0f metres" % (visibility,))
|
---|
[409] | 448 | self._logQNH(self._aircraftState)
|
---|
[101] | 449 | self._logVRef()
|
---|
[391] | 450 | self._logLandingAntiIce(self._aircraftState)
|
---|
[9] | 451 | self.flight.flareStarted(flareStart, flareStartFS)
|
---|
[134] | 452 | fs.sendMessage(const.MESSAGETYPE_INFORMATION, "Flare-time", 3)
|
---|
[331] | 453 |
|
---|
[9] | 454 | def flareFinished(self, flareEnd, flareEndFS, tdRate, tdRateCalculatedByFS,
|
---|
| 455 | ias, pitch, bank, heading):
|
---|
| 456 | """Called when the flare has finished."""
|
---|
| 457 | (flareTimeFromFS, flareTime) = self.flight.flareFinished(flareEnd,
|
---|
[170] | 458 | flareEndFS,
|
---|
| 459 | tdRate)
|
---|
[9] | 460 | self.logger.message(self._aircraftState.timestamp,
|
---|
[153] | 461 | "Flaretime: %.3f (from %s)" % \
|
---|
[331] | 462 | (flareTime,
|
---|
[9] | 463 | "the simulator" if flareTimeFromFS else "real time",))
|
---|
| 464 | self.logger.message(self._aircraftState.timestamp,
|
---|
| 465 | "Touchdown rate: %.0f feet/min" % (tdRate,))
|
---|
| 466 | self.logger.message(self._aircraftState.timestamp,
|
---|
| 467 | "Touchdown rate was calculated by the %s" % \
|
---|
| 468 | ("simulator" if tdRateCalculatedByFS else "logger",))
|
---|
[241] | 469 | flight = self._flight
|
---|
[9] | 470 | self.logger.message(self._aircraftState.timestamp,
|
---|
[241] | 471 | "Touchdown speed: %.0f %s" % \
|
---|
| 472 | (flight.speedFromKnots(ias),
|
---|
| 473 | flight.getEnglishSpeedUnit()))
|
---|
[9] | 474 | self.logger.message(self._aircraftState.timestamp,
|
---|
| 475 | "Touchdown pitch: %.1f degrees" % (pitch,))
|
---|
| 476 | self.logger.message(self._aircraftState.timestamp,
|
---|
| 477 | "Touchdown bank: %.1f degrees" % (bank,))
|
---|
| 478 | self.logger.message(self._aircraftState.timestamp,
|
---|
| 479 | "Touchdown heading: %03.0f degrees" % (heading,))
|
---|
[331] | 480 | self.logger.message(self._aircraftState.timestamp,
|
---|
[340] | 481 | "CG: %.1f%%" % \
|
---|
[271] | 482 | (self._aircraftState.cog*100.0,))
|
---|
[8] | 483 |
|
---|
[611] | 484 | if abs(pitch)>self.maxTouchDownPitch:
|
---|
| 485 | self._flight.handleNoGo("TDPitch", self._aircraftState.timestamp,
|
---|
| 486 | "Touchdown pitch higher than aircraft maximum (%.2f)" % \
|
---|
| 487 | (self.maxTouchDownPitch,),
|
---|
| 488 | "TD TAILSTRIKE NO GO")
|
---|
| 489 |
|
---|
[8] | 490 | def cancelFlare(self):
|
---|
| 491 | """Cancel flare, if it has started."""
|
---|
[9] | 492 | self.flight.simulator.cancelFlare()
|
---|
[8] | 493 |
|
---|
| 494 | def checkFlightEnd(self, aircraftState):
|
---|
| 495 | """Check if the end of the flight has arrived.
|
---|
| 496 |
|
---|
| 497 | This default implementation checks the N1 values, but for
|
---|
| 498 | piston-powered aircraft you need to check the RPMs."""
|
---|
| 499 | for n1 in aircraftState.n1:
|
---|
| 500 | if n1>=0.5: return False
|
---|
| 501 | return True
|
---|
| 502 |
|
---|
[101] | 503 | def updateV1R2(self):
|
---|
| 504 | """Update the V1, Vr and V2 values from the flight, if the these values
|
---|
| 505 | have already been logged."""
|
---|
| 506 | if self._v1r2LineIndex is not None:
|
---|
| 507 | self._logV1R2()
|
---|
| 508 |
|
---|
[384] | 509 | def updateDerate(self):
|
---|
| 510 | """Update the derate value from the flight, if the these values
|
---|
| 511 | have already been logged."""
|
---|
| 512 | if self._derateLineID is not None:
|
---|
| 513 | self._logDerate()
|
---|
| 514 |
|
---|
[391] | 515 | def updateTakeoffAntiIce(self):
|
---|
| 516 | """Update the take-off anti-ice setting."""
|
---|
| 517 | if self._takeoffAntiIceLineID is not None:
|
---|
| 518 | self._logTakeoffAntiIce()
|
---|
| 519 |
|
---|
[211] | 520 | def _appendLightsLoggers(self):
|
---|
| 521 | """Append the loggers needed for the lights.
|
---|
| 522 |
|
---|
| 523 | This default implementation adds the loggers for the anti-collision
|
---|
| 524 | lights, the landing lights, the strobe lights and the NAV lights."""
|
---|
| 525 | self._checkers.append(checks.AnticollisionLightsLogger())
|
---|
| 526 | self._checkers.append(checks.LandingLightsLogger())
|
---|
| 527 | self._checkers.append(checks.StrobeLightsLogger())
|
---|
| 528 | self._checkers.append(checks.NavLightsLogger())
|
---|
| 529 |
|
---|
| 530 | def _appendLightsCheckers(self):
|
---|
| 531 | """Append the checkers needed for the lights.
|
---|
| 532 |
|
---|
| 533 | This default implementation adds the checkers for the anti-collision
|
---|
| 534 | lights, the landing lights, the strobe lights and the NAV lights."""
|
---|
| 535 | self._checkers.append(checks.AntiCollisionLightsChecker())
|
---|
| 536 | self._checkers.append(checks.LandingLightsChecker())
|
---|
| 537 | self._checkers.append(checks.NavLightsChecker())
|
---|
| 538 | self._checkers.append(checks.StrobeLightsChecker())
|
---|
| 539 |
|
---|
[241] | 540 | def _speedToLog(self, speed):
|
---|
| 541 | """Convert the given speed (being either None or expressed in the
|
---|
| 542 | flight's speed unit into a string."""
|
---|
| 543 | if speed is None:
|
---|
| 544 | return "-"
|
---|
| 545 | else:
|
---|
| 546 | return str(speed) + " " + self._flight.getEnglishSpeedUnit()
|
---|
| 547 |
|
---|
[345] | 548 | def _logV1R2(self, state = None):
|
---|
[101] | 549 | """Log the V1, Vr and V2 value either newly, or by updating the
|
---|
| 550 | corresponding line."""
|
---|
[526] | 551 | message = "Calc. TO speeds: V1: %s, VR: %s, V2: %s" % \
|
---|
[241] | 552 | (self._speedToLog(self._flight.v1),
|
---|
| 553 | self._speedToLog(self._flight.vr),
|
---|
| 554 | self._speedToLog(self._flight.v2))
|
---|
[101] | 555 |
|
---|
| 556 | if self._v1r2LineIndex is None:
|
---|
[345] | 557 | if state is None:
|
---|
| 558 | state = self._aircraftState
|
---|
[101] | 559 | self._v1r2LineIndex = \
|
---|
[345] | 560 | self.logger.message(state.timestamp, message)
|
---|
[101] | 561 | else:
|
---|
| 562 | self.logger.updateLine(self._v1r2LineIndex, message)
|
---|
| 563 |
|
---|
[384] | 564 | def _logDerate(self, state = None):
|
---|
| 565 | """Log the derate values either newly or by updating the corresponding
|
---|
| 566 | line."""
|
---|
[512] | 567 | dt = self.derateType
|
---|
| 568 | if dt==DERATE_NONE:
|
---|
[384] | 569 | return
|
---|
| 570 |
|
---|
[512] | 571 | message = self.getDerateLine(self._flight.derate)
|
---|
| 572 | if message is not None:
|
---|
| 573 | if self._derateLineID is None:
|
---|
| 574 | if state is None:
|
---|
| 575 | state = self._aircraftState
|
---|
| 576 | self._derateLineID = \
|
---|
| 577 | self.logger.message(state.timestamp, message)
|
---|
| 578 | else:
|
---|
| 579 | self.logger.updateLine(self._derateLineID, message)
|
---|
[384] | 580 |
|
---|
[391] | 581 | def _logTakeoffAntiIce(self, state = None):
|
---|
| 582 | """Log the take-off anti-ice setting either newly or by updating the
|
---|
| 583 | corresponding line."""
|
---|
| 584 | antiIceOn = self._flight.takeoffAntiIceOn
|
---|
| 585 | if state is not None:
|
---|
| 586 | antiIceOn = antiIceOn or state.antiIceOn is True
|
---|
| 587 | self._flight.takeoffAntiIceOn = antiIceOn
|
---|
| 588 |
|
---|
| 589 | message = "Anti-ice was turned %s" % \
|
---|
| 590 | ("ON" if antiIceOn else "OFF")
|
---|
| 591 |
|
---|
| 592 | if self._takeoffAntiIceLineID is None:
|
---|
| 593 | if state is None:
|
---|
| 594 | state = self._aircraftState
|
---|
| 595 | self._takeoffAntiIceLineID = \
|
---|
| 596 | self.logger.message(state.timestamp, message)
|
---|
| 597 | else:
|
---|
| 598 | self.logger.updateLine(self._takeoffAntiIceLineID, message)
|
---|
| 599 |
|
---|
[96] | 600 | def updateVRef(self):
|
---|
| 601 | """Update the Vref value from the flight, if the Vref value has already
|
---|
| 602 | been logged."""
|
---|
| 603 | if self._vrefLineIndex is not None:
|
---|
| 604 | self._logVRef()
|
---|
| 605 |
|
---|
| 606 | def _logVRef(self):
|
---|
| 607 | """Log the Vref value either newly, or by updating the corresponding
|
---|
| 608 | line."""
|
---|
| 609 | message = "VRef speed calculated by the pilot: %s" % \
|
---|
[241] | 610 | (self._speedToLog(self._flight.vref),)
|
---|
[96] | 611 | if self._vrefLineIndex is None:
|
---|
| 612 | self._vrefLineIndex = \
|
---|
| 613 | self.logger.message(self._aircraftState.timestamp, message)
|
---|
| 614 | else:
|
---|
| 615 | self.logger.updateLine(self._vrefLineIndex, message)
|
---|
| 616 |
|
---|
[391] | 617 | def updateLandingAntiIce(self):
|
---|
| 618 | """Update the landing anti-ice setting."""
|
---|
| 619 | if self._landingAntiIceLineID is not None:
|
---|
| 620 | self._logLandingAntiIce()
|
---|
| 621 |
|
---|
| 622 | def _logLandingAntiIce(self, state = None):
|
---|
| 623 | """Log the landing anti-ice setting either newly or by updating the
|
---|
| 624 | corresponding line."""
|
---|
| 625 | antiIceOn = self._flight.landingAntiIceOn
|
---|
| 626 | if state is not None:
|
---|
| 627 | antiIceOn = antiIceOn or state.antiIceOn is True
|
---|
| 628 | self._flight.landingAntiIceOn = antiIceOn
|
---|
| 629 |
|
---|
| 630 | message = "Anti-ice was turned %s" % \
|
---|
| 631 | ("ON" if antiIceOn else "OFF")
|
---|
| 632 |
|
---|
| 633 | if self._landingAntiIceLineID is None:
|
---|
| 634 | if state is None:
|
---|
| 635 | state = self._aircraftState
|
---|
| 636 | self._landingAntiIceLineID = \
|
---|
| 637 | self.logger.message(state.timestamp, message)
|
---|
| 638 | else:
|
---|
| 639 | self.logger.updateLine(self._landingAntiIceLineID, message)
|
---|
| 640 |
|
---|
[134] | 641 | def _fleetRetrieved(self, fleet):
|
---|
| 642 | """Callback for the fleet retrieval result."""
|
---|
| 643 | if fleet is not None:
|
---|
| 644 | gateList = ""
|
---|
| 645 | occupiedGateNumbers = fleet.getOccupiedGateNumbers()
|
---|
[619] | 646 | for gate in gates.lhbpGates.gates:
|
---|
| 647 | if gate.isAvailable(gates.lhbpGates, occupiedGateNumbers):
|
---|
[134] | 648 | if gateList: gateList += ", "
|
---|
[619] | 649 | gateList += gate.number
|
---|
[134] | 650 | fs.sendMessage(const.MESSAGETYPE_GATE_SYSTEM,
|
---|
| 651 | "Free gates: " + gateList, 20)
|
---|
[331] | 652 |
|
---|
[134] | 653 |
|
---|
[321] | 654 | def _logRadios(self, aircraftState):
|
---|
| 655 | """Log the radios from the given aircraft state."""
|
---|
| 656 | flight = self._flight
|
---|
| 657 | logger = flight.logger
|
---|
| 658 |
|
---|
[366] | 659 | self._ilsLogger.forceLog(flight, logger, aircraftState)
|
---|
[321] | 660 | self._nav1Logger.forceLog(flight, logger, aircraftState)
|
---|
| 661 | self._nav2Logger.forceLog(flight, logger, aircraftState)
|
---|
[329] | 662 | self._adf1Logger.forceLog(flight, logger, aircraftState)
|
---|
| 663 | self._adf2Logger.forceLog(flight, logger, aircraftState)
|
---|
[321] | 664 |
|
---|
[409] | 665 | def _logQNH(self, aircraftState):
|
---|
| 666 | """Log the current QNH along with the altimeter setting."""
|
---|
| 667 | self.logger.message(aircraftState.timestamp,
|
---|
| 668 | "QNH: %.2f hPa, altimeter: %.2f hPa" % \
|
---|
| 669 | (aircraftState.qnh, aircraftState.altimeter))
|
---|
| 670 |
|
---|
[369] | 671 | def _logNameAndModel(self, timestamp):
|
---|
| 672 | """Log the aircraft's name and model with taking the timestamp from the
|
---|
| 673 | given state."""
|
---|
| 674 | self._flight.logger.message(timestamp,
|
---|
| 675 | "Aircraft: name='%s', model='%s'" % \
|
---|
| 676 | (self._name, self._modelName))
|
---|
| 677 |
|
---|
[4] | 678 | #---------------------------------------------------------------------------------------
|
---|
[7] | 679 |
|
---|
| 680 | class Boeing737(Aircraft):
|
---|
| 681 | """Base class for the various aircraft in the Boeing 737 family.
|
---|
| 682 |
|
---|
| 683 | The aircraft type-specific values in the aircraft state have the following
|
---|
| 684 | structure:
|
---|
[140] | 685 | - fuel: left, centre, right
|
---|
[7] | 686 | - n1: left, right
|
---|
[331] | 687 | - reverser: left, right"""
|
---|
[592] | 688 | def __init__(self, flight, minLandingFuel = 2500,
|
---|
| 689 | recommendedLandingFuel = 3500):
|
---|
| 690 | super(Boeing737, self).__init__(flight,
|
---|
| 691 | minLandingFuel = minLandingFuel,
|
---|
| 692 | recommendedLandingFuel =
|
---|
| 693 | recommendedLandingFuel)
|
---|
[95] | 694 |
|
---|
[9] | 695 | self.gearSpeedLimit = 270
|
---|
| 696 | self.flapSpeedLimits = { 1 : 260,
|
---|
| 697 | 2 : 260,
|
---|
| 698 | 5 : 250,
|
---|
| 699 | 10 : 210,
|
---|
| 700 | 15 : 200,
|
---|
| 701 | 25 : 190,
|
---|
| 702 | 30 : 175,
|
---|
| 703 | 40 : 162 }
|
---|
[7] | 704 |
|
---|
[384] | 705 | @property
|
---|
[512] | 706 | def derateType(self):
|
---|
| 707 | """Get the derate type for this type."""
|
---|
| 708 | return DERATE_BOEING
|
---|
[384] | 709 |
|
---|
[7] | 710 | #---------------------------------------------------------------------------------------
|
---|
| 711 |
|
---|
| 712 | class B736(Boeing737):
|
---|
| 713 | """Boeing 737-600 aircraft."""
|
---|
[8] | 714 | def __init__(self, flight):
|
---|
| 715 | super(B736, self).__init__(flight)
|
---|
[9] | 716 | self.dow = 38307
|
---|
| 717 | self.mtow = 58328
|
---|
| 718 | self.mlw = 54657
|
---|
| 719 | self.mzfw = 51482
|
---|
[611] | 720 | self.maxTakeOffPitch = 16.2
|
---|
| 721 | self.maxTouchDownPitch = 14.7
|
---|
[7] | 722 |
|
---|
| 723 | #---------------------------------------------------------------------------------------
|
---|
| 724 |
|
---|
| 725 | class B737(Boeing737):
|
---|
| 726 | """Boeing 737-700 aircraft."""
|
---|
[8] | 727 | def __init__(self, flight):
|
---|
| 728 | super(B737, self).__init__(flight)
|
---|
[9] | 729 | self.dow = 39250
|
---|
| 730 | self.mtow = 61410
|
---|
| 731 | self.mlw = 58059
|
---|
| 732 | self.mzfw = 54657
|
---|
[611] | 733 | self.maxTakeOffPitch = 14.7
|
---|
| 734 | self.maxTouchDownPitch = 13.2
|
---|
[7] | 735 |
|
---|
| 736 | #---------------------------------------------------------------------------------------
|
---|
| 737 |
|
---|
| 738 | class B738(Boeing737):
|
---|
| 739 | """Boeing 737-800 aircraft."""
|
---|
[8] | 740 | def __init__(self, flight):
|
---|
| 741 | super(B738, self).__init__(flight)
|
---|
[9] | 742 | self.dow = 42690
|
---|
| 743 | self.mtow = 71709
|
---|
| 744 | self.mlw = 65317
|
---|
| 745 | self.mzfw = 61688
|
---|
[611] | 746 | self.maxTakeOffPitch = 11
|
---|
| 747 | self.maxTouchDownPitch = 9.5
|
---|
[9] | 748 |
|
---|
| 749 | #---------------------------------------------------------------------------------------
|
---|
| 750 |
|
---|
| 751 | class B738Charter(B738):
|
---|
| 752 | """Boeing 737-800 aircraft used for charters."""
|
---|
| 753 | def __init__(self, flight):
|
---|
| 754 | super(B738Charter, self).__init__(flight)
|
---|
| 755 | self.mtow = 77791
|
---|
[7] | 756 |
|
---|
| 757 | #---------------------------------------------------------------------------------------
|
---|
| 758 |
|
---|
[591] | 759 | class Boeing737CL(Boeing737):
|
---|
| 760 | """Base class for the various aircraft in the Boeing 737 Classic family."""
|
---|
| 761 | def __init__(self, flight):
|
---|
[592] | 762 | super(Boeing737CL, self).__init__(flight, minLandingFuel = 3500,
|
---|
| 763 | recommendedLandingFuel = None)
|
---|
[591] | 764 |
|
---|
| 765 | #---------------------------------------------------------------------------------------
|
---|
| 766 |
|
---|
| 767 | class B733(Boeing737CL):
|
---|
[7] | 768 | """Boeing 737-300 aircraft."""
|
---|
[8] | 769 | def __init__(self, flight):
|
---|
| 770 | super(B733, self).__init__(flight)
|
---|
[9] | 771 | self.dow = 32700
|
---|
| 772 | self.mtow = 62820
|
---|
| 773 | self.mlw = 51700
|
---|
| 774 | self.mzfw = 48410
|
---|
[611] | 775 | self.maxTakeOffPitch = 13.4
|
---|
| 776 | self.maxTouchDownPitch = 12.0
|
---|
[7] | 777 |
|
---|
| 778 | #---------------------------------------------------------------------------------------
|
---|
| 779 |
|
---|
[591] | 780 | class B734(Boeing737CL):
|
---|
[7] | 781 | """Boeing 737-400 aircraft."""
|
---|
[8] | 782 | def __init__(self, flight):
|
---|
| 783 | super(B734, self).__init__(flight)
|
---|
[9] | 784 | self.dow = 33200
|
---|
| 785 | self.mtow = 68050
|
---|
| 786 | self.mlw = 56200
|
---|
| 787 | self.mzfw = 53100
|
---|
[611] | 788 | self.maxTakeOffPitch = 11.4
|
---|
| 789 | self.maxTouchDownPitch = 10
|
---|
[7] | 790 |
|
---|
| 791 | #---------------------------------------------------------------------------------------
|
---|
| 792 |
|
---|
[591] | 793 | class B735(Boeing737CL):
|
---|
[7] | 794 | """Boeing 737-500 aircraft."""
|
---|
[8] | 795 | def __init__(self, flight):
|
---|
| 796 | super(B735, self).__init__(flight)
|
---|
[9] | 797 | self.dow = 31300
|
---|
| 798 | self.mtow = 60550
|
---|
| 799 | self.mlw = 50000
|
---|
| 800 | self.mzfw = 46700
|
---|
[611] | 801 | self.maxTakeOffPitch = 14.7
|
---|
| 802 | self.maxTouchDownPitch = 13.2
|
---|
[7] | 803 |
|
---|
| 804 | #---------------------------------------------------------------------------------------
|
---|
| 805 |
|
---|
| 806 | class DH8D(Aircraft):
|
---|
| 807 | """Bombardier Dash-8 Q400 aircraft.
|
---|
| 808 |
|
---|
| 809 | The aircraft type-specific values in the aircraft state have the following
|
---|
| 810 | structure:
|
---|
[140] | 811 | - fuel: left, right
|
---|
[7] | 812 | - n1: left, right
|
---|
| 813 | - reverser: left, right."""
|
---|
[140] | 814 |
|
---|
[8] | 815 | def __init__(self, flight):
|
---|
[591] | 816 | super(DH8D, self).__init__(flight, minLandingFuel = 2000)
|
---|
[9] | 817 | self.dow = 17185
|
---|
| 818 | self.mtow = 29257
|
---|
| 819 | self.mlw = 28009
|
---|
| 820 | self.mzfw = 25855
|
---|
| 821 | self.gearSpeedLimit = 215
|
---|
| 822 | self.flapSpeedLimits = { 5 : 200,
|
---|
| 823 | 10 : 181,
|
---|
| 824 | 15 : 172,
|
---|
| 825 | 35 : 158 }
|
---|
[611] | 826 | self.maxTakeOffPitch = 8.0
|
---|
| 827 | self.maxTouchDownPitch = 7.0
|
---|
[9] | 828 |
|
---|
[7] | 829 | #---------------------------------------------------------------------------------------
|
---|
| 830 |
|
---|
| 831 | class Boeing767(Aircraft):
|
---|
| 832 | """Base class for the various aircraft in the Boeing 767 family.
|
---|
| 833 |
|
---|
| 834 | The aircraft type-specific values in the aircraft state have the following
|
---|
| 835 | structure:
|
---|
[140] | 836 | - fuel: left, centre, right
|
---|
[7] | 837 | - n1: left, right
|
---|
| 838 | - reverser: left, right"""
|
---|
[140] | 839 |
|
---|
[612] | 840 | def __init__(self, flight, minLandingFuel = 7000):
|
---|
[591] | 841 | super(Boeing767, self).__init__(flight, minLandingFuel = minLandingFuel)
|
---|
[9] | 842 | self.gearSpeedLimit = 270
|
---|
| 843 | self.flapSpeedLimits = { 1 : 255,
|
---|
| 844 | 5 : 235,
|
---|
| 845 | 10 : 215,
|
---|
| 846 | 20 : 215,
|
---|
| 847 | 25 : 185,
|
---|
| 848 | 30 : 175 }
|
---|
[7] | 849 |
|
---|
[384] | 850 | @property
|
---|
[512] | 851 | def derateType(self):
|
---|
| 852 | """Get the derate type for this type."""
|
---|
| 853 | return DERATE_BOEING
|
---|
[384] | 854 |
|
---|
[7] | 855 | #---------------------------------------------------------------------------------------
|
---|
| 856 |
|
---|
| 857 | class B762(Boeing767):
|
---|
| 858 | """Boeing 767-200 aircraft."""
|
---|
[8] | 859 | def __init__(self, flight):
|
---|
| 860 | super(B762, self).__init__(flight)
|
---|
[9] | 861 | self.dow = 84507
|
---|
| 862 | self.mtow = 175540
|
---|
| 863 | self.mlw = 126098
|
---|
| 864 | self.mzfw = 114758
|
---|
[611] | 865 | self.maxTakeOffPitch = 13.1
|
---|
| 866 | self.maxTouchDownPitch = 11.6
|
---|
[7] | 867 |
|
---|
| 868 | #---------------------------------------------------------------------------------------
|
---|
| 869 |
|
---|
| 870 | class B763(Boeing767):
|
---|
| 871 | """Boeing 767-300 aircraft."""
|
---|
[8] | 872 | def __init__(self, flight):
|
---|
[331] | 873 | super(B763, self).__init__(flight)
|
---|
[9] | 874 | self.dow = 91311
|
---|
| 875 | self.mtow = 181436
|
---|
| 876 | self.mlw = 137892
|
---|
| 877 | self.mzfw = 130635
|
---|
[611] | 878 | self.maxTakeOffPitch = 9.6
|
---|
| 879 | self.maxTouchDownPitch = 8.1
|
---|
[7] | 880 |
|
---|
| 881 | #---------------------------------------------------------------------------------------
|
---|
| 882 |
|
---|
| 883 | class CRJ2(Aircraft):
|
---|
| 884 | """Bombardier CRJ-200 aircraft.
|
---|
| 885 |
|
---|
| 886 | The aircraft type-specific values in the aircraft state have the following
|
---|
| 887 | structure:
|
---|
[140] | 888 | - fuel: left, centre, right
|
---|
[7] | 889 | - n1: left, right
|
---|
| 890 | - reverser: left, right."""
|
---|
[8] | 891 | def __init__(self, flight):
|
---|
[591] | 892 | super(CRJ2, self).__init__(flight, minLandingFuel = 1000)
|
---|
[9] | 893 | self.dow = 14549
|
---|
| 894 | self.mtow = 22995
|
---|
| 895 | self.mlw = 21319
|
---|
| 896 | self.mzfw = 19958
|
---|
| 897 | self.gearSpeedLimit = 240
|
---|
| 898 | self.flapSpeedLimits = { 8 : 260,
|
---|
| 899 | 20 : 220,
|
---|
| 900 | 30 : 190,
|
---|
| 901 | 45 : 175 }
|
---|
[611] | 902 | self.maxTakeOffPitch = 18.0
|
---|
| 903 | self.maxTouchDownPitch = 18.0
|
---|
[7] | 904 |
|
---|
| 905 | #---------------------------------------------------------------------------------------
|
---|
| 906 |
|
---|
| 907 | class F70(Aircraft):
|
---|
| 908 | """Fokker 70 aircraft.
|
---|
| 909 |
|
---|
| 910 | The aircraft type-specific values in the aircraft state have the following
|
---|
| 911 | structure:
|
---|
[140] | 912 | - fuel: left, centre, right
|
---|
[7] | 913 | - n1: left, right
|
---|
| 914 | - reverser: left, right."""
|
---|
[8] | 915 | def __init__(self, flight):
|
---|
[591] | 916 | super(F70, self).__init__(flight, minLandingFuel = 1900)
|
---|
[9] | 917 | self.dow = 24283
|
---|
| 918 | self.mtow = 38100 # FIXME: differentiate by registration number,
|
---|
| 919 | # MTOW of HA-LMF: 41955
|
---|
| 920 | self.mlw = 36740
|
---|
| 921 | self.mzfw = 32655
|
---|
| 922 | self.gearSpeedLimit = 200
|
---|
| 923 | self.flapSpeedLimits = { 8 : 250,
|
---|
| 924 | 15 : 220,
|
---|
| 925 | 25 : 220,
|
---|
| 926 | 42 : 180 }
|
---|
[360] | 927 | self.reverseMinSpeed = 50
|
---|
[611] | 928 | self.maxTakeOffPitch = 16.0
|
---|
| 929 | self.maxTouchDownPitch = 16.0
|
---|
[7] | 930 |
|
---|
[384] | 931 | @property
|
---|
[512] | 932 | def derateType(self):
|
---|
| 933 | """Get the derate type for this type."""
|
---|
| 934 | return DERATE_EPR
|
---|
[384] | 935 |
|
---|
[7] | 936 | #---------------------------------------------------------------------------------------
|
---|
| 937 |
|
---|
| 938 | class DC3(Aircraft):
|
---|
| 939 | """Lisunov Li-2 (DC-3) aircraft.
|
---|
| 940 |
|
---|
| 941 | The aircraft type-specific values in the aircraft state have the following
|
---|
| 942 | structure:
|
---|
[140] | 943 | - fuel: left aux, left, right, right aux
|
---|
[7] | 944 | - rpm: left, right
|
---|
| 945 | - reverser: left, right."""
|
---|
[8] | 946 | def __init__(self, flight):
|
---|
| 947 | super(DC3, self).__init__(flight)
|
---|
[9] | 948 | self.dow = 8627
|
---|
| 949 | self.mtow = 11884
|
---|
| 950 | self.mlw = 11793
|
---|
| 951 | self.mzfw = 11780
|
---|
| 952 | self.gearSpeedLimit = 148
|
---|
| 953 | self.flapSpeedLimits = { 15 : 135,
|
---|
| 954 | 30 : 99,
|
---|
| 955 | 45 : 97 }
|
---|
[8] | 956 |
|
---|
| 957 | def _checkFlightEnd(self, aircraftState):
|
---|
| 958 | """Check if the end of the flight has arrived.
|
---|
| 959 |
|
---|
| 960 | This implementation checks the RPM values to be 0."""
|
---|
| 961 | for rpm in aircraftState.rpm:
|
---|
[29] | 962 | if rpm>0: return False
|
---|
| 963 | return True
|
---|
[7] | 964 |
|
---|
| 965 | #---------------------------------------------------------------------------------------
|
---|
| 966 |
|
---|
| 967 | class T134(Aircraft):
|
---|
| 968 | """Tupolev Tu-134 aircraft.
|
---|
| 969 |
|
---|
| 970 | The aircraft type-specific values in the aircraft state have the following
|
---|
| 971 | structure:
|
---|
[140] | 972 | - fuel: left tip, left aux, centre, right aux, right tip, external 1,
|
---|
[7] | 973 | external 2
|
---|
| 974 | - n1: left, right
|
---|
| 975 | - reverser: left, right."""
|
---|
[8] | 976 | def __init__(self, flight):
|
---|
[591] | 977 | super(T134, self).__init__(flight, minLandingFuel = 3000)
|
---|
[210] | 978 | self.dow = 29500
|
---|
| 979 | self.mtow = 49000
|
---|
[9] | 980 | self.mlw = 43000
|
---|
| 981 | self.mzfw = 38500
|
---|
| 982 | self.gearSpeedLimit = 216
|
---|
[210] | 983 | self.flapSpeedLimits = { 10 : 450,
|
---|
| 984 | 20 : 400,
|
---|
| 985 | 30 : 300 }
|
---|
[360] | 986 | self.reverseMinSpeed = 50
|
---|
[7] | 987 |
|
---|
[644] | 988 | self.hasStrobeLight = False
|
---|
| 989 |
|
---|
[611] | 990 | self.maxTakeOffPitch = 16.0
|
---|
| 991 | self.maxTouchDownPitch = 16.0
|
---|
| 992 |
|
---|
[241] | 993 | @property
|
---|
[512] | 994 | def derateType(self):
|
---|
| 995 | """Get the derate type for this type."""
|
---|
| 996 | return DERATE_TUPOLEV
|
---|
[384] | 997 |
|
---|
| 998 | @property
|
---|
[241] | 999 | def speedInKnots(self):
|
---|
| 1000 | """Indicate if the speed is in knots."""
|
---|
| 1001 | return False
|
---|
[331] | 1002 |
|
---|
[635] | 1003 | @property
|
---|
| 1004 | def aglInFeet(self):
|
---|
| 1005 | """Indicate if AGL altituedes are in feet."""
|
---|
| 1006 | return False
|
---|
| 1007 |
|
---|
[211] | 1008 | def _appendLightsLoggers(self):
|
---|
| 1009 | """Append the loggers needed for the lights."""
|
---|
| 1010 | self._checkers.append(checks.AnticollisionLightsLogger())
|
---|
| 1011 | self._checkers.append(checks.LandingLightsLogger())
|
---|
| 1012 | self._checkers.append(checks.NavLightsLogger())
|
---|
| 1013 |
|
---|
| 1014 | def _appendLightsCheckers(self):
|
---|
| 1015 | """Append the checkers needed for the lights."""
|
---|
| 1016 | self._checkers.append(checks.TupolevAntiCollisionLightsChecker())
|
---|
[631] | 1017 | self._checkers.append(checks.TupolevLandingLightsChecker())
|
---|
[211] | 1018 | self._checkers.append(checks.LandingLightsChecker())
|
---|
| 1019 | self._checkers.append(checks.NavLightsChecker())
|
---|
| 1020 |
|
---|
[7] | 1021 | #---------------------------------------------------------------------------------------
|
---|
| 1022 |
|
---|
| 1023 | class T154(Aircraft):
|
---|
| 1024 | """Tupolev Tu-154 aircraft.
|
---|
| 1025 |
|
---|
| 1026 | The aircraft type-specific values in the aircraft state have the following
|
---|
| 1027 | structure:
|
---|
[140] | 1028 | - fuel: left aux, left, centre, centre 2, right, right aux
|
---|
[7] | 1029 | - n1: left, centre, right
|
---|
| 1030 | - reverser: left, right"""
|
---|
[8] | 1031 | def __init__(self, flight):
|
---|
[591] | 1032 | super(T154, self).__init__(flight, minLandingFuel = 5000)
|
---|
[9] | 1033 | self.dow = 53259
|
---|
| 1034 | self.mtow = 98000
|
---|
| 1035 | self.mlw = 78000
|
---|
| 1036 | self.mzfw = 72000
|
---|
| 1037 | self.gearSpeedLimit = 216
|
---|
| 1038 | self.flapSpeedLimits = { 15 : 227,
|
---|
| 1039 | 28 : 194,
|
---|
| 1040 | 45 : 162 }
|
---|
[360] | 1041 | self.reverseMinSpeed = 50
|
---|
[9] | 1042 |
|
---|
[644] | 1043 | self.hasStrobeLight = False
|
---|
| 1044 |
|
---|
[611] | 1045 | self.maxTakeOffPitch = 16.0
|
---|
| 1046 | self.maxTouchDownPitch = 16.0
|
---|
| 1047 |
|
---|
[241] | 1048 | @property
|
---|
| 1049 | def speedInKnots(self):
|
---|
| 1050 | """Indicate if the speed is in knots."""
|
---|
| 1051 | return False
|
---|
[331] | 1052 |
|
---|
[384] | 1053 | @property
|
---|
[635] | 1054 | def aglInFeet(self):
|
---|
| 1055 | """Indicate if AGL altituedes are in feet."""
|
---|
| 1056 | return False
|
---|
| 1057 |
|
---|
| 1058 | @property
|
---|
[512] | 1059 | def derateType(self):
|
---|
| 1060 | """Get the derate type for this type."""
|
---|
| 1061 | return DERATE_TUPOLEV
|
---|
[384] | 1062 |
|
---|
[211] | 1063 | def _appendLightsLoggers(self):
|
---|
| 1064 | """Append the loggers needed for the lights."""
|
---|
| 1065 | self._checkers.append(checks.AnticollisionLightsLogger())
|
---|
| 1066 | self._checkers.append(checks.LandingLightsLogger())
|
---|
| 1067 | self._checkers.append(checks.NavLightsLogger())
|
---|
| 1068 |
|
---|
| 1069 | def _appendLightsCheckers(self):
|
---|
| 1070 | """Append the checkers needed for the lights."""
|
---|
| 1071 | self._checkers.append(checks.AntiCollisionLightsChecker())
|
---|
[631] | 1072 | self._checkers.append(checks.TupolevLandingLightsChecker())
|
---|
[211] | 1073 | self._checkers.append(checks.LandingLightsChecker())
|
---|
| 1074 | self._checkers.append(checks.NavLightsChecker())
|
---|
| 1075 |
|
---|
[539] | 1076 | #---------------------------------------------------------------------------------------
|
---|
| 1077 |
|
---|
| 1078 | class YK40(Aircraft):
|
---|
| 1079 | """Yakovlev Yak-40 aircraft.
|
---|
| 1080 |
|
---|
| 1081 | The aircraft type-specific values in the aircraft state have the following
|
---|
| 1082 | structure:
|
---|
| 1083 | - fuel: left, right
|
---|
| 1084 | - n1: left, right
|
---|
| 1085 | - reverser: left, right"""
|
---|
| 1086 | def __init__(self, flight):
|
---|
| 1087 | super(YK40, self).__init__(flight)
|
---|
| 1088 | self.dow = 9400
|
---|
| 1089 | self.mtow = 17200
|
---|
| 1090 | self.mlw = 16800
|
---|
| 1091 | self.mzfw = 12100
|
---|
| 1092 | self.gearSpeedLimit = 165
|
---|
| 1093 | self.flapSpeedLimits = { 20 : 165,
|
---|
| 1094 | 35 : 135 }
|
---|
| 1095 |
|
---|
[644] | 1096 | self.hasStrobeLight = False
|
---|
| 1097 |
|
---|
[539] | 1098 | @property
|
---|
| 1099 | def speedInKnots(self):
|
---|
| 1100 | """Indicate if the speed is in knots."""
|
---|
| 1101 | return False
|
---|
| 1102 |
|
---|
| 1103 | @property
|
---|
[635] | 1104 | def aglInFeet(self):
|
---|
| 1105 | """Indicate if AGL altituedes are in feet."""
|
---|
| 1106 | return False
|
---|
| 1107 |
|
---|
| 1108 | @property
|
---|
[539] | 1109 | def derateType(self):
|
---|
| 1110 | """Get the derate type for this type."""
|
---|
| 1111 | return DERATE_TUPOLEV
|
---|
| 1112 |
|
---|
| 1113 | def _appendLightsLoggers(self):
|
---|
| 1114 | """Append the loggers needed for the lights."""
|
---|
| 1115 | self._checkers.append(checks.AnticollisionLightsLogger())
|
---|
| 1116 | self._checkers.append(checks.LandingLightsLogger())
|
---|
| 1117 | self._checkers.append(checks.NavLightsLogger())
|
---|
| 1118 |
|
---|
| 1119 | def _appendLightsCheckers(self):
|
---|
| 1120 | """Append the checkers needed for the lights."""
|
---|
| 1121 | self._checkers.append(checks.AntiCollisionLightsChecker())
|
---|
| 1122 | self._checkers.append(checks.LandingLightsChecker())
|
---|
| 1123 | self._checkers.append(checks.NavLightsChecker())
|
---|
[403] | 1124 |
|
---|
[7] | 1125 | #---------------------------------------------------------------------------------------
|
---|
| 1126 |
|
---|
[443] | 1127 | class B462(Aircraft):
|
---|
| 1128 | """British Aerospace BAe-146 aircraft.
|
---|
| 1129 |
|
---|
| 1130 | The aircraft type-specific values in the aircraft state have the following
|
---|
| 1131 | structure:
|
---|
| 1132 | - fuel: left, centre, right
|
---|
| 1133 | - n1: left outer, left inner, right inner, right outer
|
---|
| 1134 | - reverser: empty (the plane has no reversers)"""
|
---|
| 1135 | def __init__(self, flight):
|
---|
| 1136 | super(B462, self).__init__(flight)
|
---|
| 1137 | self.dow = 25706
|
---|
| 1138 | self.mtow = 43998
|
---|
| 1139 | self.mlw = 38599
|
---|
| 1140 | self.mzfw = 33792
|
---|
| 1141 | self.gearSpeedLimit = 210
|
---|
| 1142 | self.flapSpeedLimits = { 18 : 217,
|
---|
| 1143 | 24 : 180,
|
---|
| 1144 | 30 : 170,
|
---|
| 1145 | 33 : 150 }
|
---|
| 1146 |
|
---|
[445] | 1147 | @property
|
---|
[512] | 1148 | def derateType(self):
|
---|
| 1149 | """Get the derate type for this type."""
|
---|
| 1150 | return DERATE_B462
|
---|
[445] | 1151 |
|
---|
[443] | 1152 | #---------------------------------------------------------------------------------------
|
---|
| 1153 |
|
---|
[274] | 1154 | mostFuelTanks = [const.FUELTANK_LEFT_TIP, const.FUELTANK_EXTERNAL1,
|
---|
| 1155 | const.FUELTANK_LEFT_AUX,
|
---|
| 1156 | const.FUELTANK_CENTRE,
|
---|
| 1157 | const.FUELTANK_RIGHT_AUX,
|
---|
| 1158 | const.FUELTANK_EXTERNAL2, const.FUELTANK_RIGHT_TIP]
|
---|
[141] | 1159 |
|
---|
| 1160 | #---------------------------------------------------------------------------------------
|
---|
| 1161 |
|
---|
[191] | 1162 | _classes = { const.AIRCRAFT_B736 : B736,
|
---|
| 1163 | const.AIRCRAFT_B737 : B737,
|
---|
| 1164 | const.AIRCRAFT_B738 : B738,
|
---|
| 1165 | const.AIRCRAFT_B738C : B738Charter,
|
---|
| 1166 | const.AIRCRAFT_B733 : B733,
|
---|
| 1167 | const.AIRCRAFT_B734 : B734,
|
---|
| 1168 | const.AIRCRAFT_B735 : B735,
|
---|
| 1169 | const.AIRCRAFT_DH8D : DH8D,
|
---|
| 1170 | const.AIRCRAFT_B762 : B762,
|
---|
| 1171 | const.AIRCRAFT_B763 : B763,
|
---|
| 1172 | const.AIRCRAFT_CRJ2 : CRJ2,
|
---|
| 1173 | const.AIRCRAFT_F70 : F70,
|
---|
| 1174 | const.AIRCRAFT_DC3 : DC3,
|
---|
| 1175 | const.AIRCRAFT_T134 : T134,
|
---|
| 1176 | const.AIRCRAFT_T154 : T154,
|
---|
[443] | 1177 | const.AIRCRAFT_YK40 : YK40,
|
---|
| 1178 | const.AIRCRAFT_B462 : B462 }
|
---|
[8] | 1179 |
|
---|
| 1180 | #---------------------------------------------------------------------------------------
|
---|
[197] | 1181 |
|
---|
| 1182 | if __name__ == "__main__":
|
---|
| 1183 | value = SmoothedValue()
|
---|
| 1184 |
|
---|
| 1185 | print "Adding 1, 12.0"
|
---|
| 1186 | value.add(1, 12.0)
|
---|
| 1187 | print value.get()
|
---|
| 1188 |
|
---|
| 1189 | print "Adding 1, 15.0"
|
---|
| 1190 | value.add(1, 15.0)
|
---|
| 1191 | print value.get()
|
---|
| 1192 |
|
---|
| 1193 | print "Adding 2, 18.0"
|
---|
| 1194 | value.add(2, 18.0)
|
---|
| 1195 | print value.get()
|
---|
| 1196 |
|
---|
| 1197 | print "Adding 2, 20.0"
|
---|
| 1198 | value.add(2, 20.0)
|
---|
| 1199 | print value.get()
|
---|
| 1200 |
|
---|
| 1201 | print "Adding 5, 22.0"
|
---|
| 1202 | value.add(5, 22.0)
|
---|
| 1203 | print value.get()
|
---|
| 1204 |
|
---|
| 1205 | print "Adding 5, 25.0"
|
---|
| 1206 | value.add(5, 25.0)
|
---|
| 1207 | print value.get()
|
---|
| 1208 |
|
---|
| 1209 | print "Adding 5, 29.0"
|
---|
| 1210 | value.add(5, 29.0)
|
---|
| 1211 | print value.get()
|
---|
| 1212 |
|
---|
| 1213 | print "Adding 5, 21.0"
|
---|
| 1214 | value.add(5, 21.0)
|
---|
| 1215 | print value.get()
|
---|
| 1216 |
|
---|
| 1217 | print "Adding 5, 26.0"
|
---|
| 1218 | value.add(5, 26.0)
|
---|
| 1219 | print value.get()
|
---|
| 1220 |
|
---|
| 1221 | print "Adding 2, 30.0"
|
---|
| 1222 | value.add(2, 30.0)
|
---|
| 1223 | print value.get()
|
---|
| 1224 |
|
---|
| 1225 | print "Adding 2, 55.0"
|
---|
| 1226 | value.add(2, 55.0)
|
---|
| 1227 | print value.get()
|
---|
| 1228 |
|
---|
| 1229 | #---------------------------------------------------------------------------------------
|
---|