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