source: src/mlx/const.py@ 995:ad90726834d4

python3
Last change on this file since 995:ad90726834d4 was 941:2c0ae842657e, checked in by István Váradi <ivaradi@…>, 6 years ago

The version number indicates Python 3 (re #347)

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