source: src/mlx/const.py@ 918:cfa4d89368fa

Last change on this file since 918:cfa4d89368fa was 917:803dc6bacfa5, checked in by István Váradi <ivaradi@…>, 6 years ago

Merged 0.39

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