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