source: src/mlx/const.py@ 1179:7cbf103d3785

python3
Last change on this file since 1179:7cbf103d3785 was 1169:218a65ab96fe, checked in by István Váradi <ivaradi@…>, 12 days ago

Version stepped to 0.65.1

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