source: src/mlx/const.py@ 1073:a5a22d24f890

python3
Last change on this file since 1073:a5a22d24f890 was 1073:a5a22d24f890, checked in by István Váradi <ivaradi@…>, 16 months ago

New constant for X-Plane 12

File size: 15.8 KB
Line 
1
2import sys
3import datetime
4
5#-------------------------------------------------------------------------------
6
7## @package mlx.const
8#
9# The constants used by the program.
10
11#-------------------------------------------------------------------------------
12
13## The version of the program
14VERSION="0.52"
15
16#-------------------------------------------------------------------------------
17
18## The ratio between lbs and kg
19LBSTOKG=0.4536
20
21## The ratio between kgs and lbs
22KGSTOLB=1/LBSTOKG
23
24## The ratio between feet and metre
25FEETTOMETRES=0.3048
26
27#-------------------------------------------------------------------------------
28
29## The ratio between knots and km/h
30KNOTSTOKMPH=1.852
31
32## The ratio between km/h and knots
33KMPHTOKNOTS=1/1.852
34
35#-------------------------------------------------------------------------------
36
37## Flight simulator type: MS Flight Simulator 2004
38SIM_MSFS9 = 1
39
40## Flight simulator type: MS Flight Simulator X
41SIM_MSFSX = 2
42
43## Flight simulator type: X-Plane 9
44SIM_XPLANE9 = 3
45
46## Flight simulator type: X-Plane 10
47SIM_XPLANE10 = 4
48
49## Flight simulator type: Prepar3D
50SIM_P3D = 5
51
52## Flight simulator type: X-Plane 11
53SIM_XPLANE11 = 6
54
55## Flight simulator type: X-Plane 12
56SIM_XPLANE12 = 7
57
58#-------------------------------------------------------------------------------
59
60## Aircraft type: Boeing 737-600
61AIRCRAFT_B736 = 1
62
63## Aircraft type: Boeing 737-700
64AIRCRAFT_B737 = 2
65
66## Aircraft type: Boeing 737-800
67AIRCRAFT_B738 = 3
68
69## Aircraft type: Boeing 737-800 (charter configuration)
70AIRCRAFT_B738C = 16
71
72## Aircraft type: Boeing 737-200
73AIRCRAFT_B732 = 18
74
75## Aircraft type: Boeing 737-300
76AIRCRAFT_B733 = 4
77
78## Aircraft type: Boeing 737-400
79AIRCRAFT_B734 = 5
80
81## Aircraft type: Boeing 737-500
82AIRCRAFT_B735 = 6
83
84## Aircraft type: Dash-8 Q400
85AIRCRAFT_DH8D = 7
86
87## Aircraft type: Boeing 767-200
88AIRCRAFT_B762 = 8
89
90## Aircraft type: Boeing 767-300
91AIRCRAFT_B763 = 9
92
93## Aircraft type: Canadair CRJ-200
94AIRCRAFT_CRJ2 = 10
95
96## Aircraft type: Fokker F-70
97AIRCRAFT_F70 = 11
98
99## Aircraft type: Lisunov Li-2
100AIRCRAFT_DC3 = 12
101
102## Aircraft type: Tupolev Tu-134
103AIRCRAFT_T134 = 13
104
105## Aircraft type: Tupolev Tu-154
106AIRCRAFT_T154 = 14
107
108## Aircraft type: Yakovlev Yak-40
109AIRCRAFT_YK40 = 15
110
111## Aircraft type: British Aerospace BAe-146
112AIRCRAFT_B462 = 17
113
114## Aircraft type: Ilyushin IL-62
115AIRCRAFT_IL62 = 18
116
117#-------------------------------------------------------------------------------
118
119## The list of aircraft types that we know of
120# The order is mostly from most recent to oldest considering
121# Malev's history
122aircraftTypes = [AIRCRAFT_B736, AIRCRAFT_B737,
123 AIRCRAFT_B738, AIRCRAFT_B738C,
124 AIRCRAFT_DH8D,
125 AIRCRAFT_F70, AIRCRAFT_CRJ2,
126 AIRCRAFT_B762, AIRCRAFT_B763,
127 AIRCRAFT_B732, AIRCRAFT_B733, AIRCRAFT_B734, AIRCRAFT_B735,
128 AIRCRAFT_T154, AIRCRAFT_T134,
129 AIRCRAFT_YK40, AIRCRAFT_DC3,
130 AIRCRAFT_B462, AIRCRAFT_IL62]
131
132#-------------------------------------------------------------------------------
133
134## Aircraft type family: Boeing 737 NG
135AIRCRAFT_FAMILY_B737NG = 1
136
137## Aircraft type family: Boeing 737 Classic
138AIRCRAFT_FAMILY_B737CL = 2
139
140## Aircraft type family: Bombardier Dash-8 Q400
141AIRCRAFT_FAMILY_DH8D = 3
142
143## Aircraft type family: Boeing 767
144AIRCRAFT_FAMILY_B767 = 4
145
146## Aircraft type family: Canadair CRJ-200
147AIRCRAFT_FAMILY_CRJ2 = 5
148
149## Aircraft type family: Fokker F-70
150AIRCRAFT_FAMILY_F70 = 6
151
152## Aircraft type family: Lisunov Li-2
153AIRCRAFT_FAMILY_DC3 = 7
154
155## Aircraft type family: Tupolev Tu-134
156AIRCRAFT_FAMILY_T134 = 8
157
158## Aircraft type family: Tupolev Tu-154
159AIRCRAFT_FAMILY_T154 = 9
160
161## Aircraft type family: Yakovlev Yak-40
162AIRCRAFT_FAMILY_YK40 = 10
163
164## Aircraft type family: British Aerospace BAe-146
165AIRCRAFT_FAMILY_B462 = 11
166
167#-------------------------------------------------------------------------------
168
169## Map aircraft families to the list of the types they comprise of
170aircraftFamily2Types = {
171 AIRCRAFT_FAMILY_B737NG: [AIRCRAFT_B736, AIRCRAFT_B737, AIRCRAFT_B738,
172 AIRCRAFT_B738C],
173
174 AIRCRAFT_FAMILY_B737CL: [AIRCRAFT_B732, AIRCRAFT_B733, AIRCRAFT_B734,
175 AIRCRAFT_B735],
176
177 AIRCRAFT_FAMILY_DH8D: [AIRCRAFT_DH8D],
178
179 AIRCRAFT_FAMILY_B767: [AIRCRAFT_B762, AIRCRAFT_B763],
180
181 AIRCRAFT_FAMILY_CRJ2: [AIRCRAFT_CRJ2],
182
183 AIRCRAFT_FAMILY_F70: [AIRCRAFT_F70],
184
185 AIRCRAFT_FAMILY_DC3: [AIRCRAFT_DC3],
186
187 AIRCRAFT_FAMILY_T134: [AIRCRAFT_T134],
188
189 AIRCRAFT_FAMILY_T154: [AIRCRAFT_T154],
190
191 AIRCRAFT_FAMILY_YK40: [AIRCRAFT_YK40],
192
193 AIRCRAFT_FAMILY_B462: [AIRCRAFT_B462]
194
195 }
196
197#-------------------------------------------------------------------------------
198
199def aircraftType2Family(aircraftType):
200 """Get the family for the given aircraft type."""
201 for (family, types) in aircraftFamily2Types.items():
202 if aircraftType in types:
203 return family
204 assert False
205
206#-------------------------------------------------------------------------------
207
208## A mapping of aircraft types to their 'internal' ICAO codes (which are
209# the same as the real ICAO codes, except in a few cases)
210icaoCodes = { AIRCRAFT_B736 : "B736",
211 AIRCRAFT_B737 : "B737",
212 AIRCRAFT_B738 : "B738",
213 AIRCRAFT_B738C : "B738C",
214 AIRCRAFT_B732 : "B732",
215 AIRCRAFT_B733 : "B733",
216 AIRCRAFT_B734 : "B734",
217 AIRCRAFT_B735 : "B735",
218 AIRCRAFT_DH8D : "DH8D",
219 AIRCRAFT_B762 : "B762",
220 AIRCRAFT_B763 : "B763",
221 AIRCRAFT_CRJ2 : "CRJ2",
222 AIRCRAFT_F70 : "F70",
223 AIRCRAFT_DC3 : "DC3",
224 AIRCRAFT_T134 : "T134",
225 AIRCRAFT_T154 : "T154",
226 AIRCRAFT_YK40 : "YK40",
227 AIRCRAFT_B462 : "B462" }
228
229#-------------------------------------------------------------------------------
230
231## Flight stage: boarding
232STAGE_BOARDING = 1
233
234## Flight stage: pushback, startup and taxi
235STAGE_PUSHANDTAXI = 2
236
237## Flight stage: takeoff
238STAGE_TAKEOFF = 3
239
240## Flight stage: RTO
241STAGE_RTO = 4
242
243## Flight stage: climb
244STAGE_CLIMB = 5
245
246## Flight stage: cruise
247STAGE_CRUISE = 6
248
249## Flight stage: descent
250STAGE_DESCENT = 7
251
252## Flight stage: landing
253STAGE_LANDING = 8
254
255## Flight stage: taxi after landing
256STAGE_TAXIAFTERLAND = 9
257
258## Flight stage: parking
259STAGE_PARKING = 10
260
261## Flight stage: go-around
262STAGE_GOAROUND = 11
263
264## Flight stage: end
265STAGE_END = 12
266
267#-------------------------------------------------------------------------------
268
269_stageStrings = { STAGE_BOARDING : "boarding",
270 STAGE_PUSHANDTAXI : "pushback and taxi",
271 STAGE_TAKEOFF : "takeoff",
272 STAGE_RTO : "RTO",
273 STAGE_CLIMB : "climb",
274 STAGE_CRUISE : "cruise",
275 STAGE_DESCENT : "descent",
276 STAGE_LANDING : "landing",
277 STAGE_TAXIAFTERLAND : "taxi",
278 STAGE_PARKING : "parking",
279 STAGE_GOAROUND : "go-around",
280 STAGE_END : "end" }
281
282def stage2string(stage):
283 """Convert the given stage to a lower-case string."""
284 return _stageStrings[stage] if stage in _stageStrings else None
285
286#-------------------------------------------------------------------------------
287
288## Plane status: unknown
289PLANE_UNKNOWN = 0
290
291## Plane status: at home, i.e. LHBP
292PLANE_HOME = 1
293
294## Plane status: away
295PLANE_AWAY = 2
296
297## Plane status: parking
298PLANE_PARKING = 3
299
300#-------------------------------------------------------------------------------
301
302## Flight type: scheduled
303FLIGHTTYPE_SCHEDULED = 0
304
305## Flight type: VIP
306FLIGHTTYPE_VIP = 1
307
308## Flight type: charter
309FLIGHTTYPE_CHARTER = 2
310
311## Flight type: old timer (not used anymore)
312FLIGHTTYPE_OLDTIMER = -1
313
314#-------------------------------------------------------------------------------
315
316flightTypes = [ FLIGHTTYPE_SCHEDULED,
317 FLIGHTTYPE_VIP,
318 FLIGHTTYPE_CHARTER,
319 FLIGHTTYPE_OLDTIMER ]
320
321#-------------------------------------------------------------------------------
322
323_flightTypeStrings = { FLIGHTTYPE_SCHEDULED : "scheduled",
324 FLIGHTTYPE_VIP : "vip",
325 FLIGHTTYPE_CHARTER : "charter",
326 FLIGHTTYPE_OLDTIMER : "ot" }
327
328def flightType2string(flightType):
329 """Get the string equivalent of the given flight type."""
330 return _flightTypeStrings[flightType] \
331 if flightType in _flightTypeStrings else None
332
333def flightType2index(flightType):
334 """Get the index of the given flight type according to the list above"""
335 return flightTypes.index(flightType)
336
337#-------------------------------------------------------------------------------
338
339## Message type: logger error
340# FIXME: cannot set the hotkey
341MESSAGETYPE_LOGGER_ERROR = 1
342
343## Message type: information
344MESSAGETYPE_INFORMATION = 2
345
346## Message type: in-flight information
347MESSAGETYPE_INFLIGHT = 3
348
349## Message type: fault messages
350MESSAGETYPE_FAULT = 4
351
352## Message type: NO-GO fault messages
353MESSAGETYPE_NOGO = 5
354
355## Message type: gate system messages
356MESSAGETYPE_GATE_SYSTEM = 6
357
358## Message type: environment messages
359# FIXME: flight plan closed (5 sec)
360MESSAGETYPE_ENVIRONMENT = 7
361
362## Message type: help messages
363MESSAGETYPE_HELP = 8
364
365## Message type: visibility messages
366MESSAGETYPE_VISIBILITY = 9
367
368#-------------------------------------------------------------------------------
369
370messageTypes = [ MESSAGETYPE_LOGGER_ERROR,
371 MESSAGETYPE_INFORMATION,
372 MESSAGETYPE_INFLIGHT,
373 MESSAGETYPE_FAULT,
374 MESSAGETYPE_NOGO,
375 MESSAGETYPE_GATE_SYSTEM,
376 MESSAGETYPE_ENVIRONMENT,
377 MESSAGETYPE_HELP,
378 MESSAGETYPE_VISIBILITY ]
379
380#-------------------------------------------------------------------------------
381
382_messageTypeStrings = { MESSAGETYPE_LOGGER_ERROR : "loggerError",
383 MESSAGETYPE_INFORMATION : "information",
384 MESSAGETYPE_INFLIGHT : "inflight",
385 MESSAGETYPE_FAULT : "fault",
386 MESSAGETYPE_NOGO : "nogo",
387 MESSAGETYPE_GATE_SYSTEM : "gateSystem",
388 MESSAGETYPE_ENVIRONMENT : "environment",
389 MESSAGETYPE_HELP : "help",
390 MESSAGETYPE_VISIBILITY : "visibility" }
391
392def messageType2string(messageType):
393 """Get the string equivalent of the given message type."""
394 return _messageTypeStrings[messageType] \
395 if messageType in _messageTypeStrings else None
396
397#-------------------------------------------------------------------------------
398
399## Message display level: none
400MESSAGELEVEL_NONE = 0
401
402## Message display level: only message in the simulator
403MESSAGELEVEL_FS = 1
404
405## Message display level: only sound
406MESSAGELEVEL_SOUND = 2
407
408## Message display level: both
409MESSAGELEVEL_BOTH = 3
410
411#-------------------------------------------------------------------------------
412
413messageLevels = [ MESSAGELEVEL_NONE,
414 MESSAGELEVEL_FS,
415 MESSAGELEVEL_SOUND,
416 MESSAGELEVEL_BOTH ]
417
418#-------------------------------------------------------------------------------
419
420_messageLevelStrings = { MESSAGELEVEL_NONE : "none",
421 MESSAGELEVEL_FS : "fs",
422 MESSAGELEVEL_SOUND : "sound",
423 MESSAGELEVEL_BOTH : "both" }
424
425def messageLevel2string(messageLevel):
426 """Get the string equivalent of the given message level."""
427 return _messageLevelStrings[messageLevel] \
428 if messageLevel in _messageLevelStrings else None
429
430def string2messageLevel(str):
431 """Get the message level for the given string."""
432 for (value, s) in _messageLevelStrings.items():
433 if str==s:
434 return value
435 return MESSAGELEVEL_NONE
436
437#-------------------------------------------------------------------------------
438
439## Sound: ding
440SOUND_DING = "ding.wav"
441
442## Sound: notify
443SOUND_NOTIFY = "notify.wav"
444
445## Sound: NOTAM
446SOUND_NOTAM = "notam.mp3"
447
448## Sound: scream
449SOUND_SCREAM = "sikoly.mp3"
450
451## Sound: boarding
452SOUND_BOARDING = "board.mp3"
453
454## Sound: Malev theme
455SOUND_MALEV = "malev.mp3"
456
457## Sound: taxi: Boeing 737 NG
458SOUND_TAXI_BOEING737NG = "737taxi.mp3"
459
460## Sound: taxi: Boeing 767
461SOUND_TAXI_BOEING767 = "767taxi.mp3"
462
463## Sound: taxi: Fokker F70
464SOUND_TAXI_F70 = "F70taxi.mp3"
465
466## Sound: takeoff preparation request from the captain
467SOUND_CAPTAIN_TAKEOFF = "cpt_takeoff.mp3"
468
469## Sound: cruise
470SOUND_CRUISE = "TOC.mp3"
471
472## Sound: descent
473SOUND_DESCENT = "TOD.mp3"
474
475## Sound: applause
476SOUND_APPLAUSE = "taps.mp3"
477
478## Sound: speedbrake
479SOUND_SPEEDBRAKE = "speed.mp3"
480
481## Sound: taxi after landing
482SOUND_TAXIAFTERLAND = "TaxiAfterLand.mp3"
483
484
485#-------------------------------------------------------------------------------
486
487## Fuel tank: centre
488FUELTANK_CENTRE = 1
489
490## Fuel tank: left
491FUELTANK_LEFT = 2
492
493## Fuel tank: right
494FUELTANK_RIGHT = 3
495
496## Fuel tank: left aux
497FUELTANK_LEFT_AUX = 4
498
499## Fuel tank: right aux
500FUELTANK_RIGHT_AUX = 5
501
502## Fuel tank: left tip
503FUELTANK_LEFT_TIP = 6
504
505## Fuel tank: right tip
506FUELTANK_RIGHT_TIP = 7
507
508## Fuel tank: external 1
509FUELTANK_EXTERNAL1 = 8
510
511## Fuel tank: external 2
512FUELTANK_EXTERNAL2 = 9
513
514## Fuel tank: centre2
515FUELTANK_CENTRE2 = 10
516
517#-------------------------------------------------------------------------------
518
519fuelTanks = [ FUELTANK_CENTRE,
520 FUELTANK_LEFT,
521 FUELTANK_RIGHT,
522 FUELTANK_LEFT_AUX,
523 FUELTANK_RIGHT_AUX,
524 FUELTANK_LEFT_TIP,
525 FUELTANK_RIGHT_TIP,
526 FUELTANK_EXTERNAL1,
527 FUELTANK_EXTERNAL2,
528 FUELTANK_CENTRE2 ]
529
530#-------------------------------------------------------------------------------
531
532_fuelTankStrings = { FUELTANK_CENTRE : "centre",
533 FUELTANK_LEFT : "left",
534 FUELTANK_RIGHT : "right",
535 FUELTANK_LEFT_AUX : "left_aux",
536 FUELTANK_RIGHT_AUX : "right_aux",
537 FUELTANK_LEFT_TIP : "left_tip",
538 FUELTANK_RIGHT_TIP : "right_tip",
539 FUELTANK_EXTERNAL1 : "external1",
540 FUELTANK_EXTERNAL2 : "external2",
541 FUELTANK_CENTRE2 : "centre2" }
542
543def fuelTank2string(fuelTank):
544 """Get the string equivalent of the given fuelTank."""
545 return _fuelTankStrings[fuelTank] \
546 if fuelTank in _fuelTankStrings else None
547
548#-------------------------------------------------------------------------------
549
550_fuelTankLogStrings = { FUELTANK_CENTRE : "centre",
551 FUELTANK_LEFT : "left",
552 FUELTANK_RIGHT : "right",
553 FUELTANK_LEFT_AUX : "left aux",
554 FUELTANK_RIGHT_AUX : "right aux",
555 FUELTANK_LEFT_TIP : "left tip",
556 FUELTANK_RIGHT_TIP : "right tip",
557 FUELTANK_EXTERNAL1 : "external 1",
558 FUELTANK_EXTERNAL2 : "external 2",
559 FUELTANK_CENTRE2 : "centre 2" }
560
561def fuelTank2logString(fuelTank):
562 """Get the log string equivalent of the given fuelTank."""
563 return _fuelTankLogStrings[fuelTank] \
564 if fuelTank in _fuelTankLogStrings else "unknown"
565
566#-------------------------------------------------------------------------------
567
568languages = ["$system", "en_GB", "hu_HU"]
569
570#-------------------------------------------------------------------------------
571
572defaultDate = datetime.date(1900, 1, 1)
573
574#-------------------------------------------------------------------------------
575
576# The weight of a cabin crew member [kg]
577WEIGHT_CABIN_CREW = 75
578
579# The weight of an adult passenger [kg]
580WEIGHT_PASSENGER = 84
581
582# The weight of an adult passenger on charter flight [kg]
583WEIGHT_PASSENGER_CHARTER = 76
584
585# The weight of a child passenger [kg]
586WEIGHT_CHILD = 35
587
588# The weight of an infant passenger [kg]
589WEIGHT_INFANT = 0
590
591#-------------------------------------------------------------------------------
Note: See TracBrowser for help on using the repository browser.