1 | # Module for the simulator-independent aircraft classes
|
---|
2 |
|
---|
3 | #---------------------------------------------------------------------------------------
|
---|
4 |
|
---|
5 | import time
|
---|
6 |
|
---|
7 | import const
|
---|
8 |
|
---|
9 | #---------------------------------------------------------------------------------------
|
---|
10 |
|
---|
11 | class Aircraft(object):
|
---|
12 | """Base class for aircraft."""
|
---|
13 | def __init__(self, type):
|
---|
14 | """Construct the aircraft for the given type."""
|
---|
15 | self._type = type
|
---|
16 | self._aircraftState = None
|
---|
17 |
|
---|
18 | @property
|
---|
19 | def type(self):
|
---|
20 | """Get the type of the aircraft."""
|
---|
21 | return self._type
|
---|
22 |
|
---|
23 | def modelChanged(self, aircraftName, modelName):
|
---|
24 | """Called when the simulator's aircraft changes."""
|
---|
25 | print "Aircraft.modelChanged: aircraftName='%s', modelName='%s'" % \
|
---|
26 | (aircraftName, modelName)
|
---|
27 |
|
---|
28 | def handleState(self, aircraftState):
|
---|
29 | """Called when the state of the aircraft changes."""
|
---|
30 | timeStr = time.ctime(aircraftState.timestamp)
|
---|
31 |
|
---|
32 | if self._aircraftState is None or \
|
---|
33 | self._aircraftState.paused != aircraftState.paused:
|
---|
34 | print "Aircraft.handleState: %s: paused=%d" % \
|
---|
35 | (timeStr, aircraftState.paused)
|
---|
36 |
|
---|
37 | if self._aircraftState is None or \
|
---|
38 | self._aircraftState.trickMode != aircraftState.trickMode:
|
---|
39 | print "Aircraft.handleState: %s: trickMode=%d" % \
|
---|
40 | (timeStr, aircraftState.trickMode)
|
---|
41 |
|
---|
42 | if self._aircraftState is None or \
|
---|
43 | self._aircraftState.overspeed != aircraftState.overspeed:
|
---|
44 | print "Aircraft.handleState: %s: overspeed=%d" % \
|
---|
45 | (timeStr, aircraftState.overspeed)
|
---|
46 |
|
---|
47 | if self._aircraftState is None or \
|
---|
48 | self._aircraftState.stalled != aircraftState.stalled:
|
---|
49 | print "Aircraft.handleState: %s: stalled=%d" % \
|
---|
50 | (timeStr, aircraftState.stalled)
|
---|
51 |
|
---|
52 | if self._aircraftState is None or \
|
---|
53 | self._aircraftState.onTheGround != aircraftState.onTheGround:
|
---|
54 | print "Aircraft.handleState: %s: onTheGround=%d" % \
|
---|
55 | (timeStr, aircraftState.onTheGround)
|
---|
56 |
|
---|
57 | if self._aircraftState is None or \
|
---|
58 | self._aircraftState.grossWeight != aircraftState.grossWeight:
|
---|
59 | print "Aircraft.handleState: %s: grossWeight=%f" % \
|
---|
60 | (timeStr, aircraftState.grossWeight)
|
---|
61 |
|
---|
62 | if self._aircraftState is None or \
|
---|
63 | self._aircraftState.heading != aircraftState.heading:
|
---|
64 | print "Aircraft.handleState: %s: heading=%f" % \
|
---|
65 | (timeStr, aircraftState.heading)
|
---|
66 |
|
---|
67 | if self._aircraftState is None or \
|
---|
68 | self._aircraftState.pitch != aircraftState.pitch:
|
---|
69 | print "Aircraft.handleState: %s: pitch=%f" % \
|
---|
70 | (timeStr, aircraftState.pitch)
|
---|
71 |
|
---|
72 | if self._aircraftState is None or \
|
---|
73 | self._aircraftState.bank != aircraftState.bank:
|
---|
74 | print "Aircraft.handleState: %s: bank=%f" % \
|
---|
75 | (timeStr, aircraftState.bank)
|
---|
76 |
|
---|
77 | if self._aircraftState is None or \
|
---|
78 | self._aircraftState.ias != aircraftState.ias:
|
---|
79 | print "Aircraft.handleState: %s: ias=%f" % \
|
---|
80 | (timeStr, aircraftState.ias)
|
---|
81 |
|
---|
82 | if self._aircraftState is None or \
|
---|
83 | self._aircraftState.groundSpeed != aircraftState.groundSpeed:
|
---|
84 | print "Aircraft.handleState: %s: groundSpeed=%f" % \
|
---|
85 | (timeStr, aircraftState.groundSpeed)
|
---|
86 |
|
---|
87 | if self._aircraftState is None or \
|
---|
88 | self._aircraftState.vs != aircraftState.vs:
|
---|
89 | print "Aircraft.handleState: %s: vs=%f" % \
|
---|
90 | (timeStr, aircraftState.vs)
|
---|
91 |
|
---|
92 | if self._aircraftState is None or \
|
---|
93 | self._aircraftState.altitude != aircraftState.altitude:
|
---|
94 | print "Aircraft.handleState: %s: altitude=%f" % \
|
---|
95 | (timeStr, aircraftState.altitude)
|
---|
96 |
|
---|
97 | if self._aircraftState is None or \
|
---|
98 | self._aircraftState.gLoad != aircraftState.gLoad:
|
---|
99 | print "Aircraft.handleState: %s: gLoad=%f" % \
|
---|
100 | (timeStr, aircraftState.gLoad)
|
---|
101 |
|
---|
102 | if self._aircraftState is None or \
|
---|
103 | self._aircraftState.flapsSet != aircraftState.flapsSet:
|
---|
104 | print "Aircraft.handleState: %s: flapsSet=%f" % \
|
---|
105 | (timeStr, aircraftState.flapsSet)
|
---|
106 |
|
---|
107 | if self._aircraftState is None or \
|
---|
108 | self._aircraftState.flaps != aircraftState.flaps:
|
---|
109 | print "Aircraft.handleState: %s: flaps=%f" % \
|
---|
110 | (timeStr, aircraftState.flaps)
|
---|
111 |
|
---|
112 | if self._aircraftState is None or \
|
---|
113 | self._aircraftState.navLightsOn != aircraftState.navLightsOn:
|
---|
114 | print "Aircraft.handleState: %s: navLightsOn=%d" % \
|
---|
115 | (timeStr, aircraftState.navLightsOn)
|
---|
116 |
|
---|
117 | if self._aircraftState is None or \
|
---|
118 | self._aircraftState.antiCollisionLightsOn != aircraftState.antiCollisionLightsOn:
|
---|
119 | print "Aircraft.handleState: %s: antiCollisionLightsOn=%d" % \
|
---|
120 | (timeStr, aircraftState.antiCollisionLightsOn)
|
---|
121 |
|
---|
122 | if self._aircraftState is None or \
|
---|
123 | self._aircraftState.strobeLightsOn != aircraftState.strobeLightsOn:
|
---|
124 | print "Aircraft.handleState: %s: strobeLightsOn=%d" % \
|
---|
125 | (timeStr, aircraftState.strobeLightsOn)
|
---|
126 |
|
---|
127 | if self._aircraftState is None or \
|
---|
128 | self._aircraftState.landingLightsOn != aircraftState.landingLightsOn:
|
---|
129 | print "Aircraft.handleState: %s: landingLightsOn=%d" % \
|
---|
130 | (timeStr, aircraftState.landingLightsOn)
|
---|
131 |
|
---|
132 | if self._aircraftState is None or \
|
---|
133 | self._aircraftState.pitotHeatOn != aircraftState.pitotHeatOn:
|
---|
134 | print "Aircraft.handleState: %s: pitotHeatOn=%d" % \
|
---|
135 | (timeStr, aircraftState.pitotHeatOn)
|
---|
136 |
|
---|
137 | if self._aircraftState is None or \
|
---|
138 | self._aircraftState.gearsDown != aircraftState.gearsDown:
|
---|
139 | print "Aircraft.handleState: %s: gearsDown=%f" % \
|
---|
140 | (timeStr, aircraftState.gearsDown)
|
---|
141 |
|
---|
142 | if self._aircraftState is None or \
|
---|
143 | self._aircraftState.spoilersArmed != aircraftState.spoilersArmed:
|
---|
144 | print "Aircraft.handleState: %s: spoilersArmed=%f" % \
|
---|
145 | (timeStr, aircraftState.spoilersArmed)
|
---|
146 |
|
---|
147 | if self._aircraftState is None or \
|
---|
148 | self._aircraftState.spoilersExtension != aircraftState.spoilersExtension:
|
---|
149 | print "Aircraft.handleState: %s: spoilersExtension=%f" % \
|
---|
150 | (timeStr, aircraftState.spoilersExtension)
|
---|
151 |
|
---|
152 | if self._aircraftState is None or \
|
---|
153 | self._aircraftState.altimeter != aircraftState.altimeter:
|
---|
154 | print "Aircraft.handleState: %s: altimeter=%f" % \
|
---|
155 | (timeStr, aircraftState.altimeter)
|
---|
156 |
|
---|
157 | if self._aircraftState is None or \
|
---|
158 | self._aircraftState.nav1 != aircraftState.nav1:
|
---|
159 | print "Aircraft.handleState: %s: nav1=%s" % \
|
---|
160 | (timeStr, aircraftState.nav1)
|
---|
161 |
|
---|
162 | if self._aircraftState is None or \
|
---|
163 | self._aircraftState.nav2 != aircraftState.nav2:
|
---|
164 | print "Aircraft.handleState: %s: nav2=%s" % \
|
---|
165 | (timeStr, aircraftState.nav2)
|
---|
166 |
|
---|
167 | if self._aircraftState is None or \
|
---|
168 | self._aircraftState.fuel != aircraftState.fuel:
|
---|
169 | print "Aircraft.handleState: %s: fuel=%s" % \
|
---|
170 | (timeStr, aircraftState.fuel)
|
---|
171 |
|
---|
172 | if self._aircraftState is None or \
|
---|
173 | self._aircraftState.n1 != aircraftState.n1:
|
---|
174 | print "Aircraft.handleState: %s: n1=%s" % \
|
---|
175 | (timeStr, aircraftState.n1)
|
---|
176 |
|
---|
177 | if self._aircraftState is None or \
|
---|
178 | self._aircraftState.reverser != aircraftState.reverser:
|
---|
179 | print "Aircraft.handleState: %s: reverser=%s" % \
|
---|
180 | (timeStr, aircraftState.reverser)
|
---|
181 |
|
---|
182 | self._aircraftState = aircraftState
|
---|
183 |
|
---|
184 | #---------------------------------------------------------------------------------------
|
---|
185 |
|
---|
186 | class Boeing737(Aircraft):
|
---|
187 | """Base class for the various aircraft in the Boeing 737 family.
|
---|
188 |
|
---|
189 | The aircraft type-specific values in the aircraft state have the following
|
---|
190 | structure:
|
---|
191 | - fuel: centre, left, right
|
---|
192 | - n1: left, right
|
---|
193 | - reverser: left, right"""
|
---|
194 | pass
|
---|
195 |
|
---|
196 | #---------------------------------------------------------------------------------------
|
---|
197 |
|
---|
198 | class B736(Boeing737):
|
---|
199 | """Boeing 737-600 aircraft."""
|
---|
200 | def __init__(self):
|
---|
201 | super(B736, self).__init__(const.AIRCRAFT_B736)
|
---|
202 |
|
---|
203 | #---------------------------------------------------------------------------------------
|
---|
204 |
|
---|
205 | class B737(Boeing737):
|
---|
206 | """Boeing 737-700 aircraft."""
|
---|
207 | def __init__(self):
|
---|
208 | super(B737, self).__init__(const.AIRCRAFT_B737)
|
---|
209 |
|
---|
210 | #---------------------------------------------------------------------------------------
|
---|
211 |
|
---|
212 | class B738(Boeing737):
|
---|
213 | """Boeing 737-800 aircraft."""
|
---|
214 | def __init__(self):
|
---|
215 | super(B738, self).__init__(const.AIRCRAFT_B738)
|
---|
216 |
|
---|
217 | #---------------------------------------------------------------------------------------
|
---|
218 |
|
---|
219 | class B733(Boeing737):
|
---|
220 | """Boeing 737-300 aircraft."""
|
---|
221 | def __init__(self):
|
---|
222 | super(B733, self).__init__(const.AIRCRAFT_B733)
|
---|
223 |
|
---|
224 | #---------------------------------------------------------------------------------------
|
---|
225 |
|
---|
226 | class B734(Boeing737):
|
---|
227 | """Boeing 737-400 aircraft."""
|
---|
228 | def __init__(self):
|
---|
229 | super(B734, self).__init__(const.AIRCRAFT_B734)
|
---|
230 |
|
---|
231 | #---------------------------------------------------------------------------------------
|
---|
232 |
|
---|
233 | class B735(Boeing737):
|
---|
234 | """Boeing 737-500 aircraft."""
|
---|
235 | def __init__(self):
|
---|
236 | super(B735, self).__init__(const.AIRCRAFT_B735)
|
---|
237 |
|
---|
238 | #---------------------------------------------------------------------------------------
|
---|
239 |
|
---|
240 | class DH8D(Aircraft):
|
---|
241 | """Bombardier Dash-8 Q400 aircraft.
|
---|
242 |
|
---|
243 | The aircraft type-specific values in the aircraft state have the following
|
---|
244 | structure:
|
---|
245 | - fuel: centre, left, right
|
---|
246 | - n1: left, right
|
---|
247 | - reverser: left, right."""
|
---|
248 | def __init__(self):
|
---|
249 | super(DH8D, self).__init__(const.AIRCRAFT_DH8D)
|
---|
250 |
|
---|
251 | #---------------------------------------------------------------------------------------
|
---|
252 |
|
---|
253 | class Boeing767(Aircraft):
|
---|
254 | """Base class for the various aircraft in the Boeing 767 family.
|
---|
255 |
|
---|
256 | The aircraft type-specific values in the aircraft state have the following
|
---|
257 | structure:
|
---|
258 | - fuel: centre, left, right
|
---|
259 | - n1: left, right
|
---|
260 | - reverser: left, right"""
|
---|
261 |
|
---|
262 | #---------------------------------------------------------------------------------------
|
---|
263 |
|
---|
264 | class B762(Boeing767):
|
---|
265 | """Boeing 767-200 aircraft."""
|
---|
266 | def __init__(self):
|
---|
267 | super(B762, self).__init__(const.AIRCRAFT_B762)
|
---|
268 |
|
---|
269 | #---------------------------------------------------------------------------------------
|
---|
270 |
|
---|
271 | class B763(Boeing767):
|
---|
272 | """Boeing 767-300 aircraft."""
|
---|
273 | def __init__(self):
|
---|
274 | super(B763, self).__init__(const.AIRCRAFT_B763)
|
---|
275 |
|
---|
276 | #---------------------------------------------------------------------------------------
|
---|
277 |
|
---|
278 | class CRJ2(Aircraft):
|
---|
279 | """Bombardier CRJ-200 aircraft.
|
---|
280 |
|
---|
281 | The aircraft type-specific values in the aircraft state have the following
|
---|
282 | structure:
|
---|
283 | - fuel: centre, left, right
|
---|
284 | - n1: left, right
|
---|
285 | - reverser: left, right."""
|
---|
286 | def __init__(self):
|
---|
287 | super(CRJ2, self).__init__(const.AIRCRAFT_CRJ2)
|
---|
288 |
|
---|
289 | #---------------------------------------------------------------------------------------
|
---|
290 |
|
---|
291 | class F70(Aircraft):
|
---|
292 | """Fokker 70 aircraft.
|
---|
293 |
|
---|
294 | The aircraft type-specific values in the aircraft state have the following
|
---|
295 | structure:
|
---|
296 | - fuel: centre, left, right
|
---|
297 | - n1: left, right
|
---|
298 | - reverser: left, right."""
|
---|
299 | def __init__(self):
|
---|
300 | super(F70, self).__init__(const.AIRCRAFT_F70)
|
---|
301 |
|
---|
302 | #---------------------------------------------------------------------------------------
|
---|
303 |
|
---|
304 | class DC3(Aircraft):
|
---|
305 | """Lisunov Li-2 (DC-3) aircraft.
|
---|
306 |
|
---|
307 | The aircraft type-specific values in the aircraft state have the following
|
---|
308 | structure:
|
---|
309 | - fuel: left, right, left aux, right aix
|
---|
310 | - rpm: left, right
|
---|
311 | - reverser: left, right."""
|
---|
312 | def __init__(self):
|
---|
313 | super(DC3, self).__init__(const.AIRCRAFT_DC3)
|
---|
314 |
|
---|
315 | #---------------------------------------------------------------------------------------
|
---|
316 |
|
---|
317 | class T134(Aircraft):
|
---|
318 | """Tupolev Tu-134 aircraft.
|
---|
319 |
|
---|
320 | The aircraft type-specific values in the aircraft state have the following
|
---|
321 | structure:
|
---|
322 | - fuel: centre, left tip, left aux, right tip, right aux, external 1,
|
---|
323 | external 2
|
---|
324 | - n1: left, right
|
---|
325 | - reverser: left, right."""
|
---|
326 | def __init__(self):
|
---|
327 | super(T134, self).__init__(const.AIRCRAFT_T134)
|
---|
328 |
|
---|
329 | #---------------------------------------------------------------------------------------
|
---|
330 |
|
---|
331 | class T154(Aircraft):
|
---|
332 | """Tupolev Tu-154 aircraft.
|
---|
333 |
|
---|
334 | The aircraft type-specific values in the aircraft state have the following
|
---|
335 | structure:
|
---|
336 | - fuel: centre, left, right, centre 2, left aux, right aux
|
---|
337 | - n1: left, centre, right
|
---|
338 | - reverser: left, right"""
|
---|
339 | def __init__(self):
|
---|
340 | super(T154, self).__init__(const.AIRCRAFT_T154)
|
---|
341 |
|
---|
342 | #---------------------------------------------------------------------------------------
|
---|
343 |
|
---|
344 | class YK40(Aircraft):
|
---|
345 | """Yakovlev Yak-40 aircraft.
|
---|
346 |
|
---|
347 | The aircraft type-specific values in the aircraft state have the following
|
---|
348 | structure:
|
---|
349 | - fuel: left, right
|
---|
350 | - n1: left, right
|
---|
351 | - reverser: left, right"""
|
---|
352 | def __init__(self):
|
---|
353 | super(YK40, self).__init__(const.AIRCRAFT_YK40)
|
---|
354 |
|
---|
355 | #---------------------------------------------------------------------------------------
|
---|
356 |
|
---|