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