[4] | 1 | # Module for the simulator-independent aircraft classes
|
---|
| 2 |
|
---|
| 3 | #---------------------------------------------------------------------------------------
|
---|
| 4 |
|
---|
[8] | 5 | import const
|
---|
| 6 | import checks
|
---|
[89] | 7 | import util
|
---|
[4] | 8 |
|
---|
[8] | 9 | import time
|
---|
[7] | 10 |
|
---|
[4] | 11 | #---------------------------------------------------------------------------------------
|
---|
| 12 |
|
---|
| 13 | class Aircraft(object):
|
---|
| 14 | """Base class for aircraft."""
|
---|
[8] | 15 | @staticmethod
|
---|
| 16 | def create(flight):
|
---|
| 17 | """Create an aircraft instance for the type in the given flight."""
|
---|
| 18 | return _classes[flight.aircraftType](flight)
|
---|
| 19 |
|
---|
| 20 | def __init__(self, flight):
|
---|
[4] | 21 | """Construct the aircraft for the given type."""
|
---|
[8] | 22 | self._flight = flight
|
---|
[4] | 23 | self._aircraftState = None
|
---|
[9] | 24 |
|
---|
| 25 | self._maxVS = -10000.0
|
---|
| 26 | self._minVS = 10000.0
|
---|
[4] | 27 |
|
---|
[101] | 28 | self._v1r2LineIndex = None
|
---|
[96] | 29 | self._vrefLineIndex = None
|
---|
| 30 |
|
---|
[117] | 31 | self.humanWeight = 82.0
|
---|
| 32 |
|
---|
[8] | 33 | self._checkers = []
|
---|
| 34 |
|
---|
[11] | 35 | # Loggers
|
---|
| 36 |
|
---|
[8] | 37 | self._checkers.append(checks.StageChecker())
|
---|
[9] | 38 | self._checkers.append(checks.TakeOffLogger())
|
---|
[8] | 39 |
|
---|
| 40 | self._checkers.append(checks.AltimeterLogger())
|
---|
| 41 |
|
---|
| 42 | self._checkers.append(checks.NAV1Logger())
|
---|
| 43 | self._checkers.append(checks.NAV2Logger())
|
---|
| 44 | self._checkers.append(checks.SquawkLogger())
|
---|
| 45 |
|
---|
| 46 | self._checkers.append(checks.AnticollisionLightsLogger())
|
---|
| 47 | self._checkers.append(checks.LandingLightsLogger())
|
---|
| 48 | self._checkers.append(checks.StrobeLightsLogger())
|
---|
| 49 | self._checkers.append(checks.NavLightsLogger())
|
---|
| 50 |
|
---|
| 51 | self._checkers.append(checks.FlapsLogger())
|
---|
| 52 |
|
---|
| 53 | self._checkers.append(checks.GearsLogger())
|
---|
[9] | 54 | self._checkers.append(checks.CruiseSpeedLogger())
|
---|
[10] | 55 | self._checkers.append(checks.SpoilerLogger())
|
---|
[9] | 56 |
|
---|
[11] | 57 | # Fault checkers
|
---|
| 58 |
|
---|
| 59 | self._checkers.append(checks.AntiCollisionLightsChecker())
|
---|
| 60 | self._checkers.append(checks.LandingLightsChecker())
|
---|
| 61 | self._checkers.append(checks.NavLightsChecker())
|
---|
| 62 | self._checkers.append(checks.StrobeLightsChecker())
|
---|
| 63 |
|
---|
| 64 | self._checkers.append(checks.BankChecker())
|
---|
| 65 |
|
---|
| 66 | self._checkers.append(checks.FlapsRetractChecker())
|
---|
| 67 | self._checkers.append(checks.FlapsSpeedLimitChecker())
|
---|
| 68 |
|
---|
| 69 | self._checkers.append(checks.GearsDownChecker())
|
---|
| 70 | self._checkers.append(checks.GearSpeedLimitChecker())
|
---|
| 71 |
|
---|
| 72 | self._checkers.append(checks.GLoadChecker())
|
---|
| 73 |
|
---|
| 74 | self._checkers.append(checks.MLWChecker())
|
---|
| 75 | self._checkers.append(checks.MTOWChecker())
|
---|
| 76 | self._checkers.append(checks.MZFWChecker())
|
---|
| 77 | self._checkers.append(checks.PayloadChecker())
|
---|
| 78 |
|
---|
| 79 | self._checkers.append(checks.SpeedChecker())
|
---|
| 80 | self._checkers.append(checks.VSChecker())
|
---|
| 81 | self._checkers.append(checks.OverspeedChecker())
|
---|
| 82 | self._checkers.append(checks.StallChecker())
|
---|
| 83 |
|
---|
| 84 | self._checkers.append(checks.PitotChecker())
|
---|
| 85 |
|
---|
| 86 | self._checkers.append(checks.ReverserChecker())
|
---|
| 87 |
|
---|
[4] | 88 | @property
|
---|
| 89 | def type(self):
|
---|
| 90 | """Get the type of the aircraft."""
|
---|
[8] | 91 | return self._flight.aircraftType
|
---|
| 92 |
|
---|
| 93 | @property
|
---|
| 94 | def flight(self):
|
---|
| 95 | """Get the flight the aircraft belongs to."""
|
---|
| 96 | return self._flight
|
---|
[4] | 97 |
|
---|
[8] | 98 | @property
|
---|
| 99 | def logger(self):
|
---|
| 100 | """Get the logger to use for the aircraft."""
|
---|
| 101 | return self._flight.logger
|
---|
| 102 |
|
---|
[11] | 103 | def getFlapsSpeedLimit(self, flaps):
|
---|
| 104 | """Get the speed limit for the given flaps setting."""
|
---|
| 105 | return self.flapSpeedLimits[flaps] if flaps in self.flapSpeedLimits \
|
---|
| 106 | else None
|
---|
| 107 |
|
---|
[8] | 108 | def modelChanged(self, timestamp, aircraftName, modelName):
|
---|
[4] | 109 | """Called when the simulator's aircraft changes."""
|
---|
[8] | 110 | self._flight.logger.message(timestamp,
|
---|
| 111 | "Aircraft: name='%s', model='%s'" % \
|
---|
| 112 | (aircraftName, modelName))
|
---|
[4] | 113 |
|
---|
| 114 | def handleState(self, aircraftState):
|
---|
| 115 | """Called when the state of the aircraft changes."""
|
---|
[8] | 116 | for checker in self._checkers:
|
---|
| 117 | checker.check(self._flight, self, self._flight.logger,
|
---|
| 118 | self._aircraftState, aircraftState)
|
---|
[7] | 119 |
|
---|
[89] | 120 | self._flight.handleState(self._aircraftState, aircraftState)
|
---|
| 121 |
|
---|
[9] | 122 | self._maxVS = max(self._maxVS, aircraftState.vs)
|
---|
| 123 | self._minVS = min(self._minVS, aircraftState.vs)
|
---|
| 124 |
|
---|
[4] | 125 | self._aircraftState = aircraftState
|
---|
[8] | 126 |
|
---|
| 127 | def setStage(self, aircraftState, newStage):
|
---|
| 128 | """Set the given stage as the new one and do whatever should be
|
---|
| 129 | done."""
|
---|
[9] | 130 | if self._flight.setStage(aircraftState.timestamp, newStage):
|
---|
| 131 | if newStage==const.STAGE_PUSHANDTAXI:
|
---|
| 132 | self.logger.message(aircraftState.timestamp, "Block time start")
|
---|
| 133 | self.logFuel(aircraftState)
|
---|
| 134 | self.logger.message(aircraftState.timestamp,
|
---|
| 135 | "Zero-fuel weight: %.0f kg" % (aircraftState.zfw))
|
---|
| 136 | elif newStage==const.STAGE_TAKEOFF:
|
---|
| 137 | self.logger.message(aircraftState.timestamp, "Flight time start")
|
---|
| 138 | self.logger.message(aircraftState.timestamp,
|
---|
| 139 | "Takeoff weight: %.0f kg, MTOW: %.0f kg" % \
|
---|
| 140 | (aircraftState.grossWeight, self.mtow))
|
---|
| 141 | self.logger.message(aircraftState.timestamp,
|
---|
| 142 | "Wind %03.0f degrees at %.0f knots" % \
|
---|
| 143 | (aircraftState.windDirection,
|
---|
| 144 | aircraftState.windSpeed))
|
---|
[101] | 145 | self._logV1R2()
|
---|
[9] | 146 | elif newStage==const.STAGE_TAXIAFTERLAND:
|
---|
| 147 | self.logger.message(aircraftState.timestamp, "Flight time end")
|
---|
| 148 | self.logFuel(aircraftState)
|
---|
| 149 | self.logger.message(aircraftState.timestamp,
|
---|
| 150 | "Landing weight: %.0f kg, MLW: %.0f" % \
|
---|
| 151 | (aircraftState.grossWeight, self.mlw))
|
---|
| 152 | self.logger.message(aircraftState.timestamp,
|
---|
| 153 | "Vertical speed range: %.0f..%.0f feet/min" % \
|
---|
[12] | 154 | (self._minVS, self._maxVS))
|
---|
[9] | 155 | elif newStage==const.STAGE_PARKING:
|
---|
| 156 | self.logger.message(aircraftState.timestamp, "Block time end")
|
---|
[89] | 157 | elif newStage==const.STAGE_END:
|
---|
| 158 | flightLength = self._flight.flightTimeEnd - self._flight.flightTimeStart
|
---|
| 159 | self.logger.message(aircraftState.timestamp,
|
---|
| 160 | "Flight time: " +
|
---|
| 161 | util.getTimeIntervalString(flightLength))
|
---|
| 162 | self.logger.message(aircraftState.timestamp,
|
---|
| 163 | "Flown distance: %.2f NM" % \
|
---|
| 164 | (self._flight.flownDistance,))
|
---|
| 165 | blockLength = self._flight.blockTimeEnd - self._flight.blockTimeStart
|
---|
| 166 | self.logger.message(aircraftState.timestamp,
|
---|
| 167 | "Block time: " +
|
---|
| 168 | util.getTimeIntervalString(blockLength))
|
---|
[8] | 169 |
|
---|
[9] | 170 | def prepareFlare(self):
|
---|
| 171 | """Called when it is detected that we will soon flare.
|
---|
[8] | 172 |
|
---|
| 173 | On the first call, it should start monitoring some parameters more
|
---|
| 174 | closely to determine flare time."""
|
---|
[9] | 175 | self.flight.simulator.startFlare()
|
---|
| 176 |
|
---|
| 177 | def flareStarted(self, windSpeed, windDirection, visibility,
|
---|
| 178 | flareStart, flareStartFS):
|
---|
| 179 | """Called when the flare has started."""
|
---|
| 180 | self.logger.message(self._aircraftState.timestamp, "The flare has begun")
|
---|
| 181 | self.logger.message(self._aircraftState.timestamp,
|
---|
| 182 | "Wind %03.0f degrees at %.0f knots" % \
|
---|
| 183 | (windDirection, windSpeed))
|
---|
| 184 | self.logger.message(self._aircraftState.timestamp,
|
---|
| 185 | "Visibility: %.0f metres" % (visibility,))
|
---|
| 186 | self.logger.message(self._aircraftState.timestamp,
|
---|
| 187 | "Altimeter setting: %.0f hPa" % \
|
---|
| 188 | (self._aircraftState.altimeter,))
|
---|
[101] | 189 | self._logVRef()
|
---|
[9] | 190 | self.flight.flareStarted(flareStart, flareStartFS)
|
---|
| 191 |
|
---|
| 192 | def flareFinished(self, flareEnd, flareEndFS, tdRate, tdRateCalculatedByFS,
|
---|
| 193 | ias, pitch, bank, heading):
|
---|
| 194 | """Called when the flare has finished."""
|
---|
| 195 | (flareTimeFromFS, flareTime) = self.flight.flareFinished(flareEnd,
|
---|
| 196 | flareEndFS)
|
---|
| 197 | self.logger.message(self._aircraftState.timestamp,
|
---|
| 198 | "Flare time: %.1f s (from %s)" % \
|
---|
| 199 | (flareTime,
|
---|
| 200 | "the simulator" if flareTimeFromFS else "real time",))
|
---|
| 201 | self.logger.message(self._aircraftState.timestamp,
|
---|
| 202 | "Touchdown rate: %.0f feet/min" % (tdRate,))
|
---|
| 203 | self.logger.message(self._aircraftState.timestamp,
|
---|
| 204 | "Touchdown rate was calculated by the %s" % \
|
---|
| 205 | ("simulator" if tdRateCalculatedByFS else "logger",))
|
---|
| 206 | self.logger.message(self._aircraftState.timestamp,
|
---|
| 207 | "Touchdown speed: %.0f knots" % (ias,))
|
---|
| 208 | self.logger.message(self._aircraftState.timestamp,
|
---|
| 209 | "Touchdown pitch: %.1f degrees" % (pitch,))
|
---|
| 210 | self.logger.message(self._aircraftState.timestamp,
|
---|
| 211 | "Touchdown bank: %.1f degrees" % (bank,))
|
---|
| 212 | self.logger.message(self._aircraftState.timestamp,
|
---|
| 213 | "Touchdown heading: %03.0f degrees" % (heading,))
|
---|
[8] | 214 |
|
---|
| 215 | def cancelFlare(self):
|
---|
| 216 | """Cancel flare, if it has started."""
|
---|
[9] | 217 | self.flight.simulator.cancelFlare()
|
---|
[8] | 218 |
|
---|
| 219 | def checkFlightEnd(self, aircraftState):
|
---|
| 220 | """Check if the end of the flight has arrived.
|
---|
| 221 |
|
---|
| 222 | This default implementation checks the N1 values, but for
|
---|
| 223 | piston-powered aircraft you need to check the RPMs."""
|
---|
| 224 | for n1 in aircraftState.n1:
|
---|
| 225 | if n1>=0.5: return False
|
---|
| 226 | return True
|
---|
| 227 |
|
---|
[101] | 228 | def updateV1R2(self):
|
---|
| 229 | """Update the V1, Vr and V2 values from the flight, if the these values
|
---|
| 230 | have already been logged."""
|
---|
| 231 | if self._v1r2LineIndex is not None:
|
---|
| 232 | self._logV1R2()
|
---|
| 233 |
|
---|
| 234 | def _logV1R2(self):
|
---|
| 235 | """Log the V1, Vr and V2 value either newly, or by updating the
|
---|
| 236 | corresponding line."""
|
---|
| 237 | message = "Speeds calculated by the pilot: V1: %s, VR: %s, V2: %s" % \
|
---|
| 238 | ("-" if self._flight.v1 is None
|
---|
| 239 | else str(self._flight.v1),
|
---|
| 240 | "-" if self._flight.vr is None
|
---|
| 241 | else str(self._flight.vr),
|
---|
| 242 | "-" if self._flight.v2 is None
|
---|
| 243 | else str(self._flight.v2))
|
---|
| 244 |
|
---|
| 245 | if self._v1r2LineIndex is None:
|
---|
| 246 | self._v1r2LineIndex = \
|
---|
| 247 | self.logger.message(self._aircraftState.timestamp, message)
|
---|
| 248 | else:
|
---|
| 249 | self.logger.updateLine(self._v1r2LineIndex, message)
|
---|
| 250 |
|
---|
[96] | 251 | def updateVRef(self):
|
---|
| 252 | """Update the Vref value from the flight, if the Vref value has already
|
---|
| 253 | been logged."""
|
---|
| 254 | if self._vrefLineIndex is not None:
|
---|
| 255 | self._logVRef()
|
---|
| 256 |
|
---|
| 257 | def _logVRef(self):
|
---|
| 258 | """Log the Vref value either newly, or by updating the corresponding
|
---|
| 259 | line."""
|
---|
| 260 | message = "VRef speed calculated by the pilot: %s" % \
|
---|
| 261 | ("-" if self._flight.vref is None else str(self._flight.vref))
|
---|
| 262 | if self._vrefLineIndex is None:
|
---|
| 263 | self._vrefLineIndex = \
|
---|
| 264 | self.logger.message(self._aircraftState.timestamp, message)
|
---|
| 265 | else:
|
---|
| 266 | self.logger.updateLine(self._vrefLineIndex, message)
|
---|
| 267 |
|
---|
[4] | 268 | #---------------------------------------------------------------------------------------
|
---|
[7] | 269 |
|
---|
| 270 | class Boeing737(Aircraft):
|
---|
| 271 | """Base class for the various aircraft in the Boeing 737 family.
|
---|
| 272 |
|
---|
| 273 | The aircraft type-specific values in the aircraft state have the following
|
---|
| 274 | structure:
|
---|
| 275 | - fuel: centre, left, right
|
---|
| 276 | - n1: left, right
|
---|
| 277 | - reverser: left, right"""
|
---|
[9] | 278 | def __init__(self, flight):
|
---|
| 279 | super(Boeing737, self).__init__(flight)
|
---|
[95] | 280 | self._checkers.append(checks.ThrustChecker())
|
---|
| 281 |
|
---|
[9] | 282 | self.gearSpeedLimit = 270
|
---|
| 283 | self.flapSpeedLimits = { 1 : 260,
|
---|
| 284 | 2 : 260,
|
---|
| 285 | 5 : 250,
|
---|
| 286 | 10 : 210,
|
---|
| 287 | 15 : 200,
|
---|
| 288 | 25 : 190,
|
---|
| 289 | 30 : 175,
|
---|
| 290 | 40 : 162 }
|
---|
[7] | 291 |
|
---|
[9] | 292 | def logFuel(self, aircraftState):
|
---|
| 293 | """Log the amount of fuel"""
|
---|
| 294 | self.logger.message(aircraftState.timestamp,
|
---|
| 295 | "Fuel: left=%.0f kg - centre=%.0f kg - right=%.0f kg" % \
|
---|
| 296 | (aircraftState.fuel[1], aircraftState.fuel[0],
|
---|
| 297 | aircraftState.fuel[2]))
|
---|
| 298 | self.logger.message(aircraftState.timestamp,
|
---|
| 299 | "Total fuel: %.0f kg" % (sum(aircraftState.fuel),))
|
---|
| 300 |
|
---|
[7] | 301 | #---------------------------------------------------------------------------------------
|
---|
| 302 |
|
---|
| 303 | class B736(Boeing737):
|
---|
| 304 | """Boeing 737-600 aircraft."""
|
---|
[8] | 305 | def __init__(self, flight):
|
---|
| 306 | super(B736, self).__init__(flight)
|
---|
[9] | 307 | self.dow = 38307
|
---|
| 308 | self.mtow = 58328
|
---|
| 309 | self.mlw = 54657
|
---|
| 310 | self.mzfw = 51482
|
---|
[7] | 311 |
|
---|
| 312 | #---------------------------------------------------------------------------------------
|
---|
| 313 |
|
---|
| 314 | class B737(Boeing737):
|
---|
| 315 | """Boeing 737-700 aircraft."""
|
---|
[8] | 316 | def __init__(self, flight):
|
---|
| 317 | super(B737, self).__init__(flight)
|
---|
[9] | 318 | self.dow = 39250
|
---|
| 319 | self.mtow = 61410
|
---|
| 320 | self.mlw = 58059
|
---|
| 321 | self.mzfw = 54657
|
---|
[7] | 322 |
|
---|
| 323 | #---------------------------------------------------------------------------------------
|
---|
| 324 |
|
---|
| 325 | class B738(Boeing737):
|
---|
| 326 | """Boeing 737-800 aircraft."""
|
---|
[8] | 327 | def __init__(self, flight):
|
---|
| 328 | super(B738, self).__init__(flight)
|
---|
[9] | 329 | self.dow = 42690
|
---|
| 330 | self.mtow = 71709
|
---|
| 331 | self.mlw = 65317
|
---|
| 332 | self.mzfw = 61688
|
---|
| 333 |
|
---|
| 334 | #---------------------------------------------------------------------------------------
|
---|
| 335 |
|
---|
| 336 | class B738Charter(B738):
|
---|
| 337 | """Boeing 737-800 aircraft used for charters."""
|
---|
| 338 | def __init__(self, flight):
|
---|
| 339 | super(B738Charter, self).__init__(flight)
|
---|
| 340 | self.mtow = 77791
|
---|
[7] | 341 |
|
---|
| 342 | #---------------------------------------------------------------------------------------
|
---|
| 343 |
|
---|
| 344 | class B733(Boeing737):
|
---|
| 345 | """Boeing 737-300 aircraft."""
|
---|
[8] | 346 | def __init__(self, flight):
|
---|
| 347 | super(B733, self).__init__(flight)
|
---|
[9] | 348 | self.dow = 32700
|
---|
| 349 | self.mtow = 62820
|
---|
| 350 | self.mlw = 51700
|
---|
| 351 | self.mzfw = 48410
|
---|
[7] | 352 |
|
---|
| 353 | #---------------------------------------------------------------------------------------
|
---|
| 354 |
|
---|
| 355 | class B734(Boeing737):
|
---|
| 356 | """Boeing 737-400 aircraft."""
|
---|
[8] | 357 | def __init__(self, flight):
|
---|
| 358 | super(B734, self).__init__(flight)
|
---|
[9] | 359 | self.dow = 33200
|
---|
| 360 | self.mtow = 68050
|
---|
| 361 | self.mlw = 56200
|
---|
| 362 | self.mzfw = 53100
|
---|
[7] | 363 |
|
---|
| 364 | #---------------------------------------------------------------------------------------
|
---|
| 365 |
|
---|
| 366 | class B735(Boeing737):
|
---|
| 367 | """Boeing 737-500 aircraft."""
|
---|
[8] | 368 | def __init__(self, flight):
|
---|
| 369 | super(B735, self).__init__(flight)
|
---|
[9] | 370 | self.dow = 31300
|
---|
| 371 | self.mtow = 60550
|
---|
| 372 | self.mlw = 50000
|
---|
| 373 | self.mzfw = 46700
|
---|
[7] | 374 |
|
---|
| 375 | #---------------------------------------------------------------------------------------
|
---|
| 376 |
|
---|
| 377 | class DH8D(Aircraft):
|
---|
| 378 | """Bombardier Dash-8 Q400 aircraft.
|
---|
| 379 |
|
---|
| 380 | The aircraft type-specific values in the aircraft state have the following
|
---|
| 381 | structure:
|
---|
| 382 | - fuel: centre, left, right
|
---|
| 383 | - n1: left, right
|
---|
| 384 | - reverser: left, right."""
|
---|
[8] | 385 | def __init__(self, flight):
|
---|
| 386 | super(DH8D, self).__init__(flight)
|
---|
[9] | 387 | self.dow = 17185
|
---|
| 388 | self.mtow = 29257
|
---|
| 389 | self.mlw = 28009
|
---|
| 390 | self.mzfw = 25855
|
---|
| 391 | self.gearSpeedLimit = 215
|
---|
| 392 | self.flapSpeedLimits = { 5 : 200,
|
---|
| 393 | 10 : 181,
|
---|
| 394 | 15 : 172,
|
---|
| 395 | 35 : 158 }
|
---|
| 396 |
|
---|
| 397 | def logFuel(self, aircraftState):
|
---|
| 398 | """Log the amount of fuel"""
|
---|
| 399 | self.logger.message(aircraftState.timestamp,
|
---|
| 400 | "Fuel: left=%.0f kg - centre=%.0f kg - right=%.0f kg" % \
|
---|
| 401 | (aircraftState.fuel[1], aircraftState.fuel[0],
|
---|
| 402 | aircraftState.fuel[2]))
|
---|
| 403 | self.logger.message(aircraftState.timestamp,
|
---|
| 404 | "Total fuel: %.0f kg" % (sum(aircraftState.fuel),))
|
---|
[7] | 405 |
|
---|
| 406 | #---------------------------------------------------------------------------------------
|
---|
| 407 |
|
---|
| 408 | class Boeing767(Aircraft):
|
---|
| 409 | """Base class for the various aircraft in the Boeing 767 family.
|
---|
| 410 |
|
---|
| 411 | The aircraft type-specific values in the aircraft state have the following
|
---|
| 412 | structure:
|
---|
| 413 | - fuel: centre, left, right
|
---|
| 414 | - n1: left, right
|
---|
| 415 | - reverser: left, right"""
|
---|
[9] | 416 | def __init__(self, flight):
|
---|
| 417 | super(Boeing767, self).__init__(flight)
|
---|
[95] | 418 | self._checkers.append(checks.ThrustChecker())
|
---|
[9] | 419 | self.gearSpeedLimit = 270
|
---|
| 420 | self.flapSpeedLimits = { 1 : 255,
|
---|
| 421 | 5 : 235,
|
---|
| 422 | 10 : 215,
|
---|
| 423 | 20 : 215,
|
---|
| 424 | 25 : 185,
|
---|
| 425 | 30 : 175 }
|
---|
[7] | 426 |
|
---|
[9] | 427 | def logFuel(self, aircraftState):
|
---|
| 428 | """Log the amount of fuel"""
|
---|
| 429 | self.logger.message(aircraftState.timestamp,
|
---|
| 430 | "Fuel: left=%.0f kg - centre=%.0f kg - right=%.0f kg" % \
|
---|
| 431 | (aircraftState.fuel[1], aircraftState.fuel[0],
|
---|
| 432 | aircraftState.fuel[2]))
|
---|
| 433 | self.logger.message(aircraftState.timestamp,
|
---|
| 434 | "Total fuel: %.0f kg" % (sum(aircraftState.fuel),))
|
---|
| 435 |
|
---|
[7] | 436 | #---------------------------------------------------------------------------------------
|
---|
| 437 |
|
---|
| 438 | class B762(Boeing767):
|
---|
| 439 | """Boeing 767-200 aircraft."""
|
---|
[8] | 440 | def __init__(self, flight):
|
---|
| 441 | super(B762, self).__init__(flight)
|
---|
[9] | 442 | self.dow = 84507
|
---|
| 443 | self.mtow = 175540
|
---|
| 444 | self.mlw = 126098
|
---|
| 445 | self.mzfw = 114758
|
---|
[7] | 446 |
|
---|
| 447 | #---------------------------------------------------------------------------------------
|
---|
| 448 |
|
---|
| 449 | class B763(Boeing767):
|
---|
| 450 | """Boeing 767-300 aircraft."""
|
---|
[8] | 451 | def __init__(self, flight):
|
---|
| 452 | super(B763, self).__init__(cflight)
|
---|
[9] | 453 | self.dow = 91311
|
---|
| 454 | self.mtow = 181436
|
---|
| 455 | self.mlw = 137892
|
---|
| 456 | self.mzfw = 130635
|
---|
[7] | 457 |
|
---|
| 458 | #---------------------------------------------------------------------------------------
|
---|
| 459 |
|
---|
| 460 | class CRJ2(Aircraft):
|
---|
| 461 | """Bombardier CRJ-200 aircraft.
|
---|
| 462 |
|
---|
| 463 | The aircraft type-specific values in the aircraft state have the following
|
---|
| 464 | structure:
|
---|
| 465 | - fuel: centre, left, right
|
---|
| 466 | - n1: left, right
|
---|
| 467 | - reverser: left, right."""
|
---|
[8] | 468 | def __init__(self, flight):
|
---|
| 469 | super(CRJ2, self).__init__(flight)
|
---|
[95] | 470 | self._checkers.append(checks.ThrustChecker())
|
---|
[9] | 471 | self.dow = 14549
|
---|
| 472 | self.mtow = 22995
|
---|
| 473 | self.mlw = 21319
|
---|
| 474 | self.mzfw = 19958
|
---|
| 475 | self.gearSpeedLimit = 240
|
---|
| 476 | self.flapSpeedLimits = { 8 : 260,
|
---|
| 477 | 20 : 220,
|
---|
| 478 | 30 : 190,
|
---|
| 479 | 45 : 175 }
|
---|
[7] | 480 |
|
---|
[9] | 481 | def logFuel(self, aircraftState):
|
---|
| 482 | """Log the amount of fuel"""
|
---|
| 483 | self.logger.message(aircraftState.timestamp,
|
---|
| 484 | "Fuel: left=%.0f kg - centre=%.0f kg - right=%.0f kg" % \
|
---|
| 485 | (aircraftState.fuel[1], aircraftState.fuel[0],
|
---|
| 486 | aircraftState.fuel[2]))
|
---|
| 487 | self.logger.message(aircraftState.timestamp,
|
---|
| 488 | "Total fuel: %.0f kg" % (sum(aircraftState.fuel),))
|
---|
| 489 |
|
---|
[7] | 490 | #---------------------------------------------------------------------------------------
|
---|
| 491 |
|
---|
| 492 | class F70(Aircraft):
|
---|
| 493 | """Fokker 70 aircraft.
|
---|
| 494 |
|
---|
| 495 | The aircraft type-specific values in the aircraft state have the following
|
---|
| 496 | structure:
|
---|
| 497 | - fuel: centre, left, right
|
---|
| 498 | - n1: left, right
|
---|
| 499 | - reverser: left, right."""
|
---|
[8] | 500 | def __init__(self, flight):
|
---|
| 501 | super(F70, self).__init__(flight)
|
---|
[95] | 502 | self._checkers.append(checks.ThrustChecker())
|
---|
[9] | 503 | self.dow = 24283
|
---|
| 504 | self.mtow = 38100 # FIXME: differentiate by registration number,
|
---|
| 505 | # MTOW of HA-LMF: 41955
|
---|
| 506 | self.mlw = 36740
|
---|
| 507 | self.mzfw = 32655
|
---|
| 508 | self.gearSpeedLimit = 200
|
---|
| 509 | self.flapSpeedLimits = { 8 : 250,
|
---|
| 510 | 15 : 220,
|
---|
| 511 | 25 : 220,
|
---|
| 512 | 42 : 180 }
|
---|
[7] | 513 |
|
---|
[9] | 514 | def logFuel(self, aircraftState):
|
---|
| 515 | """Log the amount of fuel"""
|
---|
| 516 | self.logger.message(aircraftState.timestamp,
|
---|
| 517 | "Fuel: left=%.0f kg - centre=%.0f kg - right=%.0f kg" % \
|
---|
| 518 | (aircraftState.fuel[1], aircraftState.fuel[0],
|
---|
| 519 | aircraftState.fuel[2]))
|
---|
| 520 | self.logger.message(aircraftState.timestamp,
|
---|
| 521 | "Total fuel: %.0f kg" % (sum(aircraftState.fuel),))
|
---|
| 522 |
|
---|
[7] | 523 | #---------------------------------------------------------------------------------------
|
---|
| 524 |
|
---|
| 525 | class DC3(Aircraft):
|
---|
| 526 | """Lisunov Li-2 (DC-3) aircraft.
|
---|
| 527 |
|
---|
| 528 | The aircraft type-specific values in the aircraft state have the following
|
---|
| 529 | structure:
|
---|
[52] | 530 | - fuel: left, right, left aux, right aux
|
---|
[7] | 531 | - rpm: left, right
|
---|
| 532 | - reverser: left, right."""
|
---|
[8] | 533 | def __init__(self, flight):
|
---|
| 534 | super(DC3, self).__init__(flight)
|
---|
[9] | 535 | self.dow = 8627
|
---|
| 536 | self.mtow = 11884
|
---|
| 537 | self.mlw = 11793
|
---|
| 538 | self.mzfw = 11780
|
---|
| 539 | self.gearSpeedLimit = 148
|
---|
| 540 | self.flapSpeedLimits = { 15 : 135,
|
---|
| 541 | 30 : 99,
|
---|
| 542 | 45 : 97 }
|
---|
[8] | 543 |
|
---|
| 544 | def _checkFlightEnd(self, aircraftState):
|
---|
| 545 | """Check if the end of the flight has arrived.
|
---|
| 546 |
|
---|
| 547 | This implementation checks the RPM values to be 0."""
|
---|
| 548 | for rpm in aircraftState.rpm:
|
---|
[29] | 549 | if rpm>0: return False
|
---|
| 550 | return True
|
---|
[7] | 551 |
|
---|
[9] | 552 | def logFuel(self, aircraftState):
|
---|
| 553 | """Log the amount of fuel"""
|
---|
| 554 | self.logger.message(aircraftState.timestamp,
|
---|
| 555 | "Fuel: left aux=%.0f kg - left=%.0f kg - right=%.0f kg - right aux=%.0f kg" % \
|
---|
| 556 | (aircraftState.fuel[2], aircraftState.fuel[0],
|
---|
| 557 | aircraftState.fuel[1], aircraftState.fuel[3]))
|
---|
| 558 | self.logger.message(aircraftState.timestamp,
|
---|
| 559 | "Total fuel: %.0f kg" % (sum(aircraftState.fuel),))
|
---|
| 560 |
|
---|
[7] | 561 | #---------------------------------------------------------------------------------------
|
---|
| 562 |
|
---|
| 563 | class T134(Aircraft):
|
---|
| 564 | """Tupolev Tu-134 aircraft.
|
---|
| 565 |
|
---|
| 566 | The aircraft type-specific values in the aircraft state have the following
|
---|
| 567 | structure:
|
---|
| 568 | - fuel: centre, left tip, left aux, right tip, right aux, external 1,
|
---|
| 569 | external 2
|
---|
| 570 | - n1: left, right
|
---|
| 571 | - reverser: left, right."""
|
---|
[8] | 572 | def __init__(self, flight):
|
---|
| 573 | super(T134, self).__init__(flight)
|
---|
[95] | 574 | self._checkers.append(checks.ThrustChecker())
|
---|
[9] | 575 | self.dow = 29927
|
---|
| 576 | self.mtow = 47600
|
---|
| 577 | self.mlw = 43000
|
---|
| 578 | self.mzfw = 38500
|
---|
| 579 | self.gearSpeedLimit = 216
|
---|
| 580 | self.flapSpeedLimits = { 10 : 240,
|
---|
| 581 | 20 : 216,
|
---|
| 582 | 30 : 161 }
|
---|
[7] | 583 |
|
---|
[9] | 584 | def logFuel(self, aircraftState):
|
---|
| 585 | """Log the amount of fuel"""
|
---|
| 586 | self.logger.message(aircraftState.timestamp,
|
---|
| 587 | "Fuel: left aux=%.0f kg - left tip=%.0f kg - centre= %.0f kg - right tip=%.0f kg - right aux=%.0f kg - external 1=%.0f kg - external 2=%.0f kg" % \
|
---|
| 588 | (aircraftState.fuel[2], aircraftState.fuel[1],
|
---|
| 589 | aircraftState.fuel[0],
|
---|
| 590 | aircraftState.fuel[3], aircraftState.fuel[4],
|
---|
| 591 | aircraftState.fuel[5], aircraftState.fuel[6]))
|
---|
| 592 | self.logger.message(aircraftState.timestamp,
|
---|
| 593 | "Total fuel: %.0f kg" % (sum(aircraftState.fuel),))
|
---|
| 594 |
|
---|
[7] | 595 | #---------------------------------------------------------------------------------------
|
---|
| 596 |
|
---|
| 597 | class T154(Aircraft):
|
---|
| 598 | """Tupolev Tu-154 aircraft.
|
---|
| 599 |
|
---|
| 600 | The aircraft type-specific values in the aircraft state have the following
|
---|
| 601 | structure:
|
---|
| 602 | - fuel: centre, left, right, centre 2, left aux, right aux
|
---|
| 603 | - n1: left, centre, right
|
---|
| 604 | - reverser: left, right"""
|
---|
[8] | 605 | def __init__(self, flight):
|
---|
| 606 | super(T154, self).__init__(flight)
|
---|
[95] | 607 | self._checkers.append(checks.ThrustChecker())
|
---|
[9] | 608 | self.dow = 53259
|
---|
| 609 | self.mtow = 98000
|
---|
| 610 | self.mlw = 78000
|
---|
| 611 | self.mzfw = 72000
|
---|
| 612 | self.gearSpeedLimit = 216
|
---|
| 613 | self.flapSpeedLimits = { 15 : 227,
|
---|
| 614 | 28 : 194,
|
---|
| 615 | 45 : 162 }
|
---|
| 616 |
|
---|
| 617 | def logFuel(self, aircraftState):
|
---|
| 618 | """Log the amount of fuel"""
|
---|
| 619 | self.logger.message(aircraftState.timestamp,
|
---|
| 620 | "Fuel: left aux=%.0f kg - left=%.0f kg - centre=%.0f kg - centre 2=%.0f kg - right=%.0f kg - right aux=%.0f kg" % \
|
---|
| 621 | (aircraftState.fuel[4], aircraftState.fuel[1],
|
---|
| 622 | aircraftState.fuel[0], aircraftState.fuel[3],
|
---|
| 623 | aircraftState.fuel[2], aircraftState.fuel[5]))
|
---|
| 624 | self.logger.message(aircraftState.timestamp,
|
---|
| 625 | "Total fuel: %.0f kg" % (sum(aircraftState.fuel),))
|
---|
[7] | 626 |
|
---|
| 627 | #---------------------------------------------------------------------------------------
|
---|
| 628 |
|
---|
[9] | 629 |
|
---|
[7] | 630 | class YK40(Aircraft):
|
---|
| 631 | """Yakovlev Yak-40 aircraft.
|
---|
| 632 |
|
---|
| 633 | The aircraft type-specific values in the aircraft state have the following
|
---|
| 634 | structure:
|
---|
| 635 | - fuel: left, right
|
---|
| 636 | - n1: left, right
|
---|
| 637 | - reverser: left, right"""
|
---|
[8] | 638 | def __init__(self, flight):
|
---|
| 639 | super(YK40, self).__init__(flight)
|
---|
[95] | 640 | self._checkers.append(checks.ThrustChecker())
|
---|
[9] | 641 | self.dow = 9400
|
---|
| 642 | self.mtow = 17200
|
---|
| 643 | self.mlw = 16800
|
---|
| 644 | self.mzfw = 12100
|
---|
| 645 | self.gearSpeedLimit = 165
|
---|
| 646 | self.flapSpeedLimits = { 20 : 165,
|
---|
| 647 | 35 : 135 }
|
---|
| 648 |
|
---|
| 649 | def logFuel(self, aircraftState):
|
---|
| 650 | """Log the amount of fuel"""
|
---|
| 651 | self.logger.message(aircraftState.timestamp,
|
---|
| 652 | "Fuel: left=%.0f kg - right=%.0f kg" % \
|
---|
| 653 | (aircraftState.fuel[0], aircraftState.fuel[1]))
|
---|
| 654 | self.logger.message(aircraftState.timestamp,
|
---|
| 655 | "Total fuel: %.0f kg" % (sum(aircraftState.fuel),))
|
---|
[7] | 656 |
|
---|
| 657 | #---------------------------------------------------------------------------------------
|
---|
| 658 |
|
---|
[8] | 659 | _classes = { const.AIRCRAFT_B736 : B736,
|
---|
| 660 | const.AIRCRAFT_B737 : B737,
|
---|
| 661 | const.AIRCRAFT_B738 : B738,
|
---|
| 662 | const.AIRCRAFT_B733 : B733,
|
---|
| 663 | const.AIRCRAFT_B734 : B734,
|
---|
| 664 | const.AIRCRAFT_B735 : B735,
|
---|
| 665 | const.AIRCRAFT_DH8D : DH8D,
|
---|
| 666 | const.AIRCRAFT_B762 : B762,
|
---|
| 667 | const.AIRCRAFT_B763 : B763,
|
---|
| 668 | const.AIRCRAFT_CRJ2 : CRJ2,
|
---|
| 669 | const.AIRCRAFT_F70 : F70,
|
---|
| 670 | const.AIRCRAFT_DC3 : DC3,
|
---|
| 671 | const.AIRCRAFT_T134 : T134,
|
---|
| 672 | const.AIRCRAFT_T154 : T154,
|
---|
| 673 | const.AIRCRAFT_YK40 : YK40 }
|
---|
| 674 |
|
---|
| 675 | #---------------------------------------------------------------------------------------
|
---|