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