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